Skip to contentSkip to conversation

assume some linux syscalls are always present: epoll, splice, inotify

PATCH Superseded Michael Tokarev 2 participants 6 messages Jan 19 – Feb 3 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

v2 cover assume some linux syscalls are always present: epoll, splice, inotify

There are numerous checks in the code wrt availability of linux subsystems. It makes no sense to check for them anymore, since they're always present (since linux 2.6 or earlier).

I'm not resending the whole series, since the only difference is in patch 7/7 (CONFIG_EPOLL). Also, the inotify patches weren't reviewed (inotify is now also present on freebsd, it is not linux-specific). So I'm only re-sending patches 3, 4 and 7.

v2: do not check for epoll_create1 too, in the last patch.

Michael Tokarev (7):
linux-user/syscall.c: assume splice is always present meson.build: stop checking for splice()
linux-user: assume inotify sycalls are always present meson.build: stop checking for inotify_init()
linux-user: assume epoll is always present
meson.build: do not check for epoll.h (CONFIG_EPOLL) rename CONFIG_EPOLL_CREATE1 to CONFIG_EPOLL, and stop checking for
epoll in meson.build

 linux-user/fd-trans.c     |  5 -----
 linux-user/fd-trans.h     |  4 ----
 linux-user/syscall.c      | 44 +++++++--------------------------------
 linux-user/syscall_defs.h |  3 ---
 meson.build               | 13 +-----------
 util/aio-posix.h          |  4 ++--
 util/meson.build          |  2 +-
 7 files changed, 11 insertions(+), 64 deletions(-)
Signature · 1 line
2.47.3
#1 lore raw

PATCH v2 3/7 linux-user: assume inotify sycalls are always present

inotify_init() and other syscalls appeared in linux 2.6.13, inotify_init1() - in linux 2.6.27.

There's no need to check their presence on linux anymore.

Keep condition on TARGET_NR_inotify_init because modern architectures have only more generic inotify_init1().

Other, not linux-specific, places of the code checks for inotify_init1() syscall only.

---
 linux-user/fd-trans.c |  5 -----
 linux-user/fd-trans.h |  4 ----
 linux-user/syscall.c  | 19 ++-----------------
 3 files changed, 2 insertions(+), 26 deletions(-)
linux-user/fd-trans.c +0 -5
index f83d1f79d5..64dd0745d2 100644
@@ -18,9 +18,7 @@
 #include <sys/signalfd.h>
 #include <linux/unistd.h>
 #include <linux/audit.h>
-#ifdef CONFIG_INOTIFY
 #include <sys/inotify.h>
-#endif
 #include <linux/netlink.h>
 #ifdef CONFIG_RTNETLINK
 #include <linux/rtnetlink.h>
@@ -1861,8 +1859,6 @@ TargetFdTrans target_timerfd_trans = {
     .host_to_target_data = swap_data_u64,
 };
 
