Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Add a NetBSD native futex implementation, mostly written by ...



details:   https://anonhg.NetBSD.org/src/rev/cd4dd1cea70c
branches:  trunk
changeset: 931328:cd4dd1cea70c
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sun Apr 26 18:53:31 2020 +0000

description:
Add a NetBSD native futex implementation, mostly written by riastradh@.
Map the COMPAT_LINUX futex calls to the native ones.

diffstat:

 distrib/sets/lists/comp/mi                    |     3 +-
 distrib/sets/lists/tests/mi                   |     4 +-
 lib/libc/include/futex_private.h              |    64 +
 sys/compat/linux/arch/alpha/syscalls.master   |    16 +-
 sys/compat/linux/arch/amd64/syscalls.master   |    16 +-
 sys/compat/linux/arch/arm/syscalls.master     |    16 +-
 sys/compat/linux/arch/i386/syscalls.master    |    11 +-
 sys/compat/linux/arch/m68k/syscalls.master    |    16 +-
 sys/compat/linux/arch/mips/syscalls.master    |    16 +-
 sys/compat/linux/arch/powerpc/syscalls.master |    16 +-
 sys/compat/linux/common/linux_emuldata.h      |     5 +-
 sys/compat/linux/common/linux_exec.c          |    34 +-
 sys/compat/linux/common/linux_futex.c         |   776 +---------
 sys/compat/linux/common/linux_futex.h         |    93 -
 sys/compat/linux/common/linux_mod.c           |     7 +-
 sys/compat/linux32/arch/amd64/syscalls.master |    15 +-
 sys/compat/linux32/common/linux32_misc.c      |    70 +-
 sys/compat/netbsd32/files.netbsd32            |     3 +-
 sys/compat/netbsd32/netbsd32_futex.c          |   134 +
 sys/compat/netbsd32/syscalls.master           |     9 +-
 sys/kern/files.kern                           |     3 +-
 sys/kern/init_main.c                          |     7 +-
 sys/kern/kern_lwp.c                           |    14 +-
 sys/kern/kern_proc.c                          |    11 +-
 sys/kern/sys_futex.c                          |  1977 +++++++++++++++++++++++++
 sys/kern/syscalls.master                      |     9 +-
 sys/sys/Makefile                              |     4 +-
 sys/sys/futex.h                               |   186 ++
 sys/sys/lwp.h                                 |     4 +-
 tests/lib/libc/sys/Makefile                   |     7 +-
 tests/lib/libc/sys/t_futex_ops.c              |  1294 ++++++++++++++++
 tests/lib/libc/sys/t_futex_robust.c           |   408 +++++
 32 files changed, 4257 insertions(+), 991 deletions(-)

diffs (truncated from 5810 to 300 lines):

diff -r 39312e08c810 -r cd4dd1cea70c distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi        Sun Apr 26 17:00:31 2020 +0000
+++ b/distrib/sets/lists/comp/mi        Sun Apr 26 18:53:31 2020 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: mi,v 1.2321 2020/04/04 19:26:51 christos Exp $
+#      $NetBSD: mi,v 1.2322 2020/04/26 18:53:31 thorpej Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 ./etc/mtree/set.comp                           comp-sys-root
@@ -3059,6 +3059,7 @@
 ./usr/include/sys/float_ieee754.h              comp-c-include
 ./usr/include/sys/fnv_hash.h                   comp-obsolete           obsolete
 ./usr/include/sys/fstypes.h                    comp-c-include
+./usr/include/sys/futex.h                      comp-c-include
 ./usr/include/sys/gcq.h                                comp-c-include
 ./usr/include/sys/gmon.h                       comp-c-include
 ./usr/include/sys/gpio.h                       comp-c-include
diff -r 39312e08c810 -r cd4dd1cea70c distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Sun Apr 26 17:00:31 2020 +0000
+++ b/distrib/sets/lists/tests/mi       Sun Apr 26 18:53:31 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.836 2020/04/19 13:22:58 maxv Exp $
+# $NetBSD: mi,v 1.837 2020/04/26 18:53:32 thorpej Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -3120,6 +3120,8 @@
 ./usr/tests/lib/libc/sys/t_dup                 tests-lib-tests         compattestfile,atf
 ./usr/tests/lib/libc/sys/t_fork                        tests-lib-tests         compattestfile,atf
 ./usr/tests/lib/libc/sys/t_fsync               tests-lib-tests         compattestfile,atf
