• Hugh Dickins's avatar
    shmem: move memcg charge out of shmem_add_to_page_cache() · 054a9f7c
    Hugh Dickins authored
    Extract shmem's memcg charging out of shmem_add_to_page_cache(): it's
    misleading done there, because many calls are dealing with a swapcache
    page, whose memcg is nowadays always remembered while swapped out, then
    the charge re-levied when it's brought back into swapcache.
    
    Temporarily move it back up to the shmem_get_folio_gfp() level, where the
    memcg was charged before v5.8; but the next commit goes on to move it back
    down to a new home.
    
    In making this change, it becomes clear that shmem_swapin_folio() does not
    need to know the vma, just the fault mm (if any): call it fault_mm rather
    than charge_mm - let mem_cgroup_charge() decide whom to charge.
    
    Link: https://lkml.kernel.org/r/4b2143c5-bf32-64f0-841-81a81158dac@google.com
    
    Signed-off-by: default avatarHugh Dickins <hughd@google.com>
    Reviewed-by: default avatarJan Kara <jack@suse.cz>
    Cc: Axel Rasmussen <axelrasmussen@google.com>
    Cc: Carlos Maiolino <cem@kernel.org>
    Cc: Christian Brauner <brauner@kernel.org>
    Cc: Chuck Lever <chuck.lever@oracle.com>
    Cc: Darrick J. Wong <djwong@kernel.org>
    Cc: Dave Chinner <dchinner@redhat.com>
    Cc: Johannes Weiner <hannes@cmpxchg.org>
    Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
    Cc: Tim Chen <tim.c.chen@intel.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    054a9f7c
shmem.c 127 KB