public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf tool: Fix cross-endian analysis
@ 2015-04-09 20:15 David Ahern
  2015-04-10  8:27 ` Jiri Olsa
  2015-04-11  6:37 ` [tip:perf/core] perf tools: " tip-bot for David Ahern
  0 siblings, 2 replies; 5+ messages in thread
From: David Ahern @ 2015-04-09 20:15 UTC (permalink / raw)
  To: acme; +Cc: linux-kernel, David Ahern, Jiri Olsa, Namhyung Kim

Trying to analyze a big endian data file on little endian system
fails with the error:
  0xa9b40 [0x70]: failed to process type: 9

The problem is that header parsing is not done correctly because
the file attributes are not swapped. Make it so. With this patch
able to analyze a sparc64 data file on x86_64.

Signed-off-by: David Ahern <david.ahern@oracle.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/header.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index e38cf62..45b7e72 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -2586,8 +2586,11 @@ int perf_session__read_header(struct perf_session *session)
 		if (read_attr(fd, header, &f_attr) < 0)
 			goto out_errno;
 
-		if (header->needs_swap)
+		if (header->needs_swap) {
+			f_attr.ids.size   = bswap_64(f_attr.ids.size);
+			f_attr.ids.offset = bswap_64(f_attr.ids.offset);
 			perf_event__attr_swap(&f_attr.attr);
+		}
 
 		tmp = lseek(fd, 0, SEEK_CUR);
 		evsel = perf_evsel__new(&f_attr.attr);
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] perf tool: Fix cross-endian analysis
  2015-04-09 20:15 [PATCH] perf tool: Fix cross-endian analysis David Ahern
@ 2015-04-10  8:27 ` Jiri Olsa
  2015-04-10 12:49   ` Arnaldo Carvalho de Melo
  2015-04-10 13:52   ` David Ahern
  2015-04-11  6:37 ` [tip:perf/core] perf tools: " tip-bot for David Ahern
  1 sibling, 2 replies; 5+ messages in thread
From: Jiri Olsa @ 2015-04-10  8:27 UTC (permalink / raw)
  To: David Ahern; +Cc: acme, linux-kernel, Jiri Olsa, Namhyung Kim

On Thu, Apr 09, 2015 at 04:15:46PM -0400, David Ahern wrote:
> Trying to analyze a big endian data file on little endian system
> fails with the error:
>   0xa9b40 [0x70]: failed to process type: 9
> 
> The problem is that header parsing is not done correctly because
> the file attributes are not swapped. Make it so. With this patch
> able to analyze a sparc64 data file on x86_64.
> 
> Signed-off-by: David Ahern <david.ahern@oracle.com>
> Cc: Jiri Olsa <jolsa@kernel.org>
> Cc: Namhyung Kim <namhyung@kernel.org>
> ---
>  tools/perf/util/header.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
> index e38cf62..45b7e72 100644
> --- a/tools/perf/util/header.c
> +++ b/tools/perf/util/header.c
> @@ -2586,8 +2586,11 @@ int perf_session__read_header(struct perf_session *session)
>  		if (read_attr(fd, header, &f_attr) < 0)
>  			goto out_errno;
>  
> -		if (header->needs_swap)
> +		if (header->needs_swap) {
> +			f_attr.ids.size   = bswap_64(f_attr.ids.size);
> +			f_attr.ids.offset = bswap_64(f_attr.ids.offset);
>  			perf_event__attr_swap(&f_attr.attr);
> +		}

so people do actually use it ;-)

Acked-by: Jiri Olsa <jolsa@kernel.org>

