Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp589716imp; Thu, 21 Feb 2019 07:22:33 -0800 (PST) X-Google-Smtp-Source: AHgI3IbryTqNntUjxZfb77fNA26B30wjnVQ2CsRxhpw00dO+L8RO5cBErdruanJL34UnCRVEZtnq X-Received: by 2002:a63:e752:: with SMTP id j18mr17311584pgk.313.1550762553814; Thu, 21 Feb 2019 07:22:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550762553; cv=none; d=google.com; s=arc-20160816; b=0GIA+fhvPJsKqpk8qyWQByeZPM5g9hYbnqNMGb2wLhZIC5wHJM30V7UoyLcXP/lYTq lG5lmFUElXaxm0IaTk8Na/fEimsmK9awzoMZCHa5puSBohmSCGxrgeG8skkrOAEQAvYs qMINJoJjW7GMEXWzWBOQG1ePqEVVLR5qARJWKFEe+OgbswLqI0sfNZBaBdHn9sjiHPrn QLbcktv5B+tKcbrZpG2oVpguZ36HjcdqmXLvn1EPp8TDfcKhxRt91tM9GH8VvK815ydr kQE5ftKo+B+6BF4+VZPAXhme1VE3QeSn5dniHQomP9wYYAsydeHT94yHxiQBqnTHheLm Bqig== 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=2OcfaLdiZJ/DrcUmYGdobOiPniYbCbJZcx2QAY5FqJE=; b=NgIixMuhpzNHJ8vD05hZ9BopY7kkSfILvxEg0mH9gBj7Kf4B2OfuEkaR1vaoanzw7/ sMKRiXG7dNioxZRJx4Xkotm7V2FUHqK93UkFfT5Xva3UZPenCUtiV4/b8za+NJsHO+Ns MWSPBNiixG3Mu63uAUBnol2HLA4hpSB/mordvX26fOC/+RC8LGiEhzAEL/++YIr0V9S8 gqLpRj1Mm63Huyd7QbafFdT4XyJPKOUkueQOg86t9vd2IywRuAfv8OdyiU2oCYxcgcIH XGY6ptd4MBcXBLXAI8C8MIR/BzFJLHAOhvtb79Vm9aDljgpTmiNS/bOHEELms4MheE3A VSmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=yKG9kAR3; 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 z7si12266628plo.202.2019.02.21.07.22.18; Thu, 21 Feb 2019 07:22:33 -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=pass header.i=@joelfernandes.org header.s=google header.b=yKG9kAR3; 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 S1728231AbfBUPVm (ORCPT + 99 others); Thu, 21 Feb 2019 10:21:42 -0500 Received: from mail-qt1-f195.google.com ([209.85.160.195]:39635 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727813AbfBUPVm (ORCPT ); Thu, 21 Feb 2019 10:21:42 -0500 Received: by mail-qt1-f195.google.com with SMTP id o6so31871803qtk.6 for ; Thu, 21 Feb 2019 07:21:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=2OcfaLdiZJ/DrcUmYGdobOiPniYbCbJZcx2QAY5FqJE=; b=yKG9kAR3cFhThVITkHFpqeKZ19spKE9FoF8RXXFoPWtzTJEINdUL9NjVeUSjGgIvpU t6Agz8TVbm2+EQSEaXfA98gzdr8AmxznEkJ44+cnYfCLNPdv6YHwVtqiX/5cbb1QxcMZ xQy2qobblBIqoWahRQBYm39qt5j8yfVXoeM2k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=2OcfaLdiZJ/DrcUmYGdobOiPniYbCbJZcx2QAY5FqJE=; b=Pa7xmtO4guhhi2kHsvvDc1zy3h0C4gPZf/zWnxdt706yhbKjVZc9PVDffK6DWqhn2s c1S4IXMqEUuJbp5vGV3eKKiaZxeAFyie7EA+13wXc9BsE4PtUvLWOPMS4YWuuj0fqQC9 E4NzhpGR93hYymrJXQ++S1SU8E/5Ze8/Zu64g1SMHhvktnNfC1JVfwGMKcxSfwZ4sfFj 74jpk77b0hF7WMckPf+a0d40y0nl3ylnZv+NUgvhx3RCkQjuUfqJTHsU/qfGxvGGDxKr IqjEePjh7vSpYrxiLpcdB0uCQblpHWQnWdb4YMasHZeb7vksKZR/EtDdgqMK/WX2MqaK ZXmw== X-Gm-Message-State: AHQUAub128ly+R3kUdaNQTRe5ZwZypTtuEszfvX2846lX2KyV+rK60XW iyLDL+QtTIBoqza+zngy8m3ZXQ== X-Received: by 2002:ac8:2fc8:: with SMTP id m8mr31033726qta.83.1550762500642; Thu, 21 Feb 2019 07:21:40 -0800 (PST) Received: from localhost ([2620:0:1004:1100:cca9:fccc:8667:9bdc]) by smtp.gmail.com with ESMTPSA id p15sm14830780qta.81.2019.02.21.07.21.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Feb 2019 07:21:39 -0800 (PST) Date: Thu, 21 Feb 2019 10:21:39 -0500 From: Joel Fernandes To: Peter Zijlstra 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: <20190221152139.GB19213@google.com> References: <20190221054942.132388-1-joel@joelfernandes.org> <20190221054942.132388-4-joel@joelfernandes.org> <20190221091805.GX32477@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190221091805.GX32477@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 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(). thanks, - Joel