• Leonardo Bras's avatar
    powerpc/kernel: Enables memory hot-remove after reboot on pseries guests · b6eca183
    Leonardo Bras authored
    While providing guests, it's desirable to resize it's memory on demand.
    
    By now, it's possible to do so by creating a guest with a small base
    memory, hot-plugging all the rest, and using 'movable_node' kernel
    command-line parameter, which puts all hot-plugged memory in
    ZONE_MOVABLE, allowing it to be removed whenever needed.
    
    But there is an issue regarding guest reboot:
    If memory is hot-plugged, and then the guest is rebooted, all hot-plugged
    memory goes to ZONE_NORMAL, which offers no guaranteed hot-removal.
    It usually prevents this memory to be hot-removed from the guest.
    
    It's possible to use device-tree information to fix that behavior, as
    it stores flags for LMB ranges on ibm,dynamic-memory-vN.
    It involves marking each memblock with the correct flags as hotpluggable
    memory, which mm/memblock.c puts in ZONE_MOVABLE during boot if
    'movable_node' is passed.
    
    For carrying such information, the new flag DRCONF_MEM_HOTREMOVABLE was
    proposed and accepted into Power Architecture documentation.
    This flag should be:
    - true (b=1) if the hypervisor may want to hot-remove it later, and
    - false (b=0) if it does not care.
    
    During boot, guest kernel reads the device-tree, early_init_drmem_lmb()
    is called for every added LMBs. Here, checking for this new flag and
    marking memblocks as hotplugable memory is enough to get the desirable
    behavior.
    
    This should cause no change if 'movable_node' parameter is not passed
    in kernel command-line.
    Signed-off-by: default avatarLeonardo Bras <leonardo@linux.ibm.com>
    Reviewed-by: default avatarBharata B Rao <bharata@linux.ibm.com>
    Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20200402195156.626430-1-leonardo@linux.ibm.com
    b6eca183
prom.c 24 KB