Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp104869pxx; Tue, 27 Oct 2020 23:00:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpH4A/xpnuaZzgStwQ5LX2KdHW8f8105UNVbDXdCnWRFGFi3lyG83cf1hl6Dxx9WAZ2IMR X-Received: by 2002:a17:906:1f08:: with SMTP id w8mr5943186ejj.181.1603864815487; Tue, 27 Oct 2020 23:00:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603864815; cv=none; d=google.com; s=arc-20160816; b=fUbHjwX5OHik5ojfQr8UU0jseTYep/3AbWLP7xpARbBp8G/EiBvV79coN5Rs7sVeUg SpknvHCxJtW0W1/JRma2mQCTu8uMthYbn+FHzC9hnlwrXMBakl4M5OyywKZ1jMKSgKMb Hp0qRnxEiVGwIE6WlaQHFVFpnyGsJl6Zdo+7u1CXiUoAJjmalQJUS/tq7sbuZO8IBytA 0El0uzHRz1ZBRtGUkHnxe1dx29fR/yYd1FJO83Z9syj5Q6E2tpNALvWITpEhoIbYM/xE /nNahn6EMaONr724ZfGtQOaWnGWM9aZiIU3MmlsBNrRB4KT444YqFNy1UylV+drPYXVV 7YeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :ironport-sdr:ironport-sdr; bh=95O+jaV5hpLTHBfbBcyj0PD235W0B8P3aG6twJo6RkM=; b=ebU8q5x4ijlHCdEpZpBpEXC15VVfSUtG6ufi8qXZpH6erEsEu2kQRioJUtRWDpHIbz eL0ffk+cygVSC4NUdSBsI9qO4ZVHeQYrszOP0t5civnHWPhGGJHWPiKGNMzr8TIk1Owl Io33vqukDiBALG02lyyzaBhZah+GFnQsNxe5unFDGBpZicTtpbrgx7zGfNNyfRuxKSvu NrRFc3vMQJJkOslE8a7jUz+2L+DWi8ksMwBZioabFtV8bohN1BUSCVJn3JpuIzR43XAn YzRVO6q50KnUrExbx1q1ZAxEVRwMiEnajPJLOw59BuszI2eLI54ZB0t2SEBu1JdhpzZc 1sgw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lg11si2723867ejb.371.2020.10.27.22.59.53; Tue, 27 Oct 2020 23:00:15 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2509302AbgJ0Irv (ORCPT + 99 others); Tue, 27 Oct 2020 04:47:51 -0400 Received: from mga07.intel.com ([134.134.136.100]:61236 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406265AbgJ0Iru (ORCPT ); Tue, 27 Oct 2020 04:47:50 -0400 IronPort-SDR: yGKrNwIflwpv97rjaxrnee4gjeAgTtNosk2en39O/8tAUV0pkbqNjbzbp6nmyHDEJUqLxh1jO2 1eyWiqW9xPJg== X-IronPort-AV: E=McAfee;i="6000,8403,9786"; a="232233526" X-IronPort-AV: E=Sophos;i="5.77,423,1596524400"; d="scan'208";a="232233526" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2020 01:47:49 -0700 IronPort-SDR: joSJwF7+NAz7pl8+PeXASjinmw8/o8NZxPqSXL3ji6G69k8Iz7j45C3GBs7URP/zcJbTvqo04J YQyXabzngwEQ== X-IronPort-AV: E=Sophos;i="5.77,423,1596524400"; d="scan'208";a="524615151" Received: from zzhao15-mobl1.ccr.corp.intel.com ([10.255.30.125]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2020 01:47:47 -0700 Message-ID: <1975659e1cd98e6bbf80595bc91c78079350c677.camel@intel.com> Subject: Re: [PATCH v2 4/4] cpufreq: schedutil: Always call drvier if need_freq_update is set From: Zhang Rui To: "Rafael J. Wysocki" , Linux PM , Viresh Kumar Cc: LKML , Srinivas Pandruvada Date: Tue, 27 Oct 2020 16:47:44 +0800 In-Reply-To: <1905098.zDJocX6404@kreacher> References: <2183878.gTFULuzKx9@kreacher> <1905098.zDJocX6404@kreacher> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2020-10-23 at 17:36 +0200, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > Because sugov_update_next_freq() may skip a frequency update even if > the need_freq_update flag has been set for the policy at hand, policy > limits updates may not take effect as expected. > > For example, if the intel_pstate driver operates in the passive mode > with HWP enabled, it needs to update the HWP min and max limits when > the policy min and max limits change, respectively, but that may not > happen if the target frequency does not change along with the limit > at hand. In particular, if the policy min is changed first, causing > the target frequency to be adjusted to it, and the policy max limit > is changed later to the same value, the HWP max limit will not be > updated to follow it as expected, because the target frequency is > still equal to the policy min limit and it will not change until > that limit is updated. > > To address this issue, modify get_next_freq() to clear > need_freq_update only if the CPUFREQ_NEED_UPDATE_LIMITS flag is > not set for the cpufreq driver in use (and it should be set for all > potentially affected drivers) and make sugov_update_next_freq() > check need_freq_update and continue when it is set regardless of > whether or not the new target frequency is equal to the old one. > > Fixes: f6ebbcf08f37 ("cpufreq: intel_pstate: Implement passive mode > with HWP enabled") > Reported-by: Zhang Rui > Cc: 5.9+ # 5.9+ > Signed-off-by: Rafael J. Wysocki I have confirmed that the problem is gone with this patch series applied. Tested-by: Zhang Rui thanks, rui > --- > > New patch in v2. > > --- > kernel/sched/cpufreq_schedutil.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > Index: linux-pm/kernel/sched/cpufreq_schedutil.c > =================================================================== > --- linux-pm.orig/kernel/sched/cpufreq_schedutil.c > +++ linux-pm/kernel/sched/cpufreq_schedutil.c > @@ -102,11 +102,12 @@ static bool sugov_should_update_freq(str > static bool sugov_update_next_freq(struct sugov_policy *sg_policy, > u64 time, > unsigned int next_freq) > { > - if (sg_policy->next_freq == next_freq) > + if (sg_policy->next_freq == next_freq && !sg_policy- > >need_freq_update) > return false; > > sg_policy->next_freq = next_freq; > sg_policy->last_freq_update_time = time; > + sg_policy->need_freq_update = false; > > return true; > } > @@ -164,7 +165,10 @@ static unsigned int get_next_freq(struct > if (freq == sg_policy->cached_raw_freq && !sg_policy- > >need_freq_update) > return sg_policy->next_freq; > > - sg_policy->need_freq_update = false; > + if (sg_policy->need_freq_update) > + sg_policy->need_freq_update = > + cpufreq_driver_test_flags(CPUFREQ_NEED_UPDATE_L > IMITS); > + > sg_policy->cached_raw_freq = freq; > return cpufreq_driver_resolve_freq(policy, freq); > } > > >