Thread (8 messages) 8 messages, 4 authors, 2016-10-14

Re: [PATCH] hidraw: fix list->buffer race condition

From: Gary King <hidden>
Date: 2016-10-14 03:51:01

quoted
[snip]

list_lock does not appear to be a good solution for this, since it is
currently an IRQ-safe spinlock on the device. Using it would cause 
_read() to have unnecessary lock contention if the device is opened 
and read simultaneously from multiple fds, and every loop iteration would 
need to acquire the spinlock / disable interrupts at least once.
We could make the spinlock per struct file *, which'd remove the 
contention bottleneck when the same device is accessed from through 
multiple fds, but still maintain the correctness (as the list itself is a 
per-fd thing anyway).

Probably introducing new spinlock would make more sense, as list_lock is 
currently being used mostly to protect accessing of the dev->list linked 
list.
I've got a patch I'm testing that follows Dmitry's suggestion to add
a per-struct file spinlock and change dev->list to use RCU.

Thanks,

- Gary
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help