Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp379008rdb; Tue, 31 Oct 2023 09:56:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFTNF3XCKl1xPCHNuBGP4KMOyZsf8S2/46UsF+PQocBHjSQ5SXYHmQLTA5i82lhwI3g0bJk X-Received: by 2002:a05:6a21:3298:b0:16b:74bb:e57e with SMTP id yt24-20020a056a21329800b0016b74bbe57emr12303669pzb.12.1698771370434; Tue, 31 Oct 2023 09:56:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698771370; cv=none; d=google.com; s=arc-20160816; b=mt0u+ZvDKWxpBR3i1XCf4srjK+A7SicxGXsIF1UQa88q7M4qSp02lGJqScG8l+bv2p M76DCVxo6rNiNQGofcuHySYX4cN/ffPetLYRD3pTKLq/xFRvflfO4vfWPOMpfXyU8Zuf p2se587PaxiXqX07Ws63Sd+NTd33RCOcUq+6p5CXvKTTbQnSarStXQ6gfvJXAX5rswn1 OroiJvOo4/zpus6+G5FR2I3WpMlBEzXabQjWDEd9cV9GSJ8MbG1BOaKvaU5PoeP0R1t1 wvPgifLY0dGlzI6PP05Cp7YGIieBJwJQNOKRNzRbSH+VO68poFkFBdsGxYoJjjxY/NdE yRVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature:dkim-signature; bh=LWsQIn7ZkGzO6NK5PHMSWSWR/jIKE/XBQ2VgQvF6oWU=; fh=MMk2EqUUzINjiNK8VSlmwwFE7OtbGnXT0d+d57UXT9o=; b=sNxAv2BLg8gTbfcuilAYCvmyaNu9VsvgVhlIbNFVYPnma+l61hr7ZnRh/MJYT8GIqQ LQI1WLLgXW7E4q2GONugtbDMyl+pHI4uddEZE2mUGeqZ7QbAqUXy+CogDVb8EqfaHaEk N+598yvJ6cddCpvSBN+hup9E5A1wmoqYEwbW2bX5KXFqUtWxvgz3tyfMU9IAd5CIINmA e0c4MJs+/9qepdJIaAvkfNA0u4Nmm+qk/gz1/nawFJbmVJYAS/BW31vspS7nIxdzcs4U AVObZZgd9mIYtqBVcKOMNGsb/EZba2vC6Mpn+cH/lZAQ4fNgiydfffuR6zl1aMcDmFQI 0HYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=bnitcGCe; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=vQb9t+qZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id bs9-20020a632809000000b005adec857fd3si1199348pgb.523.2023.10.31.09.56.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 09:56:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=bnitcGCe; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=vQb9t+qZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 539AB80323CE; Tue, 31 Oct 2023 09:55:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376347AbjJaQyC (ORCPT + 99 others); Tue, 31 Oct 2023 12:54:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346927AbjJaQw1 (ORCPT ); Tue, 31 Oct 2023 12:52:27 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 780D6132; Tue, 31 Oct 2023 09:49:59 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 159411F460; Tue, 31 Oct 2023 16:49:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1698770998; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=LWsQIn7ZkGzO6NK5PHMSWSWR/jIKE/XBQ2VgQvF6oWU=; b=bnitcGCe3p+/SPIabZB6USeL/VymqpPJ4x/HtwHu9ibIjcuMhj2865GvxdFZzXXf/QL3Uj TewihLVBj8H7HsomFJ8uhcu/QngN4suBP6mOHJiR22TaIEBwiyVNQqtow+iwhohaVsuMKO UbRWSd3DJ4Vx1T9RCpC50Xh8obATvEY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1698770998; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=LWsQIn7ZkGzO6NK5PHMSWSWR/jIKE/XBQ2VgQvF6oWU=; b=vQb9t+qZHj89dN/KqgASgTL8JomW7MDHPiXGfIcN1cC3avRXpFFdk7IQ9XcFH3C9WXKf4x EaABCAWmB+iEVtDQ== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id A37E32C36A; Tue, 31 Oct 2023 16:49:56 +0000 (UTC) Received: by wotan.suse.de (Postfix, from userid 10510) id D6D9666B2; Tue, 31 Oct 2023 16:49:56 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by wotan.suse.de (Postfix) with ESMTP id D442C6050; Tue, 31 Oct 2023 16:49:56 +0000 (UTC) Date: Tue, 31 Oct 2023 16:49:56 +0000 (UTC) From: Michael Matz To: Peter Zijlstra cc: "Paul E. McKenney" , Frederic Weisbecker , LKML , Boqun Feng , Joel Fernandes , Josh Triplett , Mathieu Desnoyers , Neeraj Upadhyay , Steven Rostedt , Uladzislau Rezki , rcu , Zqiang , "Liam R . Howlett" , ubizjak@gmail.com Subject: Re: [PATCH 2/4] rcu/tasks: Handle new PF_IDLE semantics In-Reply-To: <20231031162353.GF15024@noisy.programming.kicks-ass.net> Message-ID: References: <20231027192026.GG26550@noisy.programming.kicks-ass.net> <2a0d52a5-5c28-498a-8df7-789f020e36ed@paulmck-laptop> <20231027224628.GI26550@noisy.programming.kicks-ass.net> <200c57ce-90a7-418b-9527-602dbf64231f@paulmck-laptop> <20231030082138.GJ26550@noisy.programming.kicks-ass.net> <622438a5-4d20-4bc9-86b9-f3de55ca6cda@paulmck-laptop> <20231031095202.GC35651@noisy.programming.kicks-ass.net> <20231031151645.GB15024@noisy.programming.kicks-ass.net> <20231031162353.GF15024@noisy.programming.kicks-ass.net> User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 31 Oct 2023 09:55:03 -0700 (PDT) Hey, On Tue, 31 Oct 2023, Peter Zijlstra wrote: > > equivalent to that, then it can't be used in this situation. If you > > _have_ to use a RmW for other reasons like interrupt safety, then a > > volatile variable is not the way to force this, as C simply doesn't have > > that concept and hence can't talk about it. (Of course it can't, as not > > all architectures could implement such, if it were required). > > Yeah, RISC archs typically lack the RmW ops. I can understand C not > mandating their use. However, on architectures that do have them, using > them makes a ton of sense. > > For us living in the real world, this C abstract machine is mostly a > pain in the arse :-) Believe me, without it you would live in a world where only languages like ECMA script or Rust existed, without any reliable spec at all ("it's obvious, the language should behave like this-and-that compiler from 2010 implements it! Or was it 2012?"). Even if it sometimes would make life easier without (also for compilers!), at least you _have_ an arse to feel pain in! :-) Ahem. > > So, hmm, I don't quite know what to say, you're between a rock and a hard > > place, I guess. You have to use volatile for its effects but then are > > unhappy about its effects :) > > Notably, Linux uses a *ton* of volatile and there has historically been > a lot of grumbling about the GCC stance of 'stupid' codegen the moment > it sees volatile. > > It really would help us (the Linux community) if GCC were to be less > offended by the whole volatile thing and would try to generate better > code. > > Paul has been on the C/C++ committee meetings and keeps telling me them > folks hate volatile with a passion up to the point of proposing to > remove it from the language or somesuch. But the reality is that Linux > very heavily relies on it and _Atomic simply cannot replace it. Oh yeah, I agree. People trying to get rid of volatile are misguided. Of course one can try to capture all the individual aspects of it, and make individual language constructs for them (_Atomic is one). It makes arguing about and precisely specifying the aspects much easier. But it also makes the feature-interoperability matrix explode and the language more complicated in areas that were already arcane to start with. But it's precisely _because_ of the large-scale feature set of volatile and the compilers wish to cater for the real world, that it's mostly left alone, as is, as written by the author. Sure, one can wish for better codegen related to volatile. But it's a slippery slope: "here I have volatile, because I don't want optimizations to happen." - "but here I want a little optimization to happen" - "but not these" - ... It's ... not so easy :) In this specific case I think we have now sufficiently argued that "load-modify-store --> rmw" on x86 even for volatile accesses is a correct transformation (and one that has sufficiently local effects that our heads don't explode while thinking about all consequences). You'd have to do that for each and every transformation where volatile stuff is involved, just so to not throw out the baby with the water. > > If you can confirm the above about validity of the optimization, then at > > least there'd by a point for adding a peephole in GCC for this, even if > > current codegen isn't a bug, but I still wouldn't hold my breath. > > volatile is so ... ewww, it's best left alone. > > Confirmed, and please, your SMP computer only works becuase of volatile, > it *is* important. Agreed. Ciao, Michael.