• Hugh Dickins's avatar
    tmpfs: simplify prealloc_page · e83c32e8
    Hugh Dickins authored
    The prealloc_page handling in shmem_getpage_gfp() is unnecessarily
    complicated: first simplify that before going on to filepage/swappage.
    That's right, don't report ENOMEM when the preallocation fails: we may or
    may not need the page.  But simply report ENOMEM once we find we do need
    it, instead of dropping lock, repeating allocation, unwinding on failure
    etc.  And leave the out label on the fast path, don't goto.
    Fix something that looks like a bug but turns out not to be: set
    PageSwapBacked on prealloc_page before its mem_cgroup_cache_charge(), as
    the removed case was doing.  That's important before adding to LRU
    (determines which LRU the page goes on), and does affect which path it
    takes through memcontrol.c, but in the end MEM_CGROUP_CHANGE_TYPE_ SHMEM
    is handled no differently from CACHE.
    Signed-off-by: default avatarHugh Dickins <hughd@google.com>
    Acked-by: default avatarShaohua Li <shaohua.li@intel.com>
    Cc: "Zhang, Yanmin" <yanmin.zhang@intel.com>
    Cc: Tim Chen <tim.c.chen@linux.intel.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
shmem.c 79.5 KB