linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* udevd move from select() to ppoll()
@ 2009-05-13 20:50 Coleman Kane
  2009-05-14  0:05 ` Kay Sievers
  0 siblings, 1 reply; 2+ messages in thread
From: Coleman Kane @ 2009-05-13 20:50 UTC (permalink / raw)
  To: linux-hotplug

Hi,

I'm writing as I recently encountered a regression after the select()
--> ppoll() move in the udevd daemon, running on uClibc-0.9.29 and at
least kernels since 2.6.28.

For some reason the ppoll call always returns -1 w/ EINVAL in this
configuration. I actually anticipate this to be a bug in either Linux or
uClibc...

However, while investigating this, I came across the following sequence
of steps performed in udevd.c (line 973):

fdcount = ppoll(pfd, nfds, NULL, &orig_mask);
sigprocmask(SIG_SETMASK, &orig_mask, NULL);

Maybe I am missing something, but my reading of the man page indicates
that the following sequence would accomplish the same work, but would be
faster, as it eliminates the restoration of blocked_mask at the end of
the ppoll() call, which then proceeds to be overwritten again to what it
was inside ppoll by the above sigprocmask() call.

Would it be basically the same to do the following (but faster)?

sigprocmask(SIG_SETMASK, &orig_mask, NULL);
fdcount = poll(pfd, nfds, -1);

Additionally, this reportedly fixes the EINVAL that is hit in uClibc
too, which doesn't reach the error condition in poll().

-- 
Coleman Kane


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: udevd move from select() to ppoll()
  2009-05-13 20:50 udevd move from select() to ppoll() Coleman Kane
@ 2009-05-14  0:05 ` Kay Sievers
  0 siblings, 0 replies; 2+ messages in thread
From: Kay Sievers @ 2009-05-14  0:05 UTC (permalink / raw)
  To: linux-hotplug

On Wed, May 13, 2009 at 22:50, Coleman Kane <ckane@colemankane.org> wrote:

> For some reason the ppoll call always returns -1 w/ EINVAL in this
> configuration. I actually anticipate this to be a bug in either Linux or
> uClibc...

Likely the libc, I did not hear of any such problems somewhere else.
What does strace show?

> However, while investigating this, I came across the following sequence
> of steps performed in udevd.c (line 973):
>
> fdcount = ppoll(pfd, nfds, NULL, &orig_mask);
> sigprocmask(SIG_SETMASK, &orig_mask, NULL);
>
> Maybe I am missing something, but my reading of the man page indicates
> that the following sequence would accomplish the same work, but would be
> faster, as it eliminates the restoration of blocked_mask at the end of
> the ppoll() call, which then proceeds to be overwritten again to what it
> was inside ppoll by the above sigprocmask() call.
>
> Would it be basically the same to do the following (but faster)?
>
> sigprocmask(SIG_SETMASK, &orig_mask, NULL);
> fdcount = poll(pfd, nfds, -1);

If signals happen between this sigprocmask() and the poll(), you go to
sleep, even when you need to do work. The use of ppoll() is just the
same sequence of operations, but done atomically in the kernel, which
prevents the mentioned race.

Kay

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-05-14  0:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-13 20:50 udevd move from select() to ppoll() Coleman Kane
2009-05-14  0:05 ` Kay Sievers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).