From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 73200481B1; Wed, 15 Jul 2026 01:45:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784079927; cv=none; b=bxsplz2UyoaNccL3KOPI34KL28xObe6NKWHtJsppeNwC5mefQc9OilUNLeh+NNAyvjMhlttEs2eal/z47Qm3yWkGfiPfIEpJ5HTBg9v/r5GdQm3W1MzmDw2I6d/C75365TXY4RpYCOz0E26lNDtB0af5xMmPwIQkCUpyBlfT4aE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784079927; c=relaxed/simple; bh=2fcSX4kIwFIDKw76TQlcptyp8280Ha4c+S8Uiz27Pus=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JZJTwFV5j3YBXmzadzVFrXwaJZCTs7KXJ8CIuM7a9sbk+SMob1YL93Vl40ZO5A5oNr0rEwb8fO03zfh9vnYquFFZZJ+wJKgWeaSD7FcE7ZyE5518FOOv0znWQf6bfxztTd8xaYsB0GpKGjC01E5OmyC7EXzTb7IYO7Lj4uNiDpQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HqlARus6; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HqlARus6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7004E1F000E9; Wed, 15 Jul 2026 01:45:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784079926; bh=4B52rB4RAOUe4XE25Snyjh89ZAhqqDjce8UOM+tAp3M=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=HqlARus67PjzW/EhW1vyTOxSU/8cLNQWn8K+3A0ie30rxaEgnU6ofBAt5jSP/sh5p adnTut7tYlPfh5TBQ6SoNI6R4tDjsAsSl3Olg7k7vnSQdP4Jw4PSW2OKzyeeBNQwcW rAai42ejNXl9hDsIqBlXRF8SS+AmVNYeKn0yAEXbZWjn6Dg7JIyq4RKP8V6MXIMdMg KRxolFdq/2NsPBcqno9xXNJjyMWSqSecEQ0kuFkBhAWLOqPXP2CZy3Q9eZe8ykE2Ye jWXoMnj1rPRO1DSmYcFIkc4jlsbsdgrlBACyXx3bMjrjT+dwuAEeorDFcUGE4jc8aj CjV1MU4NQQTzQ== 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 v7 07/10] x86/hw_breakpoint: Add arch_reinstall_hw_breakpoint Date: Wed, 15 Jul 2026 10:45:20 +0900 Message-ID: <178407992003.95826.8437044383333615344.stgit@devnote2> X-Mailer: git-send-email 2.43.0 In-Reply-To: <178407983818.95826.12714571928538799781.stgit@devnote2> References: <178407983818.95826.12714571928538799781.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: 8bit 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 { enum bp_slot_action { BP_SLOT_ACTION_INSTALL, + BP_SLOT_ACTION_REINSTALL, BP_SLOT_ACTION_UNINSTALL, }; @@ -65,6 +66,7 @@ extern int hw_breakpoint_exceptions_notify(struct notifier_block *unused, 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_breakpoint.c index 877509539300..9af8d81075db 100644 --- a/arch/x86/kernel/hw_breakpoint.c +++ b/arch/x86/kernel/hw_breakpoint.c @@ -100,6 +100,10 @@ static int manage_bp_slot(struct perf_event *bp, enum bp_slot_action action) old_bp = NULL; new_bp = bp; break; + case BP_SLOT_ACTION_REINSTALL: + old_bp = bp; + new_bp = bp; + break; case BP_SLOT_ACTION_UNINSTALL: old_bp = bp; new_bp = NULL; @@ -188,6 +192,11 @@ int arch_install_hw_breakpoint(struct perf_event *bp) return arch_manage_bp(bp, BP_SLOT_ACTION_INSTALL); } +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);