Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp1707079ybh; Sun, 4 Aug 2019 07:55:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqy+tMzEwUXbbQ09oT5QAE6hC5ltEg0+fSQ0yhypoHHXiE+a22/eRB+22ENUfXXx4U6t1qKT X-Received: by 2002:a63:3c5:: with SMTP id 188mr129950242pgd.394.1564930512202; Sun, 04 Aug 2019 07:55:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564930512; cv=none; d=google.com; s=arc-20160816; b=wkU6/qYKSxQEZ445C9Rlwr2CwSOKJNsJhJbyxvE9HozmRW/4OIsrWNizoB1lcWYAyf fn+PN+XvRlMwmoeObqUj0VfZAu/QMUnhv9KBejZOpJBhvBNGVHGppY/trAEfxlTj/SUh MRHnE3CCehkCl+RcgOAGN3L7crFZgqk0UG6nFB4MOEWb+bfvSwIcS9tZu8p3S7O8eaoI Yw+EmR92d+R3Z7t8zfv+ZG41DdlnI3maLNB8zM7yGvfhZyT4IPnamIOhaTkp1JEkANHQ 8zpOkmPKUS1g2NiqGhk8/OqSnrCS4w6VX3JQQyLDNtK+F/I7T6hTPU3Tx9FCVWf+bu8u XVuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=J0f8NcZWBTaPEpxB3Q2uAE6Fl3HGqWPvoXKHoJaYSuE=; b=W/znTDaoOVIWNhU7UdEoIfQdVI43Vs6xpn5UmRlvz0e46vfTXUu9HLDsUM2voyY8AY DA5X2yRHv+ZU/QE6JhorYKNEoLS7tEVwJ995RZENtiHz0XtiQGVGLLtOe+a3GWpa4Yng i1IuoMEI7yubS0hpgYCNsu58QyfdHcCQ95IaugpB7WGSJ/yVJwXRmOLy+MuTctyYZW9C isDJwiKBvmlfSrMTdCc6uGWP7D3ENzwLfs13DqSo1hMqyPn9erz4wQaw+qfJkVxOjOaY 3K+BEFOA2va9VzPgL/LGKLgOAyXKoWD2YPfzKSO0e757tmCua0RZ7x9qT2ZUR/kA4Gzi W0/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=BQqOEfMD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g32si10669575pje.38.2019.08.04.07.54.57; Sun, 04 Aug 2019 07:55:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=BQqOEfMD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726377AbfHDOxC (ORCPT + 99 others); Sun, 4 Aug 2019 10:53:02 -0400 Received: from merlin.infradead.org ([205.233.59.134]:43260 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726181AbfHDOxB (ORCPT ); Sun, 4 Aug 2019 10:53:01 -0400 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:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=J0f8NcZWBTaPEpxB3Q2uAE6Fl3HGqWPvoXKHoJaYSuE=; b=BQqOEfMDnRDOqdI3zjyJSioLH ijupLADuURkUgqwPRHgc9JSsF10z9trwSk1z/n9GIyDi1Rk+ftCOhhGcAMirJTKkw5zsAEMND+vn4 qCboKxtKd1bFZuinJ8P/5nMFoxFM/rwgwCcECSo95NLCoAawaT+j4jbI4TcTe5hoXiv967vgehmmi +/0t1WGUCPuaDR04TOjHfVYe72OATg3E1IqKYi5AZDFfZqDXr7uguqgeQOd8B8bhZrqwxshVHIQTa S3C04pY0ZQVuT2pNemVwzDFh020uo7DLTZR69j57/a/J5n2qxmKPZR4teb2i41y5nmjs5pr+KSz5d XwEU7RpPg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1huHsN-0007Ru-Sb; Sun, 04 Aug 2019 14:52:48 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 9F1A320274D7B; Sun, 4 Aug 2019 16:52:46 +0200 (CEST) Date: Sun, 4 Aug 2019 16:52:46 +0200 From: Peter Zijlstra To: "Paul E. McKenney" Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org, mingo@kernel.org, jiangshanlai@gmail.com, dipankar@in.ibm.com, akpm@linux-foundation.org, mathieu.desnoyers@efficios.com, josh@joshtriplett.org, tglx@linutronix.de, rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com, fweisbec@gmail.com, oleg@redhat.com, joel@joelfernandes.org Subject: Re: [PATCH RFC tip/core/rcu 01/14] rcu/nocb: Atomic ->len field in rcu_segcblist structure Message-ID: <20190804145246.GC2386@hirez.programming.kicks-ass.net> References: <20190802151435.GA1081@linux.ibm.com> <20190802151501.13069-1-paulmck@linux.ibm.com> <20190804145051.GG2349@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190804145051.GG2349@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Aug 04, 2019 at 04:50:51PM +0200, Peter Zijlstra wrote: > On Fri, Aug 02, 2019 at 08:14:48AM -0700, Paul E. McKenney wrote: > > +/* > > + * Exchange the numeric length of the specified rcu_segcblist structure > > + * with the specified value. This can cause the ->len field to disagree > > + * with the actual number of callbacks on the structure. This exchange is > > + * fully ordered with respect to the callers accesses both before and after. > > + */ > > +long rcu_segcblist_xchg_len(struct rcu_segcblist *rsclp, long v) > > +{ > > +#ifdef CONFIG_RCU_NOCB_CPU > > + return atomic_long_xchg(&rsclp->len, v); > > +#else > > + long ret = rsclp->len; > > + > > + smp_mb(); /* Up to the caller! */ > > + WRITE_ONCE(rsclp->len, v); > > + smp_mb(); /* Up to the caller! */ > > + return ret; > > +#endif > > +} > > That one's weird; for matching semantics the load needs to be between > the memory barriers. Also, since you WRITE_ONCE() the thing, the load needs to be a READ_ONCE().