• André Almeida's avatar
    HID: hidraw: Replace hidraw device table mutex with a rwsem · 8590222e
    André Almeida authored
    Currently, the table that stores information about the connected hidraw
    devices has a mutex to prevent concurrent hidraw users to manipulate the
    hidraw table (e.g. delete an entry) while someone is trying to use
    the table (e.g. issuing an ioctl to the device), preventing the kernel
    to referencing a NULL pointer. However, since that every user that wants
    to access the table for both manipulating it and reading it content,
    this prevents concurrent access to the table for read-only operations
    for different or the same device (e.g. two hidraw ioctls can't happen at
    the same time, even if they are completely unrelated).
    
    This proves to be a bottleneck and gives performance issues when using
    multiple HID devices at same time, like VR kits where one can have two
    controllers, the headset and some tracking sensors.
    
    To improve the performance, replace the table mutex with a read-write
    semaphore, enabling multiple threads to issue parallel syscalls to
    multiple devices at the same time while protecting the table for
    concurrent modifications.
    Signed-off-by: default avatarAndré Almeida <andrealmeid@collabora.com>
    Signed-off-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
    Link: https://lore.kernel.org/r/20211130132957.8480-2-andrealmeid@collabora.com
    8590222e
hidraw.c 14.4 KB