Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp831693pxb; Tue, 3 Nov 2020 13:49:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJx1UHhuHqGpv80Q6/TUxR0CFwalp9Y9t4M1fltNQS/mdwjAr0SA1mGoOh1+vVm89fbuS5aY X-Received: by 2002:a17:906:b216:: with SMTP id p22mr22244296ejz.228.1604440164620; Tue, 03 Nov 2020 13:49:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604440164; cv=none; d=google.com; s=arc-20160816; b=wRthcLpHXGWqNoX/F8NZi/1aflZ1Kg1A8/i422lcL4Bg3ecOd/ZwDVaYqL5zI+n6Dh fNdShmIhvrVBMKc0ZRuKnepDS5A0znV+gS+CXxUgb9/hXBhlmJLeXxwFaJVaEsYPsbER wF2QpcyU8ay19H2mmDifDOl8vJmgJ0HQeZo8P84QgsJDPkaEF4aTevOQ7XyI5s+7/Vk2 8ueXO0AuZHwuvaSZ88wuvUssRiU/B0+JOzelkl43/69T0Jq5wRwEJHSDgzAzIGqqGNHj SttPeC2b2ITVxiOMllPeLjStryMMmlBoLlRsizjLrl4VCBCYnh1//d/t+obDFIpr7vdU QSrg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jFAzTsx8I7rcO47lGNy4BztVcV4wzW71NLdHmA6gA+Q=; b=FshD+6E7RT/rkUGLTwjPEACMZBYSN5BmPyubd7kz3Ekz5QKnKGgKpxBfKBAWI2RjFM QLQjgzaUbpv+Ei4g2elPns93A879mQmBNuOv7Tsjj2D7dbTUERIeo5xXRXwn1TZG6y31 aWoCQHEK4NkdCDK/Ff+k8JRVGoC5X6imjxMkR4bpqTSOlnY/tKo3hA6tW+EoEYdqOo8m O1KUzgtY0QSgh4INV3+bga5i7gJzwI3nqWQbIvWhvlL870iev8sf5Th1yYezswaLMD50 vvjk6lZ6dpaawUTrvNrpNlB9haeIPEcxQPP/JNj4tCCz0GuJhhG7J5WwJn8gCKUN/RFj 0jgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HKN6Nr5a; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h27si91022ejd.668.2020.11.03.13.49.01; Tue, 03 Nov 2020 13:49:24 -0800 (PST) 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=@kernel.org header.s=default header.b=HKN6Nr5a; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732151AbgKCUws (ORCPT + 99 others); Tue, 3 Nov 2020 15:52:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:49818 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732148AbgKCUwq (ORCPT ); Tue, 3 Nov 2020 15:52:46 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6F0F02071E; Tue, 3 Nov 2020 20:52:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604436765; bh=aHbdgysvukX0w/wcU3rTWMj51AjJJV3UkgaeNFflHTk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HKN6Nr5aac1a0oy3P851vKdWevURkFXClGclHTILZj+FdEy67oA0j+Lw7dNbNZ3aC c1rX04P5fF30/I3wqodIX4GVujBS1k7+mzml0YAXnN5p2emliEKR4bGlmM57dDrHCb IKT2SEIffQXXdZcmp0q3gYQ2DFZcr53yWBr5HydM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhang Rui , "Rafael J. Wysocki" , Viresh Kumar Subject: [PATCH 5.9 386/391] cpufreq: schedutil: Always call driver if CPUFREQ_NEED_UPDATE_LIMITS is set Date: Tue, 3 Nov 2020 21:37:17 +0100 Message-Id: <20201103203413.208088631@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203348.153465465@linuxfoundation.org> References: <20201103203348.153465465@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki commit d1e7c2996e988866e7ceceb4641a0886885b7889 upstream. 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 let the driver callback run if the CPUFREQ_NEED_UPDATE_LIMITS cpufreq driver flag is set regardless of whether or not the new frequency to set is equal to the previous one. Fixes: f6ebbcf08f37 ("cpufreq: intel_pstate: Implement passive mode with HWP enabled") Reported-by: Zhang Rui Tested-by: Zhang Rui Cc: 5.9+ # 5.9+: 1c534352f47f cpufreq: Introduce CPUFREQ_NEED_UPDATE_LIMITS ... Cc: 5.9+ # 5.9+: a62f68f5ca53 cpufreq: Introduce cpufreq_driver_test_flags() Signed-off-by: Rafael J. Wysocki Acked-by: Viresh Kumar Signed-off-by: Rafael J. Wysocki Signed-off-by: Greg Kroah-Hartman --- kernel/sched/cpufreq_schedutil.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -102,7 +102,8 @@ 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 && + !cpufreq_driver_test_flags(CPUFREQ_NEED_UPDATE_LIMITS)) return false; sg_policy->next_freq = next_freq; @@ -175,7 +176,8 @@ static unsigned int get_next_freq(struct freq = map_util_freq(util, freq, max); - if (freq == sg_policy->cached_raw_freq && !sg_policy->need_freq_update) + if (freq == sg_policy->cached_raw_freq && !sg_policy->need_freq_update && + !cpufreq_driver_test_flags(CPUFREQ_NEED_UPDATE_LIMITS)) return sg_policy->next_freq; sg_policy->need_freq_update = false;