From: "Henrik Rydberg" <rydberg@euromail.se>
To: Jeff Brown <jeffbrown@android.com>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
Jeff Brown <jeffbrown@google.com>
Subject: Re: [PATCH 3/4] input: evdev: Indicate buffer overrun with SYN_DROPPED.
Date: Fri, 25 Mar 2011 10:02:10 +0100 [thread overview]
Message-ID: <20110325090210.GA5860@polaris.bitmath.org> (raw)
In-Reply-To: <1300842244-42723-4-git-send-email-jeffbrown@android.com>
> @@ -57,14 +57,20 @@ static void evdev_pass_event(struct evdev_client *client,
> {
> /*
> * Interrupts are disabled, just acquire the lock.
> - * Make sure we don't leave with the client buffer
> - * "empty" by having client->head == client->tail.
> + * When the client buffer is full, replace the tail with SYN_DROPPED
> + * to let the client know that events were dropped. Ensure that the
> + * head and tail never coincide so the buffer does not appear "empty".
> */
> spin_lock(&client->buffer_lock);
> - do {
> - client->buffer[client->head++] = *event;
> - client->head &= client->bufsize - 1;
> - } while (client->head == client->tail);
> + client->buffer[client->head++] = *event;
> + client->head &= client->bufsize - 1;
> + if (client->head == client->tail) {
> + client->tail = (client->tail + 1) & (client->bufsize - 1);
> + client->buffer[client->tail].time = event->time;
> + client->buffer[client->tail].type = EV_SYN;
> + client->buffer[client->tail].code = SYN_DROPPED;
> + client->buffer[client->tail].value = 0;
> + }
> spin_unlock(&client->buffer_lock);
My last comment was not right, the SYN_DROPPED is pushed ahead in the
buffer, sorry about that. However, this change does not shrink the
number of buffered elements in case of an overrun, which has been
discussed before as a possibly important feature of the current
code. I would be more comfortable prepending the head with a
SYN_DROPPED, like this:
if (client->head == client->tail) {
struct input_event drop;
drop.time = event->time;
drop.type = EV_SYN;
drop.code = SYN_DROPPED;
drop.value = 0;
client->buffer[client->head++] = drop;
client->head &= client->bufsize - 1;
client->buffer[client->head++] = *event;
client->head &= client->bufsize - 1;
}
The main point is that if we end up having to drop an event, it is
likely we will have to drop the next one, too.
Thanks,
Henrik
next prev parent reply other threads:[~2011-03-25 8:58 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-23 1:04 [PATCH 0/4] input: Sizing the evdev ring buffer for MT devices and reporting overruns Jeff Brown
2011-03-23 1:04 ` [PATCH 1/4] input: Set default events per packet Jeff Brown
2011-03-25 8:20 ` Henrik Rydberg
2011-03-25 23:30 ` Jeffrey Brown
2011-03-28 7:10 ` Henrik Rydberg
2011-03-23 1:04 ` [PATCH 2/4] hid: hid-input: Remove obsolete default events per packet setting Jeff Brown
2011-03-23 1:04 ` [PATCH 3/4] input: evdev: Indicate buffer overrun with SYN_DROPPED Jeff Brown
2011-03-25 7:47 ` Dmitry Torokhov
2011-03-25 8:14 ` Henrik Rydberg
2011-03-25 9:02 ` Henrik Rydberg [this message]
[not found] ` <AANLkTike4c7SaeAm5JVWcLyZYt1K59OUEk94rnPeRkMy@mail.gmail.com>
2011-03-25 23:10 ` Jeffrey Brown
2011-03-25 23:12 ` Jeffrey Brown
2011-03-23 1:04 ` [PATCH 4/4] input: evdev: only wake poll on EV_SYN Jeff Brown
2011-03-25 7:49 ` Dmitry Torokhov
2011-03-25 23:03 ` Jeffrey Brown
2011-03-28 6:12 ` Dmitry Torokhov
2011-03-28 8:54 ` Jeffrey Brown
2011-03-25 8:34 ` Henrik Rydberg
2011-03-25 23:07 ` Jeffrey Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110325090210.GA5860@polaris.bitmath.org \
--to=rydberg@euromail.se \
--cc=jeffbrown@android.com \
--cc=jeffbrown@google.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox