mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 13:12:46 +00:00 
			
		
		
		
	Kernel: Allow release of a specific amount of of clean pages
Previously, we could only release *all* clean pages. This patch makes it possible to release a specific amount of clean pages. If the attempted number of pages to release is more than the amount of clean pages, all clean pages will be released.
This commit is contained in:
		
							parent
							
								
									072dde9387
								
							
						
					
					
						commit
						09d0fae2c6
					
				
					 2 changed files with 20 additions and 0 deletions
				
			
		|  | @ -67,6 +67,25 @@ int InodeVMObject::release_all_clean_pages() | |||
|     return count; | ||||
| } | ||||
| 
 | ||||
| int InodeVMObject::try_release_clean_pages(int page_amount) | ||||
| { | ||||
|     SpinlockLocker locker(m_lock); | ||||
| 
 | ||||
|     int count = 0; | ||||
|     for (size_t i = 0; i < page_count() && count < page_amount; ++i) { | ||||
|         if (!m_dirty_pages.get(i) && m_physical_pages[i]) { | ||||
|             m_physical_pages[i] = nullptr; | ||||
|             ++count; | ||||
|         } | ||||
|     } | ||||
|     if (count) { | ||||
|         for_each_region([](auto& region) { | ||||
|             region.remap(); | ||||
|         }); | ||||
|     } | ||||
|     return count; | ||||
| } | ||||
| 
 | ||||
| u32 InodeVMObject::writable_mappings() const | ||||
| { | ||||
|     u32 count = 0; | ||||
|  |  | |||
|  | @ -23,6 +23,7 @@ public: | |||
|     size_t amount_clean() const; | ||||
| 
 | ||||
|     int release_all_clean_pages(); | ||||
|     int try_release_clean_pages(int page_amount); | ||||
| 
 | ||||
|     u32 writable_mappings() const; | ||||
|     u32 executable_mappings() const; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 dylanbobb
						dylanbobb