• Roger Pau Monne's avatar
    xen/x86: add extra pages to unpopulated-alloc if available · a6aa4eb9
    Roger Pau Monne authored
    Commit 262fc47a ('xen/balloon: don't use PV mode extra memory for zone
    device allocations') removed the addition of the extra memory ranges to the
    unpopulated range allocator, using those only for the balloon driver.
    
    This forces the unpopulated allocator to attach hotplug ranges even when spare
    memory (as part of the extra memory ranges) is available.  Furthermore, on PVH
    domains it defeats the purpose of commit 38620fc4 ('x86/xen: attempt to
    inflate the memory balloon on PVH'), as extra memory ranges would only be
    used to map foreign memory if the kernel is built without XEN_UNPOPULATED_ALLOC
    support.
    
    Fix this by adding a helpers that adds the extra memory ranges to the list of
    unpopulated pages, and zeroes the ranges so they are not also consumed by the
    balloon driver.
    
    This should have been part of 38620fc4, hence the fixes tag.
    
    Note the current logic relies on unpopulated_init() (and hence
    arch_xen_unpopulated_init()) always being called ahead of balloon_init(), so
    that the extra memory regions are consumed by arch_xen_unpopulated_init().
    
    Fixes: 38620fc4 ('x86/xen: attempt to inflate the memory balloon on PVH')
    Signed-off-by: default avatarRoger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
    Link: https://lore.kernel.org/r/20240429155053.72509-1-roger.pau@citrix.comSigned-off-by: default avatarJuergen Gross <jgross@suse.com>
    a6aa4eb9
enlighten.c 10.5 KB