]> www.infradead.org Git - users/jedix/linux-maple.git/commit
ntsync: Introduce NTSYNC_IOC_WAIT_ALL.
authorElizabeth Figura <zfigura@codeweavers.com>
Fri, 13 Dec 2024 19:34:45 +0000 (13:34 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 8 Jan 2025 12:18:10 +0000 (13:18 +0100)
commitcdbb997822806cc1071619b67aef485bb2b921b1
treee54283ce2dc2e14707d122af3c50d2be5b8b2a5e
parentb4a7b5fe3f5149fa35278807e0dc13ddb093f4b8
ntsync: Introduce NTSYNC_IOC_WAIT_ALL.

This is similar to NTSYNC_IOC_WAIT_ANY, but waits until all of the objects are
simultaneously signaled, and then acquires all of them as a single atomic
operation.

Because acquisition of multiple objects is atomic, some complex locking is
required. We cannot simply spin-lock multiple objects simultaneously, as that
may disable preĆ«mption for a problematically long time.

Instead, modifying any object which may be involved in a wait-all operation takes
a device-wide sleeping mutex, "wait_all_lock", instead of the normal object
spinlock.

Because wait-for-all is a rare operation, in order to optimize wait-for-any,
this lock is only taken when necessary. "all_hint" is used to mark objects which
are involved in a wait-for-all operation, and if an object is not, only its
spinlock is taken.

The locking scheme used here was written by Peter Zijlstra.

Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
Link: https://lore.kernel.org/r/20241213193511.457338-5-zfigura@codeweavers.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/ntsync.c
include/uapi/linux/ntsync.h