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 5FA6B2FF672; Thu, 16 Jul 2026 02:53:28 +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=1784170409; cv=none; b=YSt53/bqaAC8LGoEvV6pfsPdfx9r/S7aUQ9yUHT5rzJoaCdqXfRq5r9wVowOGnoyAtONc7QrKlziCunWTez2LpaxsDAlD0/kjxK0oS0FjHqeJTJ+yEKvouiqv9ddQoMlFWO6fsa1difB5VsGshOAF5NrvcTfdffhBTRJ532Led4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784170409; c=relaxed/simple; bh=PzhykzUPuS8JDdAU6J3yYevHP7F0F2W5g9Ny3Mtf/rg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bYdEodGhZMCkB+at4YnXOQMZATF1B30wwqEeiN/FcRktZR+36qIGMVrcVjOfdnzzTlisTpcM3XZ27O+OovHQZmiowP4oMpYQTiy0h1lfYv77hqkpFkE6hkWo5En4QtiVYH3rl+Kcygg+bUL/AMBnoK28aSWVh74PiC7SwzOG2yU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XdsYwZkh; 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="XdsYwZkh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 130B91F00A3D; Thu, 16 Jul 2026 02:53:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784170408; bh=HEilDAJ8vih2mm0A4cQRF/r9OkrvoKFwHGogM4rpCCM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=XdsYwZkhIClgOtgKAiw4avoF49ddZJa1r4T5WFKPRT+yXw4NnhGe4Caq3MbTALQzh FOyfwdQMCHYu9oE6R3UHmwJXtI3f4MdTPqZ+8NljnFPqb4Bw4m5CEj46YuPn5jvp5B hlhjKN4QpL0i+YA2BEkhGgcm18FkKasNF8LUdtW66zWS5dN/ZwPASw3FQoKl1N3bvR PHHzd1vY2yMcnohD8hXbRxaU3gyBFGXwLV0GwSrHAhigVtKtaKUUYfK8fSCYg81qYX 0CT5lsKENfHDzc9WJdUe3TfOMDkEx/UpEofiZhS4KDOzRJV6I4cppon+pd1A8Xc9oP VKyDAVVP1B+Ng== 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 v8 6/9] x86/hw_breakpoint: Add arch_reinstall_hw_breakpoint Date: Thu, 16 Jul 2026 11:53:21 +0900 Message-ID: <178417040126.209165.5176961124203156666.stgit@devnote2> X-Mailer: git-send-email 2.43.0 In-Reply-To: <178417033089.209165.16717079876036408877.stgit@devnote2> References: <178417033089.209165.16717079876036408877.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 c323c2aab2af..5821bb4650ce 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; @@ -189,6 +193,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);