Skip to contentSkip to conversation

eventfd: add a uapi header for eventfd userspace APIs

PATCH Superseded [email protected] 2 participants 2 messages Jun 11, 2023 – Jun 12, 2023 VFS

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 eventfd: add a uapi header for eventfd userspace APIs

From: Wen Yang <[email protected]>

Create a uapi header include/uapi/linux/eventfd.h, move the associated flags to the uapi header, and include it from linux/eventfd.h.

Cc Alexander Viro <[email protected]>
Cc Jens Axboe <[email protected]>
Cc Christian Brauner <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc Dylan Yudaken <[email protected]>
Cc David Woodhouse <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Eric Biggers <[email protected]>
---
 include/linux/eventfd.h      | 16 +---------------
 include/uapi/linux/eventfd.h | 27 +++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 15 deletions(-)
 create mode 100644 include/uapi/linux/eventfd.h
include/linux/eventfd.h +1 -15
index 98d31cdaca40..c8be8fa6795d 100644
@@ -9,26 +9,12 @@
 #ifndef _LINUX_EVENTFD_H
 #define _LINUX_EVENTFD_H
 
-#include <linux/fcntl.h>
 #include <linux/wait.h>
 #include <linux/err.h>
 #include <linux/percpu-defs.h>
 #include <linux/percpu.h>
 #include <linux/sched.h>
-
-/*
- * CAREFUL: Check include/uapi/asm-generic/fcntl.h when defining
- * new flags, since they might collide with O_* ones. We want
- * to re-use O_* flags that couldn't possibly have a meaning
- * from eventfd, in order to leave a free define-space for
- * shared O_* flags.
- */
-#define EFD_SEMAPHORE (1 << 0)
-#define EFD_CLOEXEC O_CLOEXEC
-#define EFD_NONBLOCK O_NONBLOCK
-
-#define EFD_SHARED_FCNTL_FLAGS (O_CLOEXEC | O_NONBLOCK)
-#define EFD_FLAGS_SET (EFD_SHARED_FCNTL_FLAGS | EFD_SEMAPHORE)
+#include <uapi/linux/eventfd.h>
 
 struct eventfd_ctx;
 struct file;
include/uapi/linux/eventfd.h new file +27 -0
new file mode 100644
index 000000000000..02e9dcdb8d29
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef _UAPI_LINUX_EVENTFD_H
+#define _UAPI_LINUX_EVENTFD_H
+
+#include <linux/types.h>
+
+/* For O_CLOEXEC and O_NONBLOCK */
+#include <linux/fcntl.h>
+
+/* For _IO helpers */
+#include <linux/ioctl.h>
+
+/*
+ * CAREFUL: Check include/uapi/asm-generic/fcntl.h when defining
+ * new flags, since they might collide with O_* ones. We want
+ * to re-use O_* flags that couldn't possibly have a meaning
+ * from eventfd, in order to leave a free define-space for
+ * shared O_* flags.
+ */
+#define EFD_SEMAPHORE (1 << 0)
+#define EFD_CLOEXEC O_CLOEXEC
+#define EFD_NONBLOCK O_NONBLOCK
+
+#define EFD_SHARED_FCNTL_FLAGS (O_CLOEXEC | O_NONBLOCK)
+#define EFD_FLAGS_SET (EFD_SHARED_FCNTL_FLAGS | EFD_SEMAPHORE)
+
+#endif /* _UAPI_LINUX_EVENTFD_H */
Signature · 1 line
2.34.1
#1 lore raw
Quoted 16 lines · On Mon, Jun 12, 2023 at 02:59:20AM +0800, [email protected] wrote:

From: Wen Yang <[email protected]>

Create a uapi header include/uapi/linux/eventfd.h, move the associated flags to the uapi header, and include it from linux/eventfd.h.

Cc Alexander Viro <[email protected]>
Cc Jens Axboe <[email protected]>
Cc Christian Brauner <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc Dylan Yudaken <[email protected]>
Cc David Woodhouse <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Eric Biggers <[email protected]>
Quoted 1 line

---

I think the change overall makes sense but see below.

Quoted 44 lines
 include/linux/eventfd.h      | 16 +---------------
 include/uapi/linux/eventfd.h | 27 +++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 15 deletions(-)
 create mode 100644 include/uapi/linux/eventfd.h
include/linux/eventfd.h +1 -15
index 98d31cdaca40..c8be8fa6795d 100644
@@ -9,26 +9,12 @@
 #ifndef _LINUX_EVENTFD_H
 #define _LINUX_EVENTFD_H
 
-#include <linux/fcntl.h>
 #include <linux/wait.h>
 #include <linux/err.h>
 #include <linux/percpu-defs.h>
 #include <linux/percpu.h>
 #include <linux/sched.h>
-
-/*
- * CAREFUL: Check include/uapi/asm-generic/fcntl.h when defining
- * new flags, since they might collide with O_* ones. We want
- * to re-use O_* flags that couldn't possibly have a meaning
- * from eventfd, in order to leave a free define-space for
- * shared O_* flags.
- */
-#define EFD_SEMAPHORE (1 << 0)
-#define EFD_CLOEXEC O_CLOEXEC
-#define EFD_NONBLOCK O_NONBLOCK
-
-#define EFD_SHARED_FCNTL_FLAGS (O_CLOEXEC | O_NONBLOCK)
-#define EFD_FLAGS_SET (EFD_SHARED_FCNTL_FLAGS | EFD_SEMAPHORE)
+#include <uapi/linux/eventfd.h>
 
 struct eventfd_ctx;
 struct file;
include/uapi/linux/eventfd.h new file +1 -0
new file mode 100644
index 000000000000..02e9dcdb8d29
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */

include/uapi/linux/eventfd.h line 11

Quoted 10 lines
include/uapi/linux/eventfd.h new file +10 -0
+#ifndef _UAPI_LINUX_EVENTFD_H
+#define _UAPI_LINUX_EVENTFD_H
+
+#include <linux/types.h>
+
+/* For O_CLOEXEC and O_NONBLOCK */
+#include <linux/fcntl.h>
+
+/* For _IO helpers */
+#include <linux/ioctl.h>

Why would you want to include that?

include/uapi/linux/eventfd.h line 19

Quoted 8 lines
include/uapi/linux/eventfd.h new file +8 -0
+
+/*
+ * CAREFUL: Check include/uapi/asm-generic/fcntl.h when defining
+ * new flags, since they might collide with O_* ones. We want
+ * to re-use O_* flags that couldn't possibly have a meaning
+ * from eventfd, in order to leave a free define-space for
+ * shared O_* flags.
+ */

I would leave that comment together with EFD_SHARED_FCNTL_FLAGS and EFD_FLAGS_SET in the kernel only header.

include/uapi/linux/eventfd.h line 25

Quoted 6 lines
include/uapi/linux/eventfd.h new file +6 -0
+#define EFD_SEMAPHORE (1 << 0)
+#define EFD_CLOEXEC O_CLOEXEC
+#define EFD_NONBLOCK O_NONBLOCK
+
+#define EFD_SHARED_FCNTL_FLAGS (O_CLOEXEC | O_NONBLOCK)
+#define EFD_FLAGS_SET (EFD_SHARED_FCNTL_FLAGS | EFD_SEMAPHORE)

I think that doesn't belong into the uapi header and should be left in the kernel header.

Quoted 5 lines
include/uapi/linux/eventfd.h new file +2 -0
+
+#endif /* _UAPI_LINUX_EVENTFD_H */
Signature · 1 line
2.34.1