Re: [PATCH linux-next] sched/psi: Avoid update triggers and rtpoll_total when it is unnecessary

From: yang.yang29
Date: Thu Sep 14 2023 - 01:53:57 EST


Please see this version, thanks.

---
kernel/sched/psi.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c
index 81fca77397f6..3fe96d77f275 100644
--- a/kernel/sched/psi.c
+++ b/kernel/sched/psi.c
@@ -434,7 +434,7 @@ static u64 window_update(struct psi_window *win, u64 now, u64 value)
return growth;
}

-static u64 update_triggers(struct psi_group *group, u64 now, bool *update_total,
+static void update_triggers(struct psi_group *group, u64 now, bool *update_total,
enum psi_aggregators aggregator)
{
struct psi_trigger *t;
@@ -499,8 +499,6 @@ static u64 update_triggers(struct psi_group *group, u64 now, bool *update_total,
/* Reset threshold breach flag once event got generated */
t->pending_event = false;
}
-
- return now + group->rtpoll_min_period;
}

static u64 update_averages(struct psi_group *group, u64 now)
@@ -702,10 +700,14 @@ static void psi_rtpoll_work(struct psi_group *group)
}

if (now >= group->rtpoll_next_update) {
- group->rtpoll_next_update = update_triggers(group, now, &update_total, PSI_POLL);
- if (update_total)
- memcpy(group->rtpoll_total, group->total[PSI_POLL],
- sizeof(group->rtpoll_total));
+ group->rtpoll_next_update = now + group->rtpoll_min_period;
+
+ if (changed_states & group->rtpoll_states) {
+ update_triggers(group, now, &update_total, PSI_POLL);
+ if (update_total)
+ memcpy(group->rtpoll_total, group->total[PSI_POLL],
+ sizeof(group->rtpoll_total));
+ }
}

psi_schedule_rtpoll_work(group,
--
2.25.1