public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Fix perf tool issues in tip/perf/core
@ 2014-01-15 10:44 Mark Rutland
  2014-01-15 10:44 ` [PATCH 1/3] perf: tools: Fix aliasing violation in zfree uses Mark Rutland
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Mark Rutland @ 2014-01-15 10:44 UTC (permalink / raw)
  To: linux-kernel, Jiri Olsa, Arnaldo Carvalho de Melo, Ingo Molnar
  Cc: Will Deacon, Mark Rutland

Hi Ingo, Arnaldo, Jiri,

While trying to fix perf tool cross-builds I noticed that in tip/perf/core
there are new build issues over v3.13-rc8: a build failure on x86_64, and a new
set of warnings on arm.

The following patches fix cross-building (at least for arm) and fix the new
build issues on both arm and x86_64.

Cheers,
Mark.

Mark Rutland (3):
  perf: tools: Fix aliasing violation in zfree uses
  tools lib traceevent: fix pointer-integer size mismatch
  perf: tools: fix cross building

 tools/lib/traceevent/plugin_cfg80211.c    | 2 +-
 tools/lib/traceevent/plugin_scsi.c        | 2 +-
 tools/perf/Makefile.perf                  | 1 +
 tools/perf/config/Makefile                | 6 +++---
 tools/perf/config/feature-checks/Makefile | 9 +++++----
 tools/perf/util/srcline.c                 | 4 ++--
 tools/perf/util/strlist.c                 | 2 +-
 7 files changed, 14 insertions(+), 12 deletions(-)

-- 
1.8.1.1


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

* [PATCH 1/3] perf: tools: Fix aliasing violation in zfree uses
  2014-01-15 10:44 [PATCH 0/3] Fix perf tool issues in tip/perf/core Mark Rutland
@ 2014-01-15 10:44 ` Mark Rutland
  2014-01-15 10:44 ` [PATCH 2/3] tools lib traceevent: fix pointer-integer size mismatch Mark Rutland
  2014-01-15 10:44 ` [PATCH 3/3] perf: tools: fix cross building Mark Rutland
  2 siblings, 0 replies; 9+ messages in thread
From: Mark Rutland @ 2014-01-15 10:44 UTC (permalink / raw)
  To: linux-kernel, Jiri Olsa, Arnaldo Carvalho de Melo, Ingo Molnar
  Cc: Will Deacon, Mark Rutland

Commit 74cf249d5cf7 (perf tools: Use zfree to help detect
use after free bugs) changed many uses of free to zfree, which
automatically clears the pointer. However, in a couple of places it
casts a const char** to void**, which the compiler doesn't like:

  cc1: warnings being treated as errors
  util/strlist.c: In function ‘str_node__delete’:
  util/strlist.c:42: error: dereferencing type-punned pointer will break strict-aliasing rules
  util/strlist.c:42: error: dereferencing type-punned pointer will break strict-aliasing rules
  make[1]: *** [util/strlist.o] Error 1

This patch fixes the issue by only throwing away the const, casting to char**
instead. This is more readily accepted by the compiler.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
---
 tools/perf/util/srcline.c | 4 ++--
 tools/perf/util/strlist.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c
index 7e67879..f3e4bc5 100644
--- a/tools/perf/util/srcline.c
+++ b/tools/perf/util/srcline.c
@@ -129,7 +129,7 @@ static struct a2l_data *addr2line_init(const char *path)
 
 out:
 	if (a2l) {
-		zfree((void **)&a2l->input);
+		zfree((char **)&a2l->input);
 		free(a2l);
 	}
 	bfd_close(abfd);
@@ -140,7 +140,7 @@ static void addr2line_cleanup(struct a2l_data *a2l)
 {
 	if (a2l->abfd)
 		bfd_close(a2l->abfd);
-	zfree((void **)&a2l->input);
+	zfree((char **)&a2l->input);
 	zfree(&a2l->syms);
 	free(a2l);
 }
