2

I am working on a course homework on sysfs virtual file system in Linux Kernel. As part of setting up sysfs virtual file system, Linux kernel organizes the physical memory in to blocks and further into sections in this directoy sys/devices/system/memory. In that directory, memory chunks will be represented as memory0, meomory1, memory2 etc..

After digging the Linux kernel, I have found out that the memory is being split into 128MB blocks and then further into sections of memory and found the code which does this in the C file here: Memory.c. In the above C file, the method memory_dev_init() has the logic for the whole memory block splitting and dividing into sections (or that's what i understood :) ). As per my professor, memory in Linux is split up into ranks and ranks contain interleaved memory addresses as shown below:

   rank0: [0-512KB] [2048KB-2560KB] [4096KB-4608KB] ...
   rank1: [512KB-1024KB] [2560KB-3072KB] [4608KB-5120KB] ...
   rank2: [1024KB-1536KB] [3072KB-3584KB] [5120KB-...
   rank3: [1536KB-2048KB] [3584KB-4096KB] ...

As part of my homework, I want to change the rank format into this so that i can get a contiguous memory blocks:

   rank0: [0-512KB] [512KB-1024KB] [1024KB-1536KB]...
   rank1: [1536KB-2048KB] [2048KB-2560KB] [2560KB-3072KB]...
   rank2: [3072KB-3584KB] [3584KB-4096KB] [4096KB-4608KB]...
   rank3: [4608KB-5120KB] ...

So I just want to know where exactly this memory interleaving is happening and the existing ranking is happening in the current Linux kernel. Could anyone please point me in the right direction?

Srikanth Kandalam
  • 965
  • 3
  • 15
  • 26

2 Answers2

0

I'm not quite sure as I don't see any practical use of the question, it is indeed a sort of academic research... and what you are trying to achieve is achievable by disabling the memory interleaving entirely. I guess after you disable interleaving you will see the proper "picture" in sysfs as well.

In other words -- no coding required, just the change of configuration.

Anton
  • 976
  • 8
  • 9
  • Hi Anton! Thanks for the answer. Could you please let me know where exactly I can change the configuration? I mean does it involve changing settings in BIOS or hardware? I am actually doing this by loading a linux kernel on Qemu. So could you please point me on how to change the configuration in the linux kernel? Also is there anyway to see where the interleaving is happening in my system? If so, could you please tell me how I can see it in the terminal? – Srikanth Kandalam Oct 25 '13 at 15:42
0

Have a look at the memory interleave settings in BIOS. Here's a post which describe how to do this in a couple of platforms.

vPraetor
  • 313
  • 1
  • 3
  • 13