public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <jens.axboe@oracle.com>
To: Vivek Goyal <vgoyal@redhat.com>
Cc: Gui Jianfeng <guijianfeng@cn.fujitsu.com>,
	Corrado Zoccolo <czoccolo@gmail.com>,
	linux kernel mailing list <linux-kernel@vger.kernel.org>,
	Li Zefan <lizf@cn.fujitsu.com>
Subject: Re: [PATCH] cfq: Remove useless css reference get
Date: Wed, 16 Dec 2009 19:38:17 +0100	[thread overview]
Message-ID: <20091216183817.GW28252@kernel.dk> (raw)
In-Reply-To: <20091216163941.GA2807@redhat.com>

On Wed, Dec 16 2009, Vivek Goyal wrote:
> On Wed, Dec 16, 2009 at 04:38:43PM +0800, Gui Jianfeng wrote:
> > There's no need to take css reference here, for the caller
> > has already called rcu_read_lock() to prevent cgroup from 
> > being removed.
> > 
> > Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
> > Reviewed-by: Li Zefan <lizf@cn.fujitsu.com>
> 
> Hi Gui,
> 
> How would an rcu lock protect against the possibility that blkiocg_destroy()
> has not already been called on another cpu? rcu lock will make sure that
> cgroup and blkio_cgroup object should still be around as long as I am
> holding rcu lock but will not protect against deletion path being executed
> on another cpu? So I don't want to end up in following situation.
> 
>      cpu1                      cpu2
> 
> rcu_read_lock()
> 			      blkiocg_destroy()
> 
> blkiocg_add_blkio_group()
> rcu_read_unlock()
> 
> I don't want to add blkg object on a potentially dead blkio_cgroup object
> which will go away. Does this protection is provided by generic cgroup
> code where blkiocg_destroy() will not be called if I have got cgroup
> pointer under rcu lock?

Hmm, looking at blkiocg_destroy(), it seems to free blkcg directly. You
need an RCU grace period to pass in between, if you expect blkcg to be
valid under rcu_read_lock() always. Or is ->destroy() called from an RCU
callback? Checks... OK, so it looks like cgroup guarantees
synchronize_rcu() before calling ->destroy(), so that should be safe.

Why is it doing both rcu_read_lock() and grabbing the update lock?

On the real topic, it'll of course only guarentee that blkcg is valid
inside the rcu read lock. If it needs to be valid afterwards, the
reference must be grabbed.

> Currently we are deriving cgroup information from task context so task is
> still inside cgroup, so cgroup can't be deleted anyway. What if I was 
> deriving cgroup information from bio, will taking css object reference be
> necessary in that case or just cgroup pointer under rcu lock is sufficient
> to preclude the race against cgroup deletion path?

It's guarenteed that ->destroy() cannot be called while someone is under
rcu_read_lock().

-- 
Jens Axboe


  reply	other threads:[~2009-12-16 18:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-16  8:38 [PATCH] cfq: Remove useless css reference get Gui Jianfeng
2009-12-16 11:09 ` Corrado Zoccolo
2009-12-16 13:13   ` Jens Axboe
2009-12-16 16:39 ` Vivek Goyal
2009-12-16 18:38   ` Jens Axboe [this message]
2009-12-16 19:40     ` Vivek Goyal
2009-12-17  5:57   ` Li Zefan
2009-12-18 15:08     ` Vivek Goyal
2009-12-21 16:28 ` Vivek Goyal
2010-02-26  5:21   ` Gui Jianfeng
2010-02-26  7:56     ` Jens Axboe

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=20091216183817.GW28252@kernel.dk \
    --to=jens.axboe@oracle.com \
    --cc=czoccolo@gmail.com \
    --cc=guijianfeng@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizf@cn.fujitsu.com \
    --cc=vgoyal@redhat.com \
    /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