Data Structures

The kernelcore parameter allows for specifying the amount of memory used for non-movable allocations, that is, for allocations that can neither be reclaimed nor migrated. The remaining memory is used for movable allocations. After parsing the parameter, the result is stored in the global variable required_kernelcore.

It is also possible to use the parameter movablecore to control the amount of memory that is used for movable memory. The size of required_kernelcore will be computed accordingly. If wise guys specify both parameters simultaneously, the kernel computes required_kernelcore as before, and takes the larger one of the computed and specified value.

Depending on the architecture and the kernel configuration, the new zone zone_movable is located above the high-memory or regular-memory zone:

enum zone_type {

ZONE_NORMAL #ifdef CONFIG_HIGHMEM ZONE_HIGHMEM,

#endif

ZONE_MOVABLE, MAX_NR_ZONES

In contrast to all other zones in the system, zone_movable is not associated with any memory range that is of significance to the hardware. Indeed, the zone is filled with memory taken from either the highmem or the regular zone, and accordingly we call zone_movable a virtual zone in the following.

The auxiliary function find_zone_movable_pfns_for_nodes is used to compute the amount of memory that goes into ZONE_MOVABLE. If neither the kernelcore nor movablecore parameter was specified, find_zone_movable_pfns_for_nodes leaves ZONE_MOVABLE empty, and the mechanism is not active.

Two things must be considered with respect to how many pages are taken from a physical zone and used for ZONE_MOVABLE:

□ The memory for non-movable allocations is spread evenly across all memory nodes.

□ Only memory from the highest zone is used. On 32-bit systems with much memory, this will usually be zone_highmem, but for 64-bit systems, zone_normal or zone_dma32 will be used.

The actual computation is rather lengthy, but not very interesting, so I do not consider it in detail. What matters are the results:

□ The physical zone from which pages for the virtual zone zone_movable are taken is stored in the global variable movable_zone.

□ For each node, the page frame in the movable zone from which onward the memory belongs to ZONE_MOVABLE is in zone_movable_pfn[node_id].

mm/page_alloc.c unsigned long _meminitdata zone_movable_pfn[MAX_NUMNODES];

The kernel ensures that these pages will be used to satisfy allocations that fall into the responsibility of ZONE_MOVABLE.

Continue reading here: Implementation

Was this article helpful?

0 0