How to traverse or walk, the kernel's page table without mem_map?

Jeff Donner jeffrey.donner at
Fri Sep 23 04:43:59 EDT 2011


  I have a 4 CPU machine, x86_64, with 8GB of ram, and am using the
3.0 kernel. I'm taking a kernel class and one of my assignments is to
print the address of mem_map and its number of entries and then,
translate that address to physical and, walk the whole kernel page
table counting some flags (just to do it). My problem is, that I
cannot see mem_map from my exercise module, and it's because my kernel
is .config'd to NEED_MULTIPLE_NODES, and in mm/memory.c:

/* use the per-pgdat data instead for discontigmem - mbligh */
unsigned long max_mapnr;
struct page *mem_map;


So, with my configuration the kernel isn't letting me see a mem_map.

Now in mm/Kconfig, NEED_MULTIPLE_NODES seems to depend on DISCONTIGMEM
        def_bool y
        depends on DISCONTIGMEM || NUMA

Which may not have anything to do with anything, but I'm leery of
changing such a deep setting.

I'd like to, if possible,
a) find out the right way to traverse the global kernel page table (ie
to complete the task as stated), adapted to how my kernel is now
-- or --
b) I have the idea that the lack of mem_map is due to DISCONTIGMEM,
which may be due to its being an x86_64 machine (my guess). I'd like
to find out what I need to do to simplify my kernel so that I can just
walk along mem_map as originally instructed.

I appreciate any ideas;

More information about the Kernelnewbies mailing list