linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] input/evdev: Be less aggressive about sending SIGIO notifies
@ 2010-01-04 21:08 Adam Jackson
  2010-01-05  6:51 ` Dmitry Torokhov
  0 siblings, 1 reply; 2+ messages in thread
From: Adam Jackson @ 2010-01-04 21:08 UTC (permalink / raw)
  To: linux-input

When using realtime signals, we'll enqueue one signal for every event.
This is unfortunate, because (for example) keyboard presses are three
events: key, msc scancode, and syn.  They'll be enqueued fast enough in
kernel space that all three events will be ready to read by the time
userspace runs, so the first invocation of the signal handler will read
all three events, but then the second two invocations still have to run
to do no work.

Instead, only send the SIGIO notification on syn events.  This is a
slight abuse of SIGIO semantics, in principle it ought to fire as soon
as any events are readable.  But it matches evdev semantics, which is
more important since SIGIO is rather vaguely defined to begin with.

Signed-off-by: Adam Jackson <ajax@redhat.com>
---
 drivers/input/evdev.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index dee6706..258c639 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -59,7 +59,8 @@ static void evdev_pass_event(struct evdev_client *client,
 	client->head &= EVDEV_BUFFER_SIZE - 1;
 	spin_unlock(&client->buffer_lock);
 
-	kill_fasync(&client->fasync, SIGIO, POLL_IN);
+	if (event->type == EV_SYN)
+		kill_fasync(&client->fasync, SIGIO, POLL_IN);
 }
 
 /*
-- 
1.6.5.2


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

* Re: [PATCH] input/evdev: Be less aggressive about sending SIGIO notifies
  2010-01-04 21:08 [PATCH] input/evdev: Be less aggressive about sending SIGIO notifies Adam Jackson
@ 2010-01-05  6:51 ` Dmitry Torokhov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2010-01-05  6:51 UTC (permalink / raw)
  To: Adam Jackson; +Cc: linux-input

On Mon, Jan 04, 2010 at 04:08:17PM -0500, Adam Jackson wrote:
> When using realtime signals, we'll enqueue one signal for every event.
> This is unfortunate, because (for example) keyboard presses are three
> events: key, msc scancode, and syn.  They'll be enqueued fast enough in
> kernel space that all three events will be ready to read by the time
> userspace runs, so the first invocation of the signal handler will read
> all three events, but then the second two invocations still have to run
> to do no work.
> 
> Instead, only send the SIGIO notification on syn events.  This is a
> slight abuse of SIGIO semantics, in principle it ought to fire as soon
> as any events are readable.  But it matches evdev semantics, which is
> more important since SIGIO is rather vaguely defined to begin with.

Makes sense, will apply. It might mess up evtest slightly (if a driver
author forgets using input_sync() ) but we have evbug for true hardcore
debugging :)

-- 
Dmitry

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

end of thread, other threads:[~2010-01-05  6:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-04 21:08 [PATCH] input/evdev: Be less aggressive about sending SIGIO notifies Adam Jackson
2010-01-05  6:51 ` Dmitry Torokhov

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).