Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp30728270rwd; Thu, 6 Jul 2023 09:51:08 -0700 (PDT) X-Google-Smtp-Source: APBJJlE/FchL2jl9FIjCUCuLBlXl1nA6QP+gauiIEs0N3zRRzzMAG84V+Glb0+z9PtL7sB9Y/mJo X-Received: by 2002:a05:6a00:cc9:b0:668:98a1:5e9d with SMTP id b9-20020a056a000cc900b0066898a15e9dmr4334513pfv.6.1688662267717; Thu, 06 Jul 2023 09:51:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688662267; cv=none; d=google.com; s=arc-20160816; b=qk7PzI2RyC4svY+xCQnRNLMNdkv/tN68b+MzCLOarV/YJUmvVlvIOhXFspAQOk87aW 65ICZPS7dH6Nm8r8cIk3fnr75AbSyy/xenoAcX6OURCYDy4VewNUJrckwqDi/wQs7I/Z oMvkULEIykU4raHO1vWuzl2VoY3eBDjXN6FY4Z1iQGh/yiNkdOratUAm1Pxm/JK4ReVQ HC+7naHVmrDCMxUxPxVusVDWIskKgSeigyHZvNFNdUrc7HUZv7Sq+rno/JqQzojq/NLM GA5vSdRUyyKZDlKi2meXr5zvhTU6hqwyFIqWBwLDP3p9AUv//HoWDTS0VVmWb9dFkfFx gQmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :organization:in-reply-to:subject:cc:to:from:dkim-signature; bh=EXPLOreJ4AWiXd4SULko0XwGmW6yV5aAy4wS4n9qjl8=; fh=QpORJdUaBKR0mrtcP8r8+HQeuy1MSMda1sv5ui2/YsI=; b=JktRRYtw7ThgDNJ0oFiAdSxIJ1SSL2yw5CVdGNzrhtOdLlQyQ8TmoXr+6hW+ghgozy N7wXSmDrunlGRNsspNubNGzWihSHB3LpMjCE0PppyZiO6VwHR64+JvG+frVIzwj7GFu8 pEkSaYwTDIXwNHnJgHYdZkNEFqkdTfkYE0dBBDPkEz756UZQpuvYqQxvSs8O87thp0ug re/DsgzmDqU2Js20tagZaiWJz0VqjZrkl4zuQvtk3hl7/yaLu8vmErTqTu9wY/uCnk9L L2YlqSc/vMB8X8u8mJzLh9ZTHzaiMCWNd7uVV4CMvBONoSv3EfbxmaP+p2YoDDt9Rk82 J1Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=V5+vwnmt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 7-20020a631347000000b0054fd35b2dbcsi1766882pgt.350.2023.07.06.09.50.27; Thu, 06 Jul 2023 09:51:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=V5+vwnmt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229735AbjGFQiD (ORCPT + 99 others); Thu, 6 Jul 2023 12:38:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229587AbjGFQiC (ORCPT ); Thu, 6 Jul 2023 12:38:02 -0400 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C30C21AE; Thu, 6 Jul 2023 09:38:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1688661478; bh=lwhfZRazYulsiYsKZXPsOI+0dCJb/SmcqpyPmq8W+xg=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=V5+vwnmtFaeTpMVye7LZyjBp+CBcvDlhWRyHsGt6a09D3mQLNDKSZBwx7LP/WTs7Z j7g912oLYj3A1TIQF0gX9a1OGn25C6l3MchqXU7clXjKOcWt+ynjy61eOFNruLf1iY tg2y2Vy3sCo6b/upoVrH2APR6rYVy+9DXWHUhMmiitkV0U8/IomVQVD26FX6oPE3uu 0mYGe7xioVr8UKoI1Rc7qmcLG+sQY6LIId0IB8HaEez2S9gEMqzdXg0jdTnbQjgoZQ cg9era4hELiMQ78azUIkk7MOGe6rKbmwYf3pPReaRG79ioKXnQ2II/cZgbuxlQwCEw 15Bdg97bULYcg== Received: from localhost (modemcable094.169-200-24.mc.videotron.ca [24.200.169.94]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4QxhzB3Jcxz1C9p; Thu, 6 Jul 2023 12:37:58 -0400 (EDT) From: Olivier Dion To: Alan Stern Cc: Mathieu Desnoyers , rnk@google.com, Andrea Parri , Will Deacon , Peter Zijlstra , Boqun Feng , Nicholas Piggin , David Howells , Jade Alglave , Luc Maranget , "Paul E. McKenney" , Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, gcc@gcc.gnu.org, llvm@lists.linux.dev Subject: Re: [RFC] Bridging the gap between the Linux Kernel Memory Consistency Model (LKMM) and C11/C++11 atomics In-Reply-To: Organization: EfficiOS References: <87ttukdcow.fsf@laura> <87ilazd278.fsf@laura> Date: Thu, 06 Jul 2023 12:37:58 -0400 Message-ID: <87sfa1atcp.fsf@laura> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 04 Jul 2023, Alan Stern wrote: > On Tue, Jul 04, 2023 at 01:19:23PM -0400, Olivier Dion wrote: >> On Mon, 03 Jul 2023, Alan Stern wrote: >> > On Mon, Jul 03, 2023 at 03:20:31PM -0400, Olivier Dion wrote: [...] > Oh, is that it? Then I misunderstood entirely; I thought you were > talking about augmenting the set of functions or macros made available > in liburcu. I did not realize you intended to change the compilers. Yes. We want to extend the atomic builtins API of the toolchains. >> Indeed, our intent is to discuss the Userspace RCU uatomic API by extending >> the toolchain's atomic builtins and not the LKMM itself. The reason why >> we've reached out to the Linux kernel developers is because the >> original Userspace RCU uatomic API is based on the LKMM. > > But why do you want to change the compilers to better support urcu? > That seems like going about things backward; wouldn't it make more sense > to change urcu to better match the facilities offered by the current > compilers? The initial motivation for the migration of the Userspace RCU atomics API from custom inline assembler (mimicking the LKMM) to the C11/C++11 memory model was for supporting userspace tools such as TSAN. We did that by porting everything to the compiler's atomic builtins API. However, because of the "fully-ordered" atomic semantic of the LKMM, we had no other choices than to add memory fences which are redundant on some strongly ordered architectures. > What if everybody started to do this: modifying the compilers to better > support their pet projects? The end result would be chaos! This is why we are starting this discussion which involves members of the Kernel and toolchains communities. We have prior experience, e.g. with asm gotos which were implemented in GCC, and Clang afterward, in response to Linux Kernel tracepoint's requirements. Note that the motivation for supporting TSAN in Userspace RCU is coming from the requirements of the ISC for the BIND 9 project. [...] >> If we go for the grouping in a), we have to take into account that the >> barriers emitted need to cover the worse case scenario. As an example, >> Clang can emit a store for a exchange with SEQ_CST on x86-64, if the >> returned value is not used. >> >> Therefore, for the grouping in a), all RMW would need to emit a memory >> barrier (with Clang on x86-64). But with the scheme in b), we can emit >> the barrier explicitly for the exchange operation. We however question >> the usefulness of this kind of optimization made by the compiler, since >> a user should use a store operation instead. > > So in the end you settled on a compromise? We have not settled on anything yet. Choosing between options a) and b) is open to discussion. [...] Thanks, Olivier -- Olivier Dion EfficiOS Inc. https://www.efficios.com