[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190730064657.GA1213@kroah.com>
Date: Tue, 30 Jul 2019 08:46:57 +0200
From: Greg KH <gregkh@...uxfoundation.org>
To: Tri Vo <trong@...roid.com>
Cc: rjw@...ysocki.net, viresh.kumar@...aro.org, rafael@...nel.org,
hridya@...gle.com, sspatil@...gle.com, kaleshsingh@...gle.com,
ravisadineni@...omium.org, swboyd@...omium.org,
linux-kernel@...r.kernel.org, linux-pm@...r.kernel.org,
kernel-team@...roid.com, kbuild test robot <lkp@...el.com>
Subject: Re: [PATCH v5] PM / wakeup: show wakeup sources stats in sysfs
On Mon, Jul 29, 2019 at 07:43:09PM -0700, Tri Vo wrote:
> Userspace can use wakeup_sources debugfs node to plot history of suspend
> blocking wakeup sources over device's boot cycle. This information can
> then be used (1) for power-specific bug reporting and (2) towards
> attributing battery consumption to specific processes over a period of
> time.
>
> However, debugfs doesn't have stable ABI. For this reason, create a
> 'struct device' to expose wakeup sources statistics in sysfs under
> /sys/class/wakeup/wakeup<ID>/*.
I agree with Rafael here, no need for the extra "wakeup" in the device
name as you are in the "wakeup" namespace already.
If you have an IDA-allocated name, there's no need for the extra
'wakeup' at all.
> +int wakeup_source_sysfs_add(struct device *parent, struct wakeup_source *ws)
> +{
> + struct device *dev;
> + int id;
> +
> + id = ida_simple_get(&wakeup_ida, 0, 0, GFP_KERNEL);
> + if (id < 0)
> + return id;
No lock needed for this ida? Are you sure?
> + ws->id = id;
> +
> + dev = device_create_with_groups(wakeup_class, parent, MKDEV(0, 0), ws,
> + wakeup_source_groups, "wakeup%d",
> + ws->id);
> + if (IS_ERR(dev)) {
> + ida_simple_remove(&wakeup_ida, ws->id);
> + return PTR_ERR(dev);
> + }
> +
> + ws->dev = dev;
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(wakeup_source_sysfs_add);
> +
> +/**
> + * wakeup_source_sysfs_remove - Remove wakeup_source attributes from sysfs.
> + * @ws: Wakeup source to be removed from sysfs.
> + */
> +void wakeup_source_sysfs_remove(struct wakeup_source *ws)
> +{
> + device_unregister(ws->dev);
> + ida_simple_remove(&wakeup_ida, ws->id);
Again, no lock, is that ok? I think ida's can work without a lock, but
not always, sorry, I don't remember the rules anymore given the recent
changes in that code.
thanks,
greg k-h
Powered by blists - more mailing lists