From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=44.246.1.125 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796409022; b=jLf73ocS4s6Vfteh0qc+v5hRjWtLWYVKZenXQYSWVtqgPZtAhRd2X+OAxCCjjtJukx+u XEselb5Bmi7nsE7JzXEvLvGA/PNVi92oXKzbViZaMv8hES1maghwtNOweAHEFfKtgCN/v KnvXzqoHJ2ZKT5cjSDYX+TBGNkI4Sbi5wtdLgNB4VcVlkc+EzrejAsUrxvZ8hASEAneN0 NIuJZug+iQxoZdOfXjrfif+Qu1kaMGV5GXiBs2zw/12DKWry/JljySFKvBngvPnbfdcaQ 4IRXwDPSEuuzy7RJBJZ0BXg95CqO6A3SAR4AuvYvGAPRyVu6h645o7F3SK5+9kT72zQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796409022; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:Received:Received:X-Farcaster-Flow-ID:Received:Received: From:To:CC:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding:Content-Type:X-Originating-IP: X-ClientProxiedBy; bh=Duh7PPCxkm+3wMWKfcnOR7WjfiaND3y1zDKilurEhFc=; b=C93hs3Qdim7bzG8fd5SIHVtwE/mYHHhmIM6K3fmLDnBokxoYX2alPpR6dSCA/t6pOhhK xMfZYzHOnp9DV4VZA5KU0C7X0PYS1dxuHfo/ZAqktxZ4PZOqHXv7wKIsPonVK2vGSS6ka PyYIJC9npYIDcZxFb7x/T+YXFr9NFhgWqrRQ5svmbK/zWJInq+T4SssudiCdTUd52NRQ+ eZcHbS62a8mBnyEOa5aoddkuegY3XtsVYwV9JMAilY/mZiJoDGKAvOfMbnUU5EsT6u1DZ VkBVyj151cFIh3OLrwwgy0jmXYH/9SVfodXKVHXgrRfB+aW8T6hVrMipxoZn/hEGGcw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=amazon.de; spf=pass smtp.mailfrom=amazon.de; dkim=pass header.d=amazon.de header.i=@amazon.de header.a=rsa-sha256 header.s=amazoncorp2 header.b=KBYG5zei; arc=none smtp.remote-ip=44.246.1.125 Received: from pdx-out-002.esa.us-west-2.outbound.mail-perimeter.amazon.com (pdx-out-002.esa.us-west-2.outbound.mail-perimeter.amazon.com [44.246.1.125]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C966B606A334; Fri, 4 Dec 2026 18:30:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C966B606A334 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=amazon.de header.i=@amazon.de header.a=rsa-sha256 header.s=amazoncorp2 header.b=KBYG5zei DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazoncorp2; t=1796409021; x=1827945021; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Duh7PPCxkm+3wMWKfcnOR7WjfiaND3y1zDKilurEhFc=; b=KBYG5zeilCHCD1vf7c27/I1TOSFPqCPUQxNQ/GuEzcvBmoAb24orqXG+ 9bewkRlLFTfYhro1Pk1j1ZNQxnZns01IA3ceX9lJNPi1rSKXWT2hs01V+ APicdFekGArX8JAYjo7fqNy0VEomPPxMq1sKLP/PKH4Z6Vf+8xIubC4cd v2ctpPGn82c6ig7CZkxn/toH33COdI7hIMPIZVU9FA0kgPxY1Ne0LH1uL jcWBE/PknJbdo+KXwuosckhFKNk5pmESveRocnvizmjULfbs8GN7Q380T +FT9iPN2myYZGH1ouMOnK6VNv6EeF9+0F4KLprr7e4LPADTOpb3fKdHuZ Q==; 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-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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) 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