[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <641005c453661_4258120826@john.notmuch>
Date: Mon, 13 Mar 2023 22:27:32 -0700
From: John Fastabend <john.fastabend@...il.com>
To: Ross Zwisler <zwisler@...gle.com>,
Steven Rostedt <rostedt@...dmis.org>
Cc: zwisler@...nel.org, bpf@...r.kernel.org,
linux-kernel@...r.kernel.org, Alexei Starovoitov <ast@...nel.org>,
Andrii Nakryiko <andrii@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Hao Luo <haoluo@...gle.com>, Jason Gunthorpe <jgg@...pe.ca>,
Jiri Olsa <jolsa@...nel.org>,
John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>,
Leon Romanovsky <leon@...nel.org>,
Martin KaFai Lau <martin.lau@...ux.dev>,
Mykola Lysenko <mykolal@...com>, Shuah Khan <shuah@...nel.org>,
Song Liu <song@...nel.org>,
Stanislav Fomichev <sdf@...gle.com>,
Yonghong Song <yhs@...com>, linux-kselftest@...r.kernel.org,
linux-rdma@...r.kernel.org, linux-trace-kernel@...r.kernel.org,
"Michael S . Tsirkin" <mst@...hat.com>
Subject: Re: [PATCH bpf-next v3 2/2] selftests/bpf: use canonical ftrace path
Ross Zwisler wrote:
> On Fri, Mar 10, 2023 at 06:33:52PM -0500, Steven Rostedt wrote:
> > On Fri, 10 Mar 2023 10:52:09 -0700
> > zwisler@...nel.org wrote:
> >
> > > diff --git a/tools/testing/selftests/bpf/get_cgroup_id_user.c b/tools/testing/selftests/bpf/get_cgroup_id_user.c
> > > index 156743cf5870..4fa61ac8a0ee 100644
> > > --- a/tools/testing/selftests/bpf/get_cgroup_id_user.c
> > > +++ b/tools/testing/selftests/bpf/get_cgroup_id_user.c
> > > @@ -86,8 +86,12 @@ int main(int argc, char **argv)
> > > pid = getpid();
> > > bpf_map_update_elem(pidmap_fd, &key, &pid, 0);
> > >
> > > - snprintf(buf, sizeof(buf),
> > > - "/sys/kernel/debug/tracing/events/%s/id", probe_name);
> > > + if (access("/sys/kernel/tracing/trace", F_OK) == 0)
> > > + snprintf(buf, sizeof(buf),
> > > + "/sys/kernel/tracing/events/%s/id", probe_name);
> > > + else
> > > + snprintf(buf, sizeof(buf),
> > > + "/sys/kernel/debug/tracing/events/%s/id", probe_name);
> >
> > I don't know how the BPF folks feel, but I do know some kernel developers
> > prefer that if you need to break a single command into multiple lines that
> > you then need to add brackets around it. As it makes it easier to read.
> >
> > if (access("/sys/kernel/tracing/trace", F_OK) == 0) {
> > snprintf(buf, sizeof(buf),
> > "/sys/kernel/tracing/events/%s/id", probe_name);
> > } else {
> > snprintf(buf, sizeof(buf),
> > "/sys/kernel/debug/tracing/events/%s/id", probe_name);
> > }
> >
> >
> >
> > > efd = open(buf, O_RDONLY, 0);
> > > if (CHECK(efd < 0, "open", "err %d errno %d\n", efd, errno))
> > > goto close_prog;
> > > diff --git a/tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c b/tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c
> > > index 113dba349a57..22be0a9a5a0a 100644
> > > --- a/tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c
> > > +++ b/tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c
> > > @@ -338,7 +338,12 @@ static int get_syms(char ***symsp, size_t *cntp, bool kernel)
> > > * Filtering out duplicates by using hashmap__add, which won't
> > > * add existing entry.
> > > */
> > > - f = fopen("/sys/kernel/debug/tracing/available_filter_functions", "r");
> > > +
> > > + if (access("/sys/kernel/tracing/trace", F_OK) == 0)
> > > + f = fopen("/sys/kernel/tracing/available_filter_functions", "r");
> > > + else
> > > + f = fopen("/sys/kernel/debug/tracing/available_filter_functions", "r");
> > > +
> > > if (!f)
> > > return -EINVAL;
> > >
> > > diff --git a/tools/testing/selftests/bpf/prog_tests/task_fd_query_tp.c b/tools/testing/selftests/bpf/prog_tests/task_fd_query_tp.c
> > > index c717741bf8b6..60f92fd3c37a 100644
> > > --- a/tools/testing/selftests/bpf/prog_tests/task_fd_query_tp.c
> > > +++ b/tools/testing/selftests/bpf/prog_tests/task_fd_query_tp.c
> > > @@ -17,8 +17,12 @@ static void test_task_fd_query_tp_core(const char *probe_name,
> > > if (CHECK(err, "bpf_prog_test_load", "err %d errno %d\n", err, errno))
> > > goto close_prog;
> > >
> > > - snprintf(buf, sizeof(buf),
> > > - "/sys/kernel/debug/tracing/events/%s/id", probe_name);
> > > + if (access("/sys/kernel/tracing/trace", F_OK) == 0)
> > > + snprintf(buf, sizeof(buf),
> > > + "/sys/kernel/tracing/events/%s/id", probe_name);
> > > + else
> > > + snprintf(buf, sizeof(buf),
> > > + "/sys/kernel/debug/tracing/events/%s/id", probe_name);
> >
> > Same here.
> >
> > > efd = open(buf, O_RDONLY, 0);
> > > if (CHECK(efd < 0, "open", "err %d errno %d\n", efd, errno))
> > > goto close_prog;
> > > diff --git a/tools/testing/selftests/bpf/prog_tests/tp_attach_query.c b/tools/testing/selftests/bpf/prog_tests/tp_attach_query.c
> > > index 770fcc3bb1ba..d3e377fa8e9b 100644
> > > --- a/tools/testing/selftests/bpf/prog_tests/tp_attach_query.c
> > > +++ b/tools/testing/selftests/bpf/prog_tests/tp_attach_query.c
> > > @@ -16,8 +16,12 @@ void serial_test_tp_attach_query(void)
> > > for (i = 0; i < num_progs; i++)
> > > obj[i] = NULL;
> > >
> > > - snprintf(buf, sizeof(buf),
> > > - "/sys/kernel/debug/tracing/events/sched/sched_switch/id");
> > > + if (access("/sys/kernel/tracing/trace", F_OK) == 0)
> > > + snprintf(buf, sizeof(buf),
> > > + "/sys/kernel/tracing/events/sched/sched_switch/id");
> > > + else
> > > + snprintf(buf, sizeof(buf),
> > > + "/sys/kernel/debug/tracing/events/sched/sched_switch/id");
> >
> > and here.
> >
> > But perhaps the BPF folks don't care?
>
> Sure, I agree that this is more readable. I'll gather your Reviewed-by for
> patch #1, make this change, rebase to the current bpf/bpf-next and send out
> v4.
Also for the patch. LGTM
Acked-by: John Fastabend <john.fastabend@...il.com>
Powered by blists - more mailing lists