Messages in this thread | | | Date | Thu, 24 Sep 2009 10:39:19 +0900 | From | KAMEZAWA Hiroyuki <> | Subject | Re: [PATCH 2/4] send callback when swap slot is freed |
| |
On Fri, 18 Sep 2009 04:13:30 +0530 Nitin Gupta <ngupta@vflare.org> wrote:
> @@ -585,6 +617,8 @@ static int swap_entry_free(struct swap_info_struct *p, > swap_list.next = p - swap_info; > nr_swap_pages++; > p->inuse_pages--; > + if (p->swap_free_notify_fn) > + p->swap_free_notify_fn(p->bdev, offset); > } > if (!swap_count(count)) > mem_cgroup_uncharge_swap(ent);
A nitpick but I feel I have to explain why mem_cgroup_ucharge_swap() is called here. (difference with p->swap_free_notify_fn)
if (!swap_count(count))
means "It seems no users for this swap entry but we're not sure there are SwapCache for this entry or not."
In mem_cgroup_uncharge_swap(), swap_cgroup is checked and if there is a record (which means the SwapCache is not mapped anywhere), swap usage is uncharged.
This is for race window at freeing swap entry via zap_pte_range() => free_swap_and_cache(). (swap entry is not freed if the page is locked.)
I'll add some explanation in next series of memcg-cleanup patches.
Thanks, -Kame
| |