Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp28179477rwd; Tue, 4 Jul 2023 14:38:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6vLa22ICwRg4qQvxZbfYnfc52kVvIl2g7qvrr9PgDIwgV9HSb9xOgeqC9mifJcHVtXbR6b X-Received: by 2002:a05:6808:14c4:b0:3a3:67cb:61e3 with SMTP id f4-20020a05680814c400b003a367cb61e3mr16465989oiw.25.1688506688532; Tue, 04 Jul 2023 14:38:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688506688; cv=none; d=google.com; s=arc-20160816; b=HBsxgRul084yg5u6kIkkLT5IGDgkGqMJxbf6uOr8g/TvahKukgQn+k9PtQfAA7sEIq lxvXVgdoVBc99vM41GUtc0a1qiMy8sZcA3o1Q8uemGRWw/iF3awPsj8MkElW5b3dfPkW B5pk9q6PvV0W8I8Au89pfKD2kVVzxpfEjVBDET7Spd7sKBS7KtU0nt4vagWYMJD4inZU jVVykom0rWFReP7Wg5aCXuT/TtJvWDQZs92eQEwOQrWyTP/Sq0HTKm3mTDrOHL1TJHRX mfhse7Zbe58WDre80x12wXiFPA+O7c4+lLZTtnr0F0LqM4i7ByMP1Hxx0UJrLXzBXpJv S+9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=F9cBxW8SgIMC62sxQK/fZ8seppTljj2N/AFT8OZ3l3c=; fh=K2+BY7TiQHwJiQRkmTPoSaeWmQFoTi+kKwhGiZwv300=; b=VtNNoMC+CA3MgqNTAm1p78z070iIUuK/xnN6jQQZjv6yR/XkizTgUYA/xUjVSgbJ8e NzxXzPG8pzyUFYVoRRozOkeIiDa8SgVg+3GHzxr6vuxv4g+RxQ0JalHcL1mt3nHL2AFV LgeJaA1JOREmvsWYcmzn2QIg8GNuhuEYvXvlXtnLN1qWB95AVoZhO38h8P7Q4FxAq99u ifAXm1YDlGrCIhPKVgrSwwHmqckUUyG4t1Mi0oOhBZi0LBaZ4u/wcFi7aYpfJYyMfJPq UbotIVRDPdI+1ukqce/eFG8oQ5fAvB6MOJtYTyhHwFsGBxRtoyxwDWbRMS9ydIcgFMdH eISA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=emtK38Xl; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m63-20020a632642000000b0053f25281d15si22047795pgm.537.2023.07.04.14.37.53; Tue, 04 Jul 2023 14:38:08 -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=@kernel.org header.s=k20201202 header.b=emtK38Xl; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230507AbjGDVZN (ORCPT + 99 others); Tue, 4 Jul 2023 17:25:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229903AbjGDVZL (ORCPT ); Tue, 4 Jul 2023 17:25:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA6C318B; Tue, 4 Jul 2023 14:25:10 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8196861281; Tue, 4 Jul 2023 21:25:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E04F5C433C7; Tue, 4 Jul 2023 21:25:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688505909; bh=qc56JTBHGohk1G3UBHSzdTOuW9NcRbtT8225a+8pH5Q=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=emtK38XlrYPJvK7UxLe0VHhghuLKeQeRWePjA6wNBBOj1orrQ4WKXP0zh1qDSfs/X dt1Z+Zi/mi6s9iVRg+51zLHKddCU/OAd/H0TKxYaO11JosTLjcx0/eMzvZOMH6RFVG zxCWgQn5rkYEJgfACQxzGz5C+dh48ltQeTxlPfTIwvzCzelcL35jIXmfPOn8izeKZd s2mt441asHp+men5mUbS3CcW5B2JrH1kUXrytQ8Lkr8pG4/p8evSADchqrLnhxTYFk 72W0GgjMcy0qoiTiVIFbCRPCJfsGi/XT9DVw3djQjRumGduewmom3KfKs0UYPM4I2F 0/Q4/FkK9i+7w== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 7E9CFCE0CC2; Tue, 4 Jul 2023 14:25:09 -0700 (PDT) Date: Tue, 4 Jul 2023 14:25:09 -0700 From: "Paul E. McKenney" To: Alan Stern Cc: Olivier Dion , Mathieu Desnoyers , rnk@google.com, Andrea Parri , Will Deacon , Peter Zijlstra , Boqun Feng , Nicholas Piggin , David Howells , Jade Alglave , Luc Maranget , 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 Message-ID: <3f740262-821b-4f39-8f1a-c6d02253986c@paulmck-laptop> Reply-To: paulmck@kernel.org References: <87ttukdcow.fsf@laura> <87ilazd278.fsf@laura> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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, Jul 04, 2023 at 04:25:45PM -0400, Alan Stern wrote: > On Tue, Jul 04, 2023 at 01:19:23PM -0400, Olivier Dion wrote: [ . . . ] > > I am puzzled by this. Initialization of a shared variable does not need > > to be atomic until its publication. Could you expand on this? > > In the kernel, I believe it sometimes happens that an atomic variable > may be published before it is initialized. (If that's wrong, Paul or > Peter can correct me.) But since this doesn't apply to the situations > you're concerned with, you can forget I mentioned it. Both use cases exist. A global atomic is implicitly published at compile time. If the desired initial value is not known until multiple threads are running, then it is necessary to be careful. Hence double-check locking and its various replacements. (Clearly, if you can determine the initial value before going multithreaded, life is simpler.) And dynamically allocated or on-stack storage is the other case, where there is a point in time when the storage is private even after multiple threads are running. Or am I missing the point? Thanx, Paul