Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp356585pxx; Thu, 29 Oct 2020 04:29:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymXiIiiAiC0jaRX0gQD+q9OclZm47vXs5Kukc0/M2l35etThsCZ8CoONg2FfPUygSJjGpl X-Received: by 2002:a17:906:85ce:: with SMTP id i14mr1957876ejy.22.1603970963942; Thu, 29 Oct 2020 04:29:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603970963; cv=none; d=google.com; s=arc-20160816; b=BBrb7kzMIlb+FyRUgTp/mawaHRCCJFM0SfSP4xIF3qSDvg5nz05G7VS7eicRFptvvb BoFHd0sxeBqUGLGzfO8W9gPi0bxXYCqXAUFHvErGPXHX7gXSIbH0OkvFvyrTa2XxNGmY XF3H+RmQ5DEjclyCMDn77odx5GZzZXaiaefgv1xvbgC3RI6drRIe7qpBX1IggBGUqYej VCZNG19p3kf7S5swTueAOVrndIlr6UgF4JyPfXmU3mHttVIXGdMpSzzysXDn0onSa1fY lad7hYHsFDNSGBBBuilerBuHdf4P7f756Z8WAN2+I+KtAxhW3Q8hF+37iIUBPTzALGEQ MfJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=khkMOr7THRvGQFJeYkxJ0/lSpk8ERoKlhcPz/3RiD+4=; b=Ia1pkDQIcu/of8Y4OGCDlW+Qh+afvsrjknGk81WnPXU64+cZlkK7lcE5QNVTo/HuXN 4HZXmoT5b1gEUxHYJvB9IHYFJzC+kBPJ0qSQk/czqYpT7oqkccBWMSlt1J77+hCBlR5k c+9MAf9dlLfwAwLO8rOxTAfaJoJDvudm/zSht7eHaXsWOV/+8XiRO1ED6GOnBwrc9pjA JJ0Bwl8X7yn1UtFW72AobmhIyGp/FIQodL3SpvdUHzjH0I/aMlaME5wn5Jnt16k/5FYZ 6eJDMEfJEC2srQWsYhY2PAHYHGmHxeyp3VmowDx8rxshpDFazgKzAy8kjA3RG7CkS95e zIlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eDVfOXu2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g18si1623571ejr.152.2020.10.29.04.29.00; Thu, 29 Oct 2020 04:29:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eDVfOXu2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726912AbgJ2L02 (ORCPT + 99 others); Thu, 29 Oct 2020 07:26:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725774AbgJ2L01 (ORCPT ); Thu, 29 Oct 2020 07:26:27 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78FFBC0613CF for ; Thu, 29 Oct 2020 04:26:27 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id k9so388941pgt.9 for ; Thu, 29 Oct 2020 04:26:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=khkMOr7THRvGQFJeYkxJ0/lSpk8ERoKlhcPz/3RiD+4=; b=eDVfOXu2fTM+NF4r6AwbHzmwFZ27VzLcPHb1NlE1UOGHdfuoNzZArXJuFTWy7WjpOZ U4SknfcioVkD9XPMlFORuZqfGmDCIdBC6jE5XhrakwWkYKVk8/WBtpLdsOrnid19Txke EQl/iCFP+i5hoYlUe7paIP8GUP18RzLF8ca8p/CZZbovon1UpCOaLEU+altH3wKZvagF /NwBgBqP0tgPriGqKEL2o+39PHMw1CEGE41MwXiLGq3LXGePdwFT9996ROPSh63ymVHw 84zc6InAsWvsHMtc4hBT87qKV/H+ByZZNvk5DiQIkOXQBqNsQg/5GdEXL3oIe9CczdMO k6pg== 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=khkMOr7THRvGQFJeYkxJ0/lSpk8ERoKlhcPz/3RiD+4=; b=Yk+Lo0XzBrsFatG/8tIIq2enABzeFpisZAa9qG9IxBwLkYvMTIoIL+QSXWXhbEBCMf s/p1FVITyoVQMExqKF1Iec/pATFtq7qiquj5ImIrlx7aju8oWGccBbX11leWqoyB82X5 Mrh6Gp+ptubdWxnUpPmlHjEWw5Twj3kR7tXNH9Ob/8EbAp9430A6YgLsHLy69bJMdXhy mEgWAZIK9b3Cpb1j/u6JD8ogtOBROUMsmAvE3siiGwpz+0qNw9wNgtQfOudIjYhf6tNs /G3ajTcztcS6adsD1ksewLZFIbQzickXNU62SrQnYDZW0zrZv/UVBgcqEGcpSGheCfcD eXBg== X-Gm-Message-State: AOAM531SmG5uykBu5TcPIQ3Z0g8XN0VSUOSqApskLvjx2VxriQesOvvV Hvbx4astYfPyEM8941fpss4Ifg== X-Received: by 2002:aa7:8bd7:0:b029:160:9db:d8bc with SMTP id s23-20020aa78bd70000b029016009dbd8bcmr4019961pfd.69.1603970787031; Thu, 29 Oct 2020 04:26:27 -0700 (PDT) Received: from localhost ([122.181.54.133]) by smtp.gmail.com with ESMTPSA id u124sm2799091pfc.21.2020.10.29.04.26.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Oct 2020 04:26:26 -0700 (PDT) Date: Thu, 29 Oct 2020 16:56:24 +0530 From: Viresh Kumar To: zhuguangqing83 Cc: rjw@rjwysocki.net, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, 'zhuguangqing' Subject: Re: [PATCH] cpufreq: schedutil: set sg_policy->next_freq to the final cpufreq Message-ID: <20201029112624.zvl6yh7fgqautzry@vireshk-i7> References: <004001d6ade5$0f8dde00$2ea99a00$@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <004001d6ade5$0f8dde00$2ea99a00$@gmail.com> User-Agent: NeoMutt/20180716-391-311a52 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29-10-20, 19:17, zhuguangqing83 wrote: > I think your patch is ok for tackling this problem. Great. > > diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c > > index 0c5c61a095f6..8991cc31b011 100644 > > --- a/kernel/sched/cpufreq_schedutil.c > > +++ b/kernel/sched/cpufreq_schedutil.c > > @@ -121,13 +121,8 @@ static void sugov_fast_switch(struct sugov_policy *sg_policy, u64 time, > > static void sugov_deferred_update(struct sugov_policy *sg_policy, u64 time, > > unsigned int next_freq) > > { > > - if (!sugov_update_next_freq(sg_policy, time, next_freq)) > > - return; > > - > > - if (!sg_policy->work_in_progress) { > > - sg_policy->work_in_progress = true; > > + if (sugov_update_next_freq(sg_policy, time, next_freq)) > > irq_work_queue(&sg_policy->irq_work); > > - } > > } > > > > /** > > @@ -159,6 +154,15 @@ static unsigned int get_next_freq(struct sugov_policy *sg_policy, > > unsigned int freq = arch_scale_freq_invariant() ? > > policy->cpuinfo.max_freq : policy->cur; > > > > + /* > > + * The previous frequency update didn't go as we expected it to be. Lets > > + * start again to make sure we don't miss any updates. > > + */ > > + if (unlikely(policy->cur != sg_policy->next_freq)) { > > + sg_policy->next_freq = 0; > > + sg_policy->cached_raw_freq = 0; > > + } > > + > > freq = map_util_freq(util, freq, max); > > > > if (freq == sg_policy->cached_raw_freq && !sg_policy->need_freq_update) > > @@ -337,8 +341,14 @@ static void sugov_update_single(struct update_util_data *hook, u64 time, > > > > ignore_dl_rate_limit(sg_cpu, sg_policy); > > > > + if (!sg_policy->policy->fast_switch_enabled) { > > + raw_spin_lock(&sg_policy->update_lock); > > + if (sg_policy->work_in_progress) > > + goto unlock; > > + } > > + > > Maybe it's better to bring the following code before the code above. > if (!sugov_should_update_freq(sg_policy, time)) > return; Maybe not. We want to avoid everything in case a freq-update is on the way elsewhere as there are other flags we are touching in sugov_should_update_freq(). I will send a proper patch for this shortly. It would be helpful if you can give it a go and provide your tested-by. -- viresh