Message ID | tencent_F7EEF9B42A817A28086FF22DBD84B9CF2F05@qq.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | eventfd: add a uapi header for eventfd userspace APIs | expand |
On Mon, Jun 12, 2023 at 02:59:20AM +0800, wenyang.linux@foxmail.com wrote: > From: Wen Yang <wenyang.linux@foxmail.com> > > Create a uapi header include/uapi/linux/eventfd.h, move the associated > flags to the uapi header, and include it from linux/eventfd.h. > > Signed-off-by: Wen Yang <wenyang.linux@foxmail.com> > Cc: Alexander Viro <viro@zeniv.linux.org.uk> > Cc: Jens Axboe <axboe@kernel.dk> > Cc: Christian Brauner <brauner@kernel.org> > Cc: Christoph Hellwig <hch@lst.de> > Cc: Dylan Yudaken <dylany@fb.com> > Cc: David Woodhouse <dwmw@amazon.co.uk> > Cc: Matthew Wilcox <willy@infradead.org> > Cc: Eric Biggers <ebiggers@google.com> > Cc: linux-fsdevel@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > --- I think the change overall makes sense but see below. > 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 > > diff --git a/include/linux/eventfd.h b/include/linux/eventfd.h > index 98d31cdaca40..c8be8fa6795d 100644 > --- a/include/linux/eventfd.h > +++ b/include/linux/eventfd.h > @@ -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; > diff --git a/include/uapi/linux/eventfd.h b/include/uapi/linux/eventfd.h > new file mode 100644 > index 000000000000..02e9dcdb8d29 > --- /dev/null > +++ b/include/uapi/linux/eventfd.h > @@ -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> Why would you want to include that? > + > +/* > + * 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. > +#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. > + > +#endif /* _UAPI_LINUX_EVENTFD_H */ > -- > 2.34.1 >
diff --git a/include/linux/eventfd.h b/include/linux/eventfd.h index 98d31cdaca40..c8be8fa6795d 100644 --- a/include/linux/eventfd.h +++ b/include/linux/eventfd.h @@ -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; diff --git a/include/uapi/linux/eventfd.h b/include/uapi/linux/eventfd.h new file mode 100644 index 000000000000..02e9dcdb8d29 --- /dev/null +++ b/include/uapi/linux/eventfd.h @@ -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 */