From patchwork Thu Jul 27 06:13:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Fernandes X-Patchwork-Id: 9866319 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6104360382 for ; Thu, 27 Jul 2017 06:13:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 53C9228777 for ; Thu, 27 Jul 2017 06:13:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 487B7287D7; Thu, 27 Jul 2017 06:13:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF45D28777 for ; Thu, 27 Jul 2017 06:13:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751529AbdG0GNN (ORCPT ); Thu, 27 Jul 2017 02:13:13 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:33210 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751042AbdG0GNN (ORCPT ); Thu, 27 Jul 2017 02:13:13 -0400 Received: by mail-wm0-f68.google.com with SMTP id q189so11211190wmd.0; Wed, 26 Jul 2017 23:13:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=yfVbCpBO4NPNd0n8talO09fXsulYkdvPYewb0MK+lsE=; b=kWn2+K/FeJGZzMQSlATX3uQTHVU6E28P8NXi+LG514hfyn3OoiaLAuiJUnfpuMBHXg 0nnYbbGAMEFX8HxOaZY+jdQuWJiNTbkJ6BHLmheiILDgSrDhrVIZtNFcsinhnPbtmQWV /nLG6P/UlIjcbTPyuM6KHNLRJskwhZZf8qT6kYCgf1cnC/wVHUBmI/dWdKTdIDFxIFh8 Yl4M0n84wcq0FSePGc2qenXKF/vvf8uPfNYpE9vEMsHV3eQECSDkLjS37adyWlC9MbT9 uhP/a5H0RmSGIdY6LOL5EtPtTN7jC4JrA9NHLTtw24DqOYswLbP2L7L+GOwdmyCTmZMu c7Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=yfVbCpBO4NPNd0n8talO09fXsulYkdvPYewb0MK+lsE=; b=siE+lCysYzfCelX0ROJ/RuArcJXpvjeCL1lfWGJ7UZRWHsyKZIviKYZuAeNn9M3F/1 iTynREfRs0BQABccPYP6aGRX69g/gvGeeDFK6nfq2KhWoCeKYJuCm1XllrBR4+z55/ec rxK+Iz+esNxBhRsrYuHu8axTwRtKrsQoZdyCpso0pa/ekljOypsgLITrG8alg1uz3+2T C8+MDkUTli5cvo8Wpjk/a8ewOv42rLLMXsP7thLstS//kb+5ltBRcU1Tuyz2HHjdo9Yw liEaDtBlgKdH2tZ/yljG2QQSnZdklAGfQpXkYspenNuWnFSVp+59OUvt/YquUV+SABJH BufQ== X-Gm-Message-State: AIVw111zjxW2FmEvi/E4S+hbXY2TDQXfWPB8lmdWv4HVM3EOrz3rPCgA 2+/oW/jHp1wow9mmUFahXM84ibdVdQ== X-Received: by 10.80.141.23 with SMTP id s23mr2746460eds.75.1501135991642; Wed, 26 Jul 2017 23:13:11 -0700 (PDT) MIME-Version: 1.0 Received: by 10.80.215.71 with HTTP; Wed, 26 Jul 2017 23:13:11 -0700 (PDT) In-Reply-To: <20170727055026.GK352@vireshk-i7> References: <8797d4993baa6580e3af741d081be492032ce9dd.1501060871.git.viresh.kumar@linaro.org> <20170727055026.GK352@vireshk-i7> From: "Joel Fernandes (Google)" Date: Wed, 26 Jul 2017 23:13:11 -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 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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: sg_cpu->flags = flags; @@ -304,6 +302,8 @@ static void sugov_update_shared(struct update_util_data *hook, u64 time, sugov_set_iowait_boost(sg_cpu, time, flags); sg_cpu->last_update = time; + raw_spin_lock(&sg_policy->update_lock); + if (sugov_should_update_freq(sg_policy, time)) { if (flags & SCHED_CPUFREQ_RT_DL) next_f = sg_policy->policy->cpuinfo.max_freq; thanks, -Joel diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 622eed1b7658..9a6c12fb2c16 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -295,8 +295,6 @@ static void sugov_update_shared(struct update_util_data *hook, u64 time, sugov_get_util(&util, &max); - raw_spin_lock(&sg_policy->update_lock); - sg_cpu->util = util; sg_cpu->max = max;