-#if defined(CONFIG_INOTIFY) && (defined(TARGET_NR_inotify_init) || \
-        defined(TARGET_NR_inotify_init1))
 static abi_long host_to_target_data_inotify(void *buf, size_t len)
 {
     struct inotify_event *ev;
@@ -1885,4 +1881,3 @@ static abi_long host_to_target_data_inotify(void *buf, size_t len)
 TargetFdTrans target_inotify_trans = {
     .host_to_target_data = host_to_target_data_inotify,
 };
-#endif
linux-user/fd-trans.h +0 -4
index e14f96059c..3bbc15fa1f 100644
@@ -141,9 +141,5 @@ extern TargetFdTrans target_netlink_audit_trans;
 extern TargetFdTrans target_signalfd_trans;
 extern TargetFdTrans target_eventfd_trans;
 extern TargetFdTrans target_timerfd_trans;
-#if (defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init)) || \
-    (defined(CONFIG_INOTIFY1) && defined(TARGET_NR_inotify_init1) && \
-     defined(__NR_inotify_init1))
 extern TargetFdTrans target_inotify_trans;
 #endif
-#endif
linux-user/syscall.c +2 -17
index 9d0e697981..1d35fe84d0 100644
@@ -497,15 +497,7 @@ static int sys_renameat2(int oldfd, const char *old,
 #endif
 #endif /* TARGET_NR_renameat2 */
 
-#ifdef CONFIG_INOTIFY
 #include <sys/inotify.h>
-#else
-/* Userspace can usually survive runtime without inotify */
-#undef TARGET_NR_inotify_init
-#undef TARGET_NR_inotify_init1
-#undef TARGET_NR_inotify_add_watch
-#undef TARGET_NR_inotify_rm_watch
-#endif /* CONFIG_INOTIFY  */
 
 #if defined(TARGET_NR_prlimit64)
 #ifndef __NR_prlimit64
@@ -13258,8 +13250,8 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
     case TARGET_NR_futex_time64:
         return do_futex(cpu, true, arg1, arg2, arg3, arg4, arg5, arg6);
 #endif
-#ifdef CONFIG_INOTIFY
-#if defined(TARGET_NR_inotify_init)
+
+#ifdef TARGET_NR_inotify_init
     case TARGET_NR_inotify_init:
         ret = get_errno(inotify_init());
         if (ret >= 0) {
@@ -13267,7 +13259,6 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
         }
         return ret;
 #endif
-#if defined(TARGET_NR_inotify_init1) && defined(CONFIG_INOTIFY1)
     case TARGET_NR_inotify_init1:
         ret = get_errno(inotify_init1(target_to_host_bitmask(arg1,
                                           fcntl_flags_tbl)));
@@ -13275,19 +13266,13 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
             fd_trans_register(ret, &target_inotify_trans);
         }
         return ret;
-#endif
-#if defined(TARGET_NR_inotify_add_watch)
     case TARGET_NR_inotify_add_watch:
         p = lock_user_string(arg2);
         ret = get_errno(inotify_add_watch(arg1, path(p), arg3));
         unlock_user(p, arg2, 0);
         return ret;
-#endif
-#if defined(TARGET_NR_inotify_rm_watch)
     case TARGET_NR_inotify_rm_watch:
         return get_errno(inotify_rm_watch(arg1, arg2));
-#endif
-#endif
 
 #if defined(TARGET_NR_mq_open) && defined(__NR_mq_open)
     case TARGET_NR_mq_open:
Signature · 1 line
2.47.3
#2 lore raw

PATCH v2 4/7 meson.build: stop checking for inotify_init()

In reply to Michael Tokarev

the only place in qemu which used the check for inotify_init() was linux-user, which now assumes inotify_init() is always present. There's no need to check for this function anymore.

---
 meson.build | 1 -
 1 file changed, 1 deletion(-)
meson.build +0 -1
index c7d237403f..41b6b7b0aa 100644
@@ -2669,7 +2669,6 @@ if (have_inotify_init or have_inotify_init1) and host_os == 'freebsd'
     have_inotify_init1 = inotify.found()
   endif
 endif
-config_host_data.set('CONFIG_INOTIFY', have_inotify_init)
 config_host_data.set('CONFIG_INOTIFY1', have_inotify_init1)
 
 # has_header_symbol
Signature · 1 line
2.47.3
#3 lore raw

PATCH v2 7/7 rename CONFIG_EPOLL_CREATE1 to CONFIG_EPOLL, and stop checking for epoll in meson.build

In reply to Michael Tokarev

Since CONFIG_EPOLL is now unused, it's okay to
perform this rename, to make it less ugly.

Since epoll is linux-specific and is always present on linux, define CONFIG_EPOLL to 1 on linux, without compile-time test.

---
 meson.build      | 3 +--
 util/aio-posix.h | 4 ++--
 util/meson.build | 2 +-
 3 files changed, 4 insertions(+), 5 deletions(-)
meson.build +1 -2
index f4eae50764..157189e306 100644
@@ -2673,8 +2673,7 @@ config_host_data.set('CONFIG_INOTIFY1', have_inotify_init1)
 # has_header_symbol
 config_host_data.set('CONFIG_BLKZONED',
                      cc.has_header_symbol('linux/blkzoned.h', 'BLKOPENZONE'))
-config_host_data.set('CONFIG_EPOLL_CREATE1',
-                     cc.has_header_symbol('sys/epoll.h', 'epoll_create1'))
+config_host_data.set('CONFIG_EPOLL', host_os == 'linux')
 config_host_data.set('CONFIG_FALLOCATE_PUNCH_HOLE',
                      cc.has_header_symbol('linux/falloc.h', 'FALLOC_FL_PUNCH_HOLE') and
                      cc.has_header_symbol('linux/falloc.h', 'FALLOC_FL_KEEP_SIZE'))
util/aio-posix.h +2 -2
index 0cedb8d189..ab894a3c0f 100644
@@ -52,7 +52,7 @@ extern const FDMonOps fdmon_poll_ops;
 /* Switch back to poll(2). list_lock must be held. */
 void fdmon_poll_downgrade(AioContext *ctx);
 
-#ifdef CONFIG_EPOLL_CREATE1
+#ifdef CONFIG_EPOLL
 bool fdmon_epoll_try_upgrade(AioContext *ctx, unsigned npfd);
 void fdmon_epoll_setup(AioContext *ctx);
 
@@ -71,7 +71,7 @@ static inline void fdmon_epoll_setup(AioContext *ctx)
 static inline void fdmon_epoll_disable(AioContext *ctx)
 {
 }
-#endif /* !CONFIG_EPOLL_CREATE1 */
+#endif /* !CONFIG_EPOLL */
 
 #ifdef CONFIG_LINUX_IO_URING
 bool fdmon_io_uring_setup(AioContext *ctx, Error **errp);
util/meson.build +1 -1
index 59e835a8d3..8c01d7a3de 100644
@@ -3,7 +3,7 @@ util_ss.add(files('thread-context.c'), numa)
 if host_os != 'windows'
   util_ss.add(files('aio-posix.c'))
   util_ss.add(files('fdmon-poll.c'))
-  if config_host_data.get('CONFIG_EPOLL_CREATE1')
+  if config_host_data.get('CONFIG_EPOLL')
     util_ss.add(files('fdmon-epoll.c'))
   endif
   util_ss.add(files('compatfd.c'))
Signature · 1 line
2.47.3
#4 lore raw

Re: [PATCH trivial v2 7/7] rename CONFIG_EPOLL_CREATE1 to CONFIG_EPOLL, and stop checking for epoll in meson.build

Quoted 18 lines · Michael Tokarev

Since CONFIG_EPOLL is now unused, it's okay to
perform this rename, to make it less ugly.

Since epoll is linux-specific and is always present on linux, define CONFIG_EPOLL to 1 on linux, without compile-time test.

---
  meson.build      | 3 +--
  util/aio-posix.h | 4 ++--
  util/meson.build | 2 +-
  3 files changed, 4 insertions(+), 5 deletions(-)
meson.build +0 -0
index f4eae50764..157189e306 100644

meson.build config_host_data.set('CONFIG_INOTIFY1', have_inotify_init1) · line 2676

Quoted 6 lines
meson.build +1 -2
@@ -2673,8 +2673,7 @@ config_host_data.set('CONFIG_INOTIFY1', have_inotify_init1)
  # has_header_symbol
  config_host_data.set('CONFIG_BLKZONED',
                       cc.has_header_symbol('linux/blkzoned.h', 'BLKOPENZONE'))
-config_host_data.set('CONFIG_EPOLL_CREATE1',
-                     cc.has_header_symbol('sys/epoll.h', 'epoll_create1'))
+config_host_data.set('CONFIG_EPOLL', host_os == 'linux')

I guess my question remains: Why keep CONFIG_EPOLL if it is identical to the existing CONFIG_LINUX?

r~

#5 lore raw

Re: [PATCH trivial v2 7/7] rename CONFIG_EPOLL_CREATE1 to CONFIG_EPOLL, and stop checking for epoll in meson.build

Quoted 14 lines · Richard Henderson
Quoted 13 lines · Michael Tokarev

Since CONFIG_EPOLL is now unused, it's okay to
perform this rename, to make it less ugly.

Since epoll is linux-specific and is always present on linux, define CONFIG_EPOLL to 1 on linux, without compile-time test.

---
  meson.build      | 3 +--
  util/aio-posix.h | 4 ++--
  util/meson.build | 2 +-

  3 files changed, 4 insertions(+), 5 deletions(-)
Quoted 15 lines

meson.build config_host_data.set('CONFIG_INOTIFY1', · line 2678

Quoted 13 lines
meson.build +1 -2
index f4eae50764..157189e306 100644
@@ -2673,8 +2673,7 @@ config_host_data.set('CONFIG_INOTIFY1', 
 have_inotify_init1)
   # has_header_symbol
   config_host_data.set('CONFIG_BLKZONED',
                        cc.has_header_symbol('linux/blkzoned.h', 'BLKOPENZONE'))
-config_host_data.set('CONFIG_EPOLL_CREATE1',
-                     cc.has_header_symbol('sys/epoll.h', 
 'epoll_create1'))
+config_host_data.set('CONFIG_EPOLL', host_os == 'linux')

I guess my question remains: Why keep CONFIG_EPOLL if it is identical to the existing CONFIG_LINUX?

It would be less obvious this way in the code. When you've some #ifdef, when using CONFIG_EPOLL, it's much more obvious why it's here. When it's CONFIG_LINUX, you start to wonder which of the 100500 different linux-only features this place is about.

Current code very obviously uses configuration test for particular _feature_ (presence of epoll). Yes, this interface is linux-specific, but in my view it is better to keep depending on particular feature, than to check of the os type or library version or something else like that.

Thanks,

/mjt