mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] sched/cputime: exclude ktimer threads in irqtime_account_irq
@ 2023-11-24  6:34 tiozhang
  2023-11-27 18:07 ` Steven Rostedt
  0 siblings, 1 reply; 17+ messages in thread
From: tiozhang @ 2023-11-24  6:34 UTC (permalink / raw)
  To: bigeasy, tglx, rostedt, mingo, peterz, juri.lelli, vincent.guittot
  Cc: linux-kernel, dietmar.eggemann, rostedt, bsegall, mgorman,
	bristot, vschneid, zyhtheonly, tiozhang, zyhtheonly

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


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2023-12-15 18:30 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-24  6:34 [PATCH] sched/cputime: exclude ktimer threads in irqtime_account_irq tiozhang
2023-11-27 18:07 ` Steven Rostedt
2023-11-30  9:41   ` [PATCH v2] sched/cputime: exclude ktimers " tiozhang
2023-11-30 12:00     ` Sebastian Andrzej Siewior
2023-12-01  7:27       ` Yuanhan Zhang
2023-12-01  7:32         ` Sebastian Andrzej Siewior
2023-12-01  8:05           ` [PATCH v3] sched/cputime: let ktimers align with ksoftirqd in accounting CPUTIME_SOFTIRQ tiozhang
2023-12-01 16:16             ` Sebastian Andrzej Siewior
2023-12-02 10:28               ` Yuanhan Zhang
2023-12-05 15:31                 ` Sebastian Andrzej Siewior
2023-12-07 10:43                   ` Yuanhan Zhang
2023-12-07 15:35                     ` Steven Rostedt
2023-12-07 17:19                       ` Yuanhan Zhang
2023-12-07 18:18                         ` Steven Rostedt
2023-12-08  9:26                           ` Sebastian Andrzej Siewior
2023-12-11 12:02                             ` [PATCH v4] sched/cputime: account ksoftirqd's time on SYSTEM in PREEMPT_RT Tio Zhang
2023-12-15 18:30                             ` [PATCH v3] sched/cputime: let ktimers align with ksoftirqd in accounting CPUTIME_SOFTIRQ Yuanhan Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®