Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp64665pxh; Thu, 7 Apr 2022 14:06:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxf1r9XSPrFpxv9V+DYRHmJW+p1ECz7l+uRkAVqC88+9MABHvVUV+1p317bpo5+Nw5OGFy0 X-Received: by 2002:a17:902:bd89:b0:156:8467:782b with SMTP id q9-20020a170902bd8900b001568467782bmr15893160pls.12.1649365572036; Thu, 07 Apr 2022 14:06:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649365572; cv=none; d=google.com; s=arc-20160816; b=Ts71DlrA7VxWHqqw3mJY98+aLQlRgD13ZyTbpDd7ipAx9mM0Vzn/0uQ3Z587H3rald QnfZmC32GSP/urqHRMPF/lr7KUvKIfzpyuD3dNVaDBM3TQ4sjCg8JKGKQTTWmau270aE tTbISutovZrzv8/m89//hwBekW69aWTcpkOXf/EIljkcRC9dljCuxBOcGuYZoDApvwzz ny60TIMOtcQUGKH2ZfHqaI9tov2E5xBWj9T2Qunzp0SyGsd9SGqDdEoSSSjxic49jkrn WZDzjk4FQCDyq6UOvcCYlXGjX2j4OoPMf9QZ91/Yf9+ng7FvklLhTAZttAwEnO8CYVdu RRTg== 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=E9sHyK8W40FxLtoHWz1kIs3vqNsYnM2stEBREQsVXAg=; b=KZHbzM6yAo48/VhUb3nXI/UXxNasBilVp+QR7vmhDPnhS93qXgs9RvlaAYTs+SCIx5 JI0IO2Uu5VPHwJec4IHjevpivUABcCZcQwyGvjqEhYVnanDS/viUjTPfnUcGBEx/lITw Z6mw4GTRa1b3v/4xkO6i4dk5eVmUphEvjEmu0ZMLmqGg/xy5mrTN8aZu3gNmkqwnYKDp 8dFaJDE1H/dfdklTzs8EBtCEewTdP2q/ZyVjWmv62v0uTMaRy5pvXnBHRoKNSMWc65I3 TpLoVA4sbJyuxx4ssQ5oxMpIEHWIEgmiSPVA7C/pMCD778ojOJ3gAOq14AnhznCdIOXY u6Fg== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id u6-20020a17090341c600b00156983f1b99si849993ple.267.2022.04.07.14.06.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 14:06:11 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B706845CFEE; Thu, 7 Apr 2022 13:11:49 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238199AbiDGFww (ORCPT + 99 others); Thu, 7 Apr 2022 01:52:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239900AbiDGFwl (ORCPT ); Thu, 7 Apr 2022 01:52:41 -0400 X-Greylist: delayed 1829 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 06 Apr 2022 22:50:32 PDT Received: from SHSQR01.unisoc.com (unknown [222.66.158.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F081560E9 for ; Wed, 6 Apr 2022 22:50:32 -0700 (PDT) Received: from SHSQR01.spreadtrum.com (localhost [127.0.0.2] (may be forged)) by SHSQR01.unisoc.com with ESMTP id 2375K3WR084414 for ; Thu, 7 Apr 2022 13:20:03 +0800 (CST) (envelope-from Xuewen.Yan@unisoc.com) Received: from SHSend.spreadtrum.com (bjmbx01.spreadtrum.com [10.0.64.7]) by SHSQR01.spreadtrum.com with ESMTPS id 2375JfPV083371 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NO); Thu, 7 Apr 2022 13:19:41 +0800 (CST) (envelope-from Xuewen.Yan@unisoc.com) Received: from BJ10918PCW.spreadtrum.com (10.0.74.50) by BJMBX01.spreadtrum.com (10.0.64.7) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Thu, 7 Apr 2022 13:19:40 +0800 From: Xuewen Yan To: , CC: , , , , , , , , Subject: [PATCH] sched: Take thermal pressure into account when determine rt fits capacity Date: Thu, 7 Apr 2022 13:19:32 +0800 Message-ID: <20220407051932.4071-1-xuewen.yan@unisoc.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.0.74.50] X-ClientProxiedBy: SHCAS01.spreadtrum.com (10.0.1.201) To BJMBX01.spreadtrum.com (10.0.64.7) X-MAIL: SHSQR01.spreadtrum.com 2375JfPV083371 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 There are cases when the cpu max capacity might be reduced due to thermal. Take into the thermal pressure into account when judge whether the rt task fits the cpu. And when schedutil govnor get cpu util, the thermal pressure also should be considered. Signed-off-by: Xuewen Yan --- kernel/sched/cpufreq_schedutil.c | 1 + kernel/sched/rt.c | 1 + 2 files changed, 2 insertions(+) diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 3dbf351d12d5..285ad51caf0f 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -159,6 +159,7 @@ static void sugov_get_util(struct sugov_cpu *sg_cpu) struct rq *rq = cpu_rq(sg_cpu->cpu); unsigned long max = arch_scale_cpu_capacity(sg_cpu->cpu); + max -= arch_scale_thermal_pressure(sg_cpu->cpu); sg_cpu->max = max; sg_cpu->bw_dl = cpu_bw_dl(rq); sg_cpu->util = effective_cpu_util(sg_cpu->cpu, cpu_util_cfs(sg_cpu->cpu), max, diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index a32c46889af8..d9982ebd4821 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -466,6 +466,7 @@ static inline bool rt_task_fits_capacity(struct task_struct *p, int cpu) max_cap = uclamp_eff_value(p, UCLAMP_MAX); cpu_cap = capacity_orig_of(cpu); + cpu_cap -= arch_scale_thermal_pressure(cpu); return cpu_cap >= min(min_cap, max_cap); } -- 2.25.1