From patchwork Mon Jun 2 22:44:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 4284291 Return-Path: X-Original-To: patchwork-linux-parisc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C4EE5BEEA7 for ; Mon, 2 Jun 2014 22:45:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E47C12021B for ; Mon, 2 Jun 2014 22:45:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E297020212 for ; Mon, 2 Jun 2014 22:44:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752885AbaFBWov (ORCPT ); Mon, 2 Jun 2014 18:44:51 -0400 Received: from mail-pb0-f49.google.com ([209.85.160.49]:35891 "EHLO mail-pb0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752873AbaFBWou (ORCPT ); Mon, 2 Jun 2014 18:44:50 -0400 Received: by mail-pb0-f49.google.com with SMTP id jt11so4665012pbb.36 for ; Mon, 02 Jun 2014 15:44:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:subject:from:to:cc:date:in-reply-to:references :content-type:content-transfer-encoding:mime-version; bh=1jWb+qAwE7AhKhk5weykCqXfYUyfUcAi438Xo02GyuI=; b=pJdGegrKkKZtxEJNVi7z/i85lX3przKR+QlVqImkHg7CYhCLVpmxf4LvkNhSd2uteW CNwgNEijbZw0DWq71ahzEHG3fabDnLfVSj9CYqsRsuzdsW8u2uZcQOTo2KtbU61GEgzq 4FiWVQuqVdhsVfKapnVQx4Fc68OM39sEMaf1ZaPP8IaTGxN7r3dtBDl3+EHBNcmQodYm s89Gn7ZK2ikQyro5u0ZJwufMuZuKpSWG/kG193+7JmrnrnXX2Cz86OVibDyJH1qgv9rn 0xeEgTZQg4Cldh3jOLcQoq+iQphphLZ2tL89JwoSE4UdXDa4wAsnp8FU3VEowi7v+H7a CVFQ== X-Received: by 10.68.135.42 with SMTP id pp10mr44644317pbb.58.1401749090186; Mon, 02 Jun 2014 15:44:50 -0700 (PDT) Received: from ?IPv6:2620:0:1000:3e02:29c4:7088:9f04:f3e9? ([2620:0:1000:3e02:29c4:7088:9f04:f3e9]) by mx.google.com with ESMTPSA id jq6sm22188614pbb.76.2014.06.02.15.44.49 for (version=SSLv3 cipher=RC4-SHA bits=128/128); Mon, 02 Jun 2014 15:44:49 -0700 (PDT) Message-ID: <1401749088.3645.189.camel@edumazet-glaptop2.roam.corp.google.com> Subject: Re: [PATCH v2] introduce atomic_pointer to fix a race condition in cancelable mcs spinlocks From: Eric Dumazet To: paulmck@linux.vnet.ibm.com Cc: Linus Torvalds , Peter Zijlstra , Waiman Long , Mikulas Patocka , "James E.J. Bottomley" , Helge Deller , John David Anglin , Parisc List , Linux Kernel Mailing List , "Vinod, Chegu" , Thomas Gleixner , Rik van Riel , Andrew Morton , Davidlohr Bueso , Peter Anvin , Andi Kleen , "Chandramouleeswaran, Aswin" , "Norton, Scott J" , Jason Low Date: Mon, 02 Jun 2014 15:44:48 -0700 In-Reply-To: <20140602220831.GG22231@linux.vnet.ibm.com> References: <20140602162525.GH16155@laptop.programming.kicks-ass.net> <20140602163032.GI16155@laptop.programming.kicks-ass.net> <538CB56E.5010709@hp.com> <20140602200525.GD13930@laptop.programming.kicks-ass.net> <20140602210227.GE22231@linux.vnet.ibm.com> <20140602220831.GG22231@linux.vnet.ibm.com> X-Mailer: Evolution 3.2.3-0ubuntu6 Mime-Version: 1.0 Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Mon, 2014-06-02 at 15:08 -0700, Paul E. McKenney wrote: > diff --git a/kernel/rcu/srcu.c b/kernel/rcu/srcu.c > index c639556f3fa0..c0120279dead 100644 > --- a/kernel/rcu/srcu.c > +++ b/kernel/rcu/srcu.c > @@ -295,12 +295,15 @@ EXPORT_SYMBOL_GPL(cleanup_srcu_struct); > int __srcu_read_lock(struct srcu_struct *sp) > { > int idx; > + unsigned long *lp; > > idx = ACCESS_ONCE(sp->completed) & 0x1; > preempt_disable(); > - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1; > + lp = this_cpu_ptr(&sp->per_cpu_ref->c[idx]); > + ACCESS_ONCE(*lp) = *lp + 1; > smp_mb(); /* B */ /* Avoid leaking the critical section. */ > - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1; > + lp = this_cpu_ptr(&sp->per_cpu_ref->seq[idx]); > + ACCESS_ONCE(*lp) = *lp + 1; > preempt_enable(); > return idx; > This probably could use the following --- To unsubscribe from this list: send the line "unsubscribe linux-parisc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/kernel/rcu/srcu.c b/kernel/rcu/srcu.c index c639556f3fa0..3a97eb6f9076 100644 --- a/kernel/rcu/srcu.c +++ b/kernel/rcu/srcu.c @@ -298,9 +298,9 @@ int __srcu_read_lock(struct srcu_struct *sp) idx = ACCESS_ONCE(sp->completed) & 0x1; preempt_disable(); - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1; + this_cpu_inc(sp->per_cpu_ref->c[idx]); smp_mb(); /* B */ /* Avoid leaking the critical section. */ - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1; + this_cpu_inc(sp->per_cpu_ref->seq[idx]); preempt_enable(); return idx; }