On 09/27/2013 01:46 PM, Cody P Schafer wrote: > On 09/27/2013 06:16 AM, Kirill A. Shutemov wrote: >> @@ -339,6 +339,7 @@ struct mm_struct { >> pgd_t * pgd; >> atomic_t mm_users; /* How many users with user space? */ >> atomic_t mm_count; /* How many references to "struct >> mm_struct" (users count as 1) */ >> + atomic_t nr_ptes; /* Page table pages */ >> int map_count; /* number of VMAs */ ... > > Will 32bits always be enough here? Should atomic_long_t be used instead? There are 48 bits of virtual address space on x86 today. 12 bits of that is the address inside the page, so we've at *most* 2^36 pages. 2^9 (512) pages are mapped by a pte page, so that means the page tables only hold 2^27 pte pages in a single process. We've got 31 bits of usable space in the atomic_t, so that definitely works _today_. If the virtual address space ever gets bigger, we might have problems, though. In practice, though, we steal a big chunk of that virtual address space for the kernel, and that doesn't get accounted in mm->nr_ptes, so we've got a _bit_ more wiggle room than just 4 bits. Also, anybody that's mapping >4 petabytes of memory with 4k ptes is just off their rocker. I'm also not sure what the virtual address limits are for the more obscure architectures, so I guess it's also possible they'll hit this. I guess it wouldn't hurt to stick an overflow check in there for VM debugging purposes. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>