From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: "Kornel Dulęba" <korneld@google.com>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] input: evdev: Read clock directly in __evdev_queue_syn_dropped()
Date: Mon, 2 Nov 2026 19:42:18 -0800 [thread overview]
Message-ID: <aulWqwWvx1Q1DAeL@google.com> (raw)
In-Reply-To: <20261022-evdev_syndropped_fix-v1-2-b5400740e1f7@google.com>
Hi Kornel,
On Thu, Oct 22, 2026 at 01:39:13PM +0000, Kornel Dulęba wrote:
> Currently, __evdev_queue_syn_dropped() calls input_get_timestamp() on
> the underlying input_dev to obtain the event timestamp. If no timestamp
> is set, input_get_timestamp() caches the current time and returns it;
> otherwise, it returns the cached value.
>
> There are two problems with this approach:
>
> 1. Locking. The timestamp is obtained in the same way in
> evdev_events(), which is called with dev->event_lock held. Calls to
> __evdev_queue_syn_dropped() are only serialized with
> client->buffer_lock. This makes both accesses likely racy.
handler->events() is called under dev->event_lock. I'd love to stop
doing this, this is how it is now.
> 2. If no timestamp is cached yet, the subsequent hardware event
> generated after __evdev_queue_syn_dropped() is called will receive
> the stale cached timestamp.
>
> Fix this by reading the current time directly based on the value of
> client->clk_type. Open-coding this is not the prettiest solution, but I
> couldn't figure out anything better.
>
> I initially thought about fixing this by resetting the input timestamp
> in this function instead, similarly to how INPUT_FLUSH handles it.
> However, I decided against it, as that would require non-trivial
> locking changes.
I wonder if we care about timing on the SYN_DROPPED events? Can we just
grab the dev->timestamp and if it is 0 that's fine. Or not even set the
timestamp at all on SYN_DROPPED and have it always at 0.
What do you think?
Thanks.
--
Dmitry
prev parent reply other threads:[~2026-11-03 3:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-22 13:39 [PATCH 0/2] input: evdev: Fix how SYN_DROPPED is generated Kornel Dulęba
2026-10-22 13:39 ` [PATCH 1/2] input: evdev: Always terminate SYN_DROPPED with SYN_REPORT Kornel Dulęba
2026-11-03 3:33 ` Dmitry Torokhov
2026-10-22 13:39 ` [PATCH 2/2] input: evdev: Read clock directly in __evdev_queue_syn_dropped() Kornel Dulęba
2026-11-03 3:42 ` Dmitry Torokhov [this message]
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=aulWqwWvx1Q1DAeL@google.com \
--to=dmitry.torokhov@gmail.com \
--cc=korneld@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
all inboxes | Powered by JetHome®