From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5535C2BA16 for ; Wed, 8 Apr 2020 22:36:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7C9522082D for ; Wed, 8 Apr 2020 22:36:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="wEXrrXj4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7C9522082D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D604F8E000D; Wed, 8 Apr 2020 18:36:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CEA588E0006; Wed, 8 Apr 2020 18:36:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB0A98E000D; Wed, 8 Apr 2020 18:36:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0044.hostedemail.com [216.40.44.44]) by kanga.kvack.org (Postfix) with ESMTP id 9F61D8E0006 for ; Wed, 8 Apr 2020 18:36:06 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 6379A8016D18 for ; Wed, 8 Apr 2020 22:36:06 +0000 (UTC) X-FDA: 76686147132.19.idea27_3540d97821755 X-HE-Tag: idea27_3540d97821755 X-Filterd-Recvd-Size: 5612 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf31.hostedemail.com (Postfix) with ESMTP for ; Wed, 8 Apr 2020 22:36:05 +0000 (UTC) Received: from paulmck-ThinkPad-P72.home (50-39-105-78.bvtn.or.frontiernet.net [50.39.105.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CC9A920730; Wed, 8 Apr 2020 22:36:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586385364; bh=xLXX5fEXFLevP/kGawYAXZigliHWwYZ4ZptumkLtJo0=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=wEXrrXj4cNQCCTiuMQUiNUw6HMzqr3n08ODUHqwddapfqOUmsV3O4N5qtigJ2xoi0 O/yQ+YVfFB4+7Kqg+ZhNELDoIJ7G1SNReILT4E1ofhJOrGG0VY9IF9EsIc+dSEzLc+ wLI2HhymtPEeBuw/eguJhtSuX5uudAekGRHSOx/w= Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id 8B1523523234; Wed, 8 Apr 2020 15:36:04 -0700 (PDT) Date: Wed, 8 Apr 2020 15:36:04 -0700 From: "Paul E. McKenney" To: Chris Wilson Cc: Linus Torvalds , Andrew Morton , David Laight , Marco Elver , Linux-MM , Mark Rutland , mm-commits@vger.kernel.org, Randy Dunlap , stable Subject: Re: [patch 125/166] lib/list: prevent compiler reloads inside 'safe' list iteration Message-ID: <20200408223604.GA2799@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org References: <20200406200254.a69ebd9e08c4074e41ddebaf@linux-foundation.org> <20200407031042.8o-fYMox-%akpm@linux-foundation.org> <158627540139.8918.10102358634447361335@build.alporthouse.com> <158628265081.8918.1825514020221532657@build.alporthouse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <158628265081.8918.1825514020221532657@build.alporthouse.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Apr 07, 2020 at 07:04:10PM +0100, Chris Wilson wrote: > Quoting Linus Torvalds (2020-04-07 18:28:34) > > On Tue, Apr 7, 2020 at 9:04 AM Chris Wilson wrote: [ . . . ] > There's some more shutting up required for KCSAN to bring the noise down > to usable levels which I hope has been done so I don't have to argue for > it, such as > > diff --git a/include/linux/timer.h b/include/linux/timer.h > index 1e6650ed066d..c7c8dd89f279 100644 > --- a/include/linux/timer.h > +++ b/include/linux/timer.h > @@ -164,7 +164,7 @@ static inline void destroy_timer_on_stack(struct timer_list *timer) { } > */ > static inline int timer_pending(const struct timer_list * timer) > { > - return timer->entry.pprev != NULL; > + return READ_ONCE(timer->entry.pprev) != NULL; This one is in mainline, courtesy of Eric Dumazet, though in a different form. The rest are still TBD. Thanx, Paul > } > > extern void add_timer_on(struct timer_list *timer, int cpu); > diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c > index 5352ce50a97e..7461b3f33629 100644 > --- a/kernel/locking/mutex.c > +++ b/kernel/locking/mutex.c > @@ -565,8 +565,9 @@ bool mutex_spin_on_owner(struct mutex *lock, struct task_struct *owner, > /* > * Use vcpu_is_preempted to detect lock holder preemption issue. > */ > - if (!owner->on_cpu || need_resched() || > - vcpu_is_preempted(task_cpu(owner))) { > + if (!READ_ONCE(owner->on_cpu) || > + need_resched() || > + vcpu_is_preempted(task_cpu(owner))) { > ret = false; > break; > } > @@ -602,7 +603,7 @@ static inline int mutex_can_spin_on_owner(struct mutex *lock) > * on cpu or its cpu is preempted > */ > if (owner) > - retval = owner->on_cpu && !vcpu_is_preempted(task_cpu(owner)); > + retval = READ_ONCE(owner->on_cpu) && !vcpu_is_preempted(task_cpu(owner)); > rcu_read_unlock(); > > /* > diff --git a/kernel/locking/osq_lock.c b/kernel/locking/osq_lock.c > index 1f7734949ac8..4a81fba4cf70 100644 > --- a/kernel/locking/osq_lock.c > +++ b/kernel/locking/osq_lock.c > @@ -75,7 +75,7 @@ osq_wait_next(struct optimistic_spin_queue *lock, > * wait for either @lock to point to us, through its Step-B, or > * wait for a new @node->next from its Step-C. > */ > - if (node->next) { > + if (READ_ONCE(node->next)) { > next = xchg(&node->next, NULL); > if (next) > break; > @@ -154,7 +154,7 @@ bool osq_lock(struct optimistic_spin_queue *lock) > */ > > for (;;) { > - if (prev->next == node && > + if (READ_ONCE(prev->next) == node && > cmpxchg(&prev->next, node, NULL) == node) > break; > > diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c > index 0d9b6be9ecc8..eef4835cecf2 100644 > --- a/kernel/locking/rwsem.c > +++ b/kernel/locking/rwsem.c > @@ -650,7 +650,7 @@ static inline bool owner_on_cpu(struct task_struct *owner) > * As lock holder preemption issue, we both skip spinning if > * task is not on cpu or its cpu is preempted > */ > - return owner->on_cpu && !vcpu_is_preempted(task_cpu(owner)); > + return READ_ONCE(owner->on_cpu) && !vcpu_is_preempted(task_cpu(owner)); > } > > static inline bool rwsem_can_spin_on_owner(struct rw_semaphore *sem, >