From: Peter Zijlstra <peterz@infradead.org>
To: Alexei Starovoitov <ast@fb.com>
Cc: Song Liu <songliubraving@fb.com>,
rostedt@goodmis.org, mingo@redhat.com, davem@davemloft.net,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
daniel@iogearbox.net, kernel-team@fb.com
Subject: Re: [PATCH 1/6] perf: Add new type PERF_TYPE_PROBE
Date: Mon, 27 Nov 2017 08:58:50 +0100 [thread overview]
Message-ID: <20171127075850.atthbazr4oywwoc6@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <11e688f0-c1bc-8925-225a-5b8e795336c7@fb.com>
On Sat, Nov 25, 2017 at 05:59:54PM -0800, Alexei Starovoitov wrote:
> If we were poking into 'struct perf_event_attr __user *uptr'
> directly like get|put_user(.., &uptr->config)
> then 32-bit user space with 4-byte aligned u64s would cause
> 64-bit kernel to trap on archs like sparc.
But surely archs that have hardware alignment requirements have __u64 ==
__aligned_u64 ?
It's just that the structure layout can change between archs that have
__u64 != __aligned_u64 and __u64 == __aligned_u64.
But I would argue an architecture that has hardware alignment
requirements and has an unaligned __u64 is just plain broken.
> But in this case you're right. We can use config[12] as-is, since these
> u64 fields are passing the value one way only (into the kernel) and
> we do full perf_copy_attr() first and all further accesses are from
> copied structure and u64_to_user_ptr(event->attr.config) will be fine.
Right. Also note that there are no holes in perf_event_attr, if the
structure itself is allocated aligned the individual fields will be
aligned.
> Do you mind we do
> union {
> __u64 file_path;
> __u64 func_name;
> __u64 config;
> };
> and similar with config1 ?
> Or prefer that we use 'config/config1' to store string+offset there?
> I think config/config1 is cleaner than config1/config2
I would prefer you use config1/config2 for this and leave config itself
for modifiers (like the retprobe thing). It also better lines up with
the BP stuff.
A little something like so perhaps:
diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
index 362493a2f950..b6e76512f757 100644
--- a/include/uapi/linux/perf_event.h
+++ b/include/uapi/linux/perf_event.h
@@ -380,10 +380,14 @@ struct perf_event_attr {
__u32 bp_type;
union {
__u64 bp_addr;
+ __u64 uprobe_path;
+ __u64 kprobe_func;
__u64 config1; /* extension of config */
};
union {
__u64 bp_len;
+ __u64 kprobe_addr;
+ __u64 probe_offset;
__u64 config2; /* extension of config1 */
};
__u64 branch_sample_type; /* enum perf_branch_sample_type */
next prev parent reply other threads:[~2017-11-27 7:59 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-15 17:23 [PATCH 0/6] enable creating [k,u]probe with perf_event_open Song Liu
2017-11-15 17:23 ` [PATCH] bcc: Try use new API to create " Song Liu
2017-11-15 17:23 ` [PATCH 1/6] perf: Add new type PERF_TYPE_PROBE Song Liu
2017-11-23 10:02 ` Peter Zijlstra
2017-11-24 6:31 ` Alexei Starovoitov
2017-11-24 8:28 ` Peter Zijlstra
2017-11-26 1:59 ` Alexei Starovoitov
2017-11-27 7:58 ` Peter Zijlstra [this message]
2017-11-23 10:22 ` Peter Zijlstra
2017-11-30 1:43 ` Song Liu
2017-11-30 13:37 ` Peter Zijlstra
2017-11-15 17:23 ` [PATCH] perf_event_open.2: add " Song Liu
2017-11-15 17:23 ` [PATCH 2/6] perf: copy new perf_event.h to tools/include/uapi Song Liu
2017-11-15 17:23 ` [PATCH 3/6] perf: implement kprobe support to PERF_TYPE_PROBE Song Liu
2017-11-23 10:06 ` Peter Zijlstra
2017-11-15 17:23 ` [PATCH 4/6] perf: implement uprobe " Song Liu
2017-11-15 17:23 ` [PATCH 5/6] bpf: add option for bpf_load.c to use PERF_TYPE_PROBE Song Liu
2017-11-15 17:23 ` [PATCH 6/6] bpf: add new test test_many_kprobe Song Liu
2017-11-22 5:00 ` [PATCH 0/6] enable creating [k,u]probe with perf_event_open Alexei Starovoitov
2017-11-23 9:02 ` Christoph Hellwig
2017-11-23 9:49 ` Peter Zijlstra
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=20171127075850.atthbazr4oywwoc6@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=ast@fb.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=kernel-team@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=songliubraving@fb.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 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).