From: Jiri Olsa <jolsa@redhat.com>
To: Wang Nan <wangnan0@huawei.com>
Cc: acme@kernel.org, namhyung@kernel.org,
masami.hiramatsu.pt@hitachi.com, a.p.zijlstra@chello.nl,
mingo@redhat.com, jolsa@kernel.org, linux-kernel@vger.kernel.org,
pi3orama@163.com, lizefan@huawei.com
Subject: Re: [PATCH] perf tools: Fix a problem when opening old perf.data with different byte order
Date: Wed, 17 Jun 2015 10:46:16 +0200 [thread overview]
Message-ID: <20150617084616.GA8535@krava.redhat.com> (raw)
In-Reply-To: <1434512442-41542-1-git-send-email-wangnan0@huawei.com>
On Wed, Jun 17, 2015 at 03:40:42AM +0000, Wang Nan wrote:
> Following error occurs when trying to use 'perf report' on x86_64 to
> cross analysis a perf.data generated by an old perf on a big-endian
> machine:
>
SNIP
> - attr->branch_sample_type = bswap_64(attr->branch_sample_type);
> - attr->sample_regs_user = bswap_64(attr->sample_regs_user);
> - attr->sample_stack_user = bswap_32(attr->sample_stack_user);
> - attr->aux_watermark = bswap_32(attr->aux_watermark);
> -
> - swap_bitfield((u8 *) (&attr->read_format + 1), sizeof(u64));
> +#define bswap_safe(f) \
> + (attr->size > offsetof(struct perf_event_attr, f))
> +#define bswap_field(f, sz) \
> +do { \
> + if (bswap_safe(f)) \
> + attr->f = bswap_##sz(attr->f); \
> +} while(0)
> +#define bswap_field_32(f) bswap_field(f, 32)
> +#define bswap_field_64(f) bswap_field(f, 64)
all macros are function specific, please undef them
at the bottom
> +
> + bswap_field_64(config);
> + bswap_field_64(sample_period);
> + bswap_field_64(sample_type);
> + bswap_field_64(read_format);
> + bswap_field_32(wakeup_events);
> + bswap_field_32(bp_type);
> + bswap_field_64(bp_addr);
> + bswap_field_64(bp_len);
> + bswap_field_64(branch_sample_type);
> + bswap_field_64(sample_regs_user);
> + bswap_field_32(sample_stack_user);
> + bswap_field_32(aux_watermark);
> +
> + if (bswap_safe(read_format))
should this check for 'read_format + 1' ?
jirka
> + swap_bitfield((u8 *) (&attr->read_format + 1),
> + sizeof(u64));
> }
>
> static void perf_event__hdr_attr_swap(union perf_event *event,
> --
> 1.8.3.4
>
next prev parent reply other threads:[~2015-06-17 8:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-17 3:40 [PATCH] perf tools: Fix a problem when opening old perf.data with different byte order Wang Nan
2015-06-17 8:46 ` Jiri Olsa [this message]
2015-06-17 9:56 ` [PATCH v2] " Wang Nan
2015-06-17 18:24 ` Jiri Olsa
2015-06-18 8:16 ` [tip:perf/core] " tip-bot for Wang Nan
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=20150617084616.GA8535@krava.redhat.com \
--to=jolsa@redhat.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan@huawei.com \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=pi3orama@163.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox