Commit 073e587ec2cc377867e53d8b8959738a8e16cff6
Committed by
Linus Torvalds
1 parent
47c59803be
Exists in
master
and in
4 other branches
memcg: move charge swapin under lock
While page-cache's charge/uncharge is done under page_lock(), swap-cache isn't. (anonymous page is charged when it's newly allocated.) This patch moves do_swap_page()'s charge() call under lock. I don't see any bad problem *now* but this fix will be good for future for avoiding unnecessary racy state. Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Reviewed-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 6 additions and 5 deletions Side-by-side Diff
mm/memory.c
... | ... | @@ -2326,15 +2326,16 @@ |
2326 | 2326 | count_vm_event(PGMAJFAULT); |
2327 | 2327 | } |
2328 | 2328 | |
2329 | + mark_page_accessed(page); | |
2330 | + | |
2331 | + lock_page(page); | |
2332 | + delayacct_clear_flag(DELAYACCT_PF_SWAPIN); | |
2333 | + | |
2329 | 2334 | if (mem_cgroup_charge(page, mm, GFP_KERNEL)) { |
2330 | - delayacct_clear_flag(DELAYACCT_PF_SWAPIN); | |
2331 | 2335 | ret = VM_FAULT_OOM; |
2336 | + unlock_page(page); | |
2332 | 2337 | goto out; |
2333 | 2338 | } |
2334 | - | |
2335 | - mark_page_accessed(page); | |
2336 | - lock_page(page); | |
2337 | - delayacct_clear_flag(DELAYACCT_PF_SWAPIN); | |
2338 | 2339 | |
2339 | 2340 | /* |
2340 | 2341 | * Back out if somebody else already faulted in this pte. |