Skip to content

Commit 4468fca

Browse files
lellomanPeter Zijlstra
authored andcommitted
sched/psi: Extract update_triggers side effect
This change moves update_total flag out of update_triggers function, currently called only in psi_poll_work. In the next patch, update_triggers will be called also in psi_avgs_work, but the total update information is specific to psi_poll_work. Returning update_total value to the caller let us avoid differentiating the implementation of update_triggers for different aggregators. Suggested-by: Johannes Weiner <hannes@cmpxchg.org> Signed-off-by: Domenico Cerasuolo <cerasuolodomenico@gmail.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Link: https://lore.kernel.org/r/20230330105418.77061-4-cerasuolodomenico@gmail.com
1 parent 65457b7 commit 4468fca

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

kernel/sched/psi.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -430,11 +430,11 @@ static u64 window_update(struct psi_window *win, u64 now, u64 value)
430430
return growth;
431431
}
432432

433-
static u64 update_triggers(struct psi_group *group, u64 now)
433+
static u64 update_triggers(struct psi_group *group, u64 now, bool *update_total)
434434
{
435435
struct psi_trigger *t;
436-
bool update_total = false;
437436
u64 *total = group->total[PSI_POLL];
437+
*update_total = false;
438438

439439
/*
440440
* On subsequent updates, calculate growth deltas and let
@@ -462,7 +462,7 @@ static u64 update_triggers(struct psi_group *group, u64 now)
462462
* been through all of them. Also remember to extend the
463463
* polling time if we see new stall activity.
464464
*/
465-
update_total = true;
465+
*update_total = true;
466466

467467
/* Calculate growth since last update */
468468
growth = window_update(&t->win, now, total[t->state]);
@@ -485,10 +485,6 @@ static u64 update_triggers(struct psi_group *group, u64 now)
485485
t->pending_event = false;
486486
}
487487

488-
if (update_total)
489-
memcpy(group->rtpoll_total, total,
490-
sizeof(group->rtpoll_total));
491-
492488
return now + group->rtpoll_min_period;
493489
}
494490

@@ -622,6 +618,7 @@ static void psi_rtpoll_work(struct psi_group *group)
622618
{
623619
bool force_reschedule = false;
624620
u32 changed_states;
621+
bool update_total;
625622
u64 now;
626623

627624
mutex_lock(&group->rtpoll_trigger_lock);
@@ -686,8 +683,12 @@ static void psi_rtpoll_work(struct psi_group *group)
686683
goto out;
687684
}
688685

689-
if (now >= group->rtpoll_next_update)
690-
group->rtpoll_next_update = update_triggers(group, now);
686+
if (now >= group->rtpoll_next_update) {
687+
group->rtpoll_next_update = update_triggers(group, now, &update_total);
688+
if (update_total)
689+
memcpy(group->rtpoll_total, group->total[PSI_POLL],
690+
sizeof(group->rtpoll_total));
691+
}
691692

692693
psi_schedule_rtpoll_work(group,
693694
nsecs_to_jiffies(group->rtpoll_next_update - now) + 1,

0 commit comments

Comments
 (0)