Re: [PATCH 1/9] s390/idle: Fix cpu idle exit cpu time accounting

From: Frederic Weisbecker

Date: Wed Mar 04 2026 - 09:28:32 EST


Le Wed, Feb 18, 2026 at 03:20:04PM +0100, Heiko Carstens a écrit :
> With the conversion to generic entry [1] cpu idle exit cpu time accounting
> was converted from assembly to C. This introduced an reversed order of cpu
> time accounting.
>
> On cpu idle exit the current accounting happens with the following call
> chain:
>
> -> do_io_irq()/do_ext_irq()
> -> irq_enter_rcu()
> -> account_hardirq_enter()
> -> vtime_account_irq()
> -> vtime_account_kernel()
>
> vtime_account_kernel() accounts the passed cpu time since last_update_timer
> as system time, and updates last_update_timer to the current cpu timer
> value.
>
> However the subsequent call of
>
> -> account_idle_time_irq()
>
> will incorrectly subtract passed cpu time from timer_idle_enter to the
> updated last_update_timer value from system_timer. Then last_update_timer
> is updated to a sys_enter_timer, which means that last_update_timer goes
> back in time.
>
> Subsequently account_hardirq_exit() will account too much cpu time as
> hardirq time. The sum of all accounted cpu times is still correct, however
> some cpu time which was previously accounted as system time is now
> accounted as hardirq time, plus there is the oddity that last_update_timer
> goes back in time.
>
> Restore previous behavior by extracting cpu time accounting code from
> account_idle_time_irq() into a new update_timer_idle() function and call it
> before irq_enter_rcu().
>
> Fixes: 56e62a737028 ("s390: convert to generic entry") [1]
> Signed-off-by: Heiko Carstens <hca@xxxxxxxxxxxxx>

Reviewed-by: Frederic Weisbecker <frederic@xxxxxxxxxx>

--
Frederic Weisbecker
SUSE Labs