From: Nishanth Menon <nm@ti.com>
To: "paulmck@linux.vnet.ibm.com" <paulmck@linux.vnet.ibm.com>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>,
linux-pm <linux-pm@lists.linux-foundation.org>,
linux-omap <linux-omap@vger.kernel.org>,
lkml <linux-kernel@vger.kernel.org>,
linux-arm <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v4] power: introduce library for device-specific OPPs
Date: Mon, 27 Sep 2010 09:25:30 -0500 [thread overview]
Message-ID: <4CA0A95A.4000408@ti.com> (raw)
In-Reply-To: <20100926005636.GB3396@linux.vnet.ibm.com>
Paul E. McKenney had written, on 09/25/2010 07:56 PM, the following:
> On Sat, Sep 25, 2010 at 10:55:20PM +0200, Rafael J. Wysocki wrote:
>> On Friday, September 24, 2010, Paul E. McKenney wrote:
>>> On Fri, Sep 24, 2010 at 07:50:40AM -0500, Nishanth Menon wrote:
>> ...
>>> Looks like a good start!!! Some questions and suggestions about RCU
>>> usage interspersed below.
>> ...
>>>> + * Locking: RCU reader.
>>>> + */
>>>> +int opp_get_opp_count(struct device *dev)
>>>> +{
>>>> + struct device_opp *dev_opp;
>>>> + struct opp *temp_opp;
>>>> + int count = 0;
>>>> +
>>>> + dev_opp = find_device_opp(dev);
>>>> + if (IS_ERR(dev_opp))
>>>> + return PTR_ERR(dev_opp);
>>>> +
>>>> + rcu_read_lock();
>>>> + list_for_each_entry_rcu(temp_opp, &dev_opp->opp_list, node) {
>>>> + if (temp_opp->available)
>>>> + count++;
>>>> + }
>>>> + rcu_read_unlock();
>>> This one is OK as well. You are returning a count, so if all of the
>>> counted structures are freed at this point, no problem. The count was
>>> valid when it was accumulated, and the fact that it might now be obsolete
>>> is (usually) not a problem.
>> However, it looks like it should run rcu_read_lock() before calling
>> find_device_opp(dev), shouldn't it?
>
> Indeed it does appear that you are right -- good catch!!!
>
> Thanx, Paul
dev_opp as discussed before is safe as it is never freed
(find_device_opp uses it's own rcu_read_lock, the rcu_read_lock in this
context is for the opp list. what am I missing?
ack on Paul's comments w.r.t risk on opp structures itself.. will look
to fix that in v5.
--
Regards,
Nishanth Menon
next prev parent reply other threads:[~2010-09-27 14:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <[PATCH v3] power: introduce library for device-specific OPPs>
2010-09-24 12:50 ` [PATCH v4] power: introduce library for device-specific OPPs Nishanth Menon
2010-09-24 19:37 ` Paul E. McKenney
2010-09-24 21:26 ` Nishanth Menon
2010-09-24 21:40 ` Paul E. McKenney
2010-09-27 14:29 ` Nishanth Menon
2010-09-25 20:55 ` Rafael J. Wysocki
2010-09-26 0:56 ` Paul E. McKenney
2010-09-27 14:25 ` Nishanth Menon [this message]
2010-09-27 19:53 ` Rafael J. Wysocki
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=4CA0A95A.4000408@ti.com \
--to=nm@ti.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-pm@lists.linux-foundation.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=rjw@sisk.pl \
/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;
as well as URLs for NNTP newsgroup(s).