diff --git a/tools/perf/util/strlist.c b/tools/perf/util/strlist.c
index 61a90bf..71f9d10 100644
--- a/tools/perf/util/strlist.c
+++ b/tools/perf/util/strlist.c
@@ -39,7 +39,7 @@ out_delete:
 static void str_node__delete(struct str_node *snode, bool dupstr)
 {
 	if (dupstr)
-		zfree((void **)&snode->s);
+		zfree((char **)&snode->s);
 	free(snode);
 }
 
-- 
1.8.1.1


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

* [PATCH 2/3] tools lib traceevent: fix pointer-integer size mismatch
  2014-01-15 10:44 [PATCH 0/3] Fix perf tool issues in tip/perf/core Mark Rutland
  2014-01-15 10:44 ` [PATCH 1/3] perf: tools: Fix aliasing violation in zfree uses Mark Rutland
@ 2014-01-15 10:44 ` Mark Rutland
  2014-01-15 18:14   ` Arnaldo Carvalho de Melo
  2014-01-16 13:39   ` [tip:perf/core] " tip-bot for Mark Rutland
  2014-01-15 10:44 ` [PATCH 3/3] perf: tools: fix cross building Mark Rutland
  2 siblings, 2 replies; 9+ messages in thread
From: Mark Rutland @ 2014-01-15 10:44 UTC (permalink / raw)
  To: linux-kernel, Jiri Olsa, Arnaldo Carvalho de Melo, Ingo Molnar
  Cc: Will Deacon, Mark Rutland

The scsi and cfg80211 plugins cast between unsigned long long and
pointers, which is problematic for architectures where unsigned long
long is wider than the native pointer size:

  linux/tools/lib/traceevent/plugin_scsi.c: In function ‘process_scsi_trace_parse_cdb’:
  linux/tools/lib/traceevent/plugin_scsi.c:408:26: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
    scsi_trace_parse_cdb(s, (unsigned char *) args[1], args[2]);

  linux/tools/lib/traceevent/plugin_cfg80211.c: In function ‘process___le16_to_cpup’:
  linux/tools/lib/traceevent/plugin_cfg80211.c:11:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
    uint16_t *val = (uint16_t *) args[0];

This patch adds an intermediate cast to unsigned long, silencing the
warning.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Ingo Molnar <mingo@redhat.com>
---
 tools/lib/traceevent/plugin_cfg80211.c | 2 +-
 tools/lib/traceevent/plugin_scsi.c     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

I'm not sure about this one as I'm not certain I read all the sites
input values for args could be generated. I'd appreciate if someone more
familiar with traceevent plugins could verify this makes sense.

Mark.

diff --git a/tools/lib/traceevent/plugin_cfg80211.c b/tools/lib/traceevent/plugin_cfg80211.c
index dcab8e8..57e9822 100644
--- a/tools/lib/traceevent/plugin_cfg80211.c
+++ b/tools/lib/traceevent/plugin_cfg80211.c
@@ -8,7 +8,7 @@ static unsigned long long
 process___le16_to_cpup(struct trace_seq *s,
 		       unsigned long long *args)
 {
-	uint16_t *val = (uint16_t *) args[0];
+	uint16_t *val = (uint16_t *) (unsigned long) args[0];
 	return val ? (long long) le16toh(*val) : 0;
 }
 
diff --git a/tools/lib/traceevent/plugin_scsi.c b/tools/lib/traceevent/plugin_scsi.c
index 6fb8e3e..7ef16cc 100644
--- a/tools/lib/traceevent/plugin_scsi.c
+++ b/tools/lib/traceevent/plugin_scsi.c
@@ -405,7 +405,7 @@ scsi_trace_parse_cdb(struct trace_seq *p, unsigned char *cdb, int len)
 unsigned long long process_scsi_trace_parse_cdb(struct trace_seq *s,
 						unsigned long long *args)
 {
-	scsi_trace_parse_cdb(s, (unsigned char *) args[1], args[2]);
+	scsi_trace_parse_cdb(s, (unsigned char *) (unsigned long) args[1], args[2]);
 	return 0;
 }
 
-- 
1.8.1.1


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

* [PATCH 3/3] perf: tools: fix cross building
  2014-01-15 10:44 [PATCH 0/3] Fix perf tool issues in tip/perf/core Mark Rutland
  2014-01-15 10:44 ` [PATCH 1/3] perf: tools: Fix aliasing violation in zfree uses Mark Rutland
  2014-01-15 10:44 ` [PATCH 2/3] tools lib traceevent: fix pointer-integer size mismatch Mark Rutland
@ 2014-01-15 10:44 ` Mark Rutland
  2014-01-16 13:38   ` [tip:perf/core] perf: tools: Fix " tip-bot for Mark Rutland
  2 siblings, 1 reply; 9+ messages in thread
From: Mark Rutland @ 2014-01-15 10:44 UTC (permalink / raw)
  To: linux-kernel, Jiri Olsa, Arnaldo Carvalho de Melo, Ingo Molnar
  Cc: Will Deacon, Mark Rutland

Currently the feature-checks Makefile does not inherit $(CC), and calls
cc rather than $(CROSS_COMPILE)gcc. Thus the feature checks invoke the
native toolchain rather than the cross toolchain, and can identify
features as available when they are not. This can break the build.

Additionally the native pkg-config is always called as opposed to
$(CROSS_COMPILE)pkg-config, so the wrong flags and paths may be passed
to the cross compiler.

This patch passes CROSS_COMPILE down to the feature-checks Makefile, and
forces its use. Additionally pkg-config is replaced with
$(CROSS_COMPILE)pkg-config via a new $(PKG_CONFIG) variable. This patch
has been build tested on x86_64 and arm.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
---
 tools/perf/Makefile.perf                  | 1 +
 tools/perf/config/Makefile                | 6 +++---
 tools/perf/config/feature-checks/Makefile | 9 +++++----
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 87d7726..7257e7e 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -76,6 +76,7 @@ $(OUTPUT)PERF-VERSION-FILE: ../../.git/HEAD
 
 CC = $(CROSS_COMPILE)gcc
 AR = $(CROSS_COMPILE)ar
+PKG_CONFIG = $(CROSS_COMPILE)pkg-config
 
 RM      = rm -f
 LN      = ln -f
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 01dd43d..d604e50 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -372,7 +372,7 @@ ifndef NO_SLANG
 endif
 
 ifndef NO_GTK2
-  FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null)
+  FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
   ifneq ($(feature-gtk2), 1)
     msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
     NO_GTK2 := 1
@@ -381,8 +381,8 @@ ifndef NO_GTK2
       GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
     endif
     CFLAGS += -DHAVE_GTK2_SUPPORT
-    GTK_CFLAGS += $(shell pkg-config --cflags gtk+-2.0 2>/dev/null)
-    GTK_LIBS := $(shell pkg-config --libs gtk+-2.0 2>/dev/null)
+    GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)
+    GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)
     EXTLIBS += -ldl
   endif
 endif
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 7cf6fcd..12e5513 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -28,7 +28,8 @@ FILES=					\
 	test-stackprotector-all.bin	\
 	test-timerfd.bin
 
-CC := $(CC) -MD
+CC := $(CROSS_COMPILE)gcc -MD
+PKG_CONFIG := $(CROSS_COMPILE)pkg-config
 
 all: $(FILES)
 
@@ -37,7 +38,7 @@ BUILD = $(CC) $(CFLAGS) -o $(OUTPUT)$@ $(patsubst %.bin,%.c,$@) $(LDFLAGS)
 ###############################
 
 test-all.bin:
-	$(BUILD) -Werror -fstack-protector-all -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -laudit -I/usr/include/slang -lslang $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl
+	$(BUILD) -Werror -fstack-protector-all -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -laudit -I/usr/include/slang -lslang $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl
 
 test-hello.bin:
 	$(BUILD)
@@ -82,10 +83,10 @@ test-libslang.bin:
 	$(BUILD) -I/usr/include/slang -lslang
 
 test-gtk2.bin:
-	$(BUILD) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null)
+	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
 
 test-gtk2-infobar.bin:
-	$(BUILD) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null)
+	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
 
 grep-libs  = $(filter -l%,$(1))
 strip-libs = $(filter-out -l%,$(1))
-- 
1.8.1.1


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

* Re: [PATCH 2/3] tools lib traceevent: fix pointer-integer size mismatch
  2014-01-15 10:44 ` [PATCH 2/3] tools lib traceevent: fix pointer-integer size mismatch Mark Rutland
@ 2014-01-15 18:14   ` Arnaldo Carvalho de Melo
  2014-01-15 18:42     ` Jiri Olsa
  2014-01-15 19:40     ` Steven Rostedt
  2014-01-16 13:39   ` [tip:perf/core] " tip-bot for Mark Rutland
  1 sibling, 2 replies; 9+ messages in thread
From: Arnaldo Carvalho de Melo @ 2014-01-15 18:14 UTC (permalink / raw)
  To: Steven Rostedt, Jiri Olsa
  Cc: Mark Rutland, linux-kernel, Ingo Molnar, Will Deacon

Em Wed, Jan 15, 2014 at 10:44:07AM +0000, Mark Rutland escreveu:
> The scsi and cfg80211 plugins cast between unsigned long long and
> pointers, which is problematic for architectures where unsigned long
> long is wider than the native pointer size:
> 
>   linux/tools/lib/traceevent/plugin_scsi.c: In function ‘process_scsi_trace_parse_cdb’:
>   linux/tools/lib/traceevent/plugin_scsi.c:408:26: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
>     scsi_trace_parse_cdb(s, (unsigned char *) args[1], args[2]);
> 
>   linux/tools/lib/traceevent/plugin_cfg80211.c: In function ‘process___le16_to_cpup’:
>   linux/tools/lib/traceevent/plugin_cfg80211.c:11:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
>     uint16_t *val = (uint16_t *) args[0];
> 
> This patch adds an intermediate cast to unsigned long, silencing the
> warning.

Steven, Jiri: Acked-by?
 
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Cc: Jiri Olsa <jolsa@redhat.com>
> Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
> Cc: Ingo Molnar <mingo@redhat.com>
> ---
>  tools/lib/traceevent/plugin_cfg80211.c | 2 +-
>  tools/lib/traceevent/plugin_scsi.c     | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> I'm not sure about this one as I'm not certain I read all the sites
> input values for args could be generated. I'd appreciate if someone more
> familiar with traceevent plugins could verify this makes sense.
> 
> Mark.
> 
> diff --git a/tools/lib/traceevent/plugin_cfg80211.c b/tools/lib/traceevent/plugin_cfg80211.c
> index dcab8e8..57e9822 100644
> --- a/tools/lib/traceevent/plugin_cfg80211.c
> +++ b/tools/lib/traceevent/plugin_cfg80211.c
> @@ -8,7 +8,7 @@ static unsigned long long
>  process___le16_to_cpup(struct trace_seq *s,
>  		       unsigned long long *args)
>  {
> -	uint16_t *val = (uint16_t *) args[0];
> +	uint16_t *val = (uint16_t *) (unsigned long) args[0];
>  	return val ? (long long) le16toh(*val) : 0;
>  }
>  
> diff --git a/tools/lib/traceevent/plugin_scsi.c b/tools/lib/traceevent/plugin_scsi.c
> index 6fb8e3e..7ef16cc 100644
> --- a/tools/lib/traceevent/plugin_scsi.c
> +++ b/tools/lib/traceevent/plugin_scsi.c
> @@ -405,7 +405,7 @@ scsi_trace_parse_cdb(struct trace_seq *p, unsigned char *cdb, int len)
>  unsigned long long process_scsi_trace_parse_cdb(struct trace_seq *s,
>  						unsigned long long *args)
>  {
> -	scsi_trace_parse_cdb(s, (unsigned char *) args[1], args[2]);
> +	scsi_trace_parse_cdb(s, (unsigned char *) (unsigned long) args[1], args[2]);
>  	return 0;
>  }
>  
> -- 
> 1.8.1.1

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

* Re: [PATCH 2/3] tools lib traceevent: fix pointer-integer size mismatch
  2014-01-15 18:14   ` Arnaldo Carvalho de Melo
@ 2014-01-15 18:42     ` Jiri Olsa
  2014-01-15 19:40     ` Steven Rostedt
  1 sibling, 0 replies; 9+ messages in thread
From: Jiri Olsa @ 2014-01-15 18:42 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Steven Rostedt, Mark Rutland, linux-kernel, Ingo Molnar,
	Will Deacon

On Wed, Jan 15, 2014 at 03:14:06PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Wed, Jan 15, 2014 at 10:44:07AM +0000, Mark Rutland escreveu:
> > The scsi and cfg80211 plugins cast between unsigned long long and
> > pointers, which is problematic for architectures where unsigned long
> > long is wider than the native pointer size:
> > 
> >   linux/tools/lib/traceevent/plugin_scsi.c: In function ‘process_scsi_trace_parse_cdb’:
> >   linux/tools/lib/traceevent/plugin_scsi.c:408:26: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
> >     scsi_trace_parse_cdb(s, (unsigned char *) args[1], args[2]);
> > 
> >   linux/tools/lib/traceevent/plugin_cfg80211.c: In function ‘process___le16_to_cpup’:
> >   linux/tools/lib/traceevent/plugin_cfg80211.c:11:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
> >     uint16_t *val = (uint16_t *) args[0];
> > 
> > This patch adds an intermediate cast to unsigned long, silencing the
> > warning.
> 
> Steven, Jiri: Acked-by?
>  

yep, looks ok.. args values hold pointer values, so it's ok to
convert them to pointer's size, 'unsigned long' has pointer's
size on x86-32/64.

also it compiles for me ;-)

Acked-by: Jiri Olsa <jolsa@redhat.com>

thanks,
jirka

> > Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> > Cc: Jiri Olsa <jolsa@redhat.com>
> > Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
> > Cc: Ingo Molnar <mingo@redhat.com>
> > ---
> >  tools/lib/traceevent/plugin_cfg80211.c | 2 +-
> >  tools/lib/traceevent/plugin_scsi.c     | 2 +-
> >  2 files changed, 2 insertions(+), 2 deletions(-)
> > 
> > I'm not sure about this one as I'm not certain I read all the sites
> > input values for args could be generated. I'd appreciate if someone more
> > familiar with traceevent plugins could verify this makes sense.
> > 
> > Mark.
> > 
> > diff --git a/tools/lib/traceevent/plugin_cfg80211.c b/tools/lib/traceevent/plugin_cfg80211.c
> > index dcab8e8..57e9822 100644
> > --- a/tools/lib/traceevent/plugin_cfg80211.c
> > +++ b/tools/lib/traceevent/plugin_cfg80211.c
> > @@ -8,7 +8,7 @@ static unsigned long long
> >  process___le16_to_cpup(struct trace_seq *s,
> >  		       unsigned long long *args)
> >  {
> > -	uint16_t *val = (uint16_t *) args[0];
> > +	uint16_t *val = (uint16_t *) (unsigned long) args[0];
> >  	return val ? (long long) le16toh(*val) : 0;
> >  }
> >  
> > diff --git a/tools/lib/traceevent/plugin_scsi.c b/tools/lib/traceevent/plugin_scsi.c
> > index 6fb8e3e..7ef16cc 100644
> > --- a/tools/lib/traceevent/plugin_scsi.c
> > +++ b/tools/lib/traceevent/plugin_scsi.c
> > @@ -405,7 +405,7 @@ scsi_trace_parse_cdb(struct trace_seq *p, unsigned char *cdb, int len)
> >  unsigned long long process_scsi_trace_parse_cdb(struct trace_seq *s,
> >  						unsigned long long *args)
> >  {
> > -	scsi_trace_parse_cdb(s, (unsigned char *) args[1], args[2]);
> > +	scsi_trace_parse_cdb(s, (unsigned char *) (unsigned long) args[1], args[2]);
> >  	return 0;
> >  }
> >  
> > -- 
> > 1.8.1.1

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

* Re: [PATCH 2/3] tools lib traceevent: fix pointer-integer size mismatch
  2014-01-15 18:14   ` Arnaldo Carvalho de Melo
  2014-01-15 18:42     ` Jiri Olsa
@ 2014-01-15 19:40     ` Steven Rostedt
  1 sibling, 0 replies; 9+ messages in thread
From: Steven Rostedt @ 2014-01-15 19:40 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, Mark Rutland, linux-kernel, Ingo Molnar, Will Deacon

On Wed, 15 Jan 2014 15:14:06 -0300
Arnaldo Carvalho de Melo <acme@ghostprotocols.net> wrote:

> Em Wed, Jan 15, 2014 at 10:44:07AM +0000, Mark Rutland escreveu:
> > The scsi and cfg80211 plugins cast between unsigned long long and
> > pointers, which is problematic for architectures where unsigned long
> > long is wider than the native pointer size:
> > 
> >   linux/tools/lib/traceevent/plugin_scsi.c: In function ‘process_scsi_trace_parse_cdb’:
> >   linux/tools/lib/traceevent/plugin_scsi.c:408:26: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
> >     scsi_trace_parse_cdb(s, (unsigned char *) args[1], args[2]);
> > 
> >   linux/tools/lib/traceevent/plugin_cfg80211.c: In function ‘process___le16_to_cpup’:
> >   linux/tools/lib/traceevent/plugin_cfg80211.c:11:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
> >     uint16_t *val = (uint16_t *) args[0];
> > 
> > This patch adds an intermediate cast to unsigned long, silencing the
> > warning.
> 
> Steven, Jiri: Acked-by?

Yep, that's the correct solution.

Acked-by: Steven Rostedt <rostedt@goodmis.org>

-- Steve

>  
> > Signed-off-by: Mark Rutland <mark.rutland@arm.com>


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

* [tip:perf/core] perf: tools: Fix cross building
  2014-01-15 10:44 ` [PATCH 3/3] perf: tools: fix cross building Mark Rutland
@ 2014-01-16 13:38   ` tip-bot for Mark Rutland
  0 siblings, 0 replies; 9+ messages in thread
From: tip-bot for Mark Rutland @ 2014-01-16 13:38 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, mingo, hpa, mingo, will.deacon, mark.rutland,
	jolsa, tglx

Commit-ID:  a8a5cd8b472ca20e5b8fa649c43b3756867322f8
Gitweb:     http://git.kernel.org/tip/a8a5cd8b472ca20e5b8fa649c43b3756867322f8
Author:     Mark Rutland <mark.rutland@arm.com>
AuthorDate: Wed, 15 Jan 2014 10:44:08 +0000
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 15 Jan 2014 15:15:05 -0300

perf: tools: Fix cross building

Currently the feature-checks Makefile does not inherit $(CC), and calls
cc rather than $(CROSS_COMPILE)gcc. Thus the feature checks invoke the
native toolchain rather than the cross toolchain, and can identify
features as available when they are not. This can break the build.

Additionally the native pkg-config is always called as opposed to
$(CROSS_COMPILE)pkg-config, so the wrong flags and paths may be passed
to the cross compiler.

This patch passes CROSS_COMPILE down to the feature-checks Makefile, and
forces its use. Additionally pkg-config is replaced with
$(CROSS_COMPILE)pkg-config via a new $(PKG_CONFIG) variable. This patch
has been build tested on x86_64 and arm.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Will Deacon <will.deacon@arm.com>
Link: http://lkml.kernel.org/r/1389782648-4417-4-git-send-email-mark.rutland@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Makefile.perf                  | 1 +
 tools/perf/config/Makefile                | 6 +++---
 tools/perf/config/feature-checks/Makefile | 9 +++++----
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 87d7726..7257e7e 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -76,6 +76,7 @@ $(OUTPUT)PERF-VERSION-FILE: ../../.git/HEAD
 
 CC = $(CROSS_COMPILE)gcc
 AR = $(CROSS_COMPILE)ar
+PKG_CONFIG = $(CROSS_COMPILE)pkg-config
 
 RM      = rm -f
 LN      = ln -f
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 01dd43d..d604e50 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -372,7 +372,7 @@ ifndef NO_SLANG
 endif
 
 ifndef NO_GTK2
-  FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null)
+  FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
   ifneq ($(feature-gtk2), 1)
     msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
     NO_GTK2 := 1
@@ -381,8 +381,8 @@ ifndef NO_GTK2
       GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
     endif
     CFLAGS += -DHAVE_GTK2_SUPPORT
-    GTK_CFLAGS += $(shell pkg-config --cflags gtk+-2.0 2>/dev/null)
-    GTK_LIBS := $(shell pkg-config --libs gtk+-2.0 2>/dev/null)
+    GTK_CFLAGS += $(shell $(PKG_CONFIG) --cflags gtk+-2.0 2>/dev/null)
+    GTK_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0 2>/dev/null)
     EXTLIBS += -ldl
   endif
 endif
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 7cf6fcd..12e5513 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -28,7 +28,8 @@ FILES=					\
 	test-stackprotector-all.bin	\
 	test-timerfd.bin
 
-CC := $(CC) -MD
+CC := $(CROSS_COMPILE)gcc -MD
+PKG_CONFIG := $(CROSS_COMPILE)pkg-config
 
 all: $(FILES)
 
@@ -37,7 +38,7 @@ BUILD = $(CC) $(CFLAGS) -o $(OUTPUT)$@ $(patsubst %.bin,%.c,$@) $(LDFLAGS)
 ###############################
 
 test-all.bin:
-	$(BUILD) -Werror -fstack-protector-all -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -laudit -I/usr/include/slang -lslang $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl
+	$(BUILD) -Werror -fstack-protector-all -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -laudit -I/usr/include/slang -lslang $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl
 
 test-hello.bin:
 	$(BUILD)
@@ -82,10 +83,10 @@ test-libslang.bin:
 	$(BUILD) -I/usr/include/slang -lslang
 
 test-gtk2.bin:
-	$(BUILD) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null)
+	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
 
 test-gtk2-infobar.bin:
-	$(BUILD) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null)
+	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
 
 grep-libs  = $(filter -l%,$(1))
 strip-libs = $(filter-out -l%,$(1))

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

* [tip:perf/core] tools lib traceevent: fix pointer-integer size mismatch
  2014-01-15 10:44 ` [PATCH 2/3] tools lib traceevent: fix pointer-integer size mismatch Mark Rutland
  2014-01-15 18:14   ` Arnaldo Carvalho de Melo
