From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Sumanth Korikkar <sumanthk@linux.ibm.com>
Cc: linux-perf-users@vger.kernel.org, bpf@vger.kernel.org,
Jiri Olsa <jolsa@kernel.org>,
tmricht@linux.ibm.com, heiko.carstens@de.ibm.com,
mhiramat@kernel.org, iii@linux.ibm.com,
Steven Rostedt <rostedt@goodmis.org>,
Namhyung Kim <namhyung@kernel.org>,
Wang Nan <wangnan0@huawei.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/2] perf: Fix bpf prologue generation
Date: Tue, 9 Jun 2020 12:27:14 -0300 [thread overview]
Message-ID: <20200609152714.GE24868@kernel.org> (raw)
In-Reply-To: <20200609081019.60234-3-sumanthk@linux.ibm.com>
Em Tue, Jun 09, 2020 at 10:10:19AM +0200, Sumanth Korikkar escreveu:
> Issue:
> bpf_probe_read is no longer available for architecture which has
> overlapping address space. Hence bpf prologue generation fails
>
> Fix:
> Use bpf_probe_read_kernel for kernel member access. For user
> attribute access in kprobes, use bpf_probe_read_user.
>
> Other:
> @user attribute was introduced in commit 1e032f7cfa14 ("perf-probe:
> Add user memory access attribute support")
>
> Test:
> 1. ulimit -l 128 ; ./perf record -e tests/bpf_sched_setscheduler.c
> 2. cat tests/bpf_sched_setscheduler.c
>
> static void (*bpf_trace_printk)(const char *fmt, int fmt_size, ...) =
> (void *) 6;
> static int (*bpf_probe_read_user)(void *dst, __u32 size,
> const void *unsafe_ptr) = (void *) 112;
> static int (*bpf_probe_read_kernel)(void *dst, __u32 size,
> const void *unsafe_ptr) = (void *) 113;
>
> SEC("func=do_sched_setscheduler pid policy param->sched_priority@user")
> int bpf_func__setscheduler(void *ctx, int err, pid_t pid, int policy,
> int param)
> {
> char fmt[] = "prio: %ld";
> bpf_trace_printk(fmt, sizeof(fmt), param);
> return 1;
> }
>
> char _license[] SEC("license") = "GPL";
> int _version SEC("version") = LINUX_VERSION_CODE;
>
> 3. ./perf script
> sched 305669 [000] 1614458.838675: perf_bpf_probe:func: (2904e508)
> pid=261614 policy=2 sched_priority=1
>
> 4. cat /sys/kernel/debug/tracing/trace
> <...>-309956 [006] .... 1616098.093957: 0: prio: 1
Thanks for providing a detailed set of steps to test your patch, that is
great!
I added this, an alterenative way to test it, combining all the aspects
in one 'perf trace' call:
Committer testing:
I had to add some missing headers in the bpf_sched_setscheduler.c test
proggie, then instead of using record+script I used 'perf trace' to
drive everything in one go:
# cat bpf_sched_setscheduler.c
#include <linux/types.h>
#include <bpf.h>
static void (*bpf_trace_printk)(const char *fmt, int fmt_size, ...) = (void *) 6;
static int (*bpf_probe_read_user)(void *dst, __u32 size, const void *unsafe_ptr) = (void *) 112;
static int (*bpf_probe_read_kernel)(void *dst, __u32 size, const void *unsafe_ptr) = (void *) 113;
SEC("func=do_sched_setscheduler pid policy param->sched_priority@user")
int bpf_func__setscheduler(void *ctx, int err, pid_t pid, int policy, int param)
{
char fmt[] = "prio: %ld";
bpf_trace_printk(fmt, sizeof(fmt), param);
return 1;
}
char _license[] SEC("license") = "GPL";
int _version SEC("version") = LINUX_VERSION_CODE;
#
#
# perf trace -e bpf_sched_setscheduler.c chrt -f 42 sleep 1
0.000 chrt/80125 perf_bpf_probe:func(__probe_ip: -1676607808, policy: 1, sched_priority: 42)
#
And even with backtraces :-)
# perf trace -e bpf_sched_setscheduler.c/max-stack=8/ chrt -f 42 sleep 1
0.000 chrt/79805 perf_bpf_probe:func(__probe_ip: -1676607808, policy: 1, sched_priority: 42)
do_sched_setscheduler ([kernel.kallsyms])
__x64_sys_sched_setscheduler ([kernel.kallsyms])
do_syscall_64 ([kernel.kallsyms])
entry_SYSCALL_64 ([kernel.kallsyms])
__GI___sched_setscheduler (/usr/lib64/libc-2.30.so)
#
- Arnaldo
prev parent reply other threads:[~2020-06-09 15:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-09 8:10 [PATCH v2 0/2] perf: Fix bpf prologue generation, uaccess Sumanth Korikkar
2020-06-09 8:10 ` [PATCH v2 1/2] perf: Fix user attribute access in kprobes Sumanth Korikkar
2020-06-09 15:09 ` Arnaldo Carvalho de Melo
2020-06-09 15:13 ` Arnaldo Carvalho de Melo
2020-06-09 8:10 ` [PATCH v2 2/2] perf: Fix bpf prologue generation Sumanth Korikkar
2020-06-09 15:27 ` Arnaldo Carvalho de Melo [this message]
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=20200609152714.GE24868@kernel.org \
--to=acme@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=heiko.carstens@de.ibm.com \
--cc=iii@linux.ibm.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=namhyung@kernel.org \
--cc=rostedt@goodmis.org \
--cc=sumanthk@linux.ibm.com \
--cc=tmricht@linux.ibm.com \
--cc=wangnan0@huawei.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.