On Tue, 3 Sep 2019, Akinobu Mita wrote: > 2019年9月3日(火) 6:47 Rafael J. Wysocki <rafael@xxxxxxxxxx>: > > > > On Sun, Sep 1, 2019 at 4:09 PM Akinobu Mita <akinobu.mita@xxxxxxxxx> wrote: > > > > > > This enables the /sys/devices/.../power/runtime_status attribute to > > > allow the user space to get notifications via poll/select when the device > > > runtime PM status is changed. > > > > > > An example use case is to avoid unnecessary accesses for device statistics > > > (e.g. diskstats for block devices) while the device is in runtime suspend > > > by user space LED device actitity trigger. > > > > > > Cc: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> > > > Cc: Dominik Brodowski <linux@xxxxxxxxxxxxxxxxxxxx> > > > Cc: "Rafael J. Wysocki" <rjw@xxxxxxxxxxxxx> > > > Signed-off-by: Akinobu Mita <akinobu.mita@xxxxxxxxx> > > There are concerns about this. > > > > First off, it adds overhead for devices that change the PM-runtime > > status relatively often. I'm not sure if that's sufficiently > > justified. > > > > Second, it is called for status changes from "active" to "suspending" > > and from "suspending" to "suspended" (and analogously for resume) > > which may not be particularly useful. At least, user space may not > > have enough time to act on such notifications. > > > > Finally, it is racy, because at the time user space does something on > > a device PM-runtime status change, it very well may have changed the > > other way around already. > > I withdraw this patch now. I hope I'll retry with a real use case example > program. You might want to take a look at commit 7794f486ed0b ("usbfs: Add ioctls for runtime power management") in the usb-next branch of Greg KH's usb.git tree. It adds a mechanism for user programs to wait until a device has done a runtime resume, without races. But it is not general purpose (it applies only to USB devices), it doesn't use poll(), and it doesn't check for other kinds of runtime PM status changes. Alan Stern