From: yamamoto-jCdQPDEk3idL9jVzuh4AOg@public.gmane.org (YAMAMOTO Takashi)
To: nishimura-YQH0OdQVrdy45+QrQBaojngSJqDPrsil@public.gmane.org
Cc: linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org,
kosaki.motohiro-+CUm20s59erQFUHtdCDX3A@public.gmane.org,
containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org,
hugh-DTz5qymZ9yRBDgjK7y7TUQ@public.gmane.org,
xemul-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org,
balbir-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org
Subject: Re: [PATCH -mm 5/5] swapcgroup (v3): implement force_empty
Date: Fri, 4 Jul 2008 16:48:28 +0900 (JST) [thread overview]
Message-ID: <20080704074828.330DC5A19@siro.lan> (raw)
In-Reply-To: Your message of "Fri, 4 Jul 2008 16:26:29 +0900" <20080704162629.b06b6810.nishimura-YQH0OdQVrdy45+QrQBaojngSJqDPrsil@public.gmane.org>
> Hi, Yamamoto-san.
>
> Thank you for your comment.
>
> On Fri, 4 Jul 2008 15:54:31 +0900 (JST), yamamoto-jCdQPDEk3idL9jVzuh4AOg@public.gmane.org (YAMAMOTO Takashi) wrote:
> > hi,
> >
> > > +/*
> > > + * uncharge all the entries that are charged to the group.
> > > + */
> > > +void __swap_cgroup_force_empty(struct mem_cgroup *mem)
> > > +{
> > > + struct swap_info_struct *p;
> > > + int type;
> > > +
> > > + spin_lock(&swap_lock);
> > > + for (type = swap_list.head; type >= 0; type = swap_info[type].next) {
> > > + p = swap_info + type;
> > > +
> > > + if ((p->flags & SWP_ACTIVE) == SWP_ACTIVE) {
> > > + unsigned int i = 0;
> > > +
> > > + spin_unlock(&swap_lock);
> >
> > what prevents the device from being swapoff'ed while you drop swap_lock?
> >
> Nothing.
>
> After searching the entry to be uncharged(find_next_to_unuse below),
> I recheck under swap_lock whether the entry is charged to the group.
> Even if the device is swapoff'ed, swap_off must have uncharged the entry,
> so I don't think it's needed anyway.
>
> > YAMAMOTO Takashi
> >
> > > + while ((i = find_next_to_unuse(p, i, mem)) != 0) {
> > > + spin_lock(&swap_lock);
> > > + if (p->swap_map[i] && p->memcg[i] == mem)
> Ah, I think it should be added !p->swap_map to check the device has not
> been swapoff'ed.
find_next_to_unuse seems to have fragile assumptions and
can dereference p->swap_map as well.
YAMAMOTO Takashi
>
>
> Thanks,
> Daisuke Nishimura.
>
> > > + swap_cgroup_uncharge(p, i);
> > > + spin_unlock(&swap_lock);
> > > + }
> > > + spin_lock(&swap_lock);
> > > + }
> > > + }
> > > + spin_unlock(&swap_lock);
> > > +
> > > + return;
> > > +}
> > > #endif
next prev parent reply other threads:[~2008-07-04 7:48 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-04 6:15 [PATCH -mm 0/5] swapcgroup (v3) Daisuke Nishimura
[not found] ` <20080704151536.e5384231.nishimura-YQH0OdQVrdy45+QrQBaojngSJqDPrsil@public.gmane.org>
2008-07-04 6:17 ` [PATCH -mm 1/5] swapcgroup (v3): add cgroup files Daisuke Nishimura
[not found] ` <20080704151747.470d62a3.nishimura-YQH0OdQVrdy45+QrQBaojngSJqDPrsil@public.gmane.org>
2008-07-10 20:35 ` Dave Hansen
2008-07-11 11:02 ` Daisuke Nishimura
2008-07-04 6:18 ` [PATCH -mm 2/5] swapcgroup (v3): add a member to swap_info_struct Daisuke Nishimura
2008-07-04 6:20 ` [PATCH -mm 3/5] swapcgroup (v3): implement charge and uncharge Daisuke Nishimura
2008-07-04 6:22 ` [PATCH -mm 4/5] swapcgroup (v3): modify vm_swap_full() Daisuke Nishimura
[not found] ` <20080704152244.7fc2ccd1.nishimura-YQH0OdQVrdy45+QrQBaojngSJqDPrsil@public.gmane.org>
2008-07-04 9:58 ` KAMEZAWA Hiroyuki
[not found] ` <20080704185845.0baaca76.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2008-07-04 10:40 ` Daisuke Nishimura
2008-07-04 6:24 ` [PATCH -mm 5/5] swapcgroup (v3): implement force_empty Daisuke Nishimura
[not found] ` <20080704152423.f65932b3.nishimura-YQH0OdQVrdy45+QrQBaojngSJqDPrsil@public.gmane.org>
2008-07-04 6:54 ` YAMAMOTO Takashi
[not found] ` <20080704065431.A8BDC5A19-Pcsii4f/SVk@public.gmane.org>
2008-07-04 7:26 ` Daisuke Nishimura
[not found] ` <20080704162629.b06b6810.nishimura-YQH0OdQVrdy45+QrQBaojngSJqDPrsil@public.gmane.org>
2008-07-04 7:48 ` YAMAMOTO Takashi [this message]
[not found] ` <20080704074828.330DC5A19-Pcsii4f/SVk@public.gmane.org>
2008-07-04 7:56 ` Daisuke Nishimura
2008-07-04 10:16 ` KAMEZAWA Hiroyuki
[not found] ` <20080704191638.b63892f5.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2008-07-04 12:33 ` Daisuke Nishimura
[not found] ` <20080704213301.7d476941.nishimura-YQH0OdQVrdy45+QrQBaojngSJqDPrsil@public.gmane.org>
2008-07-05 4:29 ` KAMEZAWA Hiroyuki
[not found] ` <20080705132944.7cf07bd8.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2008-07-07 6:23 ` Daisuke Nishimura
2008-07-04 9:40 ` [PATCH -mm 0/5] swapcgroup (v3) KAMEZAWA Hiroyuki
[not found] ` <20080704184033.7cac4b69.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2008-07-04 10:58 ` Daisuke Nishimura
2008-07-05 6:52 ` Balbir Singh
[not found] ` <486F1A29.4020407-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2008-07-07 6:48 ` Daisuke Nishimura
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080704074828.330DC5A19@siro.lan \
--to=yamamoto-jcdqpdek3idl9jvzuh4aog@public.gmane.org \
--cc=balbir-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org \
--cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
--cc=hugh-DTz5qymZ9yRBDgjK7y7TUQ@public.gmane.org \
--cc=kosaki.motohiro-+CUm20s59erQFUHtdCDX3A@public.gmane.org \
--cc=linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org \
--cc=nishimura-YQH0OdQVrdy45+QrQBaojngSJqDPrsil@public.gmane.org \
--cc=xemul-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox