• Badari Pulavarty's avatar
    memory-hotplug: add sysfs removable attribute for hotplug memory remove · 5c755e9f
    Badari Pulavarty authored
    Memory may be hot-removed on a per-memory-block basis, particularly on
    POWER where the SPARSEMEM section size often matches the memory-block
    size.  A user-level agent must be able to identify which sections of
    memory are likely to be removable before attempting the potentially
    expensive operation.  This patch adds a file called "removable" to the
    memory directory in sysfs to help such an agent.  In this patch, a memory
    block is considered removable if;
    
    o It contains only MOVABLE pageblocks
    o It contains only pageblocks with free pages regardless of pageblock type
    
    On the other hand, a memory block starting with a PageReserved() page will
    never be considered removable.  Without this patch, the user-agent is
    forced to choose a memory block to remove randomly.
    
    Sample output of the sysfs files:
    
    ./memory/memory0/removable: 0
    ./memory/memory1/removable: 0
    ./memory/memory2/removable: 0
    ./memory/memory3/removable: 0
    ./memory/memory4/remova...
    5c755e9f
memory_hotplug.c 20.4 KB