Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp205754rdb; Thu, 19 Oct 2023 01:47:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGdjgq/8+v+kflife+cDucZBL635cCQcgxa44BeNeZe5ddDybt1VUnejf4QB3i90bQ2tFZ3 X-Received: by 2002:a05:6358:7e16:b0:166:d1a1:7738 with SMTP id o22-20020a0563587e1600b00166d1a17738mr1661805rwm.0.1697705240832; Thu, 19 Oct 2023 01:47:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697705240; cv=none; d=google.com; s=arc-20160816; b=sGJbQsgbHceELgW2ZfoQxUKMMTIkLiqQDadiddack2VzXG65Bl1t7/3ZrDGMEbfFnr CGCSz9YUU6BI9aE+GvVu71WPesyLrOhIAEL1UtjJ6CjSAfIaoPhg/DD+6O6vnMOSOqwx yNWtR3sScaqvGekVv7yu52NOZfCueRWy6rj8Sl7TXo3G3OznE6eS7MhuH8RR1ywDUoBh GhDul1YQbknvdhPAr1ImBRk6vMXpGunafuTluth34ACVRSeHONZmyjt6xkMNzbpJ1pUk m4tNshSDJs2DBN5F2gqJJqfX56hKHmBGvNGAZOO6E2Kv4xzDut4zhyEsLsku4tavOLJv s/FQ== 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:message-id:subject:cc:to:from:date:dkim-signature; bh=2OvDv6KjjjkV7XKCQZRcKD2cr4pcyB4jYdJMvx56mP8=; fh=S7/5y/BGEz+mOJd1ujes2n4AQwqvvnwDwyLSH15u0Zw=; b=hpZ2lV91d/AE0RV354TxJcMpmdp/zSYQ0s68cG1atqgK6kc2YR54BjItMj9+9FBVpw 9FsZ7uXTfusUoKRi78UxYYla3j3OLyVIID3J+sbnlQxpDlcGiZtvu5NtDLBJqvvZcsb9 M//2CSUAl6uaf3YVXuzxsEW71+/M0jcBZKxyc6XALUxEm2F3f3liXkTKXbBvBhPJbpwH ru9oXxa8xOzFI4XUlcFjcHtfMux8pnVKNeFWVHynTeulfsmazB8tczwicrQ0J75pVQ9P rrnSvgr3UzDmBmJEohgr5vHiJlfZxMhFPddlk75/Kzo2NM9depU7TwBzzGEo7Jzohmim E5sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Xq6iV168; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id y15-20020aa79aef000000b0068fdeb84453si5622586pfp.265.2023.10.19.01.47.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 01:47:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Xq6iV168; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 8A0B480A58CC; Thu, 19 Oct 2023 01:46:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232788AbjJSIqB (ORCPT + 99 others); Thu, 19 Oct 2023 04:46:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231984AbjJSIp7 (ORCPT ); Thu, 19 Oct 2023 04:45:59 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 668C210F for ; Thu, 19 Oct 2023 01:45:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=2OvDv6KjjjkV7XKCQZRcKD2cr4pcyB4jYdJMvx56mP8=; b=Xq6iV1680szqGtsstE6IYiRZCq T63TX8lnxdJJYSj/o54VFyj8ujUaE+DTJG5mP1gteshyxDppuT+4CIy3y7pMEOQdU18QU/+LXNc1C jwWBavyk/Ebl9lw1kv2/vrPJaF1bnzvJTfOysScOmFb0JcXDS0U+8pjeMlOkrwJQojmPdpTtqgaS9 Lragrs853Ys0UVzseD1wUF2D9oWpo4jPU0ZjC53Uc/2iUqQMJgfOC4fsfrbPSy3kXu4svFfGsGn8x FimE5dMnFGPkyyYnN46rxsramsw6mQ0V1VVzkeczg5tp9lbeib/mAVVHHPt21bxt6mXd/Vp7LsVTw HVk+Xidw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1qtOeK-00648M-9p; Thu, 19 Oct 2023 08:45:00 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id ECD4C300392; Thu, 19 Oct 2023 10:44:59 +0200 (CEST) Date: Thu, 19 Oct 2023 10:44:59 +0200 From: Peter Zijlstra To: Linus Torvalds Cc: Uros Bizjak , Nadav Amit , the arch/x86 maintainers , Linux Kernel Mailing List , Andy Lutomirski , Brian Gerst , Denys Vlasenko , "H . Peter Anvin" , Thomas Gleixner , Josh Poimboeuf , Nick Desaulniers Subject: Re: [PATCH v2 -tip] x86/percpu: Use C for arch_raw_cpu_ptr() Message-ID: <20231019084459.GP33217@noisy.programming.kicks-ass.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Thu, 19 Oct 2023 01:46:08 -0700 (PDT) On Wed, Oct 18, 2023 at 03:40:05PM -0700, Linus Torvalds wrote: > Side note: the code that caused that problem is this: > > __always_inline void __cyc2ns_read(struct cyc2ns_data *data) > { > int seq, idx; > > do { > seq = this_cpu_read(cyc2ns.seq.seqcount.sequence); > ... > } while (unlikely(seq != this_cpu_read(cyc2ns.seq.seqcount.sequence))); > } > > where the issue is that the this_cpu_read() of that sequence number > needs to be ordered. I have very vague memories of other code also relying on this_cpu_read() implying READ_ONCE(). And that code really only is buggy if you do not have that. Since it is cpu local, the smp_rmb() would be confusing, as would smp_load_acquire() be -- there is no cross-cpu data ordering. The other option is of couse adding explicit barrier(), but that's entirely superfluous when all the loads are READ_ONCE(). If you want to make this_cpu_read() not imply READ_ONCE(), then we should go audit all users :/ Can be done ofc.