Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1592385

Re: [PATCH v4 2/3] perf: kretprobes: offset from reloc_sym if kernel supports it

From Masami Hiramatsu <mhiramat@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH v4 2/3] perf: kretprobes: offset from reloc_sym if kernel supports it
Date 2017-03-04 03:50 +0100
Message-ID <th7VD-1WL-11@gated-at.bofh.it> (permalink)
References <tgEJY-6SM-19@gated-at.bofh.it> <tgI1c-KT-25@gated-at.bofh.it> <th6dc-Gi-7@gated-at.bofh.it> <th7VD-1WL-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Sat, 4 Mar 2017 11:35:51 +0900
Masami Hiramatsu <mhiramat@kernel.org> wrote:

> On Sat, 4 Mar 2017 09:49:11 +0900
> Masami Hiramatsu <mhiramat@kernel.org> wrote:
> 
> > On Thu,  2 Mar 2017 23:25:06 +0530
> > "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> wrote:
> > 
> > > We indicate support for accepting sym+offset with kretprobes through a
> > > line in ftrace README. Parse the same to identify support and choose the
> > > appropriate format for kprobe_events.
> > 
> > Could you give us an example of this change here? :)
> > for example, comment of commit 613f050d68a8 .
> > 
> > I think the code is OK, but we need actual example of result.
> 
> Hi Naveen,
> 
> I've tried following commands
> 
> $ grep "[Tt] user_read$" /proc/kallsyms  
> 0000000000000000 T user_read
> 0000000000000000 t user_read
> $ sudo ./perf probe -D user_read%return
> r:probe/user_read _text+3539616
> r:probe/user_read_1 _text+3653408
> 
> OK, looks good. However, when I set the retprobes, I got an error.
> 
> $ sudo ./perf probe -a user_read%return
> Failed to write event: Invalid argument
>   Error: Failed to add events.
> 
> And kernel rejected that.
> 
> $ dmesg -k | tail -n 1
> [  850.315068] Given offset is not valid for return probe.
> 
> Hmm, curious..
> 
> I tried normal probes
> 
> $ sudo ./perf probe -D user_read
> p:probe/user_read _text+3539616
> p:probe/user_read_1 _text+3653408
> $ sudo ./perf probe -a user_read
> Added new events:
>   probe:user_read      (on user_read)
>   probe:user_read_1    (on user_read)
> 
> You can now use it in all perf tools, such as:
> 
> 	perf record -e probe:user_read_1 -aR sleep 1
> 
> It works!
> 
> $ sudo ./perf probe -l
>   probe:user_read      (on user_read@security/keys/user_defined.c)
>   probe:user_read_1    (on user_read@selinux/ss/policydb.c)
> $ sudo cat /sys/kernel/debug/kprobes/list
> ffffffff9237bf20  k  user_read+0x0    [DISABLED][FTRACE]
> ffffffff923602a0  k  user_read+0x0    [DISABLED][FTRACE]
> 
> So, the both "_text+3539616" and "_text+3653408" are correctly located
> on the entry address of user_read functions. It seems kernel-side
> symbol+offset check is wrong.

FYI, without this patch, perf probe returns same place for same-name
functions. So this patch itself looks good.

$ sudo ./perf probe -D user_read%return
r:probe/user_read user_read+0
r:probe/user_read_1 user_read+0


Thanks,


-- 
Masami Hiramatsu <mhiramat@kernel.org>

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v4 2/3] perf: kretprobes: offset from reloc_sym if kernel supports it "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2017-03-03 00:10 +0100
  Re: [PATCH v4 2/3] perf: kretprobes: offset from reloc_sym if  kernel supports it Masami Hiramatsu <mhiramat@kernel.org> - 2017-03-04 02:00 +0100
    Re: [PATCH v4 2/3] perf: kretprobes: offset from reloc_sym if  kernel supports it Masami Hiramatsu <mhiramat@kernel.org> - 2017-03-04 03:50 +0100
      Re: [PATCH v4 2/3] perf: kretprobes: offset from reloc_sym if  kernel supports it Masami Hiramatsu <mhiramat@kernel.org> - 2017-03-04 03:50 +0100
      Re: [PATCH v4 2/3] perf: kretprobes: offset from reloc_sym if  kernel supports it Masami Hiramatsu <mhiramat@kernel.org> - 2017-03-04 05:50 +0100
        Re: [PATCH v4 2/3] perf: kretprobes: offset from reloc_sym if kernel  supports it "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2017-03-06 20:10 +0100
        Re: [PATCH v4 2/3] perf: kretprobes: offset from reloc_sym if  kernel supports it Masami Hiramatsu <mhiramat@kernel.org> - 2017-03-06 22:10 +0100
          Re: [PATCH v4 2/3] perf: kretprobes: offset from reloc_sym if kernel "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2017-03-07 12:00 +0100
            [RESEND PATCH 6/6] perf: powerpc: choose local entry point with kretprobes "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2017-03-07 12:00 +0100
              [PATCH v2 6/6] perf: powerpc: choose local entry point with kretprobes "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2017-03-07 22:00 +0100
            [RESEND PATCH 2/6] powerpc: kretprobes: override default function entry offset "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2017-03-07 12:00 +0100
            [PATCH 5/6] perf: probes: move ftrace README parsing logic into trace-event-parse.c "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2017-03-07 12:00 +0100
              Re: [PATCH 5/6] perf: probes: move ftrace README parsing logic into  trace-event-parse.c Masami Hiramatsu <mhiramat@kernel.org> - 2017-03-07 17:00 +0100
                Re: [PATCH 5/6] perf: probes: move ftrace README parsing logic into  trace-event-parse.c "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2017-03-07 20:50 +0100
              Re: [PATCH 5/6] perf: probes: move ftrace README parsing logic into  trace-event-parse.c "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2017-03-07 17:40 +0100
              Re: [PATCH 5/6] perf: probes: move ftrace README parsing logic into  trace-event-parse.c Masami Hiramatsu <mhiramat@kernel.org> - 2017-03-07 18:50 +0100
        Re: [PATCH v4 2/3] perf: kretprobes: offset from reloc_sym if kernel supports it "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2017-03-07 01:50 +0100
    Re: [PATCH v4 2/3] perf: kretprobes: offset from reloc_sym if kernel  supports it "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> - 2017-03-06 16:10 +0100
      Re: [PATCH v4 2/3] perf: kretprobes: offset from reloc_sym if  kernel supports it Masami Hiramatsu <mhiramat@kernel.org> - 2017-03-06 22:30 +0100

csiph-web