Friday, January 7, 2011

Linux Memory Management Notes

Here, I will talk about some random MM things that I learned while working on it a while back. It might be useful for others. I am defining things here for MIPS but it could be tweaked for other archs as well.

1) How to define the no. of memory nodes contained it a system ??
Soln:- Its  a two step process.

a) In the .config file select CONFIG_SYS_SUPPORTS_NUMA & then CONFIG_NODES_SHIFT=<no. of nodes^2)

b) The second step is :
    in arch/mips/include/asm/mmzone.h, define the following:
   pg_data_t discontig_node_data[]
   #define NODE_DATA(nid) (&discontig_node_data[nid])
   #define NODE_MEM_MAP(nid) (NODE_DATA(nid)->node_mem_map)

& define discontig_node_data  in arch/mips/mm/discontig.c

pg_data_t discontig_node_data[MAX_NUMNODES] = {
{ .bdata = &bootmem_node_data[0]  },

and finally define MAX_NUMNODES in include/linux/numa.h

2) How many page descriptors can a page hold ??
1 page typically is 4KB (4*1024 --> 4096)
1 page descriptor is tyically 32 bytes.

So the no. of page descriptors in a page are:- 4096/32 --> 128 page descriptors

3) What does PFN_UP / PFN_DOWN macros do ??
PFN_UP macro gives a page frame number after rounding the given address to the next page frame boundary
PFN_DOWN macro gives a page frame number that contains the address passed to this macro.

(to be contd....)

No comments:

Post a Comment