From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Jean Pihet <jean.pihet@newoldbits.com>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>,
Kevin Hilman <khilman@ti.com>,
markgross@thegnar.org,
Linux PM mailing list <linux-pm@lists.linux-foundation.org>,
linux-omap@vger.kernel.org, Paul Walmsley <paul@pwsan.com>,
Magnus Damm <magnus.damm@gmail.com>,
Todd Poynor <toddpoynor@google.com>, Jean Pihet <j-pihet@ti.com>
Subject: Re: [PATCH 06/15] PM QoS: implement the per-device PM QoS constraints
Date: Sun, 14 Aug 2011 15:51:21 +0200 [thread overview]
Message-ID: <201108141551.21449.rjw@sisk.pl> (raw)
In-Reply-To: <CAORVsuVZjrqY0qhEvCpRRvt5RDcG-YT5SJo6Ejhyr-_fTyk9HQ@mail.gmail.com>
Hi,
On Sunday, August 14, 2011, Jean Pihet wrote:
...
> >> +
> >> + if (dev_pm_qos_request_active(req)) {
> >> + WARN(1, KERN_ERR "dev_pm_qos_add_request() called for already "
> >> + "added request\n");
> >> + return;
> >> + }
> >> + req->dev = dev;
> >> +
> >> + /* Allocate the constraints struct on the first call to add_request */
> >> + if (req->dev->power.constraints_state == DEV_PM_QOS_DEVICE_PRESENT)
> >> + dev_pm_qos_constraints_allocate(dev);
> >
> > Why not to do
> >
> > + if (!req->dev->power.constraints)
> > + dev_pm_qos_constraints_allocate(dev);
>
> Cf. my comments at the end of this message for the data structs
> alloc/free and the locking.
>
> >
> >> +
> >> + /* Silently return if the device has been removed */
> >> + if (req->dev->power.constraints_state != DEV_PM_QOS_ALLOCATED)
> >> + return;
> >> +
> >
> > Hmm. What will happen if two callers run dev_pm_qos_add_request()
> > concurrently for the same device?
> update_target is using the power.lock to protect the constraints lists changes.
I was referring to the scenario in particular:
Suppose that there are no constraits for dev initially.
A -> calls dev_pm_qos_add_request(dev)
B -> calls dev_pm_qos_add_request(dev)
A -> sees power.constraints_state == DEV_PM_QOS_DEVICE_PRESENT
and calls dev_pm_qos_constraints_allocate(dev)
B -> sees power.constraints_state == DEV_PM_QOS_DEVICE_PRESENT
and calls dev_pm_qos_constraints_allocate(dev)
As a result, the structure allocated by A is leaked.
...
>
> Your remarks are inline with the concerns I had about the adata
> structs alloc/free and the locking.
>
> 1) data structs alloc/free
> As described in the changelog:
> >> To minimize the data usage by the per-device constraints, the data struct
> >> is only allocated at the first call to dev_pm_qos_add_request.
> >> The data is later free'd when the device is removed from the system.
> A basic state machine is needed in order to allocate the data at the
> first call to add_request and free it when the device is removed.
> Another option is to allocate the data when the device is added to the
> system and free it when the device is removed. That would make the
> code simpler but it is using a lot of memory for unneeded data.
That's fine. You simply need to be more careful about the possible
race conditions when the constraints objects are created and destroyed.
> 2) Race conditions
> I will add a lock to isolate the API callers from
> dev_pm_qos_constraints_destroy().
> The power.lock is already used by update_target so another lock is
> needed to protect the data allocation/free.
OK
> I will rework this tomorrow and re-submit asap when it is ready.
> Is that OK?
Yes, it is.
Thanks,
Rafael
next prev parent reply other threads:[~2011-08-14 13:49 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-11 15:06 [PATCH v4 00/15] PM QoS: add a per-device latency constraints class jean.pihet
2011-08-11 15:06 ` [PATCH 01/15] PM QoS: move and rename the implementation files jean.pihet
2011-08-13 2:47 ` mark gross
2011-08-11 15:06 ` [PATCH 02/15] PM QoS: minor clean-ups jean.pihet
2011-08-13 2:48 ` mark gross
2011-08-11 15:06 ` [PATCH 03/15] PM QoS: code re-organization jean.pihet
2011-08-13 2:50 ` mark gross
2011-08-11 15:06 ` [PATCH 04/15] PM QoS: re-organize data structs jean.pihet
2011-08-13 2:56 ` mark gross
2011-08-13 20:58 ` Rafael J. Wysocki
2011-08-14 8:29 ` Jean Pihet
2011-08-14 13:34 ` Rafael J. Wysocki
2011-08-11 15:06 ` [PATCH 05/15] PM QoS: generalize and export the constraints management code jean.pihet
2011-08-13 3:09 ` mark gross
2011-08-13 20:34 ` Rafael J. Wysocki
2011-08-14 8:25 ` Jean Pihet
2011-08-14 13:37 ` Rafael J. Wysocki
2011-08-16 4:08 ` mark gross
2011-08-16 6:44 ` Jean Pihet
2011-08-16 17:45 ` mark gross
2011-08-16 18:01 ` Rafael J. Wysocki
2011-08-11 15:06 ` [PATCH 06/15] PM QoS: implement the per-device PM QoS constraints jean.pihet
2011-08-13 3:16 ` mark gross
2011-08-13 21:08 ` Rafael J. Wysocki
2011-08-14 8:50 ` Jean Pihet
2011-08-14 13:51 ` Rafael J. Wysocki [this message]
2011-08-11 15:06 ` [PATCH 07/15] PM QoS: add a global notification mechanism for the device constraints jean.pihet
2011-08-14 21:50 ` Rafael J. Wysocki
2011-08-16 9:58 ` Jean Pihet
2011-08-11 15:06 ` [PATCH 08/15] OMAP: convert I2C driver to PM QoS for latency constraints jean.pihet
2011-08-11 15:06 ` [PATCH 09/15] OMAP: PM: create a PM layer plugin for per-device constraints jean.pihet
2011-08-11 15:06 ` [PATCH 10/15] OMAP2+: powerdomain: control power domains next state jean.pihet
2011-08-11 15:06 ` [PATCH 11/15] OMAP3: powerdomain data: add wake-up latency figures jean.pihet
2011-08-11 15:06 ` [PATCH 12/15] OMAP4: " jean.pihet
2011-08-11 15:06 ` [PATCH 13/15] OMAP2+: omap_hwmod: manage the wake-up latency constraints jean.pihet
2011-08-11 15:06 ` [PATCH 14/15] OMAP: PM CONSTRAINTS: implement the devices " jean.pihet
2011-08-11 15:06 ` [PATCH 15/15] OMAP2+: cpuidle only influences the MPU state jean.pihet
2011-08-12 8:02 ` [PATCH v4 00/15] PM QoS: add a per-device latency constraints class Rafael J. Wysocki
2011-08-12 11:56 ` Jean Pihet
2011-08-12 21:56 ` Rafael J. Wysocki
2011-08-14 8:51 ` Jean Pihet
2011-08-14 13:53 ` Rafael J. Wysocki
-- strict thread matches above, loose matches on Subject: below --
2011-08-16 13:43 [PATCH v5 00/15] PM QoS: add a per-device latency constraints framework jean.pihet
2011-08-16 13:43 ` [PATCH 06/15] PM QoS: implement the per-device PM QoS constraints jean.pihet
2011-08-16 21:40 ` 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=201108141551.21449.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=j-pihet@ti.com \
--cc=jean.pihet@newoldbits.com \
--cc=khilman@ti.com \
--cc=linux-omap@vger.kernel.org \
--cc=linux-pm@lists.linux-foundation.org \
--cc=magnus.damm@gmail.com \
--cc=markgross@thegnar.org \
--cc=paul@pwsan.com \
--cc=toddpoynor@google.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