Linux Power Management development
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux PM <linux-pm@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Anna-Maria Behnsen <anna-maria@linutronix.de>,
	Doug Smythies <dsmythies@telus.net>,
	Kajetan Puchalski <kajetan.puchalski@arm.com>,
	Peter Zijlstra <peterz@infradead.org>
Subject: [PATCH v1] cpuidle: teo: Avoid unnecessary variable assignments
Date: Tue, 22 Aug 2023 13:28:02 +0200	[thread overview]
Message-ID: <12275754.O9o76ZdvQC@kreacher> (raw)

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Notice that it is not necessary to assign tick_intercept_sum in every
iteration of the first loop over idle states in teo_select(), because
the intercept_sum value does not change after the assignment in a
given iteration of the loop, so its value after the last iteration of
the loop can be used for computing the tick_intercept_sum value
directly.

Modify the code accordingly.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---

This is based on the pm-cpuidle-gov branch in linux-pm.git (which is included
into linux-next too).

---
 drivers/cpuidle/governors/teo.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Index: linux-pm/drivers/cpuidle/governors/teo.c
===================================================================
--- linux-pm.orig/drivers/cpuidle/governors/teo.c
+++ linux-pm/drivers/cpuidle/governors/teo.c
@@ -450,8 +450,6 @@ static int teo_select(struct cpuidle_dri
 		hit_sum += prev_bin->hits;
 		recent_sum += prev_bin->recent;
 
-		tick_intercept_sum = intercept_sum;
-
 		if (dev->states_usage[i].disable)
 			continue;
 
@@ -484,7 +482,8 @@ static int teo_select(struct cpuidle_dri
 		goto end;
 	}
 
-	tick_intercept_sum += cpu_data->state_bins[drv->state_count-1].intercepts;
+	tick_intercept_sum = intercept_sum +
+			cpu_data->state_bins[drv->state_count-1].intercepts;
 
 	/*
 	 * If the sum of the intercepts metric for all of the idle states




                 reply	other threads:[~2023-08-22 11:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=12275754.O9o76ZdvQC@kreacher \
    --to=rjw@rjwysocki.net \
    --cc=anna-maria@linutronix.de \
    --cc=dsmythies@telus.net \
    --cc=kajetan.puchalski@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox