]> www.infradead.org Git - linux-platform-drivers-x86.git/commitdiff
irqtime: Make accounting correct on RT
authorThomas Gleixner <tglx@linutronix.de>
Tue, 9 Mar 2021 08:55:54 +0000 (09:55 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 17 Mar 2021 15:34:09 +0000 (16:34 +0100)
vtime_account_irq and irqtime_account_irq() base checks on preempt_count()
which fails on RT because preempt_count() does not contain the softirq
accounting which is seperate on RT.

These checks do not need the full preempt count as they only operate on the
hard and softirq sections.

Use irq_count() instead which provides the correct value on both RT and non
RT kernels. The compiler is clever enough to fold the masking for !RT:

       99b: 65 8b 05 00 00 00 00  mov    %gs:0x0(%rip),%eax
 -     9a2: 25 ff ff ff 7f        and    $0x7fffffff,%eax
 +     9a2: 25 00 ff ff 00        and    $0xffff00,%eax

Reported-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Tested-by: Paul E. McKenney <paulmck@kernel.org>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20210309085727.153926793@linutronix.de
kernel/sched/cputime.c

index 5f611658eeab1be91dda5177d5359892e2dfdff9..2c36a5fad58912a4c1b27b4f5f8b0f3312e82b6d 100644 (file)
@@ -60,7 +60,7 @@ void irqtime_account_irq(struct task_struct *curr, unsigned int offset)
        cpu = smp_processor_id();
        delta = sched_clock_cpu(cpu) - irqtime->irq_start_time;
        irqtime->irq_start_time += delta;
-       pc = preempt_count() - offset;
+       pc = irq_count() - offset;
 
        /*
         * We do not account for softirq time from ksoftirqd here.
@@ -421,7 +421,7 @@ void vtime_task_switch(struct task_struct *prev)
 
 void vtime_account_irq(struct task_struct *tsk, unsigned int offset)
 {
-       unsigned int pc = preempt_count() - offset;
+       unsigned int pc = irq_count() - offset;
 
        if (pc & HARDIRQ_OFFSET) {
                vtime_account_hardirq(tsk);