Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751660AbdG1Deo (ORCPT ); Thu, 27 Jul 2017 23:34:44 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:37350 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751613AbdG1Den (ORCPT ); Thu, 27 Jul 2017 23:34:43 -0400 MIME-Version: 1.0 In-Reply-To: <20170727071441.GL352@vireshk-i7> References: <8797d4993baa6580e3af741d081be492032ce9dd.1501060871.git.viresh.kumar@linaro.org> <20170727055026.GK352@vireshk-i7> <20170727071441.GL352@vireshk-i7> From: "Joel Fernandes (Google)" Date: Thu, 27 Jul 2017 20:34:41 -0700 Message-ID: Subject: Re: [Eas-dev] [PATCH V4 1/3] sched: cpufreq: Allow remote cpufreq callbacks To: Viresh Kumar Cc: Rafael Wysocki , Srinivas Pandruvada , Len Brown , Ingo Molnar , Peter Zijlstra , linux-pm@vger.kernel.org, Linux Kernel Mailing List , smuckle.linux@gmail.com, eas-dev@lists.linaro.org, Joel Fernandes Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1954 Lines: 46 On Thu, Jul 27, 2017 at 12:14 AM, Viresh Kumar wrote: > On 26-07-17, 23:13, Joel Fernandes (Google) wrote: >> On Wed, Jul 26, 2017 at 10:50 PM, Viresh Kumar wrote: >> > On 26-07-17, 22:34, Joel Fernandes (Google) wrote: >> >> On Wed, Jul 26, 2017 at 2:22 AM, Viresh Kumar wrote: >> >> > @@ -221,7 +226,7 @@ static void sugov_update_single(struct update_util_data *hook, u64 time, >> >> > sugov_set_iowait_boost(sg_cpu, time, flags); >> >> > sg_cpu->last_update = time; >> >> > >> >> > - if (!sugov_should_update_freq(sg_policy, time)) >> >> > + if (!sugov_should_update_freq(sg_policy, time, hook->cpu)) >> >> > return; >> >> >> >> Since with the remote callbacks now possible, isn't it unsafe to >> >> modify sg_cpu and sg_policy structures without a lock in >> >> sugov_update_single? >> >> >> >> Unlike sugov_update_shared, we don't acquire any lock in >> >> sugov_update_single before updating these structures. Did I miss >> >> something? >> > >> > As Peter already mentioned it earlier, the callbacks are called with >> > rq locks held and so sugov_update_single() wouldn't get called in >> > parallel for a target CPU. >> >> Ah ok, I have to catch up with that discussion since I missed the >> whole thing. Now that you will have me on CC, that shouldn't happen, >> thanks and sorry about the noise. >> >> > That's the only race you were worried about ? >> >> Yes. So then in that case, makes sense to move raw_spin_lock in >> sugov_update_shared further down? (Just discussing, this point is >> independent of your patch), Something like: > > Even that was discussed tomorrow with Peter :) > > No it wouldn't work because sg_cpu->util we are updating here may be > getting read from some other cpu that shares policy with sg_cpu. > Ok. yes you are right :) thank you Viresh and Peter for the clarification. thanks, -Joel