Re: lsusd - The Linux SUSpend Daemon

From: Alan Stern
Date: Sun Oct 23 2011 - 12:17:45 EST


On Sun, 23 Oct 2011, NeilBrown wrote:

> > There shouldn't be any trouble about making wakeup_count pollable. It
> > also would need to respect nonblocking reads, which it currently does
> > not do.
>
> Hmm.. you are correct. I wonder why I thought it did support non-blocking
> reads...
> I guess it was the code for handling an interrupted system call.
>
> I feel a bit uncomfortable with the idea of sysfs files that block but I
> don't think I can convincingly argue against it.
> A non-blocking flag could be passed in, but it would be a very messy change -
> lots of function call signatures changing needlessly: we would need a flag
> to the 'show' method ... or add a 'show_nonblock' method which would also be
> ugly.

Right. Sysfs is pretty inflexible.

> But I think there is a need to block - if there is an in-progress event then
> it must be possible to wait for it to complete as it may not be visible to
> userspace until then.
> We could easily enable 'poll' for wakeup_count and then make it always
> non-blocking, but I'm not really sure I want to require programs to use poll,
> only to allow them. And without using poll there is no way to wait.
>
> As wakeup_count really has to be single-access we could possibly fudge
> something by remembering the last value read (like we remember the last value
> written).

A simpler approach would be to add a nonblocking variant:
/sys/power/wakeup_count_nb. It would make sense to support poll for
this file; poll isn't very useful for the wakeup_count file.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/