thanks,
jirka

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] perf tool: Fix cross-endian analysis
  2015-04-10  8:27 ` Jiri Olsa
@ 2015-04-10 12:49   ` Arnaldo Carvalho de Melo
  2015-04-10 13:52   ` David Ahern
  1 sibling, 0 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-04-10 12:49 UTC (permalink / raw)
  To: Jiri Olsa; +Cc: David Ahern, linux-kernel, Jiri Olsa, Namhyung Kim

Em Fri, Apr 10, 2015 at 10:27:26AM +0200, Jiri Olsa escreveu:
> On Thu, Apr 09, 2015 at 04:15:46PM -0400, David Ahern wrote:
> > Trying to analyze a big endian data file on little endian system
> > fails with the error:
> >   0xa9b40 [0x70]: failed to process type: 9
> > 
> > The problem is that header parsing is not done correctly because
> > the file attributes are not swapped. Make it so. With this patch
> > able to analyze a sparc64 data file on x86_64.
> > 
> > Signed-off-by: David Ahern <david.ahern@oracle.com>
> > Cc: Jiri Olsa <jolsa@kernel.org>
> > Cc: Namhyung Kim <namhyung@kernel.org>
> > ---
> >  tools/perf/util/header.c |    5 ++++-
> >  1 files changed, 4 insertions(+), 1 deletions(-)
> > 
> > diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
> > index e38cf62..45b7e72 100644
> > --- a/tools/perf/util/header.c
> > +++ b/tools/perf/util/header.c
> > @@ -2586,8 +2586,11 @@ int perf_session__read_header(struct perf_session *session)
> >  		if (read_attr(fd, header, &f_attr) < 0)
> >  			goto out_errno;
> >  
> > -		if (header->needs_swap)
> > +		if (header->needs_swap) {
> > +			f_attr.ids.size   = bswap_64(f_attr.ids.size);
> > +			f_attr.ids.offset = bswap_64(f_attr.ids.offset);
> >  			perf_event__attr_swap(&f_attr.attr);
> > +		}
> 
> so people do actually use it ;-)
> 
> Acked-by: Jiri Olsa <jolsa@kernel.org>

Thanks, applied.

- Arnaldo

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] perf tool: Fix cross-endian analysis
  2015-04-10  8:27 ` Jiri Olsa
  2015-04-10 12:49   ` Arnaldo Carvalho de Melo
@ 2015-04-10 13:52   ` David Ahern
  1 sibling, 0 replies; 5+ messages in thread
From: David Ahern @ 2015-04-10 13:52 UTC (permalink / raw)
  To: Jiri Olsa; +Cc: acme, linux-kernel, Jiri Olsa, Namhyung Kim

On 4/10/15 2:27 AM, Jiri Olsa wrote:
> so people do actually use it;-)

not when it's broken :-)

I've had to fix this a few times over the years, but before ppc on x86 
with top of tree was not frequent enough. sparc on x86 will be.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [tip:perf/core] perf tools: Fix cross-endian analysis
  2015-04-09 20:15 [PATCH] perf tool: Fix cross-endian analysis David Ahern
  2015-04-10  8:27 ` Jiri Olsa
@ 2015-04-11  6:37 ` tip-bot for David Ahern
  1 sibling, 0 replies; 5+ messages in thread
From: tip-bot for David Ahern @ 2015-04-11  6:37 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, david.ahern, jolsa, linux-kernel, tglx, namhyung, acme,
	hpa

Commit-ID:  1060ab857f64f33a9445881fd31fa91470aeb622
Gitweb:     http://git.kernel.org/tip/1060ab857f64f33a9445881fd31fa91470aeb622
Author:     David Ahern <david.ahern@oracle.com>
AuthorDate: Thu, 9 Apr 2015 16:15:46 -0400
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 10 Apr 2015 10:13:58 -0300

perf tools: Fix cross-endian analysis

Trying to analyze a big endian data file on little endian system fails
with the error:

  0xa9b40 [0x70]: failed to process type: 9

The problem is that header parsing is not done correctly because the
file attributes are not swapped. Make it so. With this patch able to
analyze a sparc64 data file on x86_64.

Signed-off-by: David Ahern <david.ahern@oracle.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1428610546-178789-1-git-send-email-david.ahern@oracle.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/header.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index fff3b2a..918fd8a 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -2504,8 +2504,11 @@ int perf_session__read_header(struct perf_session *session)
 		if (read_attr(fd, header, &f_attr) < 0)
 			goto out_errno;
 
-		if (header->needs_swap)
+		if (header->needs_swap) {
+			f_attr.ids.size   = bswap_64(f_attr.ids.size);
+			f_attr.ids.offset = bswap_64(f_attr.ids.offset);
 			perf_event__attr_swap(&f_attr.attr);
+		}
 
 		tmp = lseek(fd, 0, SEEK_CUR);
 		evsel = perf_evsel__new(&f_attr.attr);

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-04-11  6:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-09 20:15 [PATCH] perf tool: Fix cross-endian analysis David Ahern
2015-04-10  8:27 ` Jiri Olsa
2015-04-10 12:49   ` Arnaldo Carvalho de Melo
2015-04-10 13:52   ` David Ahern
2015-04-11  6:37 ` [tip:perf/core] perf tools: " tip-bot for David Ahern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox