From: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
To: Aboorva Devarajan <aboorvad@linux.ibm.com>,
Madhavan Srinivasan <maddy@linux.ibm.com>,
linuxppc-dev@lists.ozlabs.org,
Mukesh Kumar Chaurasiya <mchauras@linux.ibm.com>
Cc: Christophe Leroy <chleroy@kernel.org>,
Shrikanth Hegde <sshegde@linux.ibm.com>,
linux-kernel@vger.kernel.org,
"Nysal Jan K . A ." <nysal@linux.ibm.com>,
Aboorva Devarajan <aboorvad@linux.ibm.com>
Subject: Re: [PATCH v2] powerpc/entry: Fix double accounting of user time on interrupt entry
Date: Sat, 05 Sep 2026 10:01:35 +0530 [thread overview]
Message-ID: <cxustj2w.ritesh.list@gmail.com> (raw)
In-Reply-To: <20260904025831.3439809-1-aboorvad@linux.ibm.com>
Aboorva Devarajan <aboorvad@linux.ibm.com> writes:
> Since the switch to generic entry, an interrupt from user mode
> accounts user time twice: once in arch_interrupt_enter_prepare()
> and again in arch_enter_from_user_mode(), which irqentry_enter()
> invokes for the same interrupt:
>
> arch_interrupt_enter_prepare()
> account_cpu_user_entry() /* first */
> irqentry_enter()
> arch_enter_from_user_mode()
> account_cpu_user_entry() /* second */
>
> The second call charges the same interval again, because
> account_cpu_user_entry() accumulates the time spent in user mode
> since the last return to user space.
>
> The two calls come from the GENERIC_ENTRY preparation series,
> where each step was a no-op on its own. Commit 09a9d3a8499d
> ("powerpc: introduce arch_enter_from_user_mode") added the hook
> with the user-time accounting in it, but nothing called it yet.
> Commit 893082ac769b ("powerpc: Prepare for IRQ entry exit")
> copied interrupt_enter_prepare() verbatim into entry-common.h as
> arch_interrupt_enter_prepare(); that copy was equally unused, as
> handlers still called interrupt_enter_prepare().
>
> Commit bee25f97ad24 ("powerpc: Enable GENERIC_ENTRY feature")
> made both live. On the syscall side it did the full conversion:
> system_call_exception() now accounts once through the hook via
> syscall_enter_from_user_mode(), rather than calling
> account_cpu_user_entry() directly. On the interrupt side it
> switched the handler macros to arch_interrupt_enter_prepare()
> followed by irqentry_enter(), which also runs the hook, but the
> accounting in arch_interrupt_enter_prepare() was not removed to
> match. The double accounting starts with that commit.
>
> With CONFIG_VIRT_CPU_ACCOUNTING_NATIVE=y this roughly doubles the
> reported user time of any workload that takes interrupts. The
> other accounting modes compile account_cpu_user_entry() to an
> empty stub, so they are not affected.
>
> Remove the accounting from arch_interrupt_enter_prepare() and rely
> on arch_enter_from_user_mode(), which already runs for both
> syscalls and interrupts. The duplicate account_stolen_time() call
> is removed the same way.
>
> On a pseries LPAR a busy loop reports 6s user time in 3s elapsed
> (~210% CPU) before the fix, and 3s (~105% CPU) after it:
>
> $ python3 -c 'while True: pass' &
> $ sleep 3; ps -p $! -o etime,time,pcpu
>
> ELAPSED TIME %CPU
> Before 00:03 00:00:06 210
> After 00:03 00:00:03 105
>
> A 50% load reports ~70% usr / 30% idle before the fix, and
> ~49% usr / 51% idle after it:
>
> $ taskset -c 6 stress-ng --cpu 1 --cpu-load 50 &
> $ mpstat -P 6 1
>
> CPU %usr %idle
> Before 6 69.74 30.26
> After 6 48.51 50.50
>
> Fixes: bee25f97ad24 ("powerpc: Enable GENERIC_ENTRY feature")
> Reviewed-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
> Signed-off-by: Aboorva Devarajan <aboorvad@linux.ibm.com>
> ---
Looks good. Thanks for the descritive commit msg!
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
prev parent reply other threads:[~2026-09-05 4:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 2:58 Aboorva Devarajan
2026-09-04 6:09 ` Christophe Leroy (CS GROUP)
2026-09-05 4:31 ` Ritesh Harjani [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cxustj2w.ritesh.list@gmail.com \
--to=ritesh.list@gmail.com \
--cc=aboorvad@linux.ibm.com \
--cc=chleroy@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mchauras@linux.ibm.com \
--cc=nysal@linux.ibm.com \
--cc=sshegde@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®