From patchwork Fri Jul 28 09:58:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 127513 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp335181vqg; Fri, 28 Jul 2023 03:29:48 -0700 (PDT) X-Google-Smtp-Source: APBJJlHR2JsMWUbuO21CLgUBZdzGqYB8GU0aXKAmSeRjdLR+OdTRV31eSwmmG2F1fZgra9cIOkd3 X-Received: by 2002:aca:1902:0:b0:3a4:1319:9af1 with SMTP id l2-20020aca1902000000b003a413199af1mr2283877oii.51.1690540188096; Fri, 28 Jul 2023 03:29:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690540188; cv=none; d=google.com; s=arc-20160816; b=ezy1ub2duA5ef2jGmHHLI1DoyU6EUWxAf6cJNSdkSjqP/8LZwHfdXPeG97sSgP6AHu IM+jNgJwBWREkwGAER4YpnmLKdsF7zZ0uVxdIzY6nVhMj8IT01nr6pvYhIJ6EXcLOzzG AjgpKwa3VVgvnIdZgLZPSt3KzH4uUGIbhHIKKoW/Z9K5YdyRqSlFiBhRiEBugB6fXPNO C36fn8zxJAc60nFAhVjxkEWGWdpSnnUJgT0694NzWQv9T7QnoN0iB+hpBaakDXkyVZiJ f9G5Yq5VqgiHFvTHU1sscXBDou0LcEeXPDDHBSzO82ZK+uv9M4I2yb8KRmIY4gmMmh/6 Vc9Q== 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=oiQVWa2il+DmaGChjxdya9UmOFVP5yITnwR5OTkLQF4=; fh=vcb1WTwJPUMTZX6OxkyO+5cKBEoTRHpgQZ5gmsle4eE=; b=xip3mDc/tYFhZTc1nxS1QrOp2Spae4st608Po2Ij81DgbZbNm8W4TaysNKIXrus1jm 7LZDbNRwePgsa+LEZ0dq5XhiT9kTc39UqVsIL0VETI+J+7qlKwLGpCqErcShanYhg0Lr R9oVEEUx/kdQSsvzuNIV718U7HYFxilmWSOQyXZS2Bg7kVvS/OnHA01gR/0HfO3qpMdf iIVb3ZhHMPZ36Ob0woopIYBELFRAZgw2qFoXd/J1FIHYRduFS4AGRyfxhHmn0OMnhqhI wXKQZnnx3oXh/nZR2v4qUKPW51v3CndruLR+Xt9ZwTxl7Vt9XKZSw4+RXVMyfEPvzJoZ QDcg== 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 p8-20020a63c148000000b00563da4d2a70si2793742pgi.364.2023.07.28.03.29.35; Fri, 28 Jul 2023 03:29:48 -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 S235706AbjG1KDD (ORCPT + 99 others); Fri, 28 Jul 2023 06:03:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235380AbjG1KC3 (ORCPT ); Fri, 28 Jul 2023 06:02:29 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5F91423B; Fri, 28 Jul 2023 03:01:59 -0700 (PDT) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.2.0) id 5ad84d9e2afdf0c6; Fri, 28 Jul 2023 12:01:58 +0200 Authentication-Results: v370.home.net.pl; spf=softfail (domain owner discourages use of this host) smtp.mailfrom=rjwysocki.net (client-ip=195.136.19.94; helo=[195.136.19.94]; envelope-from=rjw@rjwysocki.net; receiver=) Received: from kreacher.localnet (unknown [195.136.19.94]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id C2326661E37; Fri, 28 Jul 2023 12:01:57 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Peter Zijlstra , Anna-Maria Behnsen , Frederic Weisbecker , Kajetan Puchalski Subject: [PATCH v2 1/3] cpuidle: teo: Update idle duration estimate when choosing shallower state Date: Fri, 28 Jul 2023 11:58:45 +0200 Message-ID: <13326870.uLZWGnKmhe@kreacher> In-Reply-To: <5707588.DvuYhMxLoT@kreacher> References: <5707588.DvuYhMxLoT@kreacher> MIME-Version: 1.0 X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedviedrieeigddvtdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvffeuiedtgfdvtddugeeujedtffetteegfeekffdvfedttddtuefhgeefvdejhfenucfkphepudelhedrudefiedrudelrdelgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduleehrddufeeirdduledrleegpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeeipdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepphgvthgvrhiisehinhhfrhgruggvrggurdhorhhgpdhrtghpthhtoheprghnnhgrqdhmrghrihgrsehlihhnuhhtrhhonhhigidruggvpdhrtghpthhtohepfhhrvggu vghrihgtsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehkrghjvghtrghnrdhpuhgthhgrlhhskhhisegrrhhmrdgtohhm X-DCC--Metrics: v370.home.net.pl 1024; Body=6 Fuz1=6 Fuz2=6 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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: 1772659868036598650 X-GMAIL-MSGID: 1772659868036598650 From: Rafael J. Wysocki The TEO governor takes CPU utilization into account by refining idle state selection when the utilization is above a certain threshold. This is done by choosing an idle state shallower than the previously selected one. However, when doing this, the idle duration estimate needs to be adjusted so as to prevent the scheduler tick from being stopped when the candidate idle state is shallow, which may lead to excessive energy usage if the CPU is not woken up quickly enough going forward. Moreover, if the scheduler tick has been stopped already and the new idle duration estimate is too small, the replacement candidate state cannot be used. Modify the relevant code to take the above observations into account. Fixes: 9ce0f7c4bc64 ("cpuidle: teo: Introduce util-awareness") Signed-off-by: Rafael J. Wysocki --- v1 -> v2: * Rework the code handling the special case when the CPU is utilized and there are only 2 idle states (drop the loop, avoid using state 0 when the tick has been stopped already and it is too shallow, check if state 1 is not disabled when about to use it, set low idle duration estimate). * Changelog edits. --- drivers/cpuidle/governors/teo.c | 43 ++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) Index: linux-pm/drivers/cpuidle/governors/teo.c =================================================================== --- linux-pm.orig/drivers/cpuidle/governors/teo.c +++ linux-pm/drivers/cpuidle/governors/teo.c @@ -397,13 +397,26 @@ static int teo_select(struct cpuidle_dri * the shallowest non-polling state and exit. */ if (drv->state_count < 3 && cpu_data->utilized) { - for (i = 0; i < drv->state_count; ++i) { - if (!dev->states_usage[i].disable && - !(drv->states[i].flags & CPUIDLE_FLAG_POLLING)) { - idx = i; - goto end; - } - } + /* The CPU is utilized, so assume a short idle duration. */ + duration_ns = teo_middle_of_bin(0, drv); + /* + * If state 0 is enabled and it is not a polling one, select it + * right away unless the scheduler tick has been stopped, in + * which case care needs to be taken to leave the CPU in a + * deep enough state in case it is not woken up any time soon + * after all. + */ + if (!idx && !(drv->states[0].flags & CPUIDLE_FLAG_POLLING) && + teo_time_ok(duration_ns)) + goto end; + + /* + * Assume that state 1 is not a polling one and select it + * unless it is disabled, in which case state 0 must be used + * no matter what. + */ + idx = dev->states_usage[1].disable ? 0 : 1; + goto end; } /* @@ -539,10 +552,20 @@ static int teo_select(struct cpuidle_dri /* * If the CPU is being utilized over the threshold, choose a shallower - * non-polling state to improve latency + * non-polling state to improve latency, unless the scheduler tick has + * been stopped already and the shallower state's target residency is + * not sufficiently large. */ - if (cpu_data->utilized) - idx = teo_find_shallower_state(drv, dev, idx, duration_ns, true); + if (cpu_data->utilized) { + s64 span_ns; + + i = teo_find_shallower_state(drv, dev, idx, duration_ns, true); + span_ns = teo_middle_of_bin(i, drv); + if (teo_time_ok(span_ns)) { + idx = i; + duration_ns = span_ns; + } + } end: /* From patchwork Fri Jul 28 10:00:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 127510 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp333320vqg; Fri, 28 Jul 2023 03:25:23 -0700 (PDT) X-Google-Smtp-Source: APBJJlEESdlGjQmRUapE7IOc9GnQHB8LTkkk9Oo/mMl/2qp9koL1kKEfEgoTasQCvzuGxHrpb9Oq X-Received: by 2002:a17:90a:a60b:b0:268:7be6:29a5 with SMTP id c11-20020a17090aa60b00b002687be629a5mr1078855pjq.9.1690539923112; Fri, 28 Jul 2023 03:25:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690539923; cv=none; d=google.com; s=arc-20160816; b=LunLeDkQ6Ffezg6cNBL/y2EDJqVQAPZKdS5P0uleEIJcsDyFIRx8AmEitS1mxNYB+T kbm3cUapltzCQPmjS8fO+ExLXlXK5keVSOJTGvZ0y10ohflQ5HOaC3QcczkmDeJFLzJz 1WKOKQI5IStVvDe56u6TgAc6bZrPJH7n3mGSWd8J91iDWOA/dF4xDJuxpWcI8yfbRzy2 C/36ugpuHzOjA5vIW6ZdBC/d0u1ckdG5nxSO7hmAKDWTNOX90u4FmRx4SWGOze4Qdc31 fRt7vYTRYwU5eiQXyLk8BlOZp2mP2EXXgUxBxxgdjX8k4/XO8cE4SXZo2k5BfWmE1+sy nA6A== 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=TW3trZaYh1/5PAH+FUrKgla5fJVPScKo/LRPhACT22s=; fh=vcb1WTwJPUMTZX6OxkyO+5cKBEoTRHpgQZ5gmsle4eE=; b=p5bFlzCXrzB5g12Klmmmt6Yx8MbecyIhrqcZrx1H55vXgzVaQ4A/n6REvcsgZkA1nE gulTXe0Z0Ot69RUbzTXlMlp53KSgXTZKy21iHD5fNhpRm7b+Niy26GWRk1x92utiRqcZ unoglMCWgzxBw/bgFNXr85zMb6zUn7otVpsVPQcLQbLr58xOcaECPrXc+O7DVXPauOP2 K4RqtOUVIK4I2ylRUjiGY7mV8SccUJT8srUwK0g+pCK+YLR2+3xa61GjCZvflbReuEN5 yvnHuZTAxAbE2rIL+P5ZiZcrIduM7ZjmPg1dP9jcjMil0Gnz2BRSLIbidbRhStyj1q6g cHvQ== 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 n6-20020a17090a2bc600b0025eee012ca4si4463374pje.30.2023.07.28.03.25.10; Fri, 28 Jul 2023 03:25:23 -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 S231266AbjG1KCz (ORCPT + 99 others); Fri, 28 Jul 2023 06:02:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235349AbjG1KC3 (ORCPT ); Fri, 28 Jul 2023 06:02:29 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AE0149CA; Fri, 28 Jul 2023 03:01:59 -0700 (PDT) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.2.0) id da2d6a680178221d; Fri, 28 Jul 2023 12:01:57 +0200 Authentication-Results: v370.home.net.pl; spf=softfail (domain owner discourages use of this host) smtp.mailfrom=rjwysocki.net (client-ip=195.136.19.94; helo=[195.136.19.94]; envelope-from=rjw@rjwysocki.net; receiver=) Received: from kreacher.localnet (unknown [195.136.19.94]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 0B801661E3D; Fri, 28 Jul 2023 12:01:57 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Peter Zijlstra , Anna-Maria Behnsen , Frederic Weisbecker , Kajetan Puchalski Subject: [PATCH v2 2/3] cpuidle: teo: Avoid stopping the tick unnecessarily when bailing out Date: Fri, 28 Jul 2023 12:00:46 +0200 Message-ID: <3254124.aeNJFYEL58@kreacher> In-Reply-To: <5707588.DvuYhMxLoT@kreacher> References: <5707588.DvuYhMxLoT@kreacher> MIME-Version: 1.0 X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedviedrieeigddvtdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvffeuiedtgfdvtddugeeujedtffetteegfeekffdvfedttddtuefhgeefvdejhfenucfkphepudelhedrudefiedrudelrdelgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduleehrddufeeirdduledrleegpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeeipdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepphgvthgvrhiisehinhhfrhgruggvrggurdhorhhgpdhrtghpthhtoheprghnnhgrqdhmrghrihgrsehlihhnuhhtrhhonhhigidruggvpdhrtghpthhtohepfhhrvggu vghrihgtsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehkrghjvghtrghnrdhpuhgthhgrlhhskhhisegrrhhmrdgtohhm X-DCC--Metrics: v370.home.net.pl 1024; Body=6 Fuz1=6 Fuz2=6 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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: 1772659590750802721 X-GMAIL-MSGID: 1772659590750802721 From: Rafael J. Wysocki When teo_select() is going to return early in some special cases, make it avoid stopping the tick if the idle state to be returned is shallow. Signed-off-by: Rafael J. Wysocki --- drivers/cpuidle/governors/teo.c | 50 +++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 18 deletions(-) Index: linux-pm/drivers/cpuidle/governors/teo.c =================================================================== --- linux-pm.orig/drivers/cpuidle/governors/teo.c +++ linux-pm/drivers/cpuidle/governors/teo.c @@ -462,9 +462,9 @@ static int teo_select(struct cpuidle_dri /* Avoid unnecessary overhead. */ if (idx < 0) { idx = 0; /* No states enabled, must use 0. */ - goto end; + goto bail_out; } else if (idx == idx0) { - goto end; + goto bail_out; } /* @@ -547,8 +547,10 @@ static int teo_select(struct cpuidle_dri * If there is a latency constraint, it may be necessary to select an * idle state shallower than the current candidate one. */ - if (idx > constraint_idx) + if (idx > constraint_idx) { idx = constraint_idx; + goto bail_out; + } /* * If the CPU is being utilized over the threshold, choose a shallower @@ -569,23 +571,35 @@ static int teo_select(struct cpuidle_dri end: /* - * Don't stop the tick if the selected state is a polling one or if the - * expected idle duration is shorter than the tick period length. + * Allow the tick to be stopped unless the selected state is a polling + * one or the expected idle duration is shorter than the tick period + * length. */ - if (((drv->states[idx].flags & CPUIDLE_FLAG_POLLING) || - duration_ns < TICK_NSEC) && !tick_nohz_tick_stopped()) { - *stop_tick = false; + if ((!(drv->states[idx].flags & CPUIDLE_FLAG_POLLING) && + duration_ns >= TICK_NSEC) || tick_nohz_tick_stopped()) + return idx; - /* - * The tick is not going to be stopped, so if the target - * residency of the state to be returned is not within the time - * till the closest timer including the tick, try to correct - * that. - */ - if (idx > idx0 && - drv->states[idx].target_residency_ns > delta_tick) - idx = teo_find_shallower_state(drv, dev, idx, delta_tick, false); - } +retain_tick: + *stop_tick = false; + + /* + * The tick is not going to be stopped, so if the target residency of + * the state to be returned is not within the time till the closest + * timer including the tick, try to correct that. + */ + if (idx > idx0 && + drv->states[idx].target_residency_ns > delta_tick) + idx = teo_find_shallower_state(drv, dev, idx, delta_tick, false); + + return idx; + +bail_out: + /* + * Do not allow the tick to be stopped if the selected state is shallow + * enough. + */ + if (drv->states[idx].target_residency_ns < TICK_NSEC) + goto retain_tick; return idx; } From patchwork Fri Jul 28 10:01:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 127509 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp332533vqg; Fri, 28 Jul 2023 03:23:45 -0700 (PDT) X-Google-Smtp-Source: APBJJlF8fLWBiOYVD4+4RWVa0txwstf+Ot7Q1vTVKbh4+i5dxnoVxkCljhchrcbrJfd/xKa2M4bl X-Received: by 2002:a05:6a00:170f:b0:686:254c:9d4e with SMTP id h15-20020a056a00170f00b00686254c9d4emr1387172pfc.14.1690539824907; Fri, 28 Jul 2023 03:23:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690539824; cv=none; d=google.com; s=arc-20160816; b=Zfv/L3HB0wDC+flbcgDKIIvCy51JvkjJK4NVw85T5nPfIewwSjpHciuV6rYWPZXwZ4 U0ZNONNF1K98xJWp7amHchXvBL5IXwMcy/3d+bAbKUG/Fi9Fvo9I6KZIP4R2mopQ3Qm8 7KPYbBt0G3W7vDGGcAG2qtKC3Nz3+jsMZy3GTvwilU91DfOyjoB8xnpBuVRnAlxUMtIi +/7xiFZsVErkG4QT0E5cHCtdOG1K9gHyf2OzotwrdS+fDY06OX2MMxAPf34SXfm88buN 6ZPraOyhQd7EF37wdXSeMeDX9mxT+u4Z46v55lY5csPy461f+/ku28FG0PR2emdGc33T 4DIw== 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=1yAc5WAO3db+u1yX8svTIr/fj7/+HjS/BzsPMH3x58E=; fh=vcb1WTwJPUMTZX6OxkyO+5cKBEoTRHpgQZ5gmsle4eE=; b=jNL5wa/tZTus/bAKaEmmEEG7EAQow5Dfk7pssOQtHQiHmmLOU131NqfoI5LxduSXSC XNfyEyEOFlJwdePRwmXy0+/9LBSkuoUnQMnvJTdU4ajYnNW7Ho7ELHyXtE7/aITvLewU GLISfeKijBG6cXuXHDPA+cyVsc+jOUD7R0Vqt8l6586XjxGC0VwPOu0+ydjflL5ZvlY7 ysGKHLGJobwmjQAlLVtsEGMm11nRQm/i9Igo1hzySui4jRAFeS2aVaa/1JbrTKxfKEMa z4lVvZCf9XI9kXAaXqELiP2W6+6QKtSetizakPHi9058vuJ0a4dhmUoWfmi295y5ExKb oWDw== 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 o6-20020a637e46000000b0055f11843b1csi2838928pgn.142.2023.07.28.03.23.31; Fri, 28 Jul 2023 03:23:44 -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 S235675AbjG1KC7 (ORCPT + 99 others); Fri, 28 Jul 2023 06:02:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233106AbjG1KC3 (ORCPT ); Fri, 28 Jul 2023 06:02:29 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2924049C4; Fri, 28 Jul 2023 03:01:58 -0700 (PDT) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.2.0) id 392725c6ea6dcf7f; Fri, 28 Jul 2023 12:01:56 +0200 Authentication-Results: v370.home.net.pl; spf=softfail (domain owner discourages use of this host) smtp.mailfrom=rjwysocki.net (client-ip=195.136.19.94; helo=[195.136.19.94]; envelope-from=rjw@rjwysocki.net; receiver=) Received: from kreacher.localnet (unknown [195.136.19.94]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 29317661E37; Fri, 28 Jul 2023 12:01:56 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Peter Zijlstra , Anna-Maria Behnsen , Frederic Weisbecker , Kajetan Puchalski Subject: [PATCH v2 3/3] cpuidle: teo: Drop utilized from struct teo_cpu Date: Fri, 28 Jul 2023 12:01:49 +0200 Message-ID: <8262074.T7Z3S40VBb@kreacher> In-Reply-To: <5707588.DvuYhMxLoT@kreacher> References: <5707588.DvuYhMxLoT@kreacher> MIME-Version: 1.0 X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedviedrieeigddvtdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvffeuiedtgfdvtddugeeujedtffetteegfeekffdvfedttddtuefhgeefvdejhfenucfkphepudelhedrudefiedrudelrdelgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduleehrddufeeirdduledrleegpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeeipdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepphgvthgvrhiisehinhhfrhgruggvrggurdhorhhgpdhrtghpthhtoheprghnnhgrqdhmrghrihgrsehlihhnuhhtrhhonhhigidruggvpdhrtghpthhtohepfhhrvggu vghrihgtsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehkrghjvghtrghnrdhpuhgthhgrlhhskhhisegrrhhmrdgtohhm X-DCC--Metrics: v370.home.net.pl 1024; Body=6 Fuz1=6 Fuz2=6 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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: 1772659487452206828 X-GMAIL-MSGID: 1772659487452206828 From: Rafael J. Wysocki Because the utilized field in struct teo_cpu is only used locally in teo_select(), replace it with a local variable in that function. No intentional functional impact. Signed-off-by: Rafael J. Wysocki --- drivers/cpuidle/governors/teo.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) Index: linux-pm/drivers/cpuidle/governors/teo.c =================================================================== --- linux-pm.orig/drivers/cpuidle/governors/teo.c +++ linux-pm/drivers/cpuidle/governors/teo.c @@ -187,7 +187,6 @@ struct teo_bin { * @next_recent_idx: Index of the next @recent_idx entry to update. * @recent_idx: Indices of bins corresponding to recent "intercepts". * @util_threshold: Threshold above which the CPU is considered utilized - * @utilized: Whether the last sleep on the CPU happened while utilized */ struct teo_cpu { s64 time_span_ns; @@ -197,7 +196,6 @@ struct teo_cpu { int next_recent_idx; int recent_idx[NR_RECENT]; unsigned long util_threshold; - bool utilized; }; static DEFINE_PER_CPU(struct teo_cpu, teo_cpus); @@ -366,6 +364,7 @@ static int teo_select(struct cpuidle_dri int idx0 = 0, idx = -1; bool alt_intercepts, alt_recent; ktime_t delta_tick; + bool cpu_utilized; s64 duration_ns; int i; @@ -390,13 +389,13 @@ static int teo_select(struct cpuidle_dri goto end; } - cpu_data->utilized = teo_cpu_is_utilized(dev->cpu, cpu_data); + cpu_utilized = teo_cpu_is_utilized(dev->cpu, cpu_data); /* * If the CPU is being utilized over the threshold and there are only 2 * states to choose from, the metrics need not be considered, so choose * the shallowest non-polling state and exit. */ - if (drv->state_count < 3 && cpu_data->utilized) { + if (drv->state_count < 3 && cpu_utilized) { /* The CPU is utilized, so assume a short idle duration. */ duration_ns = teo_middle_of_bin(0, drv); /* @@ -558,7 +557,7 @@ static int teo_select(struct cpuidle_dri * been stopped already and the shallower state's target residency is * not sufficiently large. */ - if (cpu_data->utilized) { + if (cpu_utilized) { s64 span_ns; i = teo_find_shallower_state(drv, dev, idx, duration_ns, true);