Outline of Memory Hotplug (Under Construction)


 Nonlinear is to cover discontiguous memory as a contiguous memory. Current Linux kernel basically uses this code.
    #define     pfn_to_page(pfn)         (mem_map + (pfn))
This code means mem_map which is known as page struct's array is indexed by contiguous physical address. (pfn is Page Frame Number). And mem_map is also contiguous. However, mem_map size is 1% of total size of physical memory. So, if mem_map is reserved for maximum size of physical memory to be considered for hotplug, kernel can't allocate for all of them because of maximum mem_map size on some architecture. 
 mem/phy_section is also used to manage logical chunks of memory, and it means minimum unit of hotplug memory. 

 Its original patch is posted by Daniel Phillips. Now, its extended patch set is managed by Dave Hansen.

Page migration

 To remove memory, its contents must be moved somewhere to save it. One of the good destination of migration is swap file. However, swap file isn't appropriate like following case.
 And swap out means that kernel needs more time for I/O.
 Page migration is to migrate contents from removing memory to another memory without I/O.
 Page migration is outlined as followings.
  1. Allocate a new page as the destination of migration.
  2. Modify radix tree.
  3. Invalidate PTEs which point the old page.
  4. Move contents of the page.
 Memory Migration

Removable area

 As you can imagine easily, there are structures which can't be removed like kernel/text/stack, kmalloc(). If there is a structure in a removable memory module, this means the memory module become un-removable. If they scatter everywhere, all of memory modules can't be removed. So, to maximize amount of removable memories, kernel should collect these un-removable areas as much as possible. Making removable area is to realize this.