On Fri, Sep 23, 2011 at 2:13 PM, Jeff Donner <jeffrey.don...@gmail.com>wrote:
> Hi; > > 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: > > #ifndef CONFIG_NEED_MULTIPLE_NODES > /* use the per-pgdat data instead for discontigmem - mbligh */ > unsigned long max_mapnr; > struct page *mem_map; > > EXPORT_SYMBOL(max_mapnr); > EXPORT_SYMBOL(mem_map); > #endif > > 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 > config NEED_MULTIPLE_NODES > 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; > Thanks, > Jeff > > _______________________________________________ > Kernelnewbies mailing list > Kernelnewbies@kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies > Hi Jeff, The global exported symbol mem_map is available only when the memory model is of type FLATMEM There are 3 memory models : - 1. FLATMEM. is used in case of UMA 2. DISCONTIGMEM is used in case of NUMA 3. SPARSEMEM is used in case of NUMA During kernel configuration you can select the type of the memory model, in processor type and features -> memory model Try doing this and see, if you are able to access the symbol mem_map. If CONFIG_NUMA is set, Flat memory model does not makes sense and hence is not used. Some conceptual information : - RAM memory is divided into nodes. Node to processor mapping is one-to-one. Nodes are maintained using singly linked list. Node is represented by pg_data_t struct in linux kernel. Each node is split into 3 zones.(DMA, NORMAL, HIGHMEM) On 64 bit systems, HIGHMEM zone is not required. 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. 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. Regards, Rohan Puri
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies