linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf: fix bench numa compilation
@ 2013-06-15 10:15 Riccardo Magliocchetti
  2013-06-17  8:55 ` Namhyung Kim
  0 siblings, 1 reply; 6+ messages in thread
From: Riccardo Magliocchetti @ 2013-06-15 10:15 UTC (permalink / raw)
  To: acme; +Cc: mingo, linux-kernel, Riccardo Magliocchetti

bench/numa.c: In function ‘worker_thread’:
bench/numa.c:1113:20: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
    if (diff.tv_sec >= g->p.nr_secs) {
                    ^
bench/numa.c:1161:6: error: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 5 has type ‘u64’ [-Werror=format=]
      process_nr, thread_nr, runtime_ns_max / bytes_done, val);
      ^

Signed-off-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
---
 tools/perf/bench/numa.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Diffed against 3.9.6 but should apply cleanly to latest git

diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c
index 30d1c32..90ef4cc 100644
--- a/tools/perf/bench/numa.c
+++ b/tools/perf/bench/numa.c
@@ -1110,7 +1110,7 @@ static void *worker_thread(void *__tdata)
 		/* Check whether our max runtime timed out: */
 		if (g->p.nr_secs) {
 			timersub(&stop, &start0, &diff);
-			if (diff.tv_sec >= g->p.nr_secs) {
+			if (diff.tv_sec >= (long int)g->p.nr_secs) {
 				g->stop_work = true;
 				break;
 			}
@@ -1157,7 +1157,7 @@ static void *worker_thread(void *__tdata)
 			runtime_ns_max += diff.tv_usec * 1000;
 
 			if (details >= 0) {
-				printf(" #%2d / %2d: %14.2lf nsecs/op [val: %016lx]\n",
+				printf(" #%2d / %2d: %14.2lf nsecs/op [val: %016llx]\n",
 					process_nr, thread_nr, runtime_ns_max / bytes_done, val);
 			}
 			fflush(stdout);
-- 
1.8.3.1


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

* Re: [PATCH] perf: fix bench numa compilation
  2013-06-15 10:15 [PATCH] perf: fix bench numa compilation Riccardo Magliocchetti
@ 2013-06-17  8:55 ` Namhyung Kim
  2013-06-17 10:54   ` Riccardo Magliocchetti
  0 siblings, 1 reply; 6+ messages in thread
From: Namhyung Kim @ 2013-06-17  8:55 UTC (permalink / raw)
  To: Riccardo Magliocchetti; +Cc: acme, mingo, linux-kernel

Hi Riccardo,

On Sat, 15 Jun 2013 12:15:14 +0200, Riccardo Magliocchetti wrote:
> bench/numa.c: In function ‘worker_thread’:
> bench/numa.c:1113:20: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
>     if (diff.tv_sec >= g->p.nr_secs) {
>                     ^
> bench/numa.c:1161:6: error: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 5 has type ‘u64’ [-Werror=format=]
>       process_nr, thread_nr, runtime_ns_max / bytes_done, val);
>       ^
>
> Signed-off-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
> ---
>  tools/perf/bench/numa.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> Diffed against 3.9.6 but should apply cleanly to latest git
>
> diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c
> index 30d1c32..90ef4cc 100644
> --- a/tools/perf/bench/numa.c
> +++ b/tools/perf/bench/numa.c
> @@ -1110,7 +1110,7 @@ static void *worker_thread(void *__tdata)
>  		/* Check whether our max runtime timed out: */
>  		if (g->p.nr_secs) {
>  			timersub(&stop, &start0, &diff);
> -			if (diff.tv_sec >= g->p.nr_secs) {
> +			if (diff.tv_sec >= (long int)g->p.nr_secs) {
>  				g->stop_work = true;
>  				break;
>  			}
> @@ -1157,7 +1157,7 @@ static void *worker_thread(void *__tdata)
>  			runtime_ns_max += diff.tv_usec * 1000;
>  
>  			if (details >= 0) {
> -				printf(" #%2d / %2d: %14.2lf nsecs/op [val: %016lx]\n",
> +				printf(" #%2d / %2d: %14.2lf nsecs/op [val: %016llx]\n",
>  					process_nr, thread_nr, runtime_ns_max / bytes_done, val);
>  			}
>  			fflush(stdout);

It will fail to build on 64 bit machines:

bench/numa.c: In function ‘worker_thread’:
bench/numa.c:1161:6: error: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 5 has type ‘u64’ [-Werror=format]
cc1: all warnings being treated as errors
make: *** [bench/numa.o] Error 1


You can use PRIx64 or cast val to unsigned long long type explicitly.

Thanks,
Namhyung

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

* [PATCH] perf: fix bench numa compilation
  2013-06-17  8:55 ` Namhyung Kim
