Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3046397pxa; Tue, 25 Aug 2020 09:59:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHyH/pxkgKFkSfpeIXgJGD4Tv+qW4Rf86mgpco8bKqaVo3d+09gWxwkKOWaGk13XeqrGrv X-Received: by 2002:a17:906:6146:: with SMTP id p6mr11883072ejl.211.1598374783158; Tue, 25 Aug 2020 09:59:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598374783; cv=none; d=google.com; s=arc-20160816; b=eefOO53ZR5Ede+QZEB547Alyd3oytYEAlYs1jozc8L0riD7pY+31c7oEziO392658b q9uaNLrcay0S/o+dbyX9FsFKaWaGfLm4zuXRfWT0dGiUc1PZdZnzHWp9NGn64j7oXSFO GrkWHiqguEhD130kEaMvlFhGloEZBxIPmdgsrJrExyudJSLZ62sovLEikAYKs75lqgAi nuBAyfieepex7cZUMz5qHX9hkkNZLK6eCFAn6XUdEk+Z9EOl4lqthWQqZUYbi9kTiNqN oNtvwBOQE4Sn55zdy9pbA56D/s9pJ/3Oit2jXeSR01iJszeGscPB38NYMDwA6AtN1wXx zx+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:dkim-signature:dkim-filter; bh=8pMBOx23pCf5NPePNYDHmUZ9AoEDhBHlY2NFid2+VHU=; b=cqkOeIm4yiOt9HyDVNWwZ9GDS+l1jILXOUT+mFO6AuGCoP0VbIVSNxQIiNrYaZwe2d Bsc3QQxTNCRo4uPCxyFjQ4+F+jxz5BEMg8Jqw3NE0sPSJUIfvM1pZkGEJad6p3gp7HvC 6HFlRAfSYmO77cWYNSSju0KGYgPqjQiC6XL8RQ/wsFp92MsyYAspx087Y0T7MV/ef+RM e0L9trIiN5vHqvfOQY4d7HXvbnw5uQBM024aifl7pBJz6Rk/FkZdWPobNRer/Edogkik taHPTxM7w/0N+CVTlYRIP57StIhF2lPXiuPJpzbzCULDNVMOat5bk3aULlPJBBWq9zCP MeSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b="ADy/ab3j"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t9si9432903eji.436.2020.08.25.09.59.19; Tue, 25 Aug 2020 09:59:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b="ADy/ab3j"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726413AbgHYQ6c (ORCPT + 99 others); Tue, 25 Aug 2020 12:58:32 -0400 Received: from mail.efficios.com ([167.114.26.124]:54230 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726580AbgHYQ62 (ORCPT ); Tue, 25 Aug 2020 12:58:28 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id F41EB25E13D; Tue, 25 Aug 2020 12:58:21 -0400 (EDT) Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id ddEiH_vdZ8LL; Tue, 25 Aug 2020 12:58:21 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 834F825DE54; Tue, 25 Aug 2020 12:58:21 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 834F825DE54 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1598374701; bh=8pMBOx23pCf5NPePNYDHmUZ9AoEDhBHlY2NFid2+VHU=; h=Date:From:To:Message-ID:MIME-Version; b=ADy/ab3jRq6H7i/k9KwCApzr/+L46USCep1xAaAOZAwMlaiqaPHFobZ6fcMjZ3D2Q q9F4MiDMBRBjFr6+YDUCRLL2v0z/DgHoHiTNDHvSPt2fyV9tfcpLFBJiMTGOue4Q8L ufV2D2etAJUeI4mJh5Ow/ol4Ro5W2Y1iq++LFNcQ2W8q4zl7JwsrX4Zmv9HMRMcasH Nw9hW9t2b2NRpzKwDkb/0UJoLw2DaJpWX40k5Sv5/C1f4NdgC+OtG319AvE71AmMdy xuZkcaWirWirakU75EFZLeQJwIy8F9yDjiOGg3Zhn5b7uUySk/vitfVY8ssFsDQokE Zg8XrO5g5XmAw== X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 0y5gHkg6pdUQ; Tue, 25 Aug 2020 12:58:21 -0400 (EDT) Received: from mail03.efficios.com (mail03.efficios.com [167.114.26.124]) by mail.efficios.com (Postfix) with ESMTP id 73A5F25DE53; Tue, 25 Aug 2020 12:58:21 -0400 (EDT) Date: Tue, 25 Aug 2020 12:58:21 -0400 (EDT) From: Mathieu Desnoyers To: Peter Oskolkov Cc: linux-arch , Peter Zijlstra , Peter Oskolkov , paulmck , Boqun Feng , linux-kernel , Paul Turner , Chris Kennelly Message-ID: <1336467655.17779.1598374701401.JavaMail.zimbra@efficios.com> In-Reply-To: References: <20200811000959.2486636-1-posk@google.com> <20200811062733.GP3982@worktop.programming.kicks-ass.net> <1003774683.6088.1597257002027.JavaMail.zimbra@efficios.com> <1477195446.6156.1597261492255.JavaMail.zimbra@efficios.com> Subject: Re: [PATCH 1/2 v3] rseq/membarrier: add MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [167.114.26.124] X-Mailer: Zimbra 8.8.15_GA_3959 (ZimbraWebClient - FF79 (Linux)/8.8.15_GA_3953) Thread-Topic: rseq/membarrier: add MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ Thread-Index: /ve+w4rUgTPRRwn+aSBECFJ4/3Rgfw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- On Aug 20, 2020, at 1:42 PM, Peter Oskolkov posk@posk.io wrote: > On Wed, Aug 12, 2020 at 12:44 PM Mathieu Desnoyers > wrote: >> > [...] >> >> > One way of doing what you suggest is to allow some commands to be bitwise-ORed. >> > >> > So, for example, the user could call >> > >> > membarrier(CMD_PRIVATE_EXPEDITED_SYNC_CORE | CMD_PRIVATE_EXPEDITED_RSEQ, cpu_id) >> > >> > Is this what you have in mind? >> >> Not really. This would not take care of the fact that we would end up >> multiplying >> the number of commands as we allow combinations. E.g. if we ever want to have >> RSEQ >> work in private and global, and in non-expedited and expedited, we end up >> needing: >> >> - CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ >> - CMD_PRIVATE_EXPEDITED_RSEQ >> - CMD_PRIVATE_RSEQ >> - CMD_REGISTER_GLOBAL_EXPEDITED_RSEQ >> - CMD_GLOBAL_EXPEDITED_RSEQ >> - CMD_GLOBAL_RSEQ >> >> The only thing we would save by OR'ing it with the SYNC_CORE command is the >> additional >> list: >> >> - CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ_SYNC_CORE >> - CMD_PRIVATE_EXPEDITED_RSEQ_SYNC_CORE >> - CMD_PRIVATE_RSEQ_SYNC_CORE >> - CMD_REGISTER_GLOBAL_EXPEDITED_RSEQ_SYNC_CORE >> - CMD_GLOBAL_EXPEDITED_RSEQ_SYNC_CORE >> - CMD_GLOBAL_RSEQ_SYNC_CORE >> >> But unless we receive feedback that doing a membarrier with RSEQ+sync_core all >> in >> one go is a significant use-case, I am tempted to leave out that scenario for >> now. >> If we go for new commands, this means we could add (for private-expedited-rseq): >> >> - MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ, >> - MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ, >> >> I do however have use-cases for using RSEQ across shared memory (between >> processes). Not currently for a rseq-fence, but for rseq acting as per-cpu >> atomic operations. If I ever end up needing rseq-fence across shared memory, >> that would result in the following new commands: >> >> - MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED_RSEQ, >> - MEMBARRIER_CMD_GLOBAL_EXPEDITED_RSEQ, >> >> The remaining open question is whether it would be OK to define a new >> membarrier flag=MEMBARRIER_FLAG_CPU, which would expect an additional >> @cpu parameter. > > Hi Mathieu, > > I do not think there is any reason to wait for additional feedback, so I believe > we should finalize the API/ABI. > > I see two issues to resolve: > 1: how to combine commands: > - you do not like adding new commands that are combinations of existing ones; > - you do not like ORing. > => I'm not sure what other options we have here? Concretely speaking, let's just add a new membarrier command for the use-case at hand. All other ways of doing things we have discussed are tricky to expose in a way that is discoverable by user-space through the QUERY command. (using a flag, or OR'ing many commands together) > > 2: should @flags be repurposed for cpu_id, or MEMBARRIER_FLAG_CPU > added with a new syscall parameter. > => I'm still not sure a new parameter can be cleanly added, but I can try > it in the next patchset if you prefer it this way. Yes please, it's easy to implement and we'll quickly see if anyone yells. If it turns out to be a bad idea, you can always blame me. ;-) In summary: - We add 2 new membarrier commands: - MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ - MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ - We reserve a membarrier flag: enum membarrier_flag { MEMBARRIER_FLAG_CPU = (1 << 0), } So for CMD_PRIVATE_EXPEDITED_RSEQ, if flags & MEMBARRIER_FLAG_CPU is true, then we expect the additional "int cpu" parameter (3rd parameter). Else the cpu parameter is unused. Are you OK with this approach ? Thanks, Mathieu > > Please let me know your thoughts. > > Thanks, > Peter -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com