That depends on how max_pfn is interpreted. Strictly speaking, max_pfn is the first page following the region in question. If the code fragment assigning value to this variable share the same interpretation with code fragments using the value, there is no problem. I think this is the usual convention while dealing with region in C, that is, the ending value actually means the first item following the region. 2007/1/10, Vasily Tarasov <tarasov.vasily@xxxxxxxxx>:
Hello all, I can't undestand one thing in kernel source, so if anybody has information about it, please sched the light on it. There is a max_pfn variable. According to the comment this is "the highest page frame number we have available" It is calculated on x86 while iterating over memory regions: for (i = 0; i < e820.nr_map; i++) { unsigned long start, end; /* RAM? */ if (e820.map[i].type != E820_RAM) continue; start = PFN_UP(e820.map[i].addr); end = PFN_DOWN(e820.map[i].addr + e820.map[i].size); if (start >= end) continue; if (end > max_pfn) max_pfn = end; memory_present(0, start, end); } 4GB RAM is installed on my node, 32 bit kernel, 4 * 1024 * 1024 / 4 = 1024 * 1024 = 1048576 page frames. Page frames are counted starting from 0, so, I suppose, max_pfn should equal 1048575. However on my real node max_pfn = 1048576. I think, that we should change end = PFN_DOWN(e820.map[i].addr + e820.map[i].size); to end = PFN_DOWN(e820.map[i].addr + e820.map[i].size - 1); What do you think about it, do I miss something? Thanks. -- Vasily Tarasov, tarasov.vasily@xxxxxxxxx -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/
-- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/