Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp600666imp; Thu, 21 Feb 2019 07:34:26 -0800 (PST) X-Google-Smtp-Source: AHgI3IaUq+Hke8ydQBvWI3V3fqhrGIY7vKsj/vdozG7Pj5+NQTIg4fy1Dx/Ad0hDr+K1Nu8uNh+P X-Received: by 2002:a63:a510:: with SMTP id n16mr11198421pgf.443.1550763266144; Thu, 21 Feb 2019 07:34:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550763266; cv=none; d=google.com; s=arc-20160816; b=wuYJvZye1D7Qk+oxBul2FPhpm7PhYC7kFoYxn4tDSAuRzyrHkXKaAussEsy0xOXgav /m1qgCWZBEWz9WtJfnhcj4jZkCADwjIgQuOW7ng5lo5vpROFz5+B+TOvtYUe3nuZMcOP GK0At0cF2KquUV71ezb2uqA7UzG+3luZGVt9q2m0tsPtWWYD2nG8p+ciMjwEtevQ92Cj jllEJCGroohAh6kbJhzQ0QLjchy1IwpkFCwrNXOvBbQSF9O0QlkPDxK/djDjWYiDDkaU CIp2Zq/i5FtyvNvRM+LdZLiYLVZo9NCzfrpP96tqRyM6VPqaqHBe1YRfGp5/KAy5YbUx Hnqw== 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=/eQaoz239TKQfUHXIpEoiodA8p/xYR3qGQZwY36Notw=; b=be9ExFR2YQGIeAo2eNl0D1jz7A7NYxnIi5NQn23xNizcZ5/VRkIMLS9I4Q7Ot70hih aAs4mJzcKbxKMg4ChtjpPpXLjT121je3yCCKoWAf2Z2txICnBt3EXHHnfiCYqKeHBHNh dSC66aCCtFrkIYej4H+KdEmhY2zBQlA7b7ywMX9fcKUD5wYyqk3Eit+DQU87D7v+PxIF NdFJJxqr2G5UQoIuMLmInd1pdiovGQ2sFxGc9lmNOnehaPz7GtxW5kShY4E7BWhyQS5Q CdvjJcbGTbXAqzj3rMQU9a/QPXgLaXtGLsp7xd9f4fDxtxPkxfSFzhi+ObIdruomoISI chkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=oqxcEcRu; 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 l2si21347085pfc.287.2019.02.21.07.34.10; Thu, 21 Feb 2019 07:34:26 -0800 (PST) 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=oqxcEcRu; 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 S1728466AbfBUPbt (ORCPT + 99 others); Thu, 21 Feb 2019 10:31:49 -0500 Received: from merlin.infradead.org ([205.233.59.134]:36638 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725866AbfBUPbt (ORCPT ); Thu, 21 Feb 2019 10:31:49 -0500 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=/eQaoz239TKQfUHXIpEoiodA8p/xYR3qGQZwY36Notw=; b=oqxcEcRuccvGZCmVsKZvwtoGN Mu0n1fsl8gF4wnhYcrKz5Nqqoxo1Qq7kMpyEpYE4YGcPcKLCZWlWthGHRTBhkmBSudyCeQk9rX9yB zalrR5KsLkb3wskDfdAp+2uSwFJaCOrLcLd7TjWFEX8W94Q4uc69iz5wHlLcY29QLOB+oPtyDmMYw Elq/oCah4BtOaJJWxHLzJvvjty7PeOZIUaJh+sBvLd3X+16M7D70ii3HPtd4G/tJz4Mbr8esmv+r0 9D1dq4Gq2C0BUh4fAigsBbhyz4+Hqg6Xx/i4ineQty7lRdY2u7msPNCu6skXQfJquau9s4Y5cOGZK j1VHsgevw==; 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.90_1 #2 (Red Hat Linux)) id 1gwqJi-00022p-Vv; Thu, 21 Feb 2019 15:31:19 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id B82712030EE5E; Thu, 21 Feb 2019 16:31:17 +0100 (CET) Date: Thu, 21 Feb 2019 16:31:17 +0100 From: Peter Zijlstra To: Joel Fernandes Cc: linux-kernel@vger.kernel.org, Alexei Starovoitov , Christian Brauner , Daniel Borkmann , David Ahern , "David S. Miller" , Ido Schimmel , Ingo Molnar , "moderated list:INTEL ETHERNET DRIVERS" , Jakub Kicinski , Jeff Kirsher , Jesper Dangaard Brouer , John Fastabend , Josh Triplett , keescook@chromium.org, Lai Jiangshan , Martin KaFai Lau , Mathieu Desnoyers , netdev@vger.kernel.org, "Paul E. McKenney" , rcu@vger.kernel.org, Song Liu , Steven Rostedt , xdp-newbies@vger.kernel.org, Yonghong Song Subject: Re: [PATCH RFC 3/5] sched/cpufreq: Fix incorrect RCU API usage Message-ID: <20190221153117.GT32494@hirez.programming.kicks-ass.net> References: <20190221054942.132388-1-joel@joelfernandes.org> <20190221054942.132388-4-joel@joelfernandes.org> <20190221091805.GX32477@hirez.programming.kicks-ass.net> <20190221152139.GB19213@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190221152139.GB19213@google.com> 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 Thu, Feb 21, 2019 at 10:21:39AM -0500, Joel Fernandes wrote: > On Thu, Feb 21, 2019 at 10:18:05AM +0100, Peter Zijlstra wrote: > > On Thu, Feb 21, 2019 at 12:49:40AM -0500, Joel Fernandes (Google) wrote: > > > @@ -34,8 +34,12 @@ void cpufreq_add_update_util_hook(int cpu, struct update_util_data *data, > > > if (WARN_ON(!data || !func)) > > > return; > > > > > > - if (WARN_ON(per_cpu(cpufreq_update_util_data, cpu))) > > > + rcu_read_lock(); > > > + if (WARN_ON(rcu_dereference(per_cpu(cpufreq_update_util_data, cpu)))) { > > > + rcu_read_unlock(); > > > return; > > > + } > > > + rcu_read_unlock(); > > > > > > data->func = func; > > > rcu_assign_pointer(per_cpu(cpufreq_update_util_data, cpu), data); > > > > This doesn't make any kind of sense to me. > > > > As per the rcu_assign_pointer() line, I inferred that > cpufreq_update_util_data is expected to be RCU protected. Reading the pointer > value of RCU pointers generally needs to be done from RCU read section, and > using rcu_dereference() (or using rcu_access()). > > In this patch, I changed cpufreq_update_util_data to be __rcu annotated to > avoid the sparse error thrown by rcu_assign_pointer(). > > Instead of doing that, If your intention here is RELEASE barrier, should I > just replace in this function: > rcu_assign_pointer(per_cpu(cpufreq_update_util_data, cpu), data); > with: > smp_store_release(per_cpu(cpufreq_update_util_data, cpu), data)) > ? > > It would be nice IMO to be explicit about the intention of release/publish > semantics by using smp_store_release(). No, it is RCU managed, it should be RCU. The problem is that the hunk above is utter crap. All that does is read the pointer, it never actually dereferences it.