All of lore.kernel.org
 help / color / mirror / Atom feed
From: <yang.yang29@zte.com.cn>
To: <hannes@cmpxchg.org>, <surenb@google.com>
Cc: <mingo@redhat.com>, <linux-kernel@vger.kernel.org>,
	<juri.lelli@redhat.com>
Subject: [PATCH linux-next] sched/psi: avoid unnecessary resetting min update period when destroy trigger
Date: Mon, 17 Apr 2023 16:11:54 +0800 (CST)	[thread overview]
Message-ID: <202304171611545861530@zte.com.cn> (raw)

From: Yang Yang <yang.yang19@zte.com.cn>

Psi_group's poll_min_period is determined by the min window size of
psi_trigger when creating new triggers. While destroying a psi_trigger,
there is no need to reset poll_min_period if the destroying psi_trigger
not had the min windows size, since in this condition poll_min_period
will keep the same as before.

Signed-off-by: Yang Yang <yang.yang29@zte.com.cn>
---
 kernel/sched/psi.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c
index 02e011cabe91..12869585cf89 100644
--- a/kernel/sched/psi.c
+++ b/kernel/sched/psi.c
@@ -1359,11 +1359,16 @@ void psi_trigger_destroy(struct psi_trigger *t)
 		group->nr_triggers[t->state]--;
 		if (!group->nr_triggers[t->state])
 			group->poll_states &= ~(1 << t->state);
-		/* reset min update period for the remaining triggers */
-		list_for_each_entry(tmp, &group->triggers, node)
-			period = min(period, div_u64(tmp->win.size,
-					UPDATES_PER_WINDOW));
-		group->poll_min_period = period;
+		/*
+		 * Reset min update period for the remaining triggers iff the destroying
+		 * trigger had the min window size.
+		 */
+		if (group->poll_min_period == div_u64(t->win.size, UPDATES_PER_WINDOW)) {
+			list_for_each_entry(tmp, &group->triggers, node)
+				period = min(period, div_u64(tmp->win.size,
+						UPDATES_PER_WINDOW));
+			group->poll_min_period = period;
+		}
 		/* Destroy poll_task when the last trigger is destroyed */
 		if (group->poll_states == 0) {
 			group->polling_until = 0;
-- 
2.25.1

             reply	other threads:[~2023-04-17  8:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-17  8:11 yang.yang29 [this message]
2023-04-17 19:04 ` [PATCH linux-next] sched/psi: avoid unnecessary resetting min update period when destroy trigger Suren Baghdasaryan
2023-04-26  3:18   ` Yang Yang
2023-04-26  3:23   ` Yang Yang
2023-04-26  3:31   ` Yang Yang
2023-04-26  5:08     ` Suren Baghdasaryan

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=202304171611545861530@zte.com.cn \
    --to=yang.yang29@zte.com.cn \
    --cc=hannes@cmpxchg.org \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=surenb@google.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.