live-patching.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* 'perf probe' and symbols from .text.<something>
@ 2021-02-18 17:09 Evgenii Shatokhin
  2021-02-18 19:35 ` Josh Poimboeuf
  2021-02-22 15:05 ` Masami Hiramatsu
  0 siblings, 2 replies; 16+ messages in thread
From: Evgenii Shatokhin @ 2021-02-18 17:09 UTC (permalink / raw)
  To: Masami Hiramatsu, Arnaldo Carvalho de Melo
  Cc: Kristen Carlson Accardi, live-patching, Peter Zijlstra,
	Ingo Molnar, linux-kernel, Konstantin Khorenko

Hi,

It seems, 'perf probe' can only see functions from .text section in the 
kernel modules, but not from .text.unlikely or other .text.* sections.

For example, with kernel 5.11 and nf_conntrack.ko with debug info, 'perf 
probe' succeeds for nf_conntrack_attach() from .text and fails for 
nf_ct_resolve_clash() from .text.unlikely:

------------
# perf probe -v -m nf_conntrack nf_ct_resolve_clash
probe-definition(0): nf_ct_resolve_clash
symbol:nf_ct_resolve_clash file:(null) line:0 offset:0 return:0 lazy:(null)
0 arguments
Failed to get build-id from nf_conntrack.
Cache open error: -1
Open Debuginfo file: 
/lib/modules/5.11.0-test01/kernel/net/netfilter/nf_conntrack.ko
Try to find probe point from debuginfo.
Matched function: nf_ct_resolve_clash [33616]
Probe point found: nf_ct_resolve_clash+0
Found 1 probe_trace_events.
Post processing failed or all events are skipped. (-2)
Probe point 'nf_ct_resolve_clash' not found.
   Error: Failed to add events. Reason: No such file or directory (Code: -2)

# perf probe -v -m nf_conntrack nf_conntrack_attach
probe-definition(0): nf_conntrack_attach
symbol:nf_conntrack_attach file:(null) line:0 offset:0 return:0 lazy:(null)
0 arguments
Failed to get build-id from nf_conntrack.
Cache open error: -1
Open Debuginfo file: 
/lib/modules/5.11.0-test01/kernel/net/netfilter/nf_conntrack.ko
Try to find probe point from debuginfo.
Matched function: nf_conntrack_attach [2c8c3]
Probe point found: nf_conntrack_attach+0
Found 1 probe_trace_events.
Opening /sys/kernel/tracing//kprobe_events write=1
Opening /sys/kernel/tracing//README write=0
Writing event: p:probe/nf_conntrack_attach 
nf_conntrack:nf_conntrack_attach+0
Added new event:
   probe:nf_conntrack_attach (on nf_conntrack_attach in nf_conntrack)
------------

Is there a way to allow probing of functions in .text.<something> ?

Of course, one could place probes using absolute addresses of the 
functions but that would be less convenient.

This also affects many livepatch modules where the kernel code can be 
compiled with -ffunction-sections and each function may end up in a 
separate section .text.<function_name>. 'perf probe' cannot be used 
there, except with the absolute addresses.

Moreover, if FGKASLR patches are merged 
(https://lwn.net/Articles/832434/) and the kernel is built with FGKASLR 
enabled, -ffunction-sections will be used too. 'perf probe' will be 
unable to see the kernel functions then.

Regards,
Evgenii

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2021-02-24  8:02 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-18 17:09 'perf probe' and symbols from .text.<something> Evgenii Shatokhin
2021-02-18 19:35 ` Josh Poimboeuf
2021-02-22 15:05 ` Masami Hiramatsu
2021-02-22 15:12   ` Masami Hiramatsu
2021-02-22 17:51   ` Josh Poimboeuf
2021-02-23  1:23     ` Masami Hiramatsu
2021-02-23  7:36       ` Masami Hiramatsu
2021-02-23 19:45         ` Josh Poimboeuf
2021-02-24  8:00           ` Masami Hiramatsu
2021-02-23  1:48   ` [PATCH] perf-probe: Failback to symbol-base probe for probes on module Masami Hiramatsu
2021-02-23  7:36     ` Masami Hiramatsu
2021-02-23  7:09   ` 'perf probe' and symbols from .text.<something> Masami Hiramatsu
2021-02-23  7:37   ` [PATCH] perf-probe: dso: Add symbols in .text.* subsections to text symbol map in kenrel modules Masami Hiramatsu
2021-02-23 15:02     ` Evgenii Shatokhin
2021-02-23 20:11       ` Arnaldo Carvalho de Melo
2021-02-24  7:47         ` Evgenii Shatokhin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).