memcg: mem_cgroup_charge never NULL

My memcgroup patch to fix hang with shmem/tmpfs added NULL page handling to
mem_cgroup_charge_common.  It seemed convenient at the time, but hard to
justify now: there's a perfectly appropriate swappage to charge and uncharge
instead, this is not on any hot path through shmem_getpage, and no performance
hit was observed from the slight extra overhead.

So revert that NULL page handling from mem_cgroup_charge_common; and make it
clearer by bringing page_cgroup_assign_new_page_cgroup into its body - that
was a helper I found more of a hindrance to understanding.

Signed-off-by: Hugh Dickins <[email protected]>
Cc: David Rientjes <[email protected]>
Acked-by: Balbir Singh <[email protected]>
Acked-by: KAMEZAWA Hiroyuki <[email protected]>
Cc: Hirokazu Takahashi <[email protected]>
Cc: YAMAMOTO Takashi <[email protected]>
Cc: Paul Menage <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
Hugh Dickins 2008-03-04 14:29:08 -08:00 • committed by Linus Torvalds
commit 7e924aafa4
2 changed files with 27 additions and 43 deletions

View file

@ -1370,14 +1370,17 @@ repeat:
shmem_swp_unmap(entry);
spin_unlock(&info->lock);
unlock_page(swappage);
page_cache_release(swappage);
if (error == -ENOMEM) {
/* allow reclaim from this memory cgroup */
error = mem_cgroup_cache_charge(NULL,
error = mem_cgroup_cache_charge(swappage,
current->mm, gfp & ~__GFP_HIGHMEM);
if (error)
if (error) {
page_cache_release(swappage);
goto failed;
}
mem_cgroup_uncharge_page(swappage);
}
page_cache_release(swappage);
goto repeat;
}
} else if (sgp == SGP_READ && !filepage) {