linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf hist browser: change print format from lu to llu to fit u64 type
@ 2014-11-18 23:00 Tom Huynh
  2014-11-25 23:51 ` Matt Mullins
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Huynh @ 2014-11-18 23:00 UTC (permalink / raw)
  To: mingo, acme, namhyung, jolsa
  Cc: a.p.zijlstra, paulus, kim.phillips, linux-kernel, Tom Huynh

nr_events in tools/perf/ui/browsers/hists.c is of type u64, thus it should
be printed as %llu instead of %lu. The print format %lu causes perf report
to show 0 event count when running with 32-bit userspace without 
redirection. This patch fixes that problem.

Signed-off-by: Tom Huynh <tom.huynh@freescale.com>
---
 tools/perf/ui/browsers/hists.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index cfb976b..49b2471 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1254,7 +1254,7 @@ static int hists__browser_title(struct hists *hists,
 
 	nr_samples = convert_unit(nr_samples, &unit);
 	printed = scnprintf(bf, size,
-			   "Samples: %lu%c of event '%s', Event count (approx.): %lu",
+			   "Samples: %lu%c of event '%s', Event count (approx.): %llu",
 			   nr_samples, unit, ev_name, nr_events);
 
 
-- 
1.9.1


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

* Re: [PATCH] perf hist browser: change print format from lu to llu to fit u64 type
  2014-11-18 23:00 [PATCH] perf hist browser: change print format from lu to llu to fit u64 type Tom Huynh
@ 2014-11-25 23:51 ` Matt Mullins
  2014-11-26  7:57   ` Jiri Olsa
  0 siblings, 1 reply; 3+ messages in thread
From: Matt Mullins @ 2014-11-25 23:51 UTC (permalink / raw)
  To: Tom Huynh
  Cc: mingo, acme, namhyung, jolsa, a.p.zijlstra, paulus, kim.phillips,
	linux-kernel

On Tue, Nov 18, 2014 at 05:00:27PM -0600, Tom Huynh wrote:
> nr_events in tools/perf/ui/browsers/hists.c is of type u64, thus it should
> be printed as %llu instead of %lu. The print format %lu causes perf report
> to show 0 event count when running with 32-bit userspace without 
> redirection. This patch fixes that problem.
> 
> Signed-off-by: Tom Huynh <tom.huynh@freescale.com>
> ---
>  tools/perf/ui/browsers/hists.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
> index cfb976b..49b2471 100644
> --- a/tools/perf/ui/browsers/hists.c
> +++ b/tools/perf/ui/browsers/hists.c
> @@ -1254,7 +1254,7 @@ static int hists__browser_title(struct hists *hists,
>  
>  	nr_samples = convert_unit(nr_samples, &unit);
>  	printed = scnprintf(bf, size,
> -			   "Samples: %lu%c of event '%s', Event count (approx.): %lu",
> +			   "Samples: %lu%c of event '%s', Event count (approx.): %llu",
>  			   nr_samples, unit, ev_name, nr_events);

If I enable __attribute__((format(printf, ...))) on scnprintf, on a 64-bit
build this gives me:

ui/browsers/hists.c: In function ‘hists__browser_title’:
ui/browsers/hists.c:1258:7: error: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 7 has type ‘u64’ [-Werror=format=]
       nr_samples, unit, ev_name, nr_events);
       ^

I would usually suggest using the PRIu64 macro which should(TM) evaluate to the
right string constant for the platform, but that appears to be a C99 thing.
I'm not sure if that's kosher in tools/perf, but it does seem to build for me
(on Fedora 20).

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

* Re: [PATCH] perf hist browser: change print format from lu to llu to fit u64 type
  2014-11-25 23:51 ` Matt Mullins
@ 2014-11-26  7:57   ` Jiri Olsa
  0 siblings, 0 replies; 3+ messages in thread
From: Jiri Olsa @ 2014-11-26  7:57 UTC (permalink / raw)
  To: Tom Huynh, mingo, acme, namhyung, jolsa, a.p.zijlstra, paulus,
	kim.phillips, linux-kernel

On Tue, Nov 25, 2014 at 03:51:30PM -0800, Matt Mullins wrote:
> On Tue, Nov 18, 2014 at 05:00:27PM -0600, Tom Huynh wrote:
> > nr_events in tools/perf/ui/browsers/hists.c is of type u64, thus it should
> > be printed as %llu instead of %lu. The print format %lu causes perf report
> > to show 0 event count when running with 32-bit userspace without 
> > redirection. This patch fixes that problem.
> > 
> > Signed-off-by: Tom Huynh <tom.huynh@freescale.com>
> > ---
> >  tools/perf/ui/browsers/hists.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
> > index cfb976b..49b2471 100644
> > --- a/tools/perf/ui/browsers/hists.c
> > +++ b/tools/perf/ui/browsers/hists.c
> > @@ -1254,7 +1254,7 @@ static int hists__browser_title(struct hists *hists,
> >  
> >  	nr_samples = convert_unit(nr_samples, &unit);
> >  	printed = scnprintf(bf, size,
> > -			   "Samples: %lu%c of event '%s', Event count (approx.): %lu",
> > +			   "Samples: %lu%c of event '%s', Event count (approx.): %llu",
> >  			   nr_samples, unit, ev_name, nr_events);
> 
> If I enable __attribute__((format(printf, ...))) on scnprintf, on a 64-bit
> build this gives me:
> 
> ui/browsers/hists.c: In function ‘hists__browser_title’:
> ui/browsers/hists.c:1258:7: error: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 7 has type ‘u64’ [-Werror=format=]
>        nr_samples, unit, ev_name, nr_events);
>        ^
> 
> I would usually suggest using the PRIu64 macro which should(TM) evaluate to the
> right string constant for the platform, but that appears to be a C99 thing.
> I'm not sure if that's kosher in tools/perf, but it does seem to build for me
> (on Fedora 20).

[jolsa@krava linux-perf]$ grep -rI PRIu64 tools/perf/ | wc -l
97

yep, it's kosher enough ;-)

jirka

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

end of thread, other threads:[~2014-11-26  7:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-18 23:00 [PATCH] perf hist browser: change print format from lu to llu to fit u64 type Tom Huynh
2014-11-25 23:51 ` Matt Mullins
2014-11-26  7:57   ` Jiri Olsa

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).