[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250904002126.1514566-7-wangjinchao600@gmail.com>
Date: Thu, 4 Sep 2025 08:21:03 +0800
From: Jinchao Wang <wangjinchao600@...il.com>
To: Andrew Morton <akpm@...ux-foundation.org>,
Masami Hiramatsu <mhiramat@...nel.org>,
"Naveen N . Rao" <naveen@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
x86@...nel.org,
"H. Peter Anvin" <hpa@...or.com>,
Peter Zijlstra <peterz@...radead.org>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>,
Ian Rogers <irogers@...gle.com>,
Adrian Hunter <adrian.hunter@...el.com>,
"Liang, Kan" <kan.liang@...ux.intel.com>,
David Hildenbrand <david@...hat.com>,
Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
"Liam R. Howlett" <Liam.Howlett@...cle.com>,
Vlastimil Babka <vbabka@...e.cz>,
Mike Rapoport <rppt@...nel.org>,
Suren Baghdasaryan <surenb@...gle.com>,
Michal Hocko <mhocko@...e.com>,
linux-perf-users@...r.kernel.org,
linux-mm@...ck.org,
linux-trace-kernel@...r.kernel.org
Cc: linux-kernel@...r.kernel.org,
Jinchao Wang <wangjinchao600@...il.com>
Subject: [PATCH v2 06/18] perf/hw_breakpoint: add arch-independent hw_breakpoint_modify_local()
Introduce hw_breakpoint_modify_local() as a generic helper to modify an
existing hardware breakpoint. The function invokes
hw_breakpoint_arch_parse() and delegates the reinstall step to the
architecture via arch_reinstall_hw_breakpoint().
A weak default implementation of arch_reinstall_hw_breakpoint() is
provided, returning -EOPNOTSUPP on architectures without support.
This makes the interface arch-independent while allowing x86 (and others)
to provide their own implementation.
Signed-off-by: Jinchao Wang <wangjinchao600@...il.com>
---
include/linux/hw_breakpoint.h | 1 +
kernel/events/hw_breakpoint.c | 18 ++++++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/include/linux/hw_breakpoint.h b/include/linux/hw_breakpoint.h
index db199d653dd1..9453b5bdb443 100644
--- a/include/linux/hw_breakpoint.h
+++ b/include/linux/hw_breakpoint.h
@@ -67,6 +67,7 @@ extern int
modify_user_hw_breakpoint_check(struct perf_event *bp, struct perf_event_attr *attr,
bool check);
+int hw_breakpoint_modify_local(struct perf_event *bp, struct perf_event_attr *attr);
/*
* Kernel breakpoints are not associated with any particular thread.
*/
diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c
index 8ec2cb688903..ff428739f71e 100644
--- a/kernel/events/hw_breakpoint.c
+++ b/kernel/events/hw_breakpoint.c
@@ -983,6 +983,24 @@ static void hw_breakpoint_del(struct perf_event *bp, int flags)
arch_uninstall_hw_breakpoint(bp);
}
+int hw_breakpoint_modify_local(struct perf_event *bp, struct perf_event_attr *attr)
+{
+ int err;
+
+ err = hw_breakpoint_arch_parse(bp, attr, counter_arch_bp(bp));
+ if (err)
+ return err;
+
+ return arch_reinstall_hw_breakpoint(bp);
+}
+EXPORT_SYMBOL(hw_breakpoint_modify_local);
+
+/* weak fallback for arches without support */
+__weak int arch_reinstall_hw_breakpoint(struct perf_event *bp)
+{
+ return -EOPNOTSUPP;
+}
+
static void hw_breakpoint_start(struct perf_event *bp, int flags)
{
bp->hw.state = 0;
--
2.43.0
Powered by blists - more mailing lists