[PATCH] xfree86: Use SA_SIGINFO if available for SIGIO handlers

Adam Jackson ajax at nwnk.net
Tue Nov 17 12:57:46 PST 2009

On Tue, 2009-11-10 at 21:15 +0100, Mark Kettenis wrote:
> > From: Adam Jackson <ajax at redhat.com>
> > Date: Tue, 10 Nov 2009 15:03:31 -0500
> > 
> > This one's slightly subtle, the fcntl(F_SETSIG) is required for ->si_fd
> > to actually be filled in correctly, at least on Linux.  I know this area
> > has been sensitive to platform variation in the past, so I'd appreciate
> > a second look from Solaris / BSD / Hurd people.
> Alas, OpenBSD doesn't have si_fd.  So if you really want to go this
> route, you'll need to add an additional configure check for it.


> > siginfo_t gives us the file descriptor that raised the signal directly,
> > so we don't need to select() for it.  This gets evdev event processing
> > down to exactly one syscall in the common case.
> Is that an optimizition that's really worth the added complexity?

Seems straightforward to me.  I just wrote it because it's clearly
correct.  But hey, why guess when you could measure.  This:


in a RHEL5.4 32-bit kvm guest (Fedora 12 host, Intel Core 2 Duo at
2.6GHz) runs about this fast:

% time ./ten-million-selects
./ten-million-selects  1.35s user 4.28s system 94% cpu 5.981 total

So, about 1500 cycles per select call, and if your mouse was absolutely
screaming events at you, you'd max out at something like a thousand per
second, which'd come to about half a millisecond.  If you're a gamer,
you might pretend to notice that.  But, that's a fairly fast machine;
how far down do you want to scale?  Assuming identical syscall code
paths (which is a bit spurious, I know) on a 300MHz chip that'd be 5ms,
which is starting to get into losing frames territory.

Other OSes, naturally, have different numbers.  In an otherwise
identical kvm guest setup, FreeBSD 7.2 gives:

$ time ./ten-million-selects
        9.15 real         1.27 user         7.31 sys

OpenSolaris 0906 gives:

$ time ./ten-million-selects

real    0m4.319s
user    0m2.488s
sys     0m1.379s

I'd have tried OpenBSD 4.6 but it failed to boot once installed and I
couldn't be bothered to figure out if that was a kvm bug or not.

- ajax
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
Url : http://lists.x.org/archives/xorg-devel/attachments/20091117/fb3b3c07/attachment.pgp 

More information about the xorg-devel mailing list