From nobody Sun Oct 06 23:45:38 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 4XMJnG5hDMz5YjBd; Sun, 06 Oct 2024 23:45:38 +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 4XMJnG4sYwz4GCN; Sun, 6 Oct 2024 23:45:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728258338; 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=37eXbDnR9+q7xAZEu7JdwlJRWrSySbNB2qMWl2ZcToA=; b=y4iUssPiiY5IZrwgEC7tWqqbPrP/jbS3tWXZ15ZUPj7SOz9OJ8/ijvvb7uh4N+jHom87fW AD86k8kSqQgCQEX8BBL+Wqc5EdDTlTQXnxePl5F93N80atkgnQytRp6HXHKTzfJhcI8/3m oGaF7dmlNe03Vir239pKGQJ7oblVGek6oVBU0VMzJ70JCWykpRfsWR3nWnWhwMoGpSjXxc UXKBSN1Sy5hH/caxYyE3y1kFxCiHVdcQFt6a+6sg8mHQNK6ndjMPLeXl4afS8C8Q9CZk/T VOj3M/7u6nKcuerLJVOhsEkoK1HKj0nu2MZ5eICOtInfg8vPQMJWbYrwOkWavg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728258338; 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=37eXbDnR9+q7xAZEu7JdwlJRWrSySbNB2qMWl2ZcToA=; b=CHLm+2UUIVO31Xsq4aYkXLs6+m939QGJCth3tJKx2argo0a1TlVu1T9alViyvOQbI4BN8M 7Uwq1i41yD7hjHdSJ4oCbP9iC3xvbOGzAjOFtxVEzrjwWwJd7Jnb3q0Ju+WnCo/1pPXug1 rq0M6zTNleqsplDtPh1GUOyHDPhLeciONk4f1XXlhd0nz6/1PiPCEy0jLYiQb8gkeHRbcE hNVxECWkbgCdZgmM7y176PzFUXxxHLEIjrr0/01L+gIJOJwsozHy4NxKR6uMqI9qTofM9N bVfrgXYUKkjn5enaVV9WJB3LDlIhptf7AHCFxqfvaxkPW/+UU1DvqkWgyD+tDg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728258338; a=rsa-sha256; cv=none; b=qwTKXu0ClmzRocXfW9rxkzG/xWTF6jHJUuPjQ2lhdV9Hjjj3XLpIHDBu1mjAXLt2M6pjzA g3WNqxujm3uvZKbMcSu6fcLo6zQHSCbf7yhqMsE9xafgtq2cbWHlhiXy/KId8R2rwsNaoK xqwu8lvY+AuuD6YMYWOPOWrp6LfaaO01aPDPrOCXtMeDPHrYfbgAtXW7g/F/YSjQ7R8Rej FodRmidottH38kNYATPVesdeVQnmkK1zcxd6N+NxLFOsiSJv0EHw19bqV1zczW7PdZ1qY0 lyyGGREnQOTsLAUb5nZyK/dFdkAPWKC1+qF1+K0sb6mkcrm/+QeJP8QgSBF5lQ== 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 4XMJnG3n48zNZm; Sun, 6 Oct 2024 23:45:38 +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 496NjcOI028950; Sun, 6 Oct 2024 23:45:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 496NjcK4028947; Sun, 6 Oct 2024 23:45:38 GMT (envelope-from git) Date: Sun, 6 Oct 2024 23:45:38 GMT Message-Id: <202410062345.496NjcK4028947@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 1fc766e3b41d - main - 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/main X-Git-Reftype: branch X-Git-Commit: 1fc766e3b41d0cdbd166ef95258434069a90ca52 Auto-Submitted: auto-generated The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=1fc766e3b41d0cdbd166ef95258434069a90ca52 commit 1fc766e3b41d0cdbd166ef95258434069a90ca52 Author: Ed Maste AuthorDate: 2024-10-06 17:47:34 +0000 Commit: Ed Maste CommitDate: 2024-10-06 23:41:57 +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 --- lib/libsys/membarrier.2 | 150 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) diff --git a/lib/libsys/membarrier.2 b/lib/libsys/membarrier.2 new file mode 100644 index 000000000000..fe2e6ff763d5 --- /dev/null +++ b/lib/libsys/membarrier.2 @@ -0,0 +1,150 @@ +.\" 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 +.Dv cmd +is 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 .