lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANA+-vA7TcGMndqwmYk4y8Kyi6LbcmtnBBhzWca2qreJ0dU_Hw@mail.gmail.com>
Date:   Tue, 30 Jul 2019 12:20:16 -0700
From:   Tri Vo <trong@...roid.com>
To:     Greg KH <gregkh@...uxfoundation.org>
Cc:     "Rafael J. Wysocki" <rjw@...ysocki.net>,
        Viresh Kumar <viresh.kumar@...aro.org>,
        "Rafael J. Wysocki" <rafael@...nel.org>,
        Hridya Valsaraju <hridya@...gle.com>,
        Sandeep Patil <sspatil@...gle.com>,
        Kalesh Singh <kaleshsingh@...gle.com>,
        Ravi Chandra Sadineni <ravisadineni@...omium.org>,
        Stephen Boyd <swboyd@...omium.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Linux PM <linux-pm@...r.kernel.org>,
        "Cc: Android Kernel" <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 11:47 PM Greg KH <gregkh@...uxfoundation.org> wrote:
>
> 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.

Documentation says, "The IDA handles its own locking. It is safe to
call any of the IDA functions without synchronisation in your code."
https://www.kernel.org/doc/html/latest/core-api/idr.html#ida-usage

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