Re: [PATCH v2 4/4] input: evdev: Make device readable only when itcontains a complete packet.

From: Jeffrey Brown
Date: Mon Apr 11 2011 - 16:15:48 EST


Hi Dmitry,

On Tue, Apr 5, 2011 at 9:38 AM, Dmitry Torokhov
<dmitry.torokhov@xxxxxxxxx> wrote:
>> Heh, I faced this very same dilemma.  I tried 'last_sync',
>> 'readable_tail', 'read_end', and others before settling on 'end' and a
>> descriptive comment.
>
> 'packet_head' maybe? Similar to the head but for whole event packet?

That sounds good. It marks the position one past the end of the most
recent packet, or equivalently the beginning of the next packet (if
there is one). :-)

> Before we started changing tail to advance to SYN_DROPPED position we
> could probably drop the buffer lock and sprinkle memory barriers (to
> ensure, for example, that buffer is written before advancing head).
>
> Now we do need to protect buffer and head/tail but the new field can be
> updated outside the lock.

That sounds kind of complicated. Memory barriers and volatile
reads/writers aren't free. Acquiring / releasing the lock already
performs the necessary memory barriers and keeps the code simple since
we can rely on mutual exclusion guarantees to preserve our invariants.
I doubt the buffer lock is highly contended so although we could
probably do without it, I'm not sure it's worth the necessary
contortions. *shrug*

Any further progress on this patch?

Thanks,
Jeff.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/