Nonlinear is to cover
discontiguous memory as a contiguous memory. Current Linux kernel
basically uses this code.
(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,
can't allocate for all of them because of maximum mem_map size on some
mem/phy_section is also used to manage
logical chunks of memory, and it means minimum unit of hotplug
Its original patch is posted
Phillips. Now, its extended patch set is managed by Dave Hansen
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
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.
- Allocate a new page as the destination of migration.
- Modify radix tree.
- Invalidate PTEs which point the old page.
- Move contents of the page.
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
all of memory modules can't be removed. So, to maximize amount of
removable memories, kernel should collect these un-removable areas as
as possible. Making removable area is to realize this.