psi: Use ONCPU state tracking machinery to detect reclaim
Subsystems (2)
PATCH v2 1/1 psi: Use ONCPU state tracking machinery to detect reclaim
Move the reclaim detection from the timer tick to the task state tracking machinery using the recently added ONCPU state. And we also add task psi_flags changes checking in the psi_task_switch() optimization to update the parents properly.
In terms of performance and cost, this ONCPU task state tracking is not cheaper than previous timer tick in aggregate. But the code is simpler and shorter this way, so it's a maintainability win. And Johannes did some testing with perf bench, the performace and cost changes would be acceptable for real workloads.
Thanks to Johannes Weiner for pointing out the psi_task_switch() optimization things and the clearer changelog.
Updates since v1:
- Fold changes from Johannes that compare task psi_flags instead of in_memstall in the psi_task_switch() optimization and move it out of the loop
- Include some comments about the performance and cost from Johannes too, and the detailed bench results can be seen from here:
https://lore.kernel.org/patchwork/patch/1378653/#1577607
--- include/linux/psi.h | 1 - kernel/sched/core.c | 1 - kernel/sched/psi.c | 65 +++++++++++++++++++--------------------------------- kernel/sched/stats.h | 9 -------- 4 files changed, 24 insertions(+), 52 deletions(-)
include/linux/psi.h +0 -1
@@ -20,7 +20,6 @@ void psi_task_change(struct task_struct *task, int clear, int set);void psi_task_switch (struct task_struct *prev,struct task_struct *next,bool sleep); -void psi_memstall_tick (struct task_struct *task,int cpu);void psi_memstall_enter (unsigned long *flags);void psi_memstall_leave (unsigned long *flags);
kernel/sched/core.c +0 -1
@@ -4533,7 +4533,6 @@ void scheduler_tick(void)update_thermal_load_avg (rq_clock_thermal (rq), rq, thermal_pressure); curr->sched_class->task_tick (rq, curr,0 );calc_global_load_tick (rq); -psi_task_tick (rq);rq_unlock (rq, &rf);
kernel/sched/psi.c +24 -41
106 lines not on this page · raw message
kernel/sched/stats.h +0 -9
@@ -144,14 +144,6 @@ static inline void psi_sched_switch(struct task_struct *prev, psi_task_switch(prev, next, sleep); } -static inline void psi_task_tick (struct rq *rq) -{ -if (static_branch_likely (&psi_disabled)) -return ; - -if (unlikely (rq->curr->in_memstall)) -psi_memstall_tick (rq->curr,cpu_of (rq)); -}#else /* CONFIG_PSI */ static inline void psi_enqueue (struct task_struct *p,bool wakeup) {}static inline void psi_dequeue (struct task_struct *p,bool sleep) {}
@@ -159,7 +151,6 @@ static inline void psi_ttwu_dequeue(struct task_struct *p) {}static inline void psi_sched_switch (struct task_struct *prev,struct task_struct *next,bool sleep) {} -static inline void psi_task_tick (struct rq *rq) {}#endif /* CONFIG_PSI */ #ifdef CONFIG_SCHED_INFO
Signature · 1 line
2.11.0