lkml.org 
[lkml]   [2023]   [Nov]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] sched/cputime: exclude ktimer threads in irqtime_account_irq
In CONFIG_PREEMPT_RT kernel, ktimer threads need to be excluded as well as
ksoftirqd when accounting CPUTIME_SOFTIRQ in irqtime_account_irq.
Also add this_cpu_ktimers to keep consistency with this_cpu_ksoftirqd.

Signed-off-by: tiozhang <tiozhang@didiglobal.com>
---
include/linux/interrupt.h | 5 +++++
kernel/sched/cputime.c | 5 +++++
2 files changed, 10 insertions(+)

diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index a5091ac97fc6..a88646acaf3f 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -621,6 +621,11 @@ static inline unsigned int local_pending_timers(void)
return __this_cpu_read(pending_timer_softirq);
}

+static inline struct task_struct *this_cpu_ktimers(void)
+{
+ return this_cpu_read(timersd);
+}
+
#else
static inline void raise_timer_softirq(void)
{
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);
}

--
2.17.1
\
 
 \ /
  Last update: 2023-11-24 07:39    [W:0.166 / U:0.940 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site