+./usr/tests/lib/libc/sys/t_futex_ops           tests-lib-tests         compattestfile,atf
+./usr/tests/lib/libc/sys/t_futex_robust                tests-lib-tests         compattestfile,atf
 ./usr/tests/lib/libc/sys/t_getcontext          tests-lib-tests         compattestfile,atf
 ./usr/tests/lib/libc/sys/t_getgroups           tests-lib-tests         compattestfile,atf
 ./usr/tests/lib/libc/sys/t_getitimer           tests-lib-tests         compattestfile,atf
diff -r 39312e08c810 -r cd4dd1cea70c lib/libc/include/futex_private.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/include/futex_private.h  Sun Apr 26 18:53:31 2020 +0000
@@ -0,0 +1,64 @@
+/*     $NetBSD: futex_private.h,v 1.1 2020/04/26 18:53:32 thorpej Exp $        */
+
+/*-
+ * Copyright (c) 2019 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __LIBC_FUTEX_PRIVATE
+#define __LIBC_FUTEX_PRIVATE
+
+#if defined(_LIBC)
+#include "namespace.h"
+#endif
+
+#include <sys/cdefs.h>
+#include <sys/syscall.h>
+#include <sys/futex.h>
+#include <unistd.h>
+
+static inline int __unused
+__futex(volatile int *uaddr, int op, int val, const struct timespec *timeout,
+       volatile int *uaddr2, int val2, int val3)
+{
+       return syscall(SYS___futex, uaddr, op, val, timeout, uaddr2,
+                       val2, val3);
+}
+
+static inline int __unused
+__futex_set_robust_list(void *head, size_t len)
+{
+       return syscall(SYS___futex_set_robust_list, head, len);
+}
+
+static inline int __unused
+__futex_get_robust_list(lwpid_t lwpid, void **headp, size_t *lenp)
+{
+       return syscall(SYS___futex_get_robust_list, lwpid, headp, lenp);
+}
+
+#endif /* __LIBC_FUTEX_PRIVATE */
diff -r 39312e08c810 -r cd4dd1cea70c sys/compat/linux/arch/alpha/syscalls.master
--- a/sys/compat/linux/arch/alpha/syscalls.master       Sun Apr 26 17:00:31 2020 +0000
+++ b/sys/compat/linux/arch/alpha/syscalls.master       Sun Apr 26 18:53:31 2020 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.96 2019/11/09 23:44:31 jdolecek Exp $
+       $NetBSD: syscalls.master,v 1.97 2020/04/26 18:53:32 thorpej Exp $
 ;
 ;      @(#)syscalls.master     8.1 (Berkeley) 7/19/93
 
@@ -740,11 +740,15 @@
                            struct linux_timespec *timeout, \
                            linux_sigset_t *sigset); }
 465    UNIMPL          unshare
-466    STD             { int|linux_sys||set_robust_list( \
-                           struct linux_robust_list_head *head, size_t len); }
-467    STD             { int|linux_sys||get_robust_list(int pid, \
-                           struct linux_robust_list_head **head, \
-                           size_t *len); }
+                       ;
+                       ; The NetBSD native robust list calls have different
+                       ; argument names / types, but they are ABI-compatible
+                       ; with Linux.
+                       ;
+466    NOARGS          { int|sys||__futex_set_robust_list(void *head, \
+                           size_t len); }
+467    NOARGS          { int|sys||__futex_get_robust_list(lwpid_t lwpid, \
+                           void **headp, size_t *lenp); }
 468    UNIMPL          splice
 469    UNIMPL          sync_file_range
 470    UNIMPL          tee
diff -r 39312e08c810 -r cd4dd1cea70c sys/compat/linux/arch/amd64/syscalls.master
--- a/sys/compat/linux/arch/amd64/syscalls.master       Sun Apr 26 17:00:31 2020 +0000
+++ b/sys/compat/linux/arch/amd64/syscalls.master       Sun Apr 26 18:53:31 2020 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.61 2019/11/09 23:44:31 jdolecek Exp $
+       $NetBSD: syscalls.master,v 1.62 2020/04/26 18:53:32 thorpej Exp $
 
 ;      @(#)syscalls.master     8.1 (Berkeley) 7/19/93
 
@@ -497,11 +497,15 @@
                            struct linux_timespec *timeout, \
                            linux_sigset_t *sigset); }
 272    UNIMPL          unshare
