[PATCH 0/4] memcg fix swap accounting (28/May)

From: KAMEZAWA Hiroyuki
Date: Thu May 28 2009 - 00:56:41 EST


Removed "RFC"

This patch series is restructured as following. some bugs are fixed.
Thank you for all your helps.

[1/4] ....change interface of swap_duplicate()/swap_free()
Adds an function swapcache_prepare() and swapcache_free().

[2/4] ....add SWAP_HAS_CACHE flag and modify reference counting in swap_map
Add SWAP_HAS_CACHE flag to swap_map array for knowing an information that
"there is an only swap cache and swap has no reference"
without extra call of find_get_page().

[3/4] ....reclaim swap-cache-only swap_entry when get_swap_page() find it.
Now, swap_map can tell "there is no reference other than cache", we
can reclaim it if necessary.
This code reclaim swap entries if
- vm_swap_full()==ture
&& there is no free swap cluster
&& get_swap_page() finds unused swap entry.

[4/4].... fix memcg's swap accounting
This is for fixing memcg's swap account leak. like this
==
processA | processB
-------------------------------------+-------------------------------------
(free_swap_and_cache()) | (read_swap_cache_async())
| swap_duplicate()
| __set_page_locked()
| add_to_swap_cache()
swap_entry_free() == 0 |
find_get_page() -> found |
try_lock_page() -> fail & return |
| lru_cache_add_anon()
| doesn't link this page to memcg's
| LRU, because of !PageCgroupUsed.
==
This patch tries to fix this by uncharging account when swap's refcnt goes
to 0 even if there is an unused swap-cache.

Works quite well in my test.

Thanks,
-Kame


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/