mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 17:52:45 +00:00 
			
		
		
		
	Kernel: Make it possible to turn off VM guard pages at compile time
This might be useful for debugging since guard pages introduce a fair amount of noise in the virtual address space.
This commit is contained in:
		
							parent
							
								
									1a279c5b2a
								
							
						
					
					
						commit
						ac20919b13
					
				
					 1 changed files with 11 additions and 4 deletions
				
			
		|  | @ -3,6 +3,7 @@ | ||||||
| #include <Kernel/kstdio.h> | #include <Kernel/kstdio.h> | ||||||
| 
 | 
 | ||||||
| //#define VRA_DEBUG
 | //#define VRA_DEBUG
 | ||||||
|  | #define VM_GUARD_PAGES | ||||||
| 
 | 
 | ||||||
| RangeAllocator::RangeAllocator(VirtualAddress base, size_t size) | RangeAllocator::RangeAllocator(VirtualAddress base, size_t size) | ||||||
| { | { | ||||||
|  | @ -59,14 +60,20 @@ void RangeAllocator::carve_at_index(int index, const Range& range) | ||||||
| 
 | 
 | ||||||
| Range RangeAllocator::allocate_anywhere(size_t size) | Range RangeAllocator::allocate_anywhere(size_t size) | ||||||
| { | { | ||||||
|  | #ifdef VM_GUARD_PAGES | ||||||
|     // NOTE: We pad VM allocations with a guard page on each side.
 |     // NOTE: We pad VM allocations with a guard page on each side.
 | ||||||
|     size_t padded_size = size + PAGE_SIZE * 2; |     size_t effective_size = size + PAGE_SIZE * 2; | ||||||
|  |     size_t offset_from_effective_base = PAGE_SIZE; | ||||||
|  | #else | ||||||
|  |     size_t effective_size = size; | ||||||
|  |     size_t offset_from_effective_base = 0; | ||||||
|  | #endif | ||||||
|     for (int i = 0; i < m_available_ranges.size(); ++i) { |     for (int i = 0; i < m_available_ranges.size(); ++i) { | ||||||
|         auto& available_range = m_available_ranges[i]; |         auto& available_range = m_available_ranges[i]; | ||||||
|         if (available_range.size() < padded_size) |         if (available_range.size() < effective_size) | ||||||
|             continue; |             continue; | ||||||
|         Range allocated_range(available_range.base().offset(PAGE_SIZE), size); |         Range allocated_range(available_range.base().offset(offset_from_effective_base), size); | ||||||
|         if (available_range.size() == padded_size) { |         if (available_range.size() == effective_size) { | ||||||
| #ifdef VRA_DEBUG | #ifdef VRA_DEBUG | ||||||
|             dbgprintf("VRA: Allocated perfect-fit anywhere(%u): %x\n", size, allocated_range.base().get()); |             dbgprintf("VRA: Allocated perfect-fit anywhere(%u): %x\n", size, allocated_range.base().get()); | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling