Re: [PATCH] [RFC] Add support for uevents on block device idle changes

Matthew Garrett
2009-11-20T20:29:21Z

On Thu, Nov 19, 2009 at 04:00:46PM +0100, Kay Sievers wrote:

> Yeah, it would not be as simple as your patch. It probably involves a
> way to get a file descriptor per listener, to let the kernel know if
> anybody is interested, and to auto-cleanup when the listener dies, and
> to have per instance timers.

This would seem to involve a lot of extra locking in the block
submission and completion code. I don't think it's ideal. How about
this:

* idle_hysteresis contains a value. If it's greater than 0, attempting
to increase it will give -EINVAL. It can be polled.

* On idle state transition, applications listening to the stat sysfs
node will get woken. The stat output will include the number of msecs
that the disk has been idle. If this is less than the application
requested, it can set a timer to wake it up again in the future and
recheck.

* When an application exits, if (and only if) it wrote a value to
idle_hysteresis, it should set this back to 0. This will notify any
other apps, which may then set their own wakeup time.

It's not beautiful but it satisfies the constraints. There's a minimum
of extra wakeups, it doesn't complicate the block path any further and
multiple applications can take advantage of it.

--
Matthew Garrett | mjg59@srcf.ucam.org