From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B442DC79F9E for ; Mon, 7 Sep 2026 07:06:51 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4hddRG28Hfz2yvX; Mon, 07 Sep 2026 17:06:50 +1000 (AEST) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1788764810; cv=none; b=H5+wa+ki8t5ZcYRwDdJX1+t0sLxETXdk4XQqOQBbITrSr6F/0UjrrA91qZC/XyQQqlzfJSl51yHL0+qZoFI/PAMXNHLg4A+aEVhrz+3GVk19O6mUqor7hchbq/J3DBpP512K5KiDxbdf76O8h+OL/bfA9SEC/fvVrGxXuXAQfjUXwNlecXrknwBgG+XdgdLmF+Ip099Y4kPfl0wttYgT1I6Snd/u5685GPZQavrNl5OoKLlL87YnPDlUtV5MnPZ2YJe1UaawzG5Tk/5a0CXUvw5PCW5diG969/NKZf+Cwx8yTOfeLiCrey+UbLmO3ky+nZ7UgxVtEykXiAmusP+iww== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1788764810; c=relaxed/relaxed; bh=U4F1730LiN4V0F0jaP71ngB/OBRFul8aXhg6XG0+dpA=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=WUih5wbgBFpR8jWqpDqE9NAkSwHXtKyQTpPPdX4mwr1Pe8dnl8FXeD5GmLCo35eBZnYZCg0nn4JoT9xZei06veq4tykiXst6PH7GdmC5K7yx7o5Zsy9Y4jGCFX54wsTDz+gjAn4v3jSQ9Mxv7i3ILbG5U+4es0VmL3mQ49ovf/u9HgeWMEZYrw4lXTb7ROuaSJC+Z+CsRmmHMuglWY6owgpcQ3sIfN65tgnKzkQ2n0KbYu/BD7zfWl243ejjskiDOu+XzINyltzJbPB2lku+J95D/VEQ72FWBe6vmLjPECZV+VxzDiC8xylNO2ncziKwOG3g4e9QlBq/vsi0LuZprA== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=ko0vC4FJ; dkim-atps=neutral; spf=pass (client-ip=148.163.158.5; helo=mx0b-001b2d01.pphosted.com; envelope-from=venkat88@linux.ibm.com; receiver=lists.ozlabs.org) smtp.mailfrom=linux.ibm.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=ko0vC4FJ; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.158.5; helo=mx0b-001b2d01.pphosted.com; envelope-from=venkat88@linux.ibm.com; receiver=lists.ozlabs.org) Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4hddRF1NSNz2yjw for ; Mon, 07 Sep 2026 17:06:48 +1000 (AEST) Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 68741m4U660756; Mon, 7 Sep 2026 07:06:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=U4F173 0LiN4V0F0jaP71ngB/OBRFul8aXhg6XG0+dpA=; b=ko0vC4FJh243BkxQ1m3Kxw bTK0Kc6CdnUHxEpXGEEMlkxW+XMi4/mJIG6O/xCF31GHP0Ng6aPwRpnwh1TgRLk+ SSpH1U1DG+cPQxopn58jV7AzfbqOO+GtFd3eEMJLW3VmY1BIFqDmudmjewOuo37z X63SlSAET9AHIw9gJgehzfFh/QUs50nEXgLQEo2EvWYpLsEWfbo6T7oFm5Swwi+w JLaepuehLSk30bVUTIORZ+3KkuAuTwuPQM/PBNolQt92FHMireCb7ic3WCCi0/qn JD4Z6O/ee/UxVH8KpvxHqz1PvllD/sTICd9FxFX4I17m6UKe7Gp4YYeihgBj8Stw == Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4ggbj7y19d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 07 Sep 2026 07:06:43 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 6876uGDl026935; Mon, 7 Sep 2026 07:06:43 GMT Received: from smtprelay07.dal12v.mail.ibm.com ([172.16.1.9]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4ggymg4a1g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 07 Sep 2026 07:06:42 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 68776fPR26083992 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 7 Sep 2026 07:06:42 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C10305805F; Mon, 7 Sep 2026 07:06:41 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CB3C358053; Mon, 7 Sep 2026 07:06:38 +0000 (GMT) Received: from smtpclient.apple (unknown [9.61.246.56]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTPS; Mon, 7 Sep 2026 07:06:38 +0000 (GMT) Content-Type: text/plain; charset=utf-8 X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.600.51.1.1\)) Subject: Re: [PATCH v2] powerpc/entry: Fix double accounting of user time on interrupt entry From: Venkat In-Reply-To: <20260904025831.3439809-1-aboorvad@linux.ibm.com> Date: Mon, 7 Sep 2026 12:36:25 +0530 Cc: Madhavan Srinivasan , linuxppc-dev@lists.ozlabs.org, Mukesh Kumar Chaurasiya , Christophe Leroy , Shrikanth Hegde , linux-kernel@vger.kernel.org, Ritesh Harjani , "Nysal Jan K . A ." Content-Transfer-Encoding: quoted-printable Message-Id: <31C68D4C-E2A4-4052-A884-CF142AAC01C2@linux.ibm.com> References: <20260904025831.3439809-1-aboorvad@linux.ibm.com> To: Aboorva Devarajan X-Mailer: Apple Mail (2.3864.600.51.1.1) X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-GUID: PWfMhVlJmuHV5igsf-2owlKHS7PAkfAt X-Proofpoint-ORIG-GUID: dd2lFNlfi2alnkv6gmJGNT8-EtxtSPM4 X-Authority-Analysis: v=2.4 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ius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-07_01,2026-09-03_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 clxscore=1015 spamscore=0 impostorscore=0 adultscore=0 phishscore=0 suspectscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2609070074 > On 4 Sep 2026, at 8:28=E2=80=AFAM, Aboorva Devarajan = wrote: >=20 > 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: >=20 > arch_interrupt_enter_prepare() > account_cpu_user_entry() /* first */ > irqentry_enter() > arch_enter_from_user_mode() > account_cpu_user_entry() /* second */ >=20 > 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. >=20 > 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(). >=20 > 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. >=20 > With CONFIG_VIRT_CPU_ACCOUNTING_NATIVE=3Dy 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. >=20 > 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. >=20 > 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: >=20 > $ python3 -c 'while True: pass' & > $ sleep 3; ps -p $! -o etime,time,pcpu >=20 > ELAPSED TIME %CPU > Before 00:03 00:00:06 210 > After 00:03 00:00:03 105 >=20 > A 50% load reports ~70% usr / 30% idle before the fix, and > ~49% usr / 51% idle after it: >=20 > $ taskset -c 6 stress-ng --cpu 1 --cpu-load 50 & > $ mpstat -P 6 1 >=20 > CPU %usr %idle > Before 6 69.74 30.26 > After 6 48.51 50.50 >=20 > Fixes: bee25f97ad24 ("powerpc: Enable GENERIC_ENTRY feature") > Reviewed-by: Mukesh Kumar Chaurasiya (IBM) > Signed-off-by: Aboorva Devarajan > --- I have tested this patch, by applying on top of latest mainline, and its = working as expected. Please add below tag. Tested-by: Venkat Rao Bagalkote Regards, Venkat. > Changes in v2: > - Explain which commits introduced each accounting call and how > they overlapped in commit message. > - Drop the code comment. >=20 > v1: = https://lore.kernel.org/linuxppc-dev/20260902050628.2553909-1-aboorvad@lin= ux.ibm.com/ >=20 > arch/powerpc/include/asm/entry-common.h | 2 -- > 1 file changed, 2 deletions(-) >=20 > diff --git a/arch/powerpc/include/asm/entry-common.h = b/arch/powerpc/include/asm/entry-common.h > index c5adb5006361..000fa925e26a 100644 > --- a/arch/powerpc/include/asm/entry-common.h > +++ b/arch/powerpc/include/asm/entry-common.h > @@ -222,8 +222,6 @@ static inline void = arch_interrupt_enter_prepare(struct pt_regs *regs) >=20 > if (user_mode(regs)) { > kuap_lock(); > - account_cpu_user_entry(); > - account_stolen_time(); > } else { > kuap_save_and_lock(regs); > /* >=20 > base-commit: fb442a6673ff1046bf67754957d95880fdb394b5 > --=20 > 2.54.0 >=20