From patchwork Thu Oct 5 20:23:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 149023 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2016:b0:403:3b70:6f57 with SMTP id fe22csp546944vqb; Thu, 5 Oct 2023 13:24:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFjKK7NxkD53b1nrqLi46jZn324u3eplYOaXpLT3jOOgJ0k0jX2KjVMiL40vEj63hJNKN4U X-Received: by 2002:a05:6358:63a7:b0:14b:d9de:3008 with SMTP id k39-20020a05635863a700b0014bd9de3008mr6771805rwh.5.1696537456155; Thu, 05 Oct 2023 13:24:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696537456; cv=none; d=google.com; s=arc-20160816; b=yF/8m8MYV7uKv6LWUEbKWEODoCzD8H/i0QFQiU6O9bWiRIqQnxzUoEX4XMZCn8aIyB J323k8suMI2rd19Q7xCco55S8ineuyiQxVdJXJGscO4Jid7uE1dCrZTnbN4g1j2SpGat dyrnPGfjAJwd13sQAAxxo0aZ9tDqBsunVL8BViu9Wc7anmeL7NtmJWu4hJFRyvMiaUeQ WyywtcP0PYWm+VPKYipoWTvzw7J913g2lUcvZ8JCRG6oVUOouknrcPfpUmN5gRPXeJvs cwJymK6cGdy5akZx4YLflNFalObfVcp9uXpOM/zt7VpfyACzO4SBp9ti2WJNv3VWkRHU D1dQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=dO+aKjhk4MAL25uH/UDuHKKSgxIuG2Di9bAh6yHtAtY=; fh=F66bBns2Uzky2c0k3vwxtbBbJxiXD4Sj2EETp5pO39Y=; b=dYDfHnyYbH1KU5YKan+RvOAyZTeGibgHIR2bf+ayX1LneReAbYr8Eu/diLT+D5ghmZ lqhLy/VCT+xjIARqJwsP9gdPW2LU83FX9fm/HjhgHh9LQYERUO1wm4ArGEw6+sPAU3EV F7SOjxii94mUuvpIulD7iXnGzMID3S5nuVdBPJlmsSETfD6BLb8926+PI+KpeQENYUL4 dcYCmCySUFvRphmOOpJVx/sUSseT3wsYle/c7eZXWag9bChIw1oEp8aaDb2tlA8eFbQG rjB5+kWWGD4h09qYlOfgG4dtR+xXLAoOKrthyId1KF3DVC1Ae6v0N/Oq2DSndJ+z48Pe r00g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=qzODLAM6; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id bv4-20020a17090af18400b0027744a9de69si4460528pjb.126.2023.10.05.13.24.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 13:24:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=qzODLAM6; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id BBE4783C9E9D; Thu, 5 Oct 2023 13:24:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229852AbjJEUX4 (ORCPT + 18 others); Thu, 5 Oct 2023 16:23:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229588AbjJEUXy (ORCPT ); Thu, 5 Oct 2023 16:23:54 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BC4793; Thu, 5 Oct 2023 13:23:53 -0700 (PDT) Date: Thu, 05 Oct 2023 20:23:50 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1696537431; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dO+aKjhk4MAL25uH/UDuHKKSgxIuG2Di9bAh6yHtAtY=; b=qzODLAM65gHT7XOAF4prJ2MxALLHdLauoBwxL/18hpY2PlRuqC3iwno4KARSiS/uViv43Y Khv1KPOjoFj7zoGP6SgibCQiu/jWMHxydbojZlAeHBS4ABAP6nNlt3kmTPTxp8YjOCjQ+X FV8hkhpm0GTs/owSjSwRaw4E7bvvbgSNpbr6knYFZ12fV4ePOtiQ0XeB44w+auGQJWjOk5 ydyyA19uXdhK/k5pnEgkRasjvJXBS6Q+Fw4LZGpOLanp4auoPr0YQE4gthmvDGM1q3dg7H ERPOhXWmMHaSXsRdt/IzGj1dpLRJXkxnNpElWOSNAcm+T5u5+cFbuHxgFOekoQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1696537431; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dO+aKjhk4MAL25uH/UDuHKKSgxIuG2Di9bAh6yHtAtY=; b=HER3RGNv7/z1f8iemBfj2zHxnBLR/rX3QQag4LD9u2AFl6uaELwdbYR3fU7r71kB8L8Iks s9AhEtytLiRUkZBQ== From: "tip-bot2 for Xuewen Yan" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/urgent] cpufreq: schedutil: Update next_freq when cpufreq_limits change Cc: Xuewen Yan , Guohua Yan , Ingo Molnar , "Rafael J. Wysocki" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230719130527.8074-1-xuewen.yan@unisoc.com> References: <20230719130527.8074-1-xuewen.yan@unisoc.com> MIME-Version: 1.0 Message-ID: <169653743031.3135.15393242028236328719.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 05 Oct 2023 13:24:11 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778948459453458269 X-GMAIL-MSGID: 1778948459453458269 The following commit has been merged into the sched/urgent branch of tip: Commit-ID: 9e0bc36ab07c550d791bf17feeb479f1dfc42d89 Gitweb: https://git.kernel.org/tip/9e0bc36ab07c550d791bf17feeb479f1dfc42d89 Author: Xuewen Yan AuthorDate: Wed, 19 Jul 2023 21:05:27 +08:00 Committer: Ingo Molnar CommitterDate: Thu, 05 Oct 2023 22:09:50 +02:00 cpufreq: schedutil: Update next_freq when cpufreq_limits change 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 a 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 stay at 2301000, which is wrong. To fix this, add a check for the ->need_freq_update flag. [ mingo: Clarified the changelog. ] Co-developed-by: Guohua Yan Signed-off-by: Xuewen Yan Signed-off-by: Guohua Yan Signed-off-by: Ingo Molnar Acked-by: "Rafael J. Wysocki" Link: https://lore.kernel.org/r/20230719130527.8074-1-xuewen.yan@unisoc.com --- 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 4492608..458d359 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 */