Re: [PATCH] sched/cputime: exclude ktimer threads in irqtime_account_irq

From: Steven Rostedt
Date: Mon Nov 27 2023 - 13:07:39 EST


On Fri, 24 Nov 2023 14:34:50 +0800
tiozhang <tiozhang@xxxxxxxxxxxxxx> wrote:

> diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
> index af7952f12e6c..0fac0109d151 100644
> --- a/kernel/sched/cputime.c
> +++ b/kernel/sched/cputime.c
> @@ -73,7 +73,12 @@ void irqtime_account_irq(struct task_struct *curr, unsigned int offset)
> */
> if (pc & HARDIRQ_MASK)
> irqtime_account_delta(irqtime, delta, CPUTIME_IRQ);
> +#ifdef CONFIG_PREEMPT_RT
> + else if ((pc & SOFTIRQ_OFFSET) && curr != this_cpu_ksoftirqd()
> + && curr != this_cpu_ktimers())
> +#else
> else if ((pc & SOFTIRQ_OFFSET) && curr != this_cpu_ksoftirqd())
> +#endif
> irqtime_account_delta(irqtime, delta, CPUTIME_SOFTIRQ);
> }

If the above is necessary, it would look nicer as:

else if (((pc & SOFTIRQ_OFFSET) && curr != this_cpu_ksoftirqd() &&
(!IS_ENABLED(CONFIG_PREEMPT_RT) || curr != this_cpu_ktimers()))

-- Steve