From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Jinchao Wang <wangjinchao600@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
x86@kernel.org,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Thomas Gleixner <tglx@linutronix.de>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H . Peter Anvin" <hpa@zytor.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Ian Rogers <irogers@google.com>,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v12 04/11] tracing/wprobe: Add wprobe (watchpoint probe) trace event support
Date: Wed, 19 Aug 2026 07:35:55 +0900 [thread overview]
Message-ID: <20260819073555.751f8d6a0772c84cfb21044c@kernel.org> (raw)
In-Reply-To: <77a90576-7142-4537-9e24-6fcefb0c6dde@gmail.com>
On Mon, 17 Aug 2026 19:51:22 +0800
Jinchao Wang <wangjinchao600@gmail.com> wrote:
[...]
> > +Synopsis of wprobe-events
> > +-------------------------
> > +::
> > +
> > + w:[GRP/][EVENT] SPEC [FETCHARGS] : Probe on data access
> > +
> > + GRP : Group name for wprobe. If omitted, use "wprobes" for it.
> > + EVENT : Event name for wprobe. If omitted, an event name is
> > + generated based on the address or symbol.
> > + SPEC : Breakpoint specification.
> > + [r|w|rw]@<ADDRESS|SYMBOL[[+|-]OFFS]>[:LENGTH]
> > +
> > + r|w|rw : Access type, r for read, w for write, and rw for both.
> > + Default is rw if omitted.
> > + ADDRESS : Address to trace (hexadecimal). MUST be in kernel space.
> > + SYMBOL : Symbol name to trace.
> > + LENGTH : Length of the data to trace in bytes. (1, 2, 4, or 8)
>
> Should it show default value 4?
Ah, good catch!
> > +
> > + FETCHARGS : Arguments. Each probe can have up to 128 args.
> > + $addr : Fetch the accessing address.
> > + $value : Fetch the memory value at the accessing address (same as +0($addr)).
> > + @ADDR : Fetch memory at ADDR (ADDR should be in kernel)
> > + @SYM[+|-offs] : Fetch memory at SYM +|- offs (SYM should be a data symbol)
> > + +|-[u]OFFS(FETCHARG) : Fetch memory at FETCHARG +|- OFFS address.(\*1)(\*2)
> > + \IMM : Store an immediate value to the argument.
> > + NAME=FETCHARG : Set NAME as the argument name of FETCHARG.
> > + FETCHARG:TYPE : Set TYPE as the type of FETCHARG. Currently, basic types
> > + (u8/u16/u32/u64/s8/s16/s32/s64), hexadecimal types
> > + (x8/x16/x32/x64), "char", "string", "ustring", "symbol", "symstr"
> > + and bitfield are supported.
>
> FETCHARGS block is not aligned.
OK.
>
> > +
> > + (\*1) this is useful for fetching a field of data structures.
> > + (\*2) "u" means user-space dereference.
> > +
> > +For the details of TYPE, see :ref:`kprobetrace documentation <kprobetrace_types>`.
> > +
> > +Usage examples
> > +--------------
> > +Here is an example to add a wprobe event on a variable `jiffies`.
> > +::
> > +
> > + # echo 'w:my_jiffies w@jiffies' >> dynamic_events
> > + # cat dynamic_events
> > + w:wprobes/my_jiffies w@jiffies
> > + # echo 1 > events/wprobes/enable
> > + # cat trace | head
> > + # TASK-PID CPU# ||||| TIMESTAMP FUNCTION
> > + # | | | ||||| | |
> > + <idle>-0 [000] d.Z1. 717.026259: my_jiffies: (tick_do_update_jiffies64+0xbe/0x130)
> > + <idle>-0 [000] d.Z1. 717.026373: my_jiffies: (tick_do_update_jiffies64+0xbe/0x130)
> > +
> > +You can see the code which writes to `jiffies` is `tick_do_update_jiffies64()`.
> > diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h
> > index 5cbd09c8be8d..43ffd9a76d88 100644
> > --- a/include/linux/trace_events.h
> > +++ b/include/linux/trace_events.h
> > @@ -337,6 +337,7 @@ enum {
> > TRACE_EVENT_FL_UPROBE_BIT,
> > TRACE_EVENT_FL_EPROBE_BIT,
> > TRACE_EVENT_FL_FPROBE_BIT,
> > + TRACE_EVENT_FL_WPROBE_BIT,
> > TRACE_EVENT_FL_CUSTOM_BIT,
> > TRACE_EVENT_FL_TEST_STR_BIT,
> > };
> > @@ -367,6 +368,7 @@ enum {
> > TRACE_EVENT_FL_UPROBE = (1 << TRACE_EVENT_FL_UPROBE_BIT),
> > TRACE_EVENT_FL_EPROBE = (1 << TRACE_EVENT_FL_EPROBE_BIT),
> > TRACE_EVENT_FL_FPROBE = (1 << TRACE_EVENT_FL_FPROBE_BIT),
> > + TRACE_EVENT_FL_WPROBE = (1 << TRACE_EVENT_FL_WPROBE_BIT),
> > TRACE_EVENT_FL_CUSTOM = (1 << TRACE_EVENT_FL_CUSTOM_BIT),
> > TRACE_EVENT_FL_TEST_STR = (1 << TRACE_EVENT_FL_TEST_STR_BIT),
> > };
> > diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
> > index 0ab5916575a9..b58c2565024f 100644
> > --- a/kernel/trace/Kconfig
> > +++ b/kernel/trace/Kconfig
> > @@ -862,6 +862,19 @@ config EPROBE_EVENTS
> > convert the type of an event field. For example, turn an
> > address into a string.
> >
> > +config WPROBE_EVENTS
> > + bool "Enable wprobe-based dynamic events"
> > + depends on TRACING
> > + depends on HAVE_HW_BREAKPOINT
> > + select PROBE_EVENTS
> > + select DYNAMIC_EVENTS
> > + help
> > + This allows the user to add watchpoint tracing events based on
> > + hardware breakpoints on the fly via the ftrace interface.
> > +
> > + Those events can be inserted wherever hardware breakpoints can be
> > + set, and record accessed memory address and values.
> > +
> > config BPF_EVENTS
> > depends on BPF_SYSCALL
> > depends on (KPROBE_EVENTS || UPROBE_EVENTS) && PERF_EVENTS
> > diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile
> > index f934ff586bd4..141c8323de20 100644
> > --- a/kernel/trace/Makefile
> > +++ b/kernel/trace/Makefile
> > @@ -126,6 +126,7 @@ obj-$(CONFIG_FTRACE_RECORD_RECURSION) += trace_recursion_record.o
> > obj-$(CONFIG_FPROBE) += fprobe.o
> > obj-$(CONFIG_RETHOOK) += rethook.o
> > obj-$(CONFIG_FPROBE_EVENTS) += trace_fprobe.o
> > +obj-$(CONFIG_WPROBE_EVENTS) += trace_wprobe.o
> >
> > obj-$(CONFIG_TRACEPOINT_BENCHMARK) += trace_benchmark.o
> > obj-$(CONFIG_RV) += rv/
> > diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> > index 19cc07360005..4ebece96d8b7 100644
> > --- a/kernel/trace/trace.c
> > +++ b/kernel/trace/trace.c
> > @@ -4294,8 +4294,12 @@ static const char readme_msg[] =
> > " uprobe_events\t\t- Create/append/remove/show the userspace dynamic events\n"
> > "\t\t\t Write into this file to define/undefine new trace events.\n"
> > #endif
> > +#ifdef CONFIG_WPROBE_EVENTS
> > + " wprobe_events\t\t- Create/append/remove/show the hardware breakpoint dynamic events\n"
> > + "\t\t\t Write into this file to define/undefine new trace events.\n"
> > +#endif
> > #if defined(CONFIG_KPROBE_EVENTS) || defined(CONFIG_UPROBE_EVENTS) || \
> > - defined(CONFIG_FPROBE_EVENTS)
> > + defined(CONFIG_FPROBE_EVENTS) || defined(CONFIG_WPROBE_EVENTS)
> > "\t accepts: event-definitions (one definition per line)\n"
> > #if defined(CONFIG_KPROBE_EVENTS) || defined(CONFIG_UPROBE_EVENTS)
> > "\t Format: p[:[<group>/][<event>]] <place> [<args>]\n"
> > @@ -4305,6 +4309,9 @@ static const char readme_msg[] =
> > "\t f[:[<group>/][<event>]] <func-name>[%return] [<args>]\n"
> > "\t t[:[<group>/][<event>]] <tracepoint> [<args>]\n"
> > #endif
> > +#ifdef CONFIG_WPROBE_EVENTS
> > + "\t w[:[<group>/][<event>]] [r|w|rw]@<addr>[:<len>]\n"
>
> missing [<args>]
Oops, let me fix it.
Thanks!
>
> > +#endif
> > #ifdef CONFIG_HIST_TRIGGERS
> > "\t s:[synthetic/]<event> <field> [<field>]\n"
> > #endif
>
> Thanks,
> Jinchao
>
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
next prev parent reply other threads:[~2026-08-18 22:36 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-07 15:33 [PATCH v12 00/11] tracing: wprobe: x86: Add wprobe for watchpoint Masami Hiramatsu (Google)
2026-08-07 15:33 ` [PATCH v12 01/11] x86/hw_breakpoints: Make DR7 updates NMI safe Masami Hiramatsu (Google)
2026-08-07 15:33 ` [PATCH v12 02/11] x86/hw_breakpoints: Add arch_modify_local_hw_breakpoint_addr() API Masami Hiramatsu (Google)
2026-08-07 15:33 ` [PATCH v12 03/11] HWBP: Add modify_local_hw_breakpoint_addr() API Masami Hiramatsu (Google)
2026-08-07 15:34 ` [PATCH v12 04/11] tracing/wprobe: Add wprobe (watchpoint probe) trace event support Masami Hiramatsu (Google)
2026-08-17 11:51 ` Jinchao Wang
2026-08-18 22:35 ` Masami Hiramatsu [this message]
2026-08-07 15:34 ` [PATCH v12 05/11] x86: hw_breakpoint: Add a kconfig to clarify when a breakpoint fires Masami Hiramatsu (Google)
2026-08-17 12:10 ` Jinchao Wang
2026-08-18 22:56 ` Masami Hiramatsu
2026-08-07 15:34 ` [PATCH v12 06/11] selftests: tracing: Add a basic testcase for wprobe Masami Hiramatsu (Google)
2026-08-07 15:34 ` [PATCH v12 07/11] selftests: tracing: Add syntax " Masami Hiramatsu (Google)
2026-08-07 15:34 ` [PATCH v12 08/11] tracing/wprobe: Add set_wprobe and clear_wprobe event triggers Masami Hiramatsu (Google)
2026-08-18 9:22 ` Jinchao Wang
2026-08-18 22:33 ` Masami Hiramatsu
2026-08-07 15:34 ` [PATCH v12 09/11] selftests: ftrace: Add wprobe trigger testcase Masami Hiramatsu (Google)
2026-08-07 15:35 ` [PATCH v12 10/11] tracing/wprobe: Support BTF typecast in fetchargs Masami Hiramatsu (Google)
2026-08-07 15:35 ` [PATCH v12 11/11] tracing/wprobe: Support BTF struct offset resolution in set_wprobe trigger Masami Hiramatsu (Google)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260819073555.751f8d6a0772c84cfb21044c@kernel.org \
--to=mhiramat@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=irogers@google.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=wangjinchao600@gmail.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox