From: Jun WANG <junwang1234@gmail.com>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Sleeping in RCU list traversal
Date: Mon, 08 Oct 2007 06:37:20 +0800 [thread overview]
Message-ID: <1191796640.3045.25.camel@localhost.localdomain> (raw)
In-Reply-To: <200710072226.EJF51558.LFVHJOStFOOFMQ@I-love.SAKURA.ne.jp>
> Hello.
>
> Thank you for pointing out.
>
> Jun WANG wrote:
> > >rcu_read_lock();
> > >list_for_each_rcu(p, ...) {
> > > ptr = list_entry(p, struct ..., list);
> > > /* Grab a reference to "ptr". */
> > > rcu_read_unlock();
> > > my_task_that_may_sleep(ptr);
> > > rcu_read_lock();
> > > /* Drop a reference to "ptr". */
> > > }
> > > rcu_read_unlock();
>>>Regarding my case, memory region pointed by "ptr" never be removed.
>>>Do I need to grab a reference to "ptr" ?
> >
> > In Document/RCU/whatisRCU.txt
> > Note that the value returned by rcu_dereference() is valid
> > only within the enclosing RCU read-side critical section.
> Excuse me, but I think "p" is used only between rcu_read_lock() and rcu_read_unlock().
> Is it illegal to use "ptr" after rcu_read_unlock() if "ptr" is obtained before rcu_read_unlock() ?
>
> Regards.
>
I'm sorry,I think I got your idea, if you do not need ptr in
my_task_that_may_sleep(), why you need to grab a reference to "ptr". If
your my_task_that_may_sleep() needs ptr, and according to the
>"memory region pointed by "ptr" never be removed." you say,
it is ok to use "ptr" after rcu_read_ulock(). The basic idea behind RCU
is to split updates into "removal" and "reclamation" phases. If you
memory region pointed by "ptr" will not "reclamation" in sleep, it is ok
Regards.
next prev parent reply other threads:[~2007-10-07 14:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-07 19:11 Re:Sleeping in RCU list traversal Jun WANG
2007-10-07 13:26 ` Sleeping " Tetsuo Handa
2007-10-07 22:37 ` Jun WANG [this message]
2007-10-07 16:56 ` Tetsuo Handa
2007-10-07 18:33 ` Peter Zijlstra
2007-10-07 19:56 ` Tetsuo Handa
-- strict thread matches above, loose matches on Subject: below --
2007-10-03 12:37 [TOMOYO 05/15](repost) Domain transition handler functions James Morris
2007-10-03 13:04 ` Tetsuo Handa
2007-10-03 13:14 ` KaiGai Kohei
2007-10-03 13:59 ` Tetsuo Handa
2007-10-03 14:07 ` Peter Zijlstra
2007-10-07 10:38 ` Sleeping in RCU list traversal Tetsuo Handa
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=1191796640.3045.25.camel@localhost.localdomain \
--to=junwang1234@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
/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