Skip to content

Commit a6fd161

Browse files
laoarPeter Zijlstra
authored andcommitted
sched, psi: Don't account irq time if sched_clock_irqtime is disabled
sched_clock_irqtime may be disabled due to the clock source. When disabled, irq_time_read() won't change over time, so there is nothing to account. We can save iterating the whole hierarchy on every tick and context switch. Signed-off-by: Yafang Shao <laoar.shao@gmail.com> Signed-off-by: Yafang Shao <laoar.shao@gmail.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Michal Koutný <mkoutny@suse.com> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Link: https://lore.kernel.org/r/20250103022409.2544-4-laoar.shao@gmail.com
1 parent 763a744 commit a6fd161

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

kernel/sched/psi.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,7 @@ void psi_account_irqtime(struct rq *rq, struct task_struct *curr, struct task_st
998998
s64 delta;
999999
u64 irq;
10001000

1001-
if (static_branch_likely(&psi_disabled))
1001+
if (static_branch_likely(&psi_disabled) || !irqtime_enabled())
10021002
return;
10031003

10041004
if (!curr->pid)
@@ -1240,6 +1240,11 @@ int psi_show(struct seq_file *m, struct psi_group *group, enum psi_res res)
12401240
if (static_branch_likely(&psi_disabled))
12411241
return -EOPNOTSUPP;
12421242

1243+
#ifdef CONFIG_IRQ_TIME_ACCOUNTING
1244+
if (!irqtime_enabled() && res == PSI_IRQ)
1245+
return -EOPNOTSUPP;
1246+
#endif
1247+
12431248
/* Update averages before reporting them */
12441249
mutex_lock(&group->avgs_lock);
12451250
now = sched_clock();

0 commit comments

Comments
 (0)