From nobody Fri Jun 17 19:37:21 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 0149685A79C; Fri, 17 Jun 2022 19:37:22 +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 4LPq7P4ybmz3PTM; Fri, 17 Jun 2022 19:37:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494641; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JZekC6HQ/gUc5pFEs0cjKaYK/y9MDxH/BuENoos7ajE=; b=RWi7Z83gIsqvCRHUD4sa3lqmCpQOIv53fGt6BCRDcGffJ2tSmrPr8cjiyD/z22f5FJP30f KBYLZV5+SLChqOpjSqxQHnjxCepeyRSLS0L5TuK2T/lpfgfZWASoqqGK52drJdmmZ5OkMp Y4WM7/Uas0EqGgvtD2PuYiPoFntvfJ4QaY7TZuS5V8N8muREWbqQt30g9UDJ8Nkc2xZRH5 I5MsB6wD8BFsnF7lOJpO2fS+FXgmH5Dj4uOO96hY+O8hw/Dgka+DDGNNaIdRvbZrGtxV6C VuuxsgW5BReaurLFjjOS7l5BAW+VXuCkWs0BKy9FFgFjPPjOYhlFudRfjnf3BA== 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 37CFD259B9; Fri, 17 Jun 2022 19:37:21 +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 25HJbL43013239; Fri, 17 Jun 2022 19:37:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25HJbLnU013238; Fri, 17 Jun 2022 19:37:21 GMT (envelope-from git) Date: Fri, 17 Jun 2022 19:37:21 GMT Message-Id: <202206171937.25HJbLnU013238@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dmitry Chagin Subject: git: f51368016df4 - stable/13 - umtx: Split umtx.h on two counterparts. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org 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/stable/13 X-Git-Reftype: branch X-Git-Commit: f51368016df44370803b1a5e9666f8409620b06e Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494641; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JZekC6HQ/gUc5pFEs0cjKaYK/y9MDxH/BuENoos7ajE=; b=Q1ji4OJAJfHAcTPp3WhgGUFGhQalVXH6tAxtHE0O80HMvKqjhn2q2DuyRM/hiF10Vq22Vb elASAPMd0+1nSuiTcPp0WMvQxLBsl+u4ZfpmuUU+9e8MlrRxoIkFhb1UloFAVZ0/JOB3tF aOPS52ipKKRFA9z54mgAXNbHhDZxcbnQyziz7HevvtSCViwtbGOA4l+kPzNx7VtkiwY8Es REAxaZvCqH3PDN30g38XBP/t0YTOKVfBlnJw3oBpJRPURifdszClI0g0djkTXUFETlHh7L AvhWG5emCWB4IQpqkCfInVZ4447czM1qFiuncLwvttUXd2vqYby/gRuHpI3ovA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655494641; a=rsa-sha256; cv=none; b=FNMb7BuPIOCWI9mncLRPB3fSEQT2mDi9o7kEi2OoV+TuFruBfJxiZmHIzfsc/7T7ngYrRF T/V51xrr4YvDDB2ggXBRtVhje1jQfo99bQKRuPckfjFVGpxmKekw9V9g4Jw+dE28VLR9m8 y2TiXIwEbSQahRJ8Rn7TEwXNrRmJa2RR2EzXwV17wvQGur7TKIkVokAFzHu8S2QEW0ROpM zw8g6tfcCSc0gApwU/aXtSQqPK0ZBf08nwQD5jEqral2W4ZUexPv9/uJFwZPfTS1+SBwHd ivC4DzN+pG6Ub5o3FWVTwgS+z1TDh59KsxPc2zg+IlpK+TpAZ/hT/SDr/VPL2A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=f51368016df44370803b1a5e9666f8409620b06e commit f51368016df44370803b1a5e9666f8409620b06e Author: Dmitry Chagin AuthorDate: 2021-07-29 09:41:29 +0000 Commit: Dmitry Chagin CommitDate: 2022-06-17 19:33:15 +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 (cherry picked from commit af29f3995882fac6e1c0360c2276c7a98056957f) --- 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 f62c4582e89a..d8e1779825c6 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -71,7 +71,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 e89139edc825..09bad7873ff5 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 797a06cc15b1..512e06814c24 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 3dd243199088..a0b2438acec5 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 54254112b376..c56465835b3d 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 dd1622c476c5..65e364afc35f 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 7591bef4b14e..27621b79d4b7 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 1f859b286843..2c3e9fc57bf6 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_ */