]> Git Repo - linux.git/commit
mm: modify swap_map and add SWAP_HAS_CACHE flag
authorKAMEZAWA Hiroyuki <[email protected]>
Tue, 16 Jun 2009 22:32:53 +0000 (15:32 -0700)
committerLinus Torvalds <[email protected]>
Wed, 17 Jun 2009 02:47:42 +0000 (19:47 -0700)
commit355cfa73ddff2fb8fa14e93bd94a057cc022512e
tree7ff70cd56d533070d50b06db6ba0086e8aab0d71
parentcb4b86ba47bb0937b71fb825b3ed88adf7a190f0
mm: modify swap_map and add SWAP_HAS_CACHE flag

This is a part of the patches for fixing memcg's swap accountinf leak.
But, IMHO, not a bad patch even if no memcg.

There are 2 kinds of references to swap.
 - reference from swap entry
 - reference from swap cache

Then,

 - If there is swap cache && swap's refcnt is 1, there is only swap cache.
  (*) swapcount(entry) == 1 && find_get_page(swapper_space, entry) != NULL

This counting logic have worked well for a long time.  But considering
that we cannot know there is a _real_ reference or not by swap_map[],
current usage of counter is not very good.

This patch adds a flag SWAP_HAS_CACHE and recored information that a swap
entry has a cache or not.  This will remove -1 magic used in swapfile.c
and be a help to avoid unnecessary find_get_page().

Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>
Tested-by: Daisuke Nishimura <[email protected]>
Cc: Balbir Singh <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: Li Zefan <[email protected]>
Cc: Dhaval Giani <[email protected]>
Cc: YAMAMOTO Takashi <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
include/linux/swap.h
mm/swap_state.c
mm/swapfile.c
This page took 0.054968 seconds and 4 git commands to generate.