lkml.org 
[lkml]   [2009]   [Sep]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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



\
 
 \ /
  Last update: 2009-09-24 03:43    [W:1.824 / U:0.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site