Skip to contentSkip to conversation

psi: Fix trigger being fired unexpectedly at initial

PATCH Applied Hailong Liu 4 participants 4 messages Apr 1, 2022 – Apr 22, 2022

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

PATCH 1/1 psi: Fix trigger being fired unexpectedly at initial

When a trigger being created, its win.start_value and win.start_time are reset to zero. If group->total[PSI_POLL][t->state] has accumulated before, this trigger will be fired unexpectedly in the next period, even if its growth time does not reach its threshold.

So set the window of the new trigger to the current state value.

---
 kernel/sched/psi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/sched/psi.c +2 -1
index a4fa3aadfcba..5a49a8c8783e 100644
@@ -1117,7 +1117,8 @@ struct psi_trigger *psi_trigger_create(struct psi_group *group,
 	t->state = state;
 	t->threshold = threshold_us * NSEC_PER_USEC;
 	t->win.size = window_us * NSEC_PER_USEC;
-	window_reset(&t->win, 0, 0, 0);
+	window_reset(&t->win, sched_clock(),
+			group->total[PSI_POLL][t->state], 0);
 
 	t->event = 0;
 	t->last_event_time = 0;
Signature · 1 line
2.19.1.6.gb485710b
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Hailong Liu

When a trigger being created, its win.start_value and win.start_time are reset to zero. If group->total[PSI_POLL][t->state] has accumulated before, this trigger will be fired unexpectedly in the next period, even if its growth time does not reach its threshold.

So set the window of the new trigger to the current state value.

Makes sense to me. Thanks!

Quoted 2 lines
Quoted 21 lines
---
 kernel/sched/psi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/sched/psi.c +2 -2
index a4fa3aadfcba..5a49a8c8783e 100644
@@ -1117,7 +1117,8 @@ struct psi_trigger *psi_trigger_create(struct psi_group *group,
        t->state = state;
        t->threshold = threshold_us * NSEC_PER_USEC;
        t->win.size = window_us * NSEC_PER_USEC;
-       window_reset(&t->win, 0, 0, 0);
+       window_reset(&t->win, sched_clock(),
+                       group->total[PSI_POLL][t->state], 0);
 
        t->event = 0;
        t->last_event_time = 0;
--

2.19.1.6.gb485710b

maintainer
#2 lore raw
Quoted 8 lines · Suren Baghdasaryan
Quoted 6 lines · Hailong Liu

When a trigger being created, its win.start_value and win.start_time are reset to zero. If group->total[PSI_POLL][t->state] has accumulated before, this trigger will be fired unexpectedly in the next period, even if its growth time does not reach its threshold.

Quoted 8 lines
Quoted 1 line

So set the window of the new trigger to the current state value.

Makes sense to me. Thanks!

Quoted 2 lines

Thanks!

merge bot Applied
#3 lore raw
In reply to Hailong Liu
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:     915a087e4c47334a2f7ba2a4092c4bade0873769
Gitweb:        https://git.kernel.org/tip/915a087e4c47334a2f7ba2a4092c4bade0873769
Author:        Hailong Liu <[email protected]>
AuthorDate:    Fri, 01 Apr 2022 13:10:11 +08:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Fri, 22 Apr 2022 12:14:06 +02:00

psi: Fix trigger being fired unexpectedly at initial

When a trigger being created, its win.start_value and win.start_time are reset to zero. If group->total[PSI_POLL][t->state] has accumulated before, this trigger will be fired unexpectedly in the next period, even if its growth time does not reach its threshold.

So set the window of the new trigger to the current state value.

---
 kernel/sched/psi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/sched/psi.c +2 -1
index a4fa3aa..5a49a8c 100644
@@ -1117,7 +1117,8 @@ struct psi_trigger *psi_trigger_create(struct psi_group *group,
 	t->state = state;
 	t->threshold = threshold_us * NSEC_PER_USEC;
 	t->win.size = window_us * NSEC_PER_USEC;
-	window_reset(&t->win, 0, 0, 0);
+	window_reset(&t->win, sched_clock(),
+			group->total[PSI_POLL][t->state], 0);
 
 	t->event = 0;
 	t->last_event_time = 0;