Skip to contentSkip to conversation

sched/psi: avoid resetting the min update period when it is unnecessary

PATCH Applied Suren Baghdasaryan 3 participants 3 messages May 14, 2023 – May 22, 2023

Subsystems (2)
lore
Share & tools
lore

Suren Baghdasaryan

author maintainer
#0 lore raw

PATCH 1/1 sched/psi: avoid resetting the min update period when it is unnecessary

From: Yang Yang <[email protected]>

Psi_group's poll_min_period is determined by the minimum 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 psi_trigger being destroyed did not have the minimum window size, since in this condition poll_min_period will remain the same as before.

---
rebase of https://lore.kernel.org/all/[email protected]/
over git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git sched/core branch

 kernel/sched/psi.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
kernel/sched/psi.c +10 -5
index b49af594ad28..81fca77397f6 100644
@@ -1407,11 +1407,16 @@ void psi_trigger_destroy(struct psi_trigger *t)
 			group->rtpoll_nr_triggers[t->state]--;
 			if (!group->rtpoll_nr_triggers[t->state])
 				group->rtpoll_states &= ~(1 << t->state);
-			/* reset min update period for the remaining triggers */
-			list_for_each_entry(tmp, &group->rtpoll_triggers, node)
-				period = min(period, div_u64(tmp->win.size,
-						UPDATES_PER_WINDOW));
-			group->rtpoll_min_period = period;
+			/*
+			 * Reset min update period for the remaining triggers
+			 * iff the destroying trigger had the min window size.
+			 */
+			if (group->rtpoll_min_period == div_u64(t->win.size, UPDATES_PER_WINDOW)) {
+				list_for_each_entry(tmp, &group->rtpoll_triggers, node)
+					period = min(period, div_u64(tmp->win.size,
+							UPDATES_PER_WINDOW));
+				group->rtpoll_min_period = period;
+			}
 			/* Destroy rtpoll_task when the last trigger is destroyed */
 			if (group->rtpoll_states == 0) {
 				group->rtpoll_until = 0;
Signature · 1 line
2.40.1.606.ga4b1b128d6-goog
maintainer
#1 lore raw
Quoted 8 lines · Suren Baghdasaryan

From: Yang Yang <[email protected]>

Psi_group's poll_min_period is determined by the minimum 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 psi_trigger being destroyed did not have the minimum window size, since in this condition poll_min_period will remain the same as before.

Quoted 5 lines

---
rebase of https://lore.kernel.org/all/[email protected]/
over git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git sched/core branch

Thanks!

merge bot Applied
#2 lore raw

[tip: sched/core] sched/psi: Avoid resetting the min update period when it is unnecessary

In reply to Suren Baghdasaryan
The following commit has been merged into the sched/core branch of tip:

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     e2a1f85bf9f509afd09b5d3308e3489b65845c28
Gitweb:        https://git.kernel.org/tip/e2a1f85bf9f509afd09b5d3308e3489b65845c28
Author:        Yang Yang <[email protected]>
AuthorDate:    Sun, 14 May 2023 09:33:38 -07:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Sat, 20 May 2023 12:53:16 +02:00

sched/psi: Avoid resetting the min update period when it is unnecessary

Psi_group's poll_min_period is determined by the minimum 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 psi_trigger being destroyed did not have the minimum window size, since in this condition poll_min_period will remain the same as before.

---
 kernel/sched/psi.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
kernel/sched/psi.c +10 -5
index b49af59..81fca77 100644
@@ -1407,11 +1407,16 @@ void psi_trigger_destroy(struct psi_trigger *t)
 			group->rtpoll_nr_triggers[t->state]--;
 			if (!group->rtpoll_nr_triggers[t->state])
 				group->rtpoll_states &= ~(1 << t->state);
-			/* reset min update period for the remaining triggers */
-			list_for_each_entry(tmp, &group->rtpoll_triggers, node)
-				period = min(period, div_u64(tmp->win.size,
-						UPDATES_PER_WINDOW));
-			group->rtpoll_min_period = period;
+			/*
+			 * Reset min update period for the remaining triggers
+			 * iff the destroying trigger had the min window size.
+			 */
+			if (group->rtpoll_min_period == div_u64(t->win.size, UPDATES_PER_WINDOW)) {
+				list_for_each_entry(tmp, &group->rtpoll_triggers, node)
+					period = min(period, div_u64(tmp->win.size,
+							UPDATES_PER_WINDOW));
+				group->rtpoll_min_period = period;
+			}
 			/* Destroy rtpoll_task when the last trigger is destroyed */
 			if (group->rtpoll_states == 0) {
 				group->rtpoll_until = 0;