From owner-dev-commits-src-main@freebsd.org Thu Jul 29 09:46:07 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 05FEA66FDA3; Thu, 29 Jul 2021 09:46:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gb5JG4tVlz3s60; Thu, 29 Jul 2021 09:46:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6C82B7738; Thu, 29 Jul 2021 09:46:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 16T9k6S1056723; Thu, 29 Jul 2021 09:46:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 16T9k6bn056722; Thu, 29 Jul 2021 09:46:06 GMT (envelope-from git) Date: Thu, 29 Jul 2021 09:46:06 GMT Message-Id: <202107290946.16T9k6bn056722@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: af29f3995882 - main - umtx: Split umtx.h on two counterparts. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: af29f3995882fac6e1c0360c2276c7a98056957f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Jul 2021 09:46:07 -0000 The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=af29f3995882fac6e1c0360c2276c7a98056957f commit af29f3995882fac6e1c0360c2276c7a98056957f Author: Dmitry Chagin AuthorDate: 2021-07-29 09:41:29 +0000 Commit: Dmitry Chagin CommitDate: 2021-07-29 09:41:29 +0000 umtx: Split umtx.h on two counterparts. To prevent umtx.h polluting by future changes split it on two headers: umtx.h - ABI header for userspace; umtxvar.h - the kernel staff. While here fix umtx_key_match style. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D31248 MFC after: 2 weeks --- sys/compat/cloudabi/cloudabi_futex.c | 2 +- sys/compat/linux/linux_futex.c | 2 +- sys/kern/kern_exec.c | 2 +- sys/kern/kern_exit.c | 2 +- sys/kern/kern_kthread.c | 2 +- sys/kern/kern_racct.c | 2 +- sys/kern/kern_resource.c | 2 +- sys/kern/kern_thr.c | 2 +- sys/kern/kern_thread.c | 2 +- sys/kern/kern_umtx.c | 1 + sys/kern/sched_4bsd.c | 2 +- sys/kern/sched_ule.c | 2 +- sys/sys/umtx.h | 73 ------------------------ sys/sys/umtxvar.h | 106 +++++++++++++++++++++++++++++++++++ 14 files changed, 118 insertions(+), 84 deletions(-) diff --git a/sys/compat/cloudabi/cloudabi_futex.c b/sys/compat/cloudabi/cloudabi_futex.c index 153e8bce8495..fd2a1d515483 100644 --- a/sys/compat/cloudabi/cloudabi_futex.c +++ b/sys/compat/cloudabi/cloudabi_futex.c @@ -35,7 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include diff --git a/sys/compat/linux/linux_futex.c b/sys/compat/linux/linux_futex.c index 1858c573a576..547d52c8ca4a 100644 --- a/sys/compat/linux/linux_futex.c +++ b/sys/compat/linux/linux_futex.c @@ -57,7 +57,7 @@ __KERNEL_RCSID(1, "$NetBSD: linux_futex.c,v 1.7 2006/07/24 19:01:49 manu Exp $") #include #include #include -#include +#include #include diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index e5944bfc5ac6..e6564ae48ced 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -70,7 +70,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include #ifdef KTRACE diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index bfd25366b49c..1b2cf63c9b82 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -76,7 +76,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #ifdef KTRACE #include #endif diff --git a/sys/kern/kern_kthread.c b/sys/kern/kern_kthread.c index 32832bde2f53..2eef7798f3d6 100644 --- a/sys/kern/kern_kthread.c +++ b/sys/kern/kern_kthread.c @@ -41,7 +41,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include #include diff --git a/sys/kern/kern_racct.c b/sys/kern/kern_racct.c index 7d179fe69844..e2053de3dc2c 100644 --- a/sys/kern/kern_racct.c +++ b/sys/kern/kern_racct.c @@ -57,7 +57,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #ifdef RCTL diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c index e14be34aa6e0..4c62961e1bc4 100644 --- a/sys/kern/kern_resource.c +++ b/sys/kern/kern_resource.c @@ -59,7 +59,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include diff --git a/sys/kern/kern_thr.c b/sys/kern/kern_thr.c index 69259d78811a..18722cc6a73d 100644 --- a/sys/kern/kern_thr.c +++ b/sys/kern/kern_thr.c @@ -54,7 +54,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #ifdef HWPMC_HOOKS #include diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c index 328a69bc5f23..4cfd502664bd 100644 --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.c @@ -56,7 +56,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include #ifdef HWPMC_HOOKS diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c index b76d080b8e06..c7f9afeb6c4d 100644 --- a/sys/kern/kern_umtx.c +++ b/sys/kern/kern_umtx.c @@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c index 7e6123cdcf24..ddd65b94f0ff 100644 --- a/sys/kern/sched_4bsd.c +++ b/sys/kern/sched_4bsd.c @@ -56,7 +56,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c index 3bb73d64a70c..2b55b0a7a8c5 100644 --- a/sys/kern/sched_ule.c +++ b/sys/kern/sched_ule.c @@ -61,7 +61,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include #include diff --git a/sys/sys/umtx.h b/sys/sys/umtx.h index 60e9dccdad91..82a8e0e4b0f0 100644 --- a/sys/sys/umtx.h +++ b/sys/sys/umtx.h @@ -132,83 +132,10 @@ struct umtx_robust_lists_params { uintptr_t robust_inact_offset; }; -#ifndef _KERNEL - __BEGIN_DECLS int _umtx_op(void *obj, int op, u_long val, void *uaddr, void *uaddr2); __END_DECLS -#else - -/* - * The umtx_key structure is used by both the Linux futex code and the - * umtx implementation to map userland addresses to unique keys. - */ - -enum { - TYPE_SIMPLE_WAIT, - TYPE_CV, - TYPE_SEM, - TYPE_SIMPLE_LOCK, - TYPE_NORMAL_UMUTEX, - TYPE_PI_UMUTEX, - TYPE_PP_UMUTEX, - TYPE_RWLOCK, - TYPE_FUTEX, - TYPE_SHM, - TYPE_PI_ROBUST_UMUTEX, - TYPE_PP_ROBUST_UMUTEX, -}; - -/* Key to represent a unique userland synchronous object */ -struct umtx_key { - int hash; - int type; - int shared; - union { - struct { - struct vm_object *object; - uintptr_t offset; - } shared; - struct { - struct vmspace *vs; - uintptr_t addr; - } private; - struct { - void *a; - uintptr_t b; - } both; - } info; -}; - -#define THREAD_SHARE 0 -#define PROCESS_SHARE 1 -#define AUTO_SHARE 2 - -struct thread; - -static inline int -umtx_key_match(const struct umtx_key *k1, const struct umtx_key *k2) -{ - return (k1->type == k2->type && - k1->info.both.a == k2->info.both.a && - k1->info.both.b == k2->info.both.b); -} - -int umtx_copyin_timeout(const void *, struct timespec *); -void umtx_exec(struct proc *p); -int umtx_key_get(const void *, int, int, struct umtx_key *); -void umtx_key_release(struct umtx_key *); -struct umtx_q *umtxq_alloc(void); -void umtxq_free(struct umtx_q *); -int kern_umtx_wake(struct thread *, void *, int, int); -void umtx_pi_adjust(struct thread *, u_char); -void umtx_thread_init(struct thread *); -void umtx_thread_fini(struct thread *); -void umtx_thread_alloc(struct thread *); -void umtx_thread_exit(struct thread *); - -#endif /* !_KERNEL */ #endif /* !_SYS_UMTX_H_ */ diff --git a/sys/sys/umtxvar.h b/sys/sys/umtxvar.h new file mode 100644 index 000000000000..b898c263201e --- /dev/null +++ b/sys/sys/umtxvar.h @@ -0,0 +1,106 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2002, Jeffrey Roberson + * All rights reserved. + * + * 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 unmodified, 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 AUTHOR ``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 AUTHOR 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. + * + * $FreeBSD$ + * + */ + +#ifndef _SYS_UMTXVAR_H_ +#define _SYS_UMTXVAR_H_ + +#ifdef _KERNEL + +/* + * The umtx_key structure is used by both the Linux futex code and the + * umtx implementation to map userland addresses to unique keys. + */ +enum { + TYPE_SIMPLE_WAIT, + TYPE_CV, + TYPE_SEM, + TYPE_SIMPLE_LOCK, + TYPE_NORMAL_UMUTEX, + TYPE_PI_UMUTEX, + TYPE_PP_UMUTEX, + TYPE_RWLOCK, + TYPE_FUTEX, + TYPE_SHM, + TYPE_PI_ROBUST_UMUTEX, + TYPE_PP_ROBUST_UMUTEX, +}; + +/* Key to represent a unique userland synchronous object */ +struct umtx_key { + int hash; + int type; + int shared; + union { + struct { + struct vm_object *object; + uintptr_t offset; + } shared; + struct { + struct vmspace *vs; + uintptr_t addr; + } private; + struct { + void *a; + uintptr_t b; + } both; + } info; +}; + +#define THREAD_SHARE 0 +#define PROCESS_SHARE 1 +#define AUTO_SHARE 2 + +struct thread; + +static inline int +umtx_key_match(const struct umtx_key *k1, const struct umtx_key *k2) +{ + + return (k1->type == k2->type && + k1->info.both.a == k2->info.both.a && + k1->info.both.b == k2->info.both.b); +} + +int umtx_copyin_timeout(const void *, struct timespec *); +void umtx_exec(struct proc *p); +int umtx_key_get(const void *, int, int, struct umtx_key *); +void umtx_key_release(struct umtx_key *); +struct umtx_q *umtxq_alloc(void); +void umtxq_free(struct umtx_q *); +int kern_umtx_wake(struct thread *, void *, int, int); +void umtx_pi_adjust(struct thread *, u_char); +void umtx_thread_init(struct thread *); +void umtx_thread_fini(struct thread *); +void umtx_thread_alloc(struct thread *); +void umtx_thread_exit(struct thread *); + +#endif /* _KERNEL */ +#endif /* !_SYS_UMTXVAR_H_ */