From: Alexei Starovoitov <ast@fb.com>
To: Peter Zijlstra <peterz@infradead.org>, Song Liu <songliubraving@fb.com>
Cc: <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: Thu, 23 Nov 2017 22:31:29 -0800 [thread overview]
Message-ID: <adfbe341-7599-6819-27ef-4bc13cb65d6d@fb.com> (raw)
In-Reply-To: <20171123100214.qm3s4h5b6i4r2iaa@hirez.programming.kicks-ass.net>
On 11/23/17 2:02 AM, Peter Zijlstra wrote:
> On Wed, Nov 15, 2017 at 09:23:33AM -0800, Song Liu wrote:
>
>> Note: We use type __u64 for pointer probe_desc instead of __aligned_u64.
>> The reason here is to avoid changing the size of struct perf_event_attr,
>> and breaking new-kernel-old-utility scenario. To avoid alignment problem
>> with the pointer, we will (in the following patches) copy probe_desc to
>> __aligned_u64 before using it as pointer.
>
> ISTR there are only relatively few architectures where __u64 and
> __aligned_u64 are not the same thing.
>
> The comment that goes with it seems to suggest i386 has short alignment
> for u64 but my compiler says differently:
>
> printf("%d, %d\n", sizeof(unsigned long long), __alignof__(unsigned long long));
>
> $ gcc -m32 -o align align.c && ./align
> 8, 8
unfortunately 32-bit is more screwed than it seems:
$ cat align.c
#include <stdio.h>
struct S {
unsigned long long a;
} s;
struct U {
unsigned long long a;
} u;
int main()
{
printf("%d, %d\n", sizeof(unsigned long long),
__alignof__(unsigned long long));
printf("%d, %d\n", sizeof(s), __alignof__(s));
printf("%d, %d\n", sizeof(u), __alignof__(u));
}
$ gcc -m32 align.c
$ ./a.out
8, 8
8, 4
8, 4
so we have to use __aligned_u64 in uapi.
Otherwise, yes, we could have used config1 and config2 to pass pointers
to the kernel, but since they're defined as __u64 already we cannot
change them and have to do this ugly dance around 'config' field.
If you prefer we can do the same around 'config1', but it's not
any prettier.
We considered adding __aligned_u64 to the end of
'struct perf_event_attr', but it's a waste for most users, so reusing
the space of 'config' field like this seems the least evil.
next prev parent reply other threads:[~2017-11-24 6:32 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 [this message]
2017-11-24 8:28 ` Peter Zijlstra
2017-11-26 1:59 ` Alexei Starovoitov
2017-11-27 7:58 ` Peter Zijlstra
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=adfbe341-7599-6819-27ef-4bc13cb65d6d@fb.com \
--to=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=peterz@infradead.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
all inboxes | Powered by JetHome®