From nobody Thu Oct 2 18:17:15 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1541884A3E; Sun, 14 Sep 2025 14:10:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757859015; cv=none; b=OpBtH/dh+OBTcS4akdSUUKFD6nRxMuBKIKbs3aaS3BDmiBSq4kalbNzZBDQDqEGuofa7FtBB2cb2tNBhhrusrV/Dvf/Y//ztpbEh2or9YcLMYKkGNLVF981NKZLZASLvMajnLhOgIeZAMkYYPQaaodrkzdLrZXo8QZMw9NDa7NU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757859015; c=relaxed/simple; bh=HMBQRx7JyB5v7TgDveyCx2NTj+Btta/jIE/kq7ocmdE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NZjoHMsnhrWUwDKf1TRH4AogT4/pkWh9GDhcV4FgWd7Ijv6hTQTX6UvU4zxSH6ujvsgfbtFczpd4/k6h83HehTJKjdihIqoH/lpwphddVBi/yWYYuhkdGAZc49pqeZDK6QRun0lhN+i7WrLcEtQPyBJ6+nlOq/FZWoyNIMT4dHM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=I/MDOG1g; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="I/MDOG1g" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D783C4CEF0; Sun, 14 Sep 2025 14:10:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757859014; bh=HMBQRx7JyB5v7TgDveyCx2NTj+Btta/jIE/kq7ocmdE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I/MDOG1gpEqo9fLkFiJzHX1h2jZnL1CSF18i1Eh2Dcuq9dbXxnQnuPHIJhVlxgZuZ Dnx3T8SK3LmKYPk7FnSD62Z0WSM7SqPWjApEXzodO6W/xFRgTmpXheSaH05+hF40vD BZU/297t/lzMsXywMuHM4oH4kfwsvuTWJUMcnL9Egt8TeqGNURggg6IOHYqpgI7t5e Fgkxl7mtSwUyEhjk3m7BvtQj/WzzFXODIRxxVrx6MHQ5S6gMpku9YBPSD2sBlyqGkp bTJ3PIcmHJUuDZ29JGDk63PD679dlG47hmXat9DWuhCpT5/pumQTp/cOBpKEEk0bVu BuN1QebWN0z4A== From: "Masami Hiramatsu (Google)" To: Steven Rostedt , Peter Zijlstra , Ingo Molnar , x86@kernel.org Cc: Jinchao Wang , Mathieu Desnoyers , Masami Hiramatsu , Thomas Gleixner , Borislav Petkov , Dave Hansen , "H . Peter Anvin" , Alexander Shishkin , Ian Rogers , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: [PATCH v4 3/8] x86/hw_breakpoint: Add arch_reinstall_hw_breakpoint Date: Sun, 14 Sep 2025 23:10:08 +0900 Message-ID: <175785900886.234168.4223927561031767856.stgit@devnote2> X-Mailer: git-send-email 2.43.0 In-Reply-To: <175785897434.234168.6798590787777427098.stgit@devnote2> References: <175785897434.234168.6798590787777427098.stgit@devnote2> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Jinchao Wang The new arch_reinstall_hw_breakpoint() function can be used in an atomic context, unlike the more expensive free and re-allocation path. This allows callers to efficiently re-establish an existing breakpoint. Signed-off-by: Jinchao Wang Reviewed-by: Masami Hiramatsu (Google) --- arch/x86/include/asm/hw_breakpoint.h | 2 ++ arch/x86/kernel/hw_breakpoint.c | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/arch/x86/include/asm/hw_breakpoint.h b/arch/x86/include/asm/hw= _breakpoint.h index aa6adac6c3a2..c22cc4e87fc5 100644 --- a/arch/x86/include/asm/hw_breakpoint.h +++ b/arch/x86/include/asm/hw_breakpoint.h @@ -21,6 +21,7 @@ struct arch_hw_breakpoint { =20 enum bp_slot_action { BP_SLOT_ACTION_INSTALL, + BP_SLOT_ACTION_REINSTALL, BP_SLOT_ACTION_UNINSTALL, }; =20 @@ -65,6 +66,7 @@ extern int hw_breakpoint_exceptions_notify(struct notifie= r_block *unused, =20 =20 int arch_install_hw_breakpoint(struct perf_event *bp); +int arch_reinstall_hw_breakpoint(struct perf_event *bp); void arch_uninstall_hw_breakpoint(struct perf_event *bp); void hw_breakpoint_pmu_read(struct perf_event *bp); void hw_breakpoint_pmu_unthrottle(struct perf_event *bp); diff --git a/arch/x86/kernel/hw_breakpoint.c b/arch/x86/kernel/hw_breakpoin= t.c index 3658ace4bd8d..29c9369264d4 100644 --- a/arch/x86/kernel/hw_breakpoint.c +++ b/arch/x86/kernel/hw_breakpoint.c @@ -99,6 +99,10 @@ static int manage_bp_slot(struct perf_event *bp, enum bp= _slot_action action) old_bp =3D NULL; new_bp =3D bp; break; + case BP_SLOT_ACTION_REINSTALL: + old_bp =3D bp; + new_bp =3D bp; + break; case BP_SLOT_ACTION_UNINSTALL: old_bp =3D bp; new_bp =3D NULL; @@ -187,6 +191,11 @@ int arch_install_hw_breakpoint(struct perf_event *bp) return arch_manage_bp(bp, BP_SLOT_ACTION_INSTALL); } =20 +int arch_reinstall_hw_breakpoint(struct perf_event *bp) +{ + return arch_manage_bp(bp, BP_SLOT_ACTION_REINSTALL); +} + void arch_uninstall_hw_breakpoint(struct perf_event *bp) { arch_manage_bp(bp, BP_SLOT_ACTION_UNINSTALL);