Skip to content
  • Toshi Kani's avatar
    resource: add release_mem_region_adjustable() · 825f787b
    Toshi Kani authored
    
    
    Add release_mem_region_adjustable(), which releases a requested region
    from a currently busy memory resource.  This interface adjusts the
    matched memory resource accordingly even if the requested region does
    not match exactly but still fits into.
    
    This new interface is intended for memory hot-delete.  During bootup,
    memory resources are inserted from the boot descriptor table, such as
    EFI Memory Table and e820.  Each memory resource entry usually covers
    the whole contigous memory range.  Memory hot-delete request, on the
    other hand, may target to a particular range of memory resource, and its
    size can be much smaller than the whole contiguous memory.  Since the
    existing release interfaces like __release_region() require a requested
    region to be exactly matched to a resource entry, they do not allow a
    partial resource to be released.
    
    This new interface is restrictive (i.e.  release under certain
    conditions), which is consistent with other release interfaces,
    __release_region() and __release_resource().  Additional release
    conditions, such as an overlapping region to a resource entry, can be
    supported after they are confirmed as valid cases.
    
    There is no change to the existing interfaces since their restriction is
    valid for I/O resources.
    
    [akpm@linux-foundation.org: use GFP_ATOMIC under write_lock()]
    [akpm@linux-foundation.org: switch back to GFP_KERNEL, less buggily]
    [akpm@linux-foundation.org: remove unneeded and wrong kfree(), per Toshi]
    Signed-off-by: default avatarToshi Kani <toshi.kani@hp.com>
    Reviewed-by : Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
    Cc: David Rientjes <rientjes@google.com>
    Reviewed-by: default avatarRam Pai <linuxram@us.ibm.com>
    Cc: T Makphaibulchoke <tmac@hp.com>
    Cc: Wen Congyang <wency@cn.fujitsu.com>
    Cc: Tang Chen <tangchen@cn.fujitsu.com>
    Cc: Jiang Liu <jiang.liu@huawei.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    825f787b