• Adam Litke's avatar
    hugetlb: debit quota in alloc_huge_page · 2fc39cec
    Adam Litke authored
    Now that quota is credited by free_huge_page(), calls to hugetlb_get_quota()
    seem out of place.  The alloc/free API is unbalanced because we handle the
    hugetlb_put_quota() but expect the caller to open-code hugetlb_get_quota().
    Move the get inside alloc_huge_page to clean up this disparity.
    This patch has been kept apart from the previous patch because of the somewhat
    dodgy ERR_PTR() use herein.  Moving the quota logic means that
    alloc_huge_page() has two failure modes.  Quota failure must result in a
    SIGBUS while a standard allocation failure is OOM.  Unfortunately, ERR_PTR()
    doesn't like the small positive errnos we have in VM_FAULT_* so they must be
    negated before they are used.
    Does anyone take issue with the way I am using PTR_ERR.  If so, what are your
    thoughts on how to clean this up (without needing an if,else if,else block at
    each alloc_huge_page() callsite)?
    Signed-off-by: default avatarAdam Litke <agl@us.ibm.com>
    Cc: Ken Chen <kenchen@google.com>
    Cc: Andy Whitcroft <apw@shadowen.org>
    Cc: Dave Hansen <haveblue@us.ibm.com>
    Cc: David Gibson <hermes@gibson.dropbear.id.au>
    Cc: William Lee Irwin III <wli@holomorphy.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>