-273    STD             { int|linux_sys||set_robust_list( \
-                           struct linux_robust_list_head *head, size_t len); }
-274    STD             { int|linux_sys||get_robust_list(int pid, \
-                           struct linux_robust_list_head **head, \
-                           size_t *len); }
+                       ;
+                       ; The NetBSD native robust list calls have different
+                       ; argument names / types, but they are ABI-compatible
+                       ; with Linux.
+                       ;
+273    NOARGS          { int|sys||__futex_set_robust_list(void *head, \
+                           size_t len); }
+274    NOARGS          { int|sys||__futex_get_robust_list(lwpid_t lwpid, \
+                           void **headp, size_t *lenp); }
 275    UNIMPL          splice
 276    UNIMPL          tee
 277    UNIMPL          sync_file_range
diff -r 39312e08c810 -r cd4dd1cea70c sys/compat/linux/arch/arm/syscalls.master
--- a/sys/compat/linux/arch/arm/syscalls.master Sun Apr 26 17:00:31 2020 +0000
+++ b/sys/compat/linux/arch/arm/syscalls.master Sun Apr 26 18:53:31 2020 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.68 2019/11/09 23:44:31 jdolecek Exp $
+       $NetBSD: syscalls.master,v 1.69 2020/04/26 18:53:32 thorpej Exp $
 
 ; Derived from sys/compat/linux/arch/*/syscalls.master
 ; and from Linux 2.4.12 arch/arm/kernel/calls.S
@@ -538,11 +538,15 @@
                            struct linux_timespec *timeout, \
                            linux_sigset_t *sigset); }
 337    UNIMPL          unshare
-338    STD             { int|linux_sys||set_robust_list( \
-                           struct linux_robust_list_head *head, size_t len); }
-339    STD             { int|linux_sys||get_robust_list(int pid, \
-                           struct linux_robust_list_head **head, \
-                           size_t *len); }
+                       ;
+                       ; The NetBSD native robust list calls have different
+                       ; argument names / types, but they are ABI-compatible
+                       ; with Linux.
+                       ;
+338    NOARGS          { int|sys||__futex_set_robust_list(void *head, \
+                           size_t len); }
+339    NOARGS          { int|sys||__futex_get_robust_list(lwpid_t lwpid, \
+                           void **headp, size_t *lenp); }
 340    UNIMPL          splice
 341    UNIMPL          sync_file_range2
 342    UNIMPL          tee
diff -r 39312e08c810 -r cd4dd1cea70c sys/compat/linux/arch/i386/syscalls.master
--- a/sys/compat/linux/arch/i386/syscalls.master        Sun Apr 26 17:00:31 2020 +0000
+++ b/sys/compat/linux/arch/i386/syscalls.master        Sun Apr 26 18:53:31 2020 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.123 2019/11/09 23:44:32 jdolecek Exp $
+       $NetBSD: syscalls.master,v 1.124 2020/04/26 18:53:32 thorpej Exp $
 
 ;      @(#)syscalls.master     8.1 (Berkeley) 7/19/93
 
@@ -511,11 +511,10 @@
                            struct linux_timespec *timeout, \
                            linux_sigset_t *sigset); }
 310    UNIMPL          unshare
-311    STD             { int|linux_sys||set_robust_list( \
-                           struct linux_robust_list_head *head, size_t len); }
-312    STD             { int|linux_sys||get_robust_list(int pid, \
-                           struct linux_robust_list_head **head, \
-                           size_t *len); }
+311    NOARGS          { int|sys||__futex_set_robust_list(void *head, \
+                           size_t len); }
+312    NOARGS          { int|sys||__futex_get_robust_list(lwpid_t lwpid, \
+                           void **headp, size_t *lenp); }
 313    UNIMPL          splice
 314    UNIMPL          sync_file_range
 315    UNIMPL          tee
diff -r 39312e08c810 -r cd4dd1cea70c sys/compat/linux/arch/m68k/syscalls.master
--- a/sys/compat/linux/arch/m68k/syscalls.master        Sun Apr 26 17:00:31 2020 +0000
+++ b/sys/compat/linux/arch/m68k/syscalls.master        Sun Apr 26 18:53:31 2020 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.94 2019/11/09 23:44:32 jdolecek Exp $
+       $NetBSD: syscalls.master,v 1.95 2020/04/26 18:53:32 thorpej Exp $
 
 ;      @(#)syscalls.master     8.1 (Berkeley) 7/19/93
 
@@ -519,11 +519,15 @@
                            struct linux_timespec *timeout, \
                            linux_sigset_t *sigset); }
 303    UNIMPL          unshare
-304    STD             { int|linux_sys||set_robust_list( \
-                           struct linux_robust_list_head *head, size_t len); }
-305    STD             { int|linux_sys||get_robust_list(int pid, \
-                           struct linux_robust_list_head **head, \
-                           size_t *len); }
+                       ;
+                       ; The NetBSD native robust list calls have different
+                       ; argument names / types, but they are ABI-compatible
+                       ; with Linux.
+                       ;
+304    NOARGS          { int|sys||__futex_set_robust_list(void *head, \
+                           size_t len); }
+305    NOARGS          { int|sys||__futex_get_robust_list(lwpid_t lwpid, \
+                           void **headp, size_t *lenp); }
 306    UNIMPL          splice
 307    UNIMPL          sync_file_range
 308    UNIMPL          tee
diff -r 39312e08c810 -r cd4dd1cea70c sys/compat/linux/arch/mips/syscalls.master
--- a/sys/compat/linux/arch/mips/syscalls.master        Sun Apr 26 17:00:31 2020 +0000
+++ b/sys/compat/linux/arch/mips/syscalls.master        Sun Apr 26 18:53:31 2020 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.67 2019/11/09 23:44:32 jdolecek Exp $  
+       $NetBSD: syscalls.master,v 1.68 2020/04/26 18:53:32 thorpej Exp $  
 
 ;      @(#)syscalls.master     8.1 (Berkeley) 7/19/93
 
@@ -514,11 +514,15 @@
 306    UNIMPL          tee
 307    UNIMPL          vmsplice
 308    UNIMPL          move_pages
-309    STD             { int|linux_sys||set_robust_list( \
-                           struct linux_robust_list_head *head, size_t len); }
-310    STD             { int|linux_sys||get_robust_list(int pid, \
-                           struct linux_robust_list_head **head, \
-                           size_t *len); }
+                       ;
+                       ; The NetBSD native robust list calls have different
+                       ; argument names / types, but they are ABI-compatible
+                       ; with Linux.
+                       ;
+309    NOARGS          { int|sys||__futex_set_robust_list(void *head, \
+                           size_t len); }
+310    NOARGS          { int|sys||__futex_get_robust_list(lwpid_t lwpid, \
+                           void **headp, size_t *lenp); }
 311    UNIMPL          kexec_load
 312    UNIMPL          getcpu
 313    UNIMPL          epoll_pwait
diff -r 39312e08c810 -r cd4dd1cea70c sys/compat/linux/arch/powerpc/syscalls.master
--- a/sys/compat/linux/arch/powerpc/syscalls.master     Sun Apr 26 17:00:31 2020 +0000
+++ b/sys/compat/linux/arch/powerpc/syscalls.master     Sun Apr 26 18:53:31 2020 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.73 2019/11/09 23:44:32 jdolecek Exp $  
+       $NetBSD: syscalls.master,v 1.74 2020/04/26 18:53:32 thorpej Exp $  
 
 ;      @(#)syscalls.master     8.1 (Berkeley) 7/19/93
 
@@ -514,11 +514,15 @@
                            linux_umode_t mode); }
 298    STD             { int|linux_sys||faccessat(int fd, const char *path, \
                            int amode); }
-299    STD             { int|linux_sys||set_robust_list( \
-                           struct linux_robust_list_head *head, size_t len); }
-300    STD             { int|linux_sys||get_robust_list(int pid, \
-                           struct linux_robust_list_head **head, \
-                           size_t *len); }
+                       ;
+                       ; The NetBSD native robust list calls have different
+                       ; argument names / types, but they are ABI-compatible
+                       ; with Linux.



Home | Main Index | Thread Index | Old Index