Re: [PATCH] PERF(kernel): Cleanup power events V2
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- Subject: Re: [PATCH] PERF(kernel): Cleanup power events V2
- From: "Rafael J. Wysocki" <rjw@xxxxxxx>
- Date: Tue, 26 Oct 2010 21:04:21 +0200
- Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>, "Greg Kroah-Hartman" <greg@xxxxxxxxx>, Pierre Tardy <tardyp@xxxxxxxxx>, Arjan van de Ven <arjan@xxxxxxxxxxxxxxx>, Ingo Molnar <mingo@xxxxxxx>, Thomas Renninger <trenn@xxxxxxx>, Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>, Thomas Gleixner <tglx@xxxxxxxxxxxxx>, Masami Hiramatsu <masami.hiramatsu.pt@xxxxxxxxxxx>, Frank Eigler <fche@xxxxxxxxxx>, Steven Rostedt <rostedt@xxxxxxxxxxx>, Kevin Hilman <khilman@xxxxxxxxxxxxxxxxxxx>, linux-omap@xxxxxxxxxxxxxxx, linux-pm@xxxxxxxxxxxxxxxxxxxxxxxxxx, linux-trace-users@xxxxxxxxxxxxxxx, Jean Pihet <jean.pihet@xxxxxxxxxxxxxx>, Frederic Weisbecker <fweisbec@xxxxxxxxx>, Tejun Heo <tj@xxxxxxxxxx>
- In-reply-to: <20101026181421.GA30090@Krystal>
- References: <1287488171-25303-3-git-send-email-trenn@xxxxxxx> <1288115894.3673.12.camel@laptop> <20101026181421.GA30090@Krystal>
- User-agent: KMail/1.13.5 (Linux/2.6.36-rjw+; KDE/4.4.4; x86_64; ; )
On Tuesday, October 26, 2010, Mathieu Desnoyers wrote:
> * Peter Zijlstra (peterz@xxxxxxxxxxxxx) wrote:
> > On Tue, 2010-10-26 at 11:56 -0500, Pierre Tardy wrote:
> > >
> > > + trace_runtime_pm_usage(dev, atomic_read(&dev->power.usage_count)+1);
> > > atomic_inc(&dev->power.usage_count);
> >
> > That's terribly racy..
>
> Looking at the original code, it looks racy even without considering the
> tracepoint:
>
> int __pm_runtime_get(struct device *dev, bool sync)
> {
> int retval;
>
> + trace_runtime_pm_usage(dev, atomic_read(&dev->power.usage_count)+1);
> atomic_inc(&dev->power.usage_count);
> retval = sync ? pm_runtime_resume(dev) : pm_request_resume(dev);
>
> There is no implied memory barrier after "atomic_inc". So either all these
> inc/dec are protected with mutexes or spinlocks, in which case one might wonder
> why atomic operations are used at all, or it's a racy mess. (I vote for the
> second option)
No, it isn't.
> kref should certainly be used there.
No, it shouldn't.
Please try to understand the code you're commenting on first.
Thanks,
Rafael
--
To unsubscribe from this list: send the line "unsubscribe linux-trace-users" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
[Index of Archives]
[Linux USB Development]
[Linux USB Development]
[Linux Audio Users]
[Yosemite Hiking]
[Linux Kernel]
[Linux SCSI]