From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 94458606A69D for ; Fri, 4 Dec 2026 18:34:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=OymNEzoB; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=TjoDYwKU; dkim=pass (2048-bit key, unprotected) header.d=amazon.de header.i=@amazon.de header.a=rsa-sha256 header.s=amazoncorp2 header.b=jTsHekds DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:CC:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Unsubscribe-Post:List-Owner; bh=Duh7PPCxkm+3wMWKfcnOR7WjfiaND3y1zDKilurEhFc=; b=OymNEzoByKl6ZGMbdBFcavpjld NqoDwr4C1Nlv6y6aa0XeNtn55t9jY1Fqt6uiKnc6/QIwHvVfcMNeIYoDK5qQ4wZ0pbN70dbhy0vPf cB9ImmBwBxfERa5ZSV4pI93lILxEIb5kTo8pEul6+GwEnwpiauqiIhLZ1RPN3T/VySCIP6UJqTBMl 0X1Fa7szuBbJFM3G/LTbbn1QJ0jTlSVJsuk19D6QHT4y6ELAbzaWVQV16gFPOlfOn3d3hCdOhou5v IcKIVmvmxNY9AIxpn87oRMDjlgoTsu8RXG2PTuWHrl6WyIlx0sPbSxUUvqryaFVUAGF95UVMoIxXl upk2yzkQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZY6s-00000001Aj8-3rXL; Fri, 04 Dec 2026 18:34:18 +0000 Received: from desiato.infradead.org ([90.155.92.199]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZY3C-00000001AOz-0q7v for linux-arm-kernel@bombadil.infradead.org; Fri, 04 Dec 2026 18:32:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Content-Transfer-Encoding :MIME-Version:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To:Content-ID: Content-Description:In-Reply-To:References; bh=Duh7PPCxkm+3wMWKfcnOR7WjfiaND3y1zDKilurEhFc=; b=TjoDYwKU1P4raTIZS4t0BmlzHM ItIjEh+MdTWyqOIdMOa9c4NLin3DiAC0ruJ/K+zOlchToGgRzlapLVptCuld4Zjwp2NWnihfGuREq yMaJb1VLf3Z8VMdLCWzAx/nfIS2spzpTQoIpmwiqqWi1yMiPtadkIQYz2lS6jipjPADId1tGzH8jr 9lRO2tjhpZApcBub+TnBuAN2ZXUJ3jiK9AK7U+WF8X0cnH/jMoGGfB0j8x0d+bTEqoTRfCziAsPMQ PK+3zSRsQFaDcSKytdFDK0T/04v+Yu+ASmQ/qWbiIFtjbNDw4s8FViuh9CZD+s9mpYEJUHNTbqgy5 Bw9BtrdQ==; Received: from pdx-out-002.esa.us-west-2.outbound.mail-perimeter.amazon.com ([44.246.1.125]) by desiato.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZY38-0000000Egto-13aq for linux-arm-kernel@lists.infradead.org; Fri, 04 Dec 2026 18:30:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazoncorp2; t=1796409026; x=1827945026; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Duh7PPCxkm+3wMWKfcnOR7WjfiaND3y1zDKilurEhFc=; b=jTsHekdsg5RmD+uqhzfOBw1/FP28JIHZ73PtpgPqcFeMsUAnKqLHhw4W 9Fn6e2mqnhaVZdZPJrfzLYJSQLloeec3R/mATz8Q6CK3N0kh4NM8uxGNd uOxkQ+YvrIjzlcbgkQvsclJFsXjlxbj5WI1j9kv0WL6yCRKZ1c/BPegTW RCAfRcmAUHeeFmiz88FG6PZY3aQCarGbwDjSBQdzUlGwbotvW+w5vBzf4 06MpgKJuFXwX28afl5Ys5L6A5wC5KyDvtdLnJ+U0r3wfEfgZJpGIqhChf /IWhXFlXGTT9aPvrNTvg/R/JbLOMCYVo5XJSwaWzXZCXbutbkyGbdkXz1 g==; X-CSE-ConnectionGUID: 0EeDyAlkQm+UrwknnBVsGA== X-CSE-MsgGUID: lXExDD7QRl216TuTA45x1Q== X-IronPort-AV: E=Sophos;i="6.29,78,1794873600"; d="scan'208";a="35924080" Received: from ip-10-5-12-219.us-west-2.compute.internal (HELO smtpout.naws.us-west-2.prod.farcaster.email.amazon.dev) ([10.5.12.219]) by internal-pdx-out-002.esa.us-west-2.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2026 18:30:18 +0000 Received: from EX19MTAUWB001.ant.amazon.com [205.251.233.104:20368] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.11.100:2525] with esmtp (Farcaster) id a2e3095b-5f26-45f6-a23d-1f981deeed65; Fri, 4 Dec 2026 18:30:18 +0000 (UTC) X-Farcaster-Flow-ID: a2e3095b-5f26-45f6-a23d-1f981deeed65 Received: from EX19D001UWA001.ant.amazon.com (10.13.138.214) by EX19MTAUWB001.ant.amazon.com (10.250.64.248) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.57; Fri, 4 Dec 2026 18:30:17 +0000 Received: from dev-dsk-ayubjon-1b-10c4b89e.eu-west-1.amazon.com (10.253.64.208) by EX19D001UWA001.ant.amazon.com (10.13.138.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.57; Fri, 4 Dec 2026 18:30:16 +0000 From: Ayubjon Qosimov To: Catalin Marinas , Will Deacon , Mark Rutland CC: , , , Subject: [PATCH] arm64: hw_breakpoint: Reset the debug registers on all CPUs at once Date: Fri, 4 Dec 2026 18:30:14 +0000 Message-ID: <20261204183014.79514-1-ayubjon@amazon.de> X-Mailer: git-send-email 2.47.3 X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: EX19D031UWA001.ant.amazon.com (10.13.139.88) To EX19D001UWA001.ant.amazon.com (10.13.138.214) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261204_183027_265250_5A827D95 X-CRM114-Status: GOOD ( 16.72 ) X-Spam-Score: -2.5 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-19.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 arch_hw_breakpoint_init() runs after SMP bringup, so cpuhp_setup_state() invokes hw_breakpoint_reset() on each online CPU in turn: it kicks that CPU's hotplug thread and waits for it to finish before moving on to the next one. The time grows linearly with the number of CPUs, and most of it is spent where accesses to the debug registers trap to a hypervisor: in a 96-vCPU KVM guest the initcall takes about 1.0 ms, around 10 us per CPU. This is on the boot path of a kernel started by kexec with Kexec HandOver for a live update (Documentation/core-api/liveupdate.rst), where the preserved workloads stay paused until the new kernel is up. Reset the online CPUs with a single on_each_cpu() call instead, so that they all run the reset at the same time, with interrupts disabled as in the STARTING callback, and register the callback for CPUs that come up later with cpuhp_setup_state_nocalls_cpuslocked(). With the hotplug lock held across both, no CPU can come up in between and every online CPU is past the STARTING states, so the same CPUs are reset as before. In the 96-vCPU KVM guest on a Graviton4 host, arch_hw_breakpoint_init() goes from about 1.0 ms to 0.085 ms (13 boots each). Signed-off-by: Ayubjon Qosimov --- The same could be done for every STARTING state in the CPU hotplug core, since STARTING callbacks cannot fail. I kept the change local to this file, but can look at kernel/cpu.c instead if that is preferred. --- arch/arm64/kernel/hw_breakpoint.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c index 32b38967433e..7d54e2f35cf7 100644 --- a/arch/arm64/kernel/hw_breakpoint.c +++ b/arch/arm64/kernel/hw_breakpoint.c @@ -1003,6 +1003,11 @@ static int hw_breakpoint_reset(unsigned int cpu) return 0; } +static void __init hw_breakpoint_reset_ipi(void *unused) +{ + hw_breakpoint_reset(smp_processor_id()); +} + /* * One-time initialisation. */ @@ -1019,10 +1024,17 @@ static int __init arch_hw_breakpoint_init(void) /* * Reset the breakpoint resources. We assume that a halting * debugger will leave the world in a nice state for us. + * + * The online CPUs are reset here, the ones that come up later by the + * hotplug callback. Holding the hotplug lock keeps a CPU from coming + * up in between. */ - ret = cpuhp_setup_state(CPUHP_AP_PERF_ARM_HW_BREAKPOINT_STARTING, - "perf/arm64/hw_breakpoint:starting", - hw_breakpoint_reset, NULL); + cpus_read_lock(); + on_each_cpu(hw_breakpoint_reset_ipi, NULL, 1); + ret = cpuhp_setup_state_nocalls_cpuslocked(CPUHP_AP_PERF_ARM_HW_BREAKPOINT_STARTING, + "perf/arm64/hw_breakpoint:starting", + hw_breakpoint_reset, NULL); + cpus_read_unlock(); if (ret) pr_err("failed to register CPU hotplug notifier: %d\n", ret); base-commit: f46be4da2cbb17574b5369517a9a1e1b414063b4 -- 2.47.3