@ 2014-01-16 13:39   ` tip-bot for Mark Rutland
  1 sibling, 0 replies; 9+ messages in thread
From: tip-bot for Mark Rutland @ 2014-01-16 13:39 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, mingo, hpa, mingo, will.deacon, mark.rutland,
	jolsa, rostedt, tglx

Commit-ID:  0e9e79a13ab9d56b86db6538305babc23b1445cc
Gitweb:     http://git.kernel.org/tip/0e9e79a13ab9d56b86db6538305babc23b1445cc
Author:     Mark Rutland <mark.rutland@arm.com>
AuthorDate: Wed, 15 Jan 2014 10:44:07 +0000
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 15 Jan 2014 17:04:38 -0300

tools lib traceevent: fix pointer-integer size mismatch

The scsi and cfg80211 plugins cast between unsigned long long and
pointers, which is problematic for architectures where unsigned long
long is wider than the native pointer size:

  linux/tools/lib/traceevent/plugin_scsi.c: In function ‘process_scsi_trace_parse_cdb’:
  linux/tools/lib/traceevent/plugin_scsi.c:408:26: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
    scsi_trace_parse_cdb(s, (unsigned char *) args[1], args[2]);

  linux/tools/lib/traceevent/plugin_cfg80211.c: In function ‘process___le16_to_cpup’:
  linux/tools/lib/traceevent/plugin_cfg80211.c:11:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
    uint16_t *val = (uint16_t *) args[0];

This patch adds an intermediate cast to unsigned long, silencing the
warning.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Will Deacon <will.deacon@arm.com>
Link: http://lkml.kernel.org/r/1389782648-4417-3-git-send-email-mark.rutland@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/lib/traceevent/plugin_cfg80211.c | 2 +-
 tools/lib/traceevent/plugin_scsi.c     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/lib/traceevent/plugin_cfg80211.c b/tools/lib/traceevent/plugin_cfg80211.c
index dcab8e8..57e9822 100644
--- a/tools/lib/traceevent/plugin_cfg80211.c
+++ b/tools/lib/traceevent/plugin_cfg80211.c
@@ -8,7 +8,7 @@ static unsigned long long
 process___le16_to_cpup(struct trace_seq *s,
 		       unsigned long long *args)
 {
-	uint16_t *val = (uint16_t *) args[0];
+	uint16_t *val = (uint16_t *) (unsigned long) args[0];
 	return val ? (long long) le16toh(*val) : 0;
 }
 
diff --git a/tools/lib/traceevent/plugin_scsi.c b/tools/lib/traceevent/plugin_scsi.c
index 6fb8e3e..7ef16cc 100644
--- a/tools/lib/traceevent/plugin_scsi.c
+++ b/tools/lib/traceevent/plugin_scsi.c
@@ -405,7 +405,7 @@ scsi_trace_parse_cdb(struct trace_seq *p, unsigned char *cdb, int len)
 unsigned long long process_scsi_trace_parse_cdb(struct trace_seq *s,
 						unsigned long long *args)
 {
-	scsi_trace_parse_cdb(s, (unsigned char *) args[1], args[2]);
+	scsi_trace_parse_cdb(s, (unsigned char *) (unsigned long) args[1], args[2]);
 	return 0;
 }
 

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

end of thread, other threads:[~2014-01-16 13:39 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-15 10:44 [PATCH 0/3] Fix perf tool issues in tip/perf/core Mark Rutland
2014-01-15 10:44 ` [PATCH 1/3] perf: tools: Fix aliasing violation in zfree uses Mark Rutland
2014-01-15 10:44 ` [PATCH 2/3] tools lib traceevent: fix pointer-integer size mismatch Mark Rutland
2014-01-15 18:14   ` Arnaldo Carvalho de Melo
2014-01-15 18:42     ` Jiri Olsa
2014-01-15 19:40     ` Steven Rostedt
2014-01-16 13:39   ` [tip:perf/core] " tip-bot for Mark Rutland
2014-01-15 10:44 ` [PATCH 3/3] perf: tools: fix cross building Mark Rutland
2014-01-16 13:38   ` [tip:perf/core] perf: tools: Fix " tip-bot for Mark Rutland

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