mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-25 05:04:09 +08:00
mm: memcg: only check swap cache pages for repeated charging
Only anon and shmem pages in the swap cache are attempted to be charged multiple times, from every swap pte fault or from shmem_unuse(). No other pages require checking PageCgroupUsed(). Charging pages in the swap cache is also serialized by the page lock, and since both the try_charge and commit_charge are called under the same page lock section, the PageCgroupUsed() check might as well happen before the counter charging, let alone reclaim. Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Acked-by: Michal Hocko <mhocko@suse.cz> Cc: David Rientjes <rientjes@google.com> Cc: Hugh Dickins <hughd@google.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Wanpeng Li <liwp.linux@gmail.com> Cc: Mel Gorman <mel@csn.ul.ie> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
0435a2fdcb
commit
90deb78839
@ -2538,11 +2538,7 @@ static void __mem_cgroup_commit_charge(struct mem_cgroup *memcg,
|
|||||||
bool anon;
|
bool anon;
|
||||||
|
|
||||||
lock_page_cgroup(pc);
|
lock_page_cgroup(pc);
|
||||||
if (unlikely(PageCgroupUsed(pc))) {
|
VM_BUG_ON(PageCgroupUsed(pc));
|
||||||
unlock_page_cgroup(pc);
|
|
||||||
__mem_cgroup_cancel_charge(memcg, nr_pages);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* we don't need page_cgroup_lock about tail pages, becase they are not
|
* we don't need page_cgroup_lock about tail pages, becase they are not
|
||||||
* accessed by any other context at this point.
|
* accessed by any other context at this point.
|
||||||
@ -2807,8 +2803,19 @@ static int __mem_cgroup_try_charge_swapin(struct mm_struct *mm,
|
|||||||
struct mem_cgroup **memcgp)
|
struct mem_cgroup **memcgp)
|
||||||
{
|
{
|
||||||
struct mem_cgroup *memcg;
|
struct mem_cgroup *memcg;
|
||||||
|
struct page_cgroup *pc;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
pc = lookup_page_cgroup(page);
|
||||||
|
/*
|
||||||
|
* Every swap fault against a single page tries to charge the
|
||||||
|
* page, bail as early as possible. shmem_unuse() encounters
|
||||||
|
* already charged pages, too. The USED bit is protected by
|
||||||
|
* the page lock, which serializes swap cache removal, which
|
||||||
|
* in turn serializes uncharging.
|
||||||
|
*/
|
||||||
|
if (PageCgroupUsed(pc))
|
||||||
|
return 0;
|
||||||
if (!do_swap_account)
|
if (!do_swap_account)
|
||||||
goto charge_cur_mm;
|
goto charge_cur_mm;
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user