mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-23 05:56:14 -04:00
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>
38 lines
800 B
C
38 lines
800 B
C
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
|
/*
|
|
* Kernel support for NT synchronization primitive emulation
|
|
*
|
|
* Copyright (C) 2021-2022 Elizabeth Figura <zfigura@codeweavers.com>
|
|
*/
|
|
|
|
#ifndef __LINUX_NTSYNC_H
|
|
#define __LINUX_NTSYNC_H
|
|
|
|
#include <linux/types.h>
|
|
|
|
struct ntsync_sem_args {
|
|
__u32 count;
|
|
__u32 max;
|
|
};
|
|
|
|
#define NTSYNC_WAIT_REALTIME 0x1
|
|
|
|
struct ntsync_wait_args {
|
|
__u64 timeout;
|
|
__u64 objs;
|
|
__u32 count;
|
|
__u32 index;
|
|
__u32 flags;
|
|
__u32 pad[3];
|
|
};
|
|
|
|
#define NTSYNC_MAX_WAIT_COUNT 64
|
|
|
|
#define NTSYNC_IOC_CREATE_SEM _IOW ('N', 0x80, struct ntsync_sem_args)
|
|
#define NTSYNC_IOC_WAIT_ANY _IOWR('N', 0x82, struct ntsync_wait_args)
|
|
#define NTSYNC_IOC_WAIT_ALL _IOWR('N', 0x83, struct ntsync_wait_args)
|
|
|
|
#define NTSYNC_IOC_SEM_RELEASE _IOWR('N', 0x81, __u32)
|
|
|
|
#endif
|