Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2524678pxu; Mon, 7 Dec 2020 08:42:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwzjxTpw/Y3QQcitLG+JDAE5K6Onk6vV/PSdQQEb6j7tcFsdUEVNueA80g3sUXqDwDuSEVX X-Received: by 2002:a17:906:17d1:: with SMTP id u17mr20175903eje.229.1607359358905; Mon, 07 Dec 2020 08:42:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607359358; cv=none; d=google.com; s=arc-20160816; b=n0W21erP7RVhxneJBbm6B5bGKNRlMn3yBjA0Dk/hVl5qDuhPXy6n0rSjH/FvE8s5ZA J+5Q2cAqiYIMQ89+jla9laY4M/7Iktns7x5hnBm4h7LABqnZ+9wdfNP+CfvW6cYF3+y4 6voAJkrSrw4YnpI6BPJK057WnQngaeMP849/cvAZj3DS+RyjzESWjrjWSznJY7VUOrH2 db1YFaS00npUP8YBHisiJ1EcJhIc7uBi5rj+4CS9u3sOSTKf/pPyjGwMdILAESWJcjc+ 0Oy9noDj5eDUlET6CiPRflQogsUhdSJ4aOdpIswXnH6D3y41p4tsOMN0NIO7kv+z8HJ4 jZWA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=CGxPP51jqS7ZAkEdvnKu2+BxNpRVENXiHTPeBYv/OfI=; b=sh440Ie4C0L+x5dV98B9a+rbgLqh6HJqFZ43sxwk+JnQWxIGRWYElNeDfdqggiloIZ N/5FGA3pshHmwWsJxcA1OMSpqQweXcltof2YWxIzATgMoKIWKxFsglsz5NcX8hn5xCVD z1t78tTnfbhgyNuiEEZTc1hPlOBxOMnTKGONh524CSaDXJg1HIchgeoWZ+AJoR07gclb yQOznR5YPTlUOh0KzETUi9Ee2QFlGNcx7DnoUL6qqv+uC4N3oCdtZ/M7vnlMT5oDdu8u b0JZlSgYRszzyLgzoZ0vDCD/M3xi5W5rAdtnVdO1h3EM6aTOQCX8NJOJ/pcn09/3Bgz1 16tw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c22si6663287ejx.290.2020.12.07.08.42.14; Mon, 07 Dec 2020 08:42:38 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727701AbgLGQkd (ORCPT + 99 others); Mon, 7 Dec 2020 11:40:33 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:43374 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726660AbgLGQkc (ORCPT ); Mon, 7 Dec 2020 11:40:32 -0500 Received: from 89-64-79-106.dynamic.chello.pl (89.64.79.106) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.530) id f644db2eefb3634f; Mon, 7 Dec 2020 17:39:50 +0100 From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Viresh Kumar , Srinivas Pandruvada , Peter Zijlstra , Doug Smythies , Giovanni Gherdovich Subject: [PATCH v1 2/4] cpufreq: schedutil: Adjust utilization instead of frequency Date: Mon, 07 Dec 2020 17:29:47 +0100 Message-ID: <1916732.tSaCp9PeQq@kreacher> In-Reply-To: <20360841.iInq7taT2Z@kreacher> References: <20360841.iInq7taT2Z@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki When avoiding reduction of the frequency after the target CPU has been busy since the previous frequency update, adjust the utilization instead of adjusting the frequency, because doing so is more prudent (it is done to counter a possible utilization deficit after all) and it will allow some code to be shared after a subsequent change. Signed-off-by: Rafael J. Wysocki --- kernel/sched/cpufreq_schedutil.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) Index: linux-pm/kernel/sched/cpufreq_schedutil.c =================================================================== --- linux-pm.orig/kernel/sched/cpufreq_schedutil.c +++ linux-pm/kernel/sched/cpufreq_schedutil.c @@ -437,7 +437,7 @@ static void sugov_update_single(struct u { struct sugov_cpu *sg_cpu = container_of(hook, struct sugov_cpu, update_util); struct sugov_policy *sg_policy = sg_cpu->sg_policy; - unsigned int cached_freq = sg_policy->cached_raw_freq; + unsigned long prev_util = sg_cpu->util; unsigned int next_f; sugov_iowait_boost(sg_cpu, time, flags); @@ -451,17 +451,14 @@ static void sugov_update_single(struct u sugov_get_util(sg_cpu); sugov_iowait_apply(sg_cpu, time); - next_f = get_next_freq(sg_policy, sg_cpu->util, sg_cpu->max); /* * Do not reduce the frequency if the CPU has not been idle * recently, as the reduction is likely to be premature then. */ - if (sugov_cpu_is_busy(sg_cpu) && next_f < sg_policy->next_freq) { - next_f = sg_policy->next_freq; + if (sugov_cpu_is_busy(sg_cpu) && sg_cpu->util < prev_util) + sg_cpu->util = prev_util; - /* Restore cached freq as next_freq has changed */ - sg_policy->cached_raw_freq = cached_freq; - } + next_f = get_next_freq(sg_policy, sg_cpu->util, sg_cpu->max); /* * This code runs under rq->lock for the target CPU, so it won't run