Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp538600rdb; Thu, 5 Oct 2023 13:24:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHx68S8h0p0AaN744+oQjTgfm+bf63C/HGsT6Mtw10zGMRi2US8lSX80fCP4vcZ+8L0rNuj X-Received: by 2002:a05:6a20:a110:b0:161:3013:b499 with SMTP id q16-20020a056a20a11000b001613013b499mr7410165pzk.60.1696537448576; Thu, 05 Oct 2023 13:24:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696537448; cv=none; d=google.com; s=arc-20160816; b=czAOcvRnWHg/qbqW2vtZDVeNCku8yKiMIU0DtKboP2nmX3VhY8WqGqX47Ie0Ogk5su jZw9UFwyV5SvGiUDsZ7TPMfS/dOGVUU6B3Mu2423ATsAyO1EU+voG7oYylbgjlnt6CGW /bB9wY7a8ivHY26yGrTEbFKMaY7sLZc8BwvMM0ESfxU0/ie6lMDMf5dxGDe4oJZFgv+F VNpgfrOWNpu8HTnROs51YjtpAAhG1qsBRNQRWVW2c6D7GkZxxM2WoJ+7swoyIqsRAqX/ AOq/SZpEo5ooYj+AX4AfgcUkWeU5Sbw65rkMQAuXbGK9dr1P92r6uI2njqidM++SDEkL GrAA== 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:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id q20-20020a056a00085400b00690ca3d66bbsi2146031pfk.262.2023.10.05.13.24.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 13:24:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; 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:8 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 fry.vger.email (Postfix) with ESMTP id D84458079316; Thu, 5 Oct 2023 13:24:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229835AbjJEUXz (ORCPT + 99 others); Thu, 5 Oct 2023 16:23:55 -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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Thu, 05 Oct 2023 13:24:06 -0700 (PDT) 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 */