• Michael Kelley's avatar
    hv_balloon: Enable hot-add for memblock sizes > 128 MiB · 8852ebf1
    Michael Kelley authored
    The Hyper-V balloon driver supports hot-add of memory in addition
    to ballooning. Current code hot-adds in fixed size chunks of
    128 MiB (fixed constant HA_CHUNK in the code). While this works
    in Hyper-V VMs with 64 GiB or less or memory where the Linux
    memblock size is 128 MiB, the hot-add fails for larger memblock
    sizes because add_memory() expects memory to be added in chunks
    that match the memblock size. Messages like the following are
    reported when Linux has a 256 MiB memblock size:
    
    [  312.668859] Block size [0x10000000] unaligned hotplug range:
                   start 0x310000000, size 0x8000000
    [  312.668880] hv_balloon: hot_add memory failed error is -22
    [  312.668984] hv_balloon: Memory hot add failed
    
    Larger memblock sizes are usually used in VMs with more than
    64 GiB of memory, depending on the alignment of the VM's
    physical address space.
    
    Fix this problem by having the Hyper-V balloon driver determine
    the Linux memblock size, and process hot-add requests in that
    chunk size instead of a fixed 128 MiB. Also update the hot-add
    alignment requested of the Hyper-V host to match the memblock
    size.
    
    The code changes look significant, but in fact are just a
    simple text substitution of a new global variable for the
    previous HA_CHUNK constant. No algorithms are changed except
    to initialize the new global variable and to calculate the
    alignment value to pass to Hyper-V. Testing with memblock
    sizes of 256 MiB and 2 GiB shows correct operation.
    Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
    Signed-off-by: default avatarMichael Kelley <mhklinux@outlook.com>
    Link: https://lore.kernel.org/r/20240503154312.142466-2-mhklinux@outlook.comSigned-off-by: default avatarWei Liu <wei.liu@kernel.org>
    Message-ID: <20240503154312.142466-2-mhklinux@outlook.com>
    8852ebf1
hv_balloon.c 53.5 KB