Received: by 10.223.185.116 with SMTP id b49csp2577409wrg; Mon, 12 Feb 2018 11:57:02 -0800 (PST) X-Google-Smtp-Source: AH8x2272puVVvQ54V635FPgVfJjnX4uZZUMsbtaAzJYX3YPX9TeT8xQK/ucNCoArRVD/HXjNhqHF X-Received: by 10.99.113.7 with SMTP id m7mr10074638pgc.403.1518465422818; Mon, 12 Feb 2018 11:57:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518465422; cv=none; d=google.com; s=arc-20160816; b=XLJA+i9s1AB2v+YvgBHd2pE3aU1E1Bcls10HfDGwZZPpZoazfZhbyVViwoc3RyLP23 fEYLA8APEDjlyhQ6QoOwMut9PD5V5c5yFUJ7ukByJUg6qudsG6J7wn99zC1M6/qmORdS 2JMw+lZu014flQK83aCKyleFDaROpxJYvEQdtNNxpNiB1hG5eTf9fL0j5L/l5BUo4rjc 6aQB/MqdpUlxJ2aAo+2rolLOuqWk1rrLKbZ8K/K6kuGun1SAG2Kt5lpIZ/cy/x4eiGya mXKWKxSQJhGPIzuXyePXSXddQ6g04RioSEwwu+VQap1VZWsOQZSSE0LBePDhjg7VPdIe dwUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=T8nRijTb4Cz8uq7cS62jl9PKsuS+rub37t3QmzmWZDI=; b=fYqKlzGCfRjWyuBDrHmsmzWXsIgQXKAyuEHNGcxiIpjwcM/QwpoLA4ijC4uLpYlsfe 7s0NxcK/C6gN5eg3DhDUg708kqhzMfBychZloZKAy4yr9HKyrZ75+zaiwCAJ4jGevLwU msi5NsOWtW3G0tEzDGJYM57dm5oIrztSZEdLJT4typuasa93bjz51BCh/EwI1aToTK6b Rdt17KzYkufoEtssjhz/QsGcgQ2VoTIgkISuN/7rD+kmMySLviEw06pqu2pDQJWiJ3U3 KztZOX2KgQnrrEA7V2MoqRDXbNsyV8XdbQHHw42Vz/wVFTDKxD/3f71Os3R3zz5M8vSo 3V2Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u136si672816pgc.481.2018.02.12.11.56.47; Mon, 12 Feb 2018 11:57:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751624AbeBLT4H (ORCPT + 99 others); Mon, 12 Feb 2018 14:56:07 -0500 Received: from mail.efficios.com ([167.114.142.141]:60928 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750953AbeBLT4F (ORCPT ); Mon, 12 Feb 2018 14:56:05 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 90C443401B7; Mon, 12 Feb 2018 19:57:01 +0000 (UTC) Received: from mail.efficios.com ([127.0.0.1]) by localhost (evm-mail-1.efficios.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 3Rg1zw1msLKF; Mon, 12 Feb 2018 19:56:56 +0000 (UTC) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 4241034024E; Mon, 12 Feb 2018 19:56:56 +0000 (UTC) X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([127.0.0.1]) by localhost (evm-mail-1.efficios.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id pRuM-Vf_kiuU; Mon, 12 Feb 2018 19:56:56 +0000 (UTC) Received: from thinkos.internal.efficios.com (192-222-157-41.qc.cable.ebox.net [192.222.157.41]) by mail.efficios.com (Postfix) with ESMTPSA id B70093401B7; Mon, 12 Feb 2018 19:56:55 +0000 (UTC) From: Mathieu Desnoyers To: Michael Kerrisk Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Ingo Molnar , Peter Zijlstra , Thomas Gleixner , Andy Lutomirski , "Paul E . McKenney" , Boqun Feng , Andrew Hunter , Maged Michael , Avi Kivity , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Dave Watson , "H . Peter Anvin" , Andrea Parri , Russell King , Greg Hackmann , Will Deacon , David Sehr , Mathieu Desnoyers Subject: [PATCH manpages] membarrier.2: New membarrier commands introduced in 4.16 Date: Mon, 12 Feb 2018 14:55:49 -0500 Message-Id: <20180212195549.11485-1-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Document the following membarrier commands introduced in 4.16: - MEMBARRIER_CMD_GLOBAL_EXPEDITED (the old enum label MEMBARRIER_CMD_SHARED is now an alias to preserve header backward compatibility), - MEMBARRIER_CMD_GLOBAL_EXPEDITED, - MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED, - MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE, - MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE. Signed-off-by: Mathieu Desnoyers CC: Michael Kerrisk CC: Ingo Molnar CC: Peter Zijlstra CC: Thomas Gleixner --- man2/membarrier.2 | 73 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 62 insertions(+), 11 deletions(-) diff --git a/man2/membarrier.2 b/man2/membarrier.2 index c47bc875a..e878301ca 100644 --- a/man2/membarrier.2 +++ b/man2/membarrier.2 @@ -80,7 +80,7 @@ This command is always supported (on kernels where .BR membarrier () is provided). .TP -.B MEMBARRIER_CMD_SHARED +.B MEMBARRIER_CMD_GLOBAL " (since Linux 4.16)" Ensure that all threads from all processes on the system pass through a state where all memory accesses to user-space addresses match program order between entry to and return from the @@ -88,7 +88,30 @@ order between entry to and return from the system call. All threads on the system are targeted by this command. .TP -.BR MEMBARRIER_CMD_PRIVATE_EXPEDITED " (since Linux 4.14)" +.B MEMBARRIER_CMD_GLOBAL_EXPEDITED " (since Linux 4.16)" +Execute a memory barrier on all running threads of all processes which +previously registered with +.BR MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED . +Upon return from system call, the caller thread is ensured that all +running threads have passed through a state where all memory accesses to +user-space addresses match program order between entry to and return +from the system call (non-running threads are de facto in such a state). +This only covers threads from processes which registered with +.BR MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED . +Given that registration is about the intent to receive the barriers, it +is valid to invoke +.BR MEMBARRIER_CMD_GLOBAL_EXPEDITED +from a non-registered process. +.IP +The "expedited" commands complete faster than the non-expedited ones; +they never block, but have the downside of causing extra overhead. +.TP +.B MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED " (since Linux 4.16)" +Register the process intent to receive +.BR MEMBARRIER_CMD_GLOBAL_EXPEDITED +memory barriers. +.TP +.B MEMBARRIER_CMD_PRIVATE_EXPEDITED " (since Linux 4.14)" Execute a memory barrier on each running thread belonging to the same process as the current thread. Upon return from system call, the calling @@ -103,9 +126,29 @@ they never block, but have the downside of causing extra overhead. A process needs to register its intent to use the private expedited command prior to using it. .TP -.BR MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED " (since Linux 4.14)" +.B MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED " (since Linux 4.14)" Register the process's intent to use -.BR MEMBARRIER_CMD_PRIVATE_EXPEDITED . +.B MEMBARRIER_CMD_PRIVATE_EXPEDITED . +.TP +.B MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE " (since Linux 4.16)" +In addition to provide memory ordering guarantees described in +.BR MEMBARRIER_CMD_PRIVATE_EXPEDITED , +ensure the caller thread, upon return from system call, that all its +running threads siblings have executed a core serializing instruction. +This only covers threads from the same process as the caller thread. +The "expedited" commands complete faster than the non-expedited ones, +they never block, but have the downside of causing extra overhead. A +process needs to register its intent to use the private expedited sync +core command prior to using it. +.TP +.B MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE " (since Linux 4.16)" +Register the process intent to use +.BR MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE . +.TP +.B MEMBARRIER_CMD_SHARED + Alias to +.BR MEMBARRIER_CMD_GLOBAL . +Provided for header backward compatibility. .PP The .I flags @@ -137,10 +180,14 @@ The pair ordering is detailed as (O: ordered, X: not ordered): On success, the .B MEMBARRIER_CMD_QUERY operation returns a bit mask of supported commands, and the -.B MEMBARRIER_CMD_SHARED , +.B MEMBARRIER_CMD_GLOBAL , +.B MEMBARRIER_CMD_GLOBAL_EXPEDITED , +.B MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED , .B MEMBARRIER_CMD_PRIVATE_EXPEDITED , -and .B MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED , +.B MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE , +and +.B MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE operations return zero. On error, \-1 is returned, and @@ -163,10 +210,14 @@ set to 0, error handling is required only for the first call to is invalid, or .I flags is nonzero, or the -.BR MEMBARRIER_CMD_SHARED +.BR MEMBARRIER_CMD_GLOBAL command is disabled because the .I nohz_full -CPU parameter has been set. +CPU parameter has been set, or the +.BR MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE +and +.BR MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE +commands are not implemented by the architecture. .TP .B ENOSYS The @@ -294,9 +345,9 @@ init_membarrier(void) return \-1; } - if (!(ret & MEMBARRIER_CMD_SHARED)) { + if (!(ret & MEMBARRIER_CMD_GLOBAL)) { fprintf(stderr, - "membarrier does not support MEMBARRIER_CMD_SHARED\\n"); + "membarrier does not support MEMBARRIER_CMD_GLOBAL\\n"); return \-1; } @@ -315,7 +366,7 @@ static void slow_path(int *read_a) { b = 1; - membarrier(MEMBARRIER_CMD_SHARED, 0); + membarrier(MEMBARRIER_CMD_GLOBAL, 0); *read_a = a; } -- 2.11.0