From patchwork Wed Jul 19 13:05:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xuewen Yan X-Patchwork-Id: 122619 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp2437991vqt; Wed, 19 Jul 2023 06:26:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlHTh+RNVI6Auu9yeHvKhxbwCXByHtbAxLecY70qgsa9K2qLQzPCwRV0HL3jcu6NvVbawJil X-Received: by 2002:a05:6a00:1586:b0:67e:18c6:d2db with SMTP id u6-20020a056a00158600b0067e18c6d2dbmr6432957pfk.28.1689773201523; Wed, 19 Jul 2023 06:26:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689773201; cv=none; d=google.com; s=arc-20160816; b=K3JssPmxtoFr35J08JobTQei6AgRi4fN2DSZs2vq+hTU4Yxn6gmsHn6F81TrovOhEe Ssysb2q0O6O+u4/bwizbgVsJImGIzlz2RXGXqio+V4zMQxWDy5hLm6Wwen4xXEi5ssYw pY79dX1oecNJ9+HCtB7We80IcV3hD/LRhHyaZBNcvutFDZIMhda73UKutHjk/KnFdkEO DKT1dqyxEPjokZmTYtUTegcZatccg3k2897JzhlqsDC4lgduE5IkWBWCUffYdIALXS/J ubJu2I0JMQLBvmnNl3Cz2wAh33gvuE0ZkAICW0tv/IMkuR9SmpCd6gWaw3My/N6uB9cd pXYw== 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 :message-id:date:subject:cc:to:from; bh=rWsfZSTggDeW4UF3qJacqU+qfYkHByL3+knQJTTEIAc=; fh=jB3RFmkL4ZcCpRVJnBESXBROqUq2t2fdebv3Kn2zBho=; b=nCDWqDcOUxhhWxIUyRHuAnDdQlNmsy9bFetphwJ5J5C8YnFNDaY4+kC3uFf0j6jwpH 88IxNlcrYxcA2xGvUKgTUXLLIm+5M4gf8+UjGblDekm2zdms2201NbdZ964qFCFrJjwC T+yp2Hs0QQMThlJ9+z6uoABG9XfVvXcexVBGxRyif9D1d6fWH0rar7dt3N1pO6VnA+Tm k3+QNAAQVN/3dFw6XassSyMFsw+01XpBcPsA3htq44HYe+jgQXhsDgKQcEaImwE9//7i Q5hm6rX9Ilc4qGSu/t4eODv85dSfTd59moPwRbNNLtN9ZbvRlKxXLmBEXG2HLqnjFwSu D/bA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v24-20020a63f218000000b0055b037b55ecsi3455379pgh.147.2023.07.19.06.26.27; Wed, 19 Jul 2023 06:26:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230453AbjGSNFr (ORCPT + 99 others); Wed, 19 Jul 2023 09:05:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230405AbjGSNFq (ORCPT ); Wed, 19 Jul 2023 09:05:46 -0400 Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 143161711 for ; Wed, 19 Jul 2023 06:05:43 -0700 (PDT) Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 36JD5Zqj043653; Wed, 19 Jul 2023 21:05:35 +0800 (+08) (envelope-from Xuewen.Yan@unisoc.com) Received: from SHDLP.spreadtrum.com (bjmbx01.spreadtrum.com [10.0.64.7]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4R5bch0SXJz2K1r9p; Wed, 19 Jul 2023 21:04:20 +0800 (CST) Received: from BJ10918NBW01.spreadtrum.com (10.0.73.72) by BJMBX01.spreadtrum.com (10.0.64.7) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Wed, 19 Jul 2023 21:05:33 +0800 From: Xuewen Yan To: , , , , CC: , , , , , , , , , Subject: [PATCH] cpufreq: schedutil: next_freq need update when cpufreq_limits changed Date: Wed, 19 Jul 2023 21:05:27 +0800 Message-ID: <20230719130527.8074-1-xuewen.yan@unisoc.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.0.73.72] X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX01.spreadtrum.com (10.0.64.7) X-MAIL: SHSQR01.spreadtrum.com 36JD5Zqj043653 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771855624728499559 X-GMAIL-MSGID: 1771855624728499559 When cpufreq's policy is single, there is a scenario that will cause sg_policy's next_freq to be unable to update. When the cpu's util is always max, the cpufreq will be max, and then if we change the policy's scaling_max_freq to be a lower freq, indeed, the sg_policy's next_freq need change to be the lower freq, however, because the cpu_is_busy, the next_freq would keep the max_freq. For example: The cpu7 is single cpu: unisoc:/sys/devices/system/cpu/cpufreq/policy7 # while true;do done& [1] 4737 unisoc:/sys/devices/system/cpu/cpufreq/policy7 # taskset -p 80 4737 pid 4737's current affinity mask: ff pid 4737's new affinity mask: 80 unisoc:/sys/devices/system/cpu/cpufreq/policy7 # cat scaling_max_freq 2301000 unisoc:/sys/devices/system/cpu/cpufreq/policy7 # cat scaling_cur_freq 2301000 unisoc:/sys/devices/system/cpu/cpufreq/policy7 # echo 2171000 > scaling_max_freq unisoc:/sys/devices/system/cpu/cpufreq/policy7 # cat scaling_max_freq 2171000 At this time, the sg_policy's next_freq would keep 2301000. To prevent the case happen, add the judgment of the need_freq_update flag. Signed-off-by: Xuewen Yan Co-developed-by: Guohua Yan Signed-off-by: Guohua Yan --- kernel/sched/cpufreq_schedutil.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 4492608b7d7f..458d359f5991 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -350,7 +350,8 @@ static void sugov_update_single_freq(struct update_util_data *hook, u64 time, * Except when the rq is capped by uclamp_max. */ if (!uclamp_rq_is_capped(cpu_rq(sg_cpu->cpu)) && - sugov_cpu_is_busy(sg_cpu) && next_f < sg_policy->next_freq) { + sugov_cpu_is_busy(sg_cpu) && next_f < sg_policy->next_freq && + !sg_policy->need_freq_update) { next_f = sg_policy->next_freq; /* Restore cached freq as next_freq has changed */