@ 2013-06-17 10:54   ` Riccardo Magliocchetti
  2013-06-19 17:23     ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 6+ messages in thread
From: Riccardo Magliocchetti @ 2013-06-17 10:54 UTC (permalink / raw)
  To: namhyung, acme; +Cc: mingo, linux-kernel, Riccardo Magliocchetti

Fix the following errors on gcc 4.8.1 / x86:

bench/numa.c: In function ‘worker_thread’:
bench/numa.c:1113:20: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
    if (diff.tv_sec >= g->p.nr_secs) {
                    ^
bench/numa.c:1161:6: error: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 5 has type ‘u64’ [-Werror=format=]
      process_nr, thread_nr, runtime_ns_max / bytes_done, val);
      ^

Signed-off-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
---
 tools/perf/bench/numa.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

changes from v1:
- make it actually work on 64bit too as reported by Namhyung Kim

diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c
index 30d1c32..bd501454 100644
--- a/tools/perf/bench/numa.c
+++ b/tools/perf/bench/numa.c
@@ -1110,7 +1110,7 @@ static void *worker_thread(void *__tdata)
 		/* Check whether our max runtime timed out: */
 		if (g->p.nr_secs) {
 			timersub(&stop, &start0, &diff);
-			if (diff.tv_sec >= g->p.nr_secs) {
+			if (diff.tv_sec >= (long int)g->p.nr_secs) {
 				g->stop_work = true;
 				break;
 			}
@@ -1157,8 +1157,8 @@ static void *worker_thread(void *__tdata)
 			runtime_ns_max += diff.tv_usec * 1000;
 
 			if (details >= 0) {
-				printf(" #%2d / %2d: %14.2lf nsecs/op [val: %016lx]\n",
-					process_nr, thread_nr, runtime_ns_max / bytes_done, val);
+				printf(" #%2d / %2d: %14.2lf nsecs/op [val: %016llx]\n",
+					process_nr, thread_nr, runtime_ns_max / bytes_done, (unsigned long long)val);
 			}
 			fflush(stdout);
 		}
-- 
1.8.3.1


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

* Re: [PATCH] perf: fix bench numa compilation
  2013-06-17 10:54   ` Riccardo Magliocchetti
@ 2013-06-19 17:23     ` Arnaldo Carvalho de Melo
  2013-06-20  7:33       ` Riccardo Magliocchetti
  2013-06-20  7:39       ` [PATCH v3] " Riccardo Magliocchetti
  0 siblings, 2 replies; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-06-19 17:23 UTC (permalink / raw)
  To: Riccardo Magliocchetti; +Cc: namhyung, mingo, linux-kernel

> -					process_nr, thread_nr, runtime_ns_max / bytes_done, val);
> +				printf(" #%2d / %2d: %14.2lf nsecs/op [val: %016llx]\n",
> +					process_nr, thread_nr, runtime_ns_max / bytes_done, (unsigned long long)val);

Shouldn't this use PRIu64?

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

* Re: [PATCH] perf: fix bench numa compilation
  2013-06-19 17:23     ` Arnaldo Carvalho de Melo
@ 2013-06-20  7:33       ` Riccardo Magliocchetti
  2013-06-20  7:39       ` [PATCH v3] " Riccardo Magliocchetti
  1 sibling, 0 replies; 6+ messages in thread
From: Riccardo Magliocchetti @ 2013-06-20  7:33 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: namhyung, mingo, linux-kernel

Hello,

Il 19/06/2013 19:23, Arnaldo Carvalho de Melo ha scritto:
>> -					process_nr, thread_nr, runtime_ns_max / bytes_done, val);
>> +				printf(" #%2d / %2d: %14.2lf nsecs/op [val: %016llx]\n",
>> +					process_nr, thread_nr, runtime_ns_max / bytes_done, (unsigned long long)val);
>
> Shouldn't this use PRIu64?

Will respin.

thanks,
riccardo

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

* [PATCH v3] perf: fix bench numa compilation
  2013-06-19 17:23     ` Arnaldo Carvalho de Melo
  2013-06-20  7:33       ` Riccardo Magliocchetti
@ 2013-06-20  7:39       ` Riccardo Magliocchetti
  1 sibling, 0 replies; 6+ messages in thread
From: Riccardo Magliocchetti @ 2013-06-20  7:39 UTC (permalink / raw)
  To: acme; +Cc: namhyung, mingo, linux-kernel, Riccardo Magliocchetti

Fix the following errors on gcc 4.8.1 / x86:

bench/numa.c: In function ‘worker_thread’:
bench/numa.c:1113:20: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
    if (diff.tv_sec >= g->p.nr_secs) {
                    ^
bench/numa.c:1161:6: error: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 5 has type ‘u64’ [-Werror=format=]
      process_nr, thread_nr, runtime_ns_max / bytes_done, val);
      ^

Signed-off-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
---
 tools/perf/bench/numa.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Changes since v2:
- use PRIu64 as suggested by Arnaldo Carvalho da Melo

diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c
index 30d1c32..f5c0834 100644
--- a/tools/perf/bench/numa.c
+++ b/tools/perf/bench/numa.c
@@ -21,6 +21,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <pthread.h>
+#include <inttypes.h>
 #include <sys/mman.h>
 #include <sys/time.h>
 #include <sys/wait.h>
@@ -1110,7 +1111,7 @@ static void *worker_thread(void *__tdata)
 		/* Check whether our max runtime timed out: */
 		if (g->p.nr_secs) {
 			timersub(&stop, &start0, &diff);
-			if (diff.tv_sec >= g->p.nr_secs) {
+			if (diff.tv_sec >= (long int)g->p.nr_secs) {
 				g->stop_work = true;
 				break;
 			}
@@ -1157,7 +1158,7 @@ static void *worker_thread(void *__tdata)
 			runtime_ns_max += diff.tv_usec * 1000;
 
 			if (details >= 0) {
-				printf(" #%2d / %2d: %14.2lf nsecs/op [val: %016lx]\n",
+				printf(" #%2d / %2d: %14.2lf nsecs/op [val: %016"PRIu64"x]\n",
 					process_nr, thread_nr, runtime_ns_max / bytes_done, val);
 			}
 			fflush(stdout);
-- 
1.8.3.1


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

end of thread, other threads:[~2013-06-20  7:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-15 10:15 [PATCH] perf: fix bench numa compilation Riccardo Magliocchetti
2013-06-17  8:55 ` Namhyung Kim
2013-06-17 10:54   ` Riccardo Magliocchetti
2013-06-19 17:23     ` Arnaldo Carvalho de Melo
2013-06-20  7:33       ` Riccardo Magliocchetti
2013-06-20  7:39       ` [PATCH v3] " Riccardo Magliocchetti

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