Skip to contentSkip to conversation

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

PATCH RESEND In review [email protected] 3 participants 4 messages May 12, 2023 – May 14, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 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.

---
 kernel/sched/psi.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
kernel/sched/psi.c +10 -5
index 02e011cabe91..12869585cf89 100644
@@ -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;
Signature · 1 line
2.25.1
#1 lore raw
Quoted 11 lines · On Fri, May 12, 2023 at 1:42 AM <[email protected]> wrote:

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.

Hi Peter,
This is another psi-related patch that slipped through the cracks. Could you please take it into your tree? The original one [1] had a different title but the same code.
Thanks,
Suren.

[1] https://lore.kernel.org/all/[email protected]/

Quoted 32 lines
---
 kernel/sched/psi.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
kernel/sched/psi.c +10 -6
index 02e011cabe91..12869585cf89 100644
@@ -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

maintainer
#2 lore raw
Quoted 10 lines · Suren Baghdasaryan
Quoted 9 lines · On Fri, May 12, 2023 at 1:42 AM <[email protected]> wrote:

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 7 lines
Quoted 2 lines

Hi Peter,
This is another psi-related patch that slipped through the cracks. Could you please take it into your tree? The original one [1] had a different title but the same code.

It does not cleanly apply to tip/sched/core; could either of you rebase please?

Thanks!

#3 lore raw
Quoted 15 lines · Peter Zijlstra
Quoted 13 lines · Suren Baghdasaryan
Quoted 11 lines · On Fri, May 12, 2023 at 1:42 AM <[email protected]> wrote:

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 7 lines
Quoted 4 lines

Hi Peter,
This is another psi-related patch that slipped through the cracks. Could you please take it into your tree? The original one [1] had a different title but the same code.

It does not cleanly apply to tip/sched/core; could either of you rebase please?

Rebase is posted here:
https://lore.kernel.org/all/[email protected]/
Thanks!

Quoted 2 lines

Thanks!