Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1151347ybg; Thu, 4 Jun 2020 02:19:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyaknTPydwsKYbDhhZMlc7ltf89kcaju3kXSTVdMNWdfQQLTm4VrVxVxmKbEmYcAkpFBxl4 X-Received: by 2002:aa7:c38f:: with SMTP id k15mr3540858edq.342.1591262344954; Thu, 04 Jun 2020 02:19:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591262344; cv=none; d=google.com; s=arc-20160816; b=ESJkauIZh/dh9J6CpRRVZvApn0amnzip778wuNVDFaiN8jAoAtKPlbTLZUtVMap27t URVHM0m55W7BhlyYVr8h3ldcUGdRwNez6Od/N23paJh5mDA97I8OylPOEbiDXVBHZ8C7 FzJEaboJdEfQJRGqo+XH845B2ypJaFTKw0H+PXZcKMovDbDKYrx4cGsvCBE1HvanyjCb WBtBcsx2BuKaIHIMwlufj4ZEfWEKkvdvmEpo1oCI0Xmg+YYnGkFg7G0sUBYHg4tG1Mt9 QZb3ZZUPFaUGL55D4S4Mcxw4FyuGQO7qLQ4W1oy3xpG/MTnD9Rf2TJqVDcmk9ZyEsKjm R5Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=KNW9NL3uD47FUjnpw82UUardVK7E6+mLshnuYV72GPY=; b=R4Dd6tfYSDzab8QlFFqS/Y3PvWrEubG52JHRgzN7Ux3i4HgNVQyMcomNt7H2dgYnPJ QfHwN3EUbXfQoUSXMvpO/G5BvS2OojG1YKt0dkBEubaT3T4w/3axv3dzBWanHoAGJz8K K0vEE8kFTXUuJd2ba1ciDNy0dhMTWE+FsopW2C7XgNOvKcwVKx1GVhR07Pf1s3ytSQ+G NDOS/f1HNQv+g0jYAbgSzyz0ppHVLEHZi5xEG/hIvsmGr2jh8t3eLM2YwtgAVq/egSCy LJod6VXi+lweC9VTJkKktM7F1K6ndla8EQ6TAoAXkIPXTQYWMHbFReO9LyOYZMkR6zHK QeyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b="Z/jlrBjK"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a39si1431712edf.25.2020.06.04.02.18.42; Thu, 04 Jun 2020 02:19:04 -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=fail header.i=@infradead.org header.s=merlin.20170209 header.b="Z/jlrBjK"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726469AbgFDIFg (ORCPT + 99 others); Thu, 4 Jun 2020 04:05:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726115AbgFDIFg (ORCPT ); Thu, 4 Jun 2020 04:05:36 -0400 Received: from merlin.infradead.org (unknown [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1BCBC05BD1E for ; Thu, 4 Jun 2020 01:05:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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=KNW9NL3uD47FUjnpw82UUardVK7E6+mLshnuYV72GPY=; b=Z/jlrBjKW0MRevBunVgGpP3jxt 9zJmaTnmIvj7HFbmAOIvv4XWEeGYATe/HU2elxWGE8vfdjJ72zSzTDkJf9JFeEGGpDoKpo/wC7X/e v9nahNm2MloAxtMNgTskxxRt9vBYLkiXLVOxnPjPoS6ngb3v8QktpPl99X3camS3Z59VJQA00+VJq 8g/yIJ4zUwgPF7yn5ziabEvp4J/meFJdJbTG8zAhNqcsMvSXOc1EBfE43GLLzienRwx2sltACZs1i 9W3b+bljl/zwWevxmETiS7pbqgbOhzotTwrN+KtCsQJUbgqhZPi/6t+S62Y+lLQUp2ZkS0lSdc91q J4DsKyQQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jgksE-0000Go-TI; Thu, 04 Jun 2020 08:05:15 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 45B8D301DFD; Thu, 4 Jun 2020 10:05:12 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 31B5620CC68B2; Thu, 4 Jun 2020 10:05:12 +0200 (CEST) Date: Thu, 4 Jun 2020 10:05:12 +0200 From: Peter Zijlstra To: "Paul E. McKenney" Cc: tglx@linutronix.de, x86@kernel.org, elver@google.com, kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, will@kernel.org, dvyukov@google.com, glider@google.com, andreyknvl@google.com Subject: Re: [PATCH 2/9] rcu: Fixup noinstr warnings Message-ID: <20200604080512.GA2587@hirez.programming.kicks-ass.net> References: <20200603114014.152292216@infradead.org> <20200603114051.896465666@infradead.org> <20200603164600.GQ29598@paulmck-ThinkPad-P72> <20200603171320.GE2570@hirez.programming.kicks-ass.net> <20200604033409.GX29598@paulmck-ThinkPad-P72> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200604033409.GX29598@paulmck-ThinkPad-P72> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 03, 2020 at 08:34:09PM -0700, Paul E. McKenney wrote: > On Wed, Jun 03, 2020 at 07:13:20PM +0200, Peter Zijlstra wrote: > > On Wed, Jun 03, 2020 at 09:46:00AM -0700, Paul E. McKenney wrote: > > > > @@ -313,7 +313,7 @@ static __always_inline bool rcu_dynticks > > > > { > > > > struct rcu_data *rdp = this_cpu_ptr(&rcu_data); > > > > > > > > - return !(atomic_read(&rdp->dynticks) & RCU_DYNTICK_CTRL_CTR); > > > > + return !(arch_atomic_read(&rdp->dynticks) & RCU_DYNTICK_CTRL_CTR); > > > > The above is actually instrumented by KCSAN, due to arch_atomic_read() > > being a READ_ONCE() and it now understanding volatile. > > > > > Also instrument_atomic_write(&rdp->dynticks, sizeof(rdp->dynticks)) as > > Right, this should instead be instrument_read(...). > > Though if KCSAN is unconditionally instrumenting volatile, how does > this help? Or does KCSAN's instrumentation of volatile somehow avoid > causing trouble? As Marco already explained, when used inside noinstr no instrumentation will be emitted, when used outside noinstr it will emit the right instrumentation. > > > o In theory in rcu_irq_exit_preempt(), but as this generates code > > > only in lockdep builds, it might not be worth worrying about. > > > > > > o Ditto for rcu_irq_exit_check_preempt(). > > > > > > o Ditto for __rcu_irq_enter_check_tick(). > > > > Not these, afaict they're all the above arch_atomic_read(), which is > > instrumented due to volatile in these cases. I this case, the above call-sites are all not noinstr (double negative!) and will thus cause instrumentation to be emitted. This is all a 'special' case for arch_atomic_read() (and _set()), because they're basically READ_ONCE() (and WRITE_ONCE() resp.). The normal atomics are asm() and it doesn't do anything for those (although I suppose clang could, since it has this internal assembler to parse the inline asm, but afaiu that's not something GCC ever wants to do).