From nobody Mon Oct 21 03:32:58 2024 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 4XX19628HWz5b7PR; Mon, 21 Oct 2024 03:32:58 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XX1961fcjz48d5; Mon, 21 Oct 2024 03:32:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729481578; 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=LmWBvaTvyuzQxZnQ9HV/v/hAh49LMpFoywsqjmSKqmU=; b=tFsX4vVxeyBja0W6+QtqZcbHu0PUk3fRgQfpcMHbWjdKWI/6uvd1ZQOTDUIQg/m2Ylf7fW Ho6zixfZ0WVLZbeYzKAnYPikk9GTpKyCVMaDhWklx8Uz9OUNcX6M15O2iDpP7u+4R+o4X8 qtVKd8XkK88kY1tIql/2RYHRK8hma5mSOAnmypbiaONe9ASN6w/qaX4QLEiDEdy35fAtrA nrZQvTgyiaq419CLw6C0tB4mrZzNqJWzVECox2xFAFNbb4CUuxXVjdDAnA0KN9Fe7hOSY5 9d4TO8sK4XBwN52bzZxI4yfeMTSSoJQm0boGsm27b/bzOGcsni679o843Og1Rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729481578; 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=LmWBvaTvyuzQxZnQ9HV/v/hAh49LMpFoywsqjmSKqmU=; b=T1CHFoqvROd5xXN9R8GuJ8DvyVrvVEwANyi/FJgQVpmZosqm7wVIWjARr45tPpr7B9Jzlu iYbZeuzawF59BvEwEur+rOjTaHO6DsdJPWCnk0GC6rrZj+gBbYyAn2EBnE8zgj6IZKWc7Q QK1z9OAdhWXY5NqY9U/3DsyK8KSzfW06o4g0IdUlDrDj2CZIBQCz01wuVxOWUkRE1empHP C2TJjKpLDxEiVSA4ZAThe5Wur4BuBa92ux/6PrL84xYOWh8mAO8Hw7t3WafX66EdWIMM7b pDeSGz6A0GtaBne5hCzT9/U8DulUZLk+8OvxLU34oDBce0+j40/aG6aHUqlEzA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729481578; a=rsa-sha256; cv=none; b=SBfu7AH7rkzGbg3p46OfmSPHsKs75M/2KfTAwhRpIb12gFOBYGwDMioEW0UkzemCa0A61S 8SFA9B7114CUlCIVXpgnBVw/frygJeAYcwGLf6bgW2M6Es8UVQsQayROObURVtWqafLUDB s12c50f7JRfC/SRvJG9E+jgpcFK9BY//n/yon3i+hrOAJlRuYHxfqxeVAdrKMbQX0gtxO9 cL0aknhcz31tO4nRuKeILt2WXOC4zHX87Zy0whxpgaNB5rFcQcL585frQSHRvlaoT8Bwy1 eWumUtzqz7amkI4xegRniNKky6vxoJF3XtiOFjNhH4Nf7uO+OyfZ8gQ6unEHbQ== 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 4XX1961FfLzDkg; Mon, 21 Oct 2024 03:32:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49L3WwVA060880; Mon, 21 Oct 2024 03:32:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49L3Ww1e060877; Mon, 21 Oct 2024 03:32:58 GMT (envelope-from git) Date: Mon, 21 Oct 2024 03:32:58 GMT Message-Id: <202410210332.49L3Ww1e060877@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 45b0537f0ecf - stable/14 - membarrier: Add manual page 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 45b0537f0ecf6ea3663f7180ad50fcd8170426ab Auto-Submitted: auto-generated The branch stable/14 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=45b0537f0ecf6ea3663f7180ad50fcd8170426ab commit 45b0537f0ecf6ea3663f7180ad50fcd8170426ab Author: Ed Maste AuthorDate: 2024-10-06 17:47:34 +0000 Commit: Ed Maste CommitDate: 2024-10-21 03:32:46 +0000 membarrier: Add manual page Add a minimal membarrier man page that documents the available cmd values and errors that can be returned. We can add more information and iterate on it in the tree. Reviewed by: kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D46967 (cherry picked from commit 1fc766e3b41d0cdbd166ef95258434069a90ca52) (cherry picked from commit 92cd5abb64dd70c305535c9504c6a2b73552147f) (cherry picked from commit 8b41e693fc3956385d5771d60ee93e18001a5a0d) --- lib/libc/sys/Makefile.inc | 1 + lib/libc/sys/membarrier.2 | 151 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 152 insertions(+) diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc index 33c0b9711d46..e964e3dcff26 100644 --- a/lib/libc/sys/Makefile.inc +++ b/lib/libc/sys/Makefile.inc @@ -244,6 +244,7 @@ MAN+= abort2.2 \ listen.2 \ lseek.2 \ madvise.2 \ + membarrier.2 \ mincore.2 \ minherit.2 \ mkdir.2 \ diff --git a/lib/libc/sys/membarrier.2 b/lib/libc/sys/membarrier.2 new file mode 100644 index 000000000000..87db620975ef --- /dev/null +++ b/lib/libc/sys/membarrier.2 @@ -0,0 +1,151 @@ +.\" SPDX-License-Identifier: BSD-2-Clause +.\" +.\" Copyright (c) 2024 The FreeBSD Foundation +.\" +.\" This documentation was written by Ed Maste +.\" under sponsorship from the FreeBSD Foundation. +.\" +.\" 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 AUTHORS 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 AUTHORS 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. +.\" +.Dd October 6, 2024 +.Dt MEMBARRIER 2 +.Os +.Sh NAME +.Nm membarrier +.Nd memory barrier +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/membarrier.h +.Ft int +.Fn membarrier "int cmd" "unsigned flags" "int cpu_id" +.Sh DESCRIPTION +The +.Nm +system call provides a memory barrier, ensuring ordering between memory +accesses performed by different threads or processes within the same address +space. +.Pp +The following values for +.Fa cmd +may be specified: +.Bl -tag -width Dv +.It Dv MEMBARRIER_CMD_QUERY +Query supported commands. +A bitmask of commands supported by the kernel is returned. +.It Dv MEMBARRIER_CMD_GLOBAL +Issue a memory barrier for all threads from all processes. +.It Dv MEMBARRIER_CMD_SHARED +This is an alias for +.Dv MEMBARRIER_CMD_GLOBAL . +.It Dv MEMBARRIER_CMD_GLOBAL_EXPEDITED +Execute a memory barrier on all running threads of all processes registered +with +.Dv MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED . +.It Dv MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED +Register the process to receive +.Dv MEMBARRIER_CMD_GLOBAL_EXPEDITED +memory barriers. +.It Dv MEMBARRIER_CMD_PRIVATE_EXPEDITED +Execute a memory barrier on each running thread belonging to the same process +as the thread calling +.Nm . +.It Dv MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED +Register the process to receive +.Dv MEMBARRIER_CMD_PRIVATE_EXPEDITED +memory barriers. +.It Dv MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE +In addition to the guarantees provided by +.Dv MEMBARRIER_CMD_PRIVATE_EXPEDITED +it also executes machine-specific serialization instructions, which +ensures that all possible speculative and out-of-order activities on the target +CPU are fenced. +.It Dv MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE +Register the process to receive +.Dv MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE +memory barriers. +.El +.Pp +The following +.Fa cmd +values are defined for source compatibility but are not yet supported: +.Pp +.Bl -tag -width Dv -compact +.It Dv MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ +.It Dv MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ +.El +.Pp +The +.Fa flags +argument must be 0. +The +.Fa cpu_id +argument is ignored. +.Sh RETURN VALUES +If the +.Fa cmd +is +.Dv MEMBARRIER_CMD_QUERY +a bitmask of supported commands is returned. +Otherwise, on success, +.Nm +returns 0. +On error, -1 is returned and +.Va errno +is set to indicate the error. +.Sh ERRORS +.Nm +may fail with the following errors: +.Bl -tag -width Er +.It Bq Er EINVAL +.Fa cmd +does not specify a valid command. +.It Bq Er EINVAL +.Fa flags +is not 0. +.It Bq Er EPERM +An attempt was made to use +.Dv MEMBARRIER_CMD_GLOBAL_EXPEDITED , +.Dv MEMBARRIER_CMD_PRIVATE_EXPEDITED , +or +.Dv MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE +by a process that did not previously register use with the corresponding +.Dv MEMBARRIER_CMD_REGISTER_* +.Fa cmd . +.El +.\" .Sh SEE ALSO +.Sh STANDARDS +The +.Nm +system call originated in Linux. +This implementation aims to be source-compatible with the Linux implementation. +Certain +.Fa cmd +and +.Fa flags +values are currently not supported by +.Fx . +.Sh HISTORY +The +.Nm +function was introduced in +.Fx 14.1 .