[lkml]   [2015]   [Mar]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [RFC] ->poll() bugs
On Sat, Mar 07, 2015 at 12:53:14PM -0800, Linus Torvalds wrote:
> On Sat, Mar 7, 2015 at 12:44 PM, Al Viro <> wrote:
> >
> > Most of the catch consists of ->poll() instances that return -E...; there's
> > also an unpleasant mess in net/9p/trans_fd.c and a braino in sunrpc
> > unexpectedly caught by the same annotations.
> Hmm. I do wonder if we should just *allow* ->poll() to return an
> error, and just turn it into "all bits set"?

Doable, but... we do have a bunch of ->poll() call sites (AFAICS, right
now it's
) and while they could be turned into calls of a wrapper, I really don't
like returning negatives as a part of ->poll() calling conventions. I mean,
really - "you should return a bitmap of POLL... flags *or* -E...; doesn't
matter which error number it is, it'll be lost anyway"... It's OK to have the
caller(s) catch such bugs (and report them, IMO), but silently treating it
that way as a part of calling conventions...

Besides, that doesn't catch the bugs like one in net/9p; sparse annotations do.

> But if getting sparse to catch them all isn't *too* painful and the
> patch doesn't end up being horribly big, then I guess that's ok.

Getting sparse to catch them all is as trivial as
* introduce a __bitwise typedef __poll_t => unsigned int
* say that ->poll() (in file_operations, as well as in proto_ops,
tty_ldisc_ops and several in other subsystems) returns __poll_t
* switch the return type of instances from unsigned int to __poll_t
* do the same to local variable(s) (if any) used to hold the return
value to be.

Again, from cc(1) POV it's a no-op - unannotated foo_poll() will be just
fine as it is. The only place where I did something more fancy than
such type change actually had been buggy -
drivers/media/common/siano/smsdvb-debugfs.c:smsdvb_stats_poll() relied
upon smsdvb_stats_wait_read() never returning negatives and it needs
s/__poll_t rc/& = 0/ for correctness (fixed and folded).

 \ /
  Last update: 2015-03-08 02:41    [W:0.060 / U:0.916 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site