Re: [PATCH 2/4] send callback when swap slot is freed

From: KAMEZAWA Hiroyuki
Date: Wed Sep 23 2009 - 21:42:06 EST


On Fri, 18 Sep 2009 04:13:30 +0530
Nitin Gupta <ngupta@xxxxxxxxxx> 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

--
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/