<br><br><div class="gmail_quote">On Fri, Sep 23, 2011 at 2:13 PM, Jeff Donner <span dir="ltr"><<a href="mailto:jeffrey.donner@gmail.com">jeffrey.donner@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi;<br>
<br>
I have a 4 CPU machine, x86_64, with 8GB of ram, and am using the<br>
3.0 kernel. I'm taking a kernel class and one of my assignments is to<br>
print the address of mem_map and its number of entries and then,<br>
translate that address to physical and, walk the whole kernel page<br>
table counting some flags (just to do it). My problem is, that I<br>
cannot see mem_map from my exercise module, and it's because my kernel<br>
is .config'd to NEED_MULTIPLE_NODES, and in mm/memory.c:<br>
<br>
#ifndef CONFIG_NEED_MULTIPLE_NODES<br>
/* use the per-pgdat data instead for discontigmem - mbligh */<br>
unsigned long max_mapnr;<br>
struct page *mem_map;<br>
<br>
EXPORT_SYMBOL(max_mapnr);<br>
EXPORT_SYMBOL(mem_map);<br>
#endif<br>
<br>
So, with my configuration the kernel isn't letting me see a mem_map.<br>
<br>
Now in mm/Kconfig, NEED_MULTIPLE_NODES seems to depend on DISCONTIGMEM<br>
config NEED_MULTIPLE_NODES<br>
def_bool y<br>
depends on DISCONTIGMEM || NUMA<br>
<br>
Which may not have anything to do with anything, but I'm leery of<br>
changing such a deep setting.<br>
<br>
I'd like to, if possible,<br>
a) find out the right way to traverse the global kernel page table (ie<br>
to complete the task as stated), adapted to how my kernel is now<br>
-- or --<br>
b) I have the idea that the lack of mem_map is due to DISCONTIGMEM,<br>
which may be due to its being an x86_64 machine (my guess). I'd like<br>
to find out what I need to do to simplify my kernel so that I can just<br>
walk along mem_map as originally instructed.<br>
<br>
I appreciate any ideas;<br>
Thanks,<br>
Jeff<br>
<br>
_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
<a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
</blockquote></div><br>Hi Jeff,<br><br>The global exported symbol mem_map is available only when the memory model is of type FLATMEM<br><br>There are 3 memory models : -<br><br>1. FLATMEM. is used in case of UMA<br>2. DISCONTIGMEM is used in case of NUMA<br>
3. SPARSEMEM is used in case of NUMA<br><br>During kernel configuration you can select the type of the memory model, in processor type and features -> memory model<br><br><br>Try doing this and see, if you are able to access the symbol mem_map.<br>
<br>If CONFIG_NUMA is set, Flat memory model does not makes sense and hence is not used.<br><br>Some conceptual information : -<br><br>RAM memory is divided into nodes. Node to processor mapping is one-to-one. Nodes are maintained using singly linked list.<br>
<br>Node is represented by pg_data_t struct in linux kernel.<br><br>Each node is split into 3 zones.(DMA, NORMAL, HIGHMEM) On 64 bit systems, HIGHMEM zone is not required.<br><br>pg_data_t structure contains a member known as "node_mem_map", which is a ptr to array of page instances used to describe all physical pages of the node. Includes pages of all the zones in that node.<br>
<br>So, if for NUMA i mean for DISCONTIGMEM, you want to mem_map ptr, then that would be maintained per node (per processor), so you need to get hold of all the nodes in the system, in this way you can complete your assigment.<br>
<br>Regards,<br>Rohan Puri<br><br>