linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [GIT PULL 0/2] perf/urgent fixes
@ 2014-02-28 21:25 Arnaldo Carvalho de Melo
  2014-02-28 21:25 ` [PATCH 1/2] perf tools: fix BFD detection on opensuse Arnaldo Carvalho de Melo
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Arnaldo Carvalho de Melo @ 2014-02-28 21:25 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter, Andi Kleen,
	Corey Ashford, David Ahern, Frederic Weisbecker, Jiri Olsa,
	Namhyung Kim, Paul Mackerras, Peter Zijlstra,
	Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>

Hi Ingo,

	Please consider pulling,

- Arnaldo

The following changes since commit b6e53f321ee6f4b237d8cc54fbace3217fa96e05:

  Merge tag 'perf-urgent-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent (2014-02-27 12:47:59 +0100)

are available in the git repository at:


  git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux tags/perf-urgent-for-mingo

for you to fetch changes up to b39c2a57a00a841f057a75b41df4c26173288b66:

  perf tools: Fix strict alias issue for find_first_bit (2014-02-28 10:39:40 -0300)

----------------------------------------------------------------
perf/urgent build fixes:

. Problem on recent gcc on x86-32 related to strict alias issue for
  find_first_bit (Jiri Olsa).

. OpenSuSE: BFD detection problems related to not explicitely listing all
  required libraries (Andi Kleen)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

----------------------------------------------------------------
Andi Kleen (1):
      perf tools: fix BFD detection on opensuse

Jiri Olsa (1):
      perf tools: Fix strict alias issue for find_first_bit

 tools/perf/config/Makefile                | 2 +-
 tools/perf/config/feature-checks/Makefile | 2 +-
 tools/perf/util/include/linux/bitops.h    | 4 +++-
 3 files changed, 5 insertions(+), 3 deletions(-)

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

* [PATCH 1/2] perf tools: fix BFD detection on opensuse
  2014-02-28 21:25 [GIT PULL 0/2] perf/urgent fixes Arnaldo Carvalho de Melo
@ 2014-02-28 21:25 ` Arnaldo Carvalho de Melo
  2014-02-28 21:25 ` [PATCH 2/2] perf tools: Fix strict alias issue for find_first_bit Arnaldo Carvalho de Melo
  2014-03-01  9:14 ` [GIT PULL 0/2] perf/urgent fixes Ingo Molnar
  2 siblings, 0 replies; 8+ messages in thread
From: Arnaldo Carvalho de Melo @ 2014-02-28 21:25 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Andi Kleen, Adrian Hunter, David Ahern,
	Frederic Weisbecker, Jiri Olsa, Namhyung Kim,
	Arnaldo Carvalho de Melo

From: Andi Kleen <ak@linux.intel.com>

opensuse libbfd requires -lz -liberty to build. Add those to the BFD
feature detection.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: David Ahern <dsahern@gmail.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1389469379-13340-2-git-send-email-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/config/Makefile                | 2 +-
 tools/perf/config/feature-checks/Makefile | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index c48d44958172..0331ea2701a3 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -478,7 +478,7 @@ else
 endif
 
 ifeq ($(feature-libbfd), 1)
-  EXTLIBS += -lbfd
+  EXTLIBS += -lbfd -lz -liberty
 endif
 
 ifdef NO_DEMANGLE
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 12e551346fa6..523b7bc10553 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -121,7 +121,7 @@ test-libpython-version.bin:
 	$(BUILD) $(FLAGS_PYTHON_EMBED)
 
 test-libbfd.bin:
-	$(BUILD) -DPACKAGE='"perf"' -lbfd -ldl
+	$(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
 
 test-liberty.bin:
 	$(CC) -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty
-- 
1.8.1.4


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

* [PATCH 2/2] perf tools: Fix strict alias issue for find_first_bit
  2014-02-28 21:25 [GIT PULL 0/2] perf/urgent fixes Arnaldo Carvalho de Melo
  2014-02-28 21:25 ` [PATCH 1/2] perf tools: fix BFD detection on opensuse Arnaldo Carvalho de Melo
@ 2014-02-28 21:25 ` Arnaldo Carvalho de Melo
  2014-02-28 21:29   ` Peter Zijlstra
  2014-03-01  9:14 ` [GIT PULL 0/2] perf/urgent fixes Ingo Molnar
  2 siblings, 1 reply; 8+ messages in thread
From: Arnaldo Carvalho de Melo @ 2014-02-28 21:25 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Jiri Olsa, Corey Ashford, David Ahern,
	Frederic Weisbecker, Ingo Molnar, Namhyung Kim, Paul Mackerras,
	Peter Zijlstra, Arnaldo Carvalho de Melo

From: Jiri Olsa <jolsa@redhat.com>

When compiling perf tool code with gcc 4.4.7 I'm getting
following error:

    CC       util/session.o
  cc1: warnings being treated as errors
  util/session.c: In function ‘perf_session_deliver_event’:
  tools/perf/util/include/linux/bitops.h:109: error: dereferencing pointer ‘p’ does break strict-aliasing rules
  tools/perf/util/include/linux/bitops.h:101: error: dereferencing pointer ‘p’ does break strict-aliasing rules
  util/session.c:697: note: initialized from here
  tools/perf/util/include/linux/bitops.h:101: note: initialized from here
  make[1]: *** [util/session.o] Error 1
  make: *** [util/session.o] Error 2

The aliased types here are u64 and unsigned long pointers, which is safe
for the find_first_bit processing.

This error shows up for me only for gcc 4.4 on 32bit x86, even for
-Wstrict-aliasing=3, while newer gcc are quiet and scream here for
-Wstrict-aliasing={2,1}. Looks like newer gcc changed the rules for
strict alias warnings.

The gcc documentation offers workaround for valid aliasing by using
__may_alias__ attribute:

  http://gcc.gnu.org/onlinedocs/gcc-4.4.0/gcc/Type-Attributes.html

Using this workaround for the find_first_bit function.

Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1393434867-20271-1-git-send-email-jolsa@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/include/linux/bitops.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/include/linux/bitops.h b/tools/perf/util/include/linux/bitops.h
index 45cf10a562bd..dadfa7e54287 100644
--- a/tools/perf/util/include/linux/bitops.h
+++ b/tools/perf/util/include/linux/bitops.h
@@ -87,13 +87,15 @@ static __always_inline unsigned long __ffs(unsigned long word)
 	return num;
 }
 
+typedef const unsigned long __attribute__((__may_alias__)) long_alias_t;
+
 /*
  * Find the first set bit in a memory region.
  */
 static inline unsigned long
 find_first_bit(const unsigned long *addr, unsigned long size)
 {
-	const unsigned long *p = addr;
+	long_alias_t *p = (long_alias_t *) addr;
 	unsigned long result = 0;
 	unsigned long tmp;
 
-- 
1.8.1.4


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

* Re: [PATCH 2/2] perf tools: Fix strict alias issue for find_first_bit
  2014-02-28 21:25 ` [PATCH 2/2] perf tools: Fix strict alias issue for find_first_bit Arnaldo Carvalho de Melo
@ 2014-02-28 21:29   ` Peter Zijlstra
  2014-03-01  0:03     ` David Ahern
  2014-03-06 20:46     ` Arnaldo Carvalho de Melo
  0 siblings, 2 replies; 8+ messages in thread
From: Peter Zijlstra @ 2014-02-28 21:29 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, linux-kernel, Jiri Olsa, Corey Ashford, David Ahern,
	Frederic Weisbecker, Ingo Molnar, Namhyung Kim, Paul Mackerras,
	Arnaldo Carvalho de Melo

On Fri, Feb 28, 2014 at 06:25:51PM -0300, Arnaldo Carvalho de Melo wrote:
> From: Jiri Olsa <jolsa@redhat.com>
> 
> When compiling perf tool code with gcc 4.4.7 I'm getting
> following error:
> 
>     CC       util/session.o
>   cc1: warnings being treated as errors
>   util/session.c: In function ‘perf_session_deliver_event’:
>   tools/perf/util/include/linux/bitops.h:109: error: dereferencing pointer ‘p’ does break strict-aliasing rules
>   tools/perf/util/include/linux/bitops.h:101: error: dereferencing pointer ‘p’ does break strict-aliasing rules
>   util/session.c:697: note: initialized from here
>   tools/perf/util/include/linux/bitops.h:101: note: initialized from here
>   make[1]: *** [util/session.o] Error 1
>   make: *** [util/session.o] Error 2
> 
> The aliased types here are u64 and unsigned long pointers, which is safe
> for the find_first_bit processing.
> 
> This error shows up for me only for gcc 4.4 on 32bit x86, even for
> -Wstrict-aliasing=3, while newer gcc are quiet and scream here for
> -Wstrict-aliasing={2,1}. Looks like newer gcc changed the rules for
> strict alias warnings.
> 
> The gcc documentation offers workaround for valid aliasing by using
> __may_alias__ attribute:
> 
>   http://gcc.gnu.org/onlinedocs/gcc-4.4.0/gcc/Type-Attributes.html
> 
> Using this workaround for the find_first_bit function.

Hurm; didn't I suggest using -fno-strict-aliasing just like the kernel
does? Because the C aliasing rules are bonghits heavy?

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

* Re: [PATCH 2/2] perf tools: Fix strict alias issue for find_first_bit
  2014-02-28 21:29   ` Peter Zijlstra
@ 2014-03-01  0:03     ` David Ahern
  2014-03-01  9:12       ` Ingo Molnar
  2014-03-06 20:46     ` Arnaldo Carvalho de Melo
  1 sibling, 1 reply; 8+ messages in thread
From: David Ahern @ 2014-03-01  0:03 UTC (permalink / raw)
  To: Peter Zijlstra, Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, linux-kernel, Jiri Olsa, Corey Ashford,
	Frederic Weisbecker, Ingo Molnar, Namhyung Kim, Paul Mackerras,
	Arnaldo Carvalho de Melo

On 2/28/14, 2:29 PM, Peter Zijlstra wrote:
> Hurm; didn't I suggest using -fno-strict-aliasing just like the kernel
> does? Because the C aliasing rules are bonghits heavy?

you, and Ingo in 2009 -- 65014ab3



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

* Re: [PATCH 2/2] perf tools: Fix strict alias issue for find_first_bit
  2014-03-01  0:03     ` David Ahern
@ 2014-03-01  9:12       ` Ingo Molnar
  0 siblings, 0 replies; 8+ messages in thread
From: Ingo Molnar @ 2014-03-01  9:12 UTC (permalink / raw)
  To: David Ahern
  Cc: Peter Zijlstra, Arnaldo Carvalho de Melo, linux-kernel, Jiri Olsa,
	Corey Ashford, Frederic Weisbecker, Ingo Molnar, Namhyung Kim,
	Paul Mackerras, Arnaldo Carvalho de Melo


* David Ahern <dsahern@gmail.com> wrote:

> On 2/28/14, 2:29 PM, Peter Zijlstra wrote:
> >Hurm; didn't I suggest using -fno-strict-aliasing just like the kernel
> >does? Because the C aliasing rules are bonghits heavy?
> 
> you, and Ingo in 2009 -- 65014ab3

Yeah, so that's certainly true for the kernel, but for user-space the 
aggressive optimizations that come with the aliasing rules were pretty 
good, last I checked.

So it would be nice to check the code generation and performance 
impact of -fno-strict-aliasing on perf (if any). If the impact is 
restricted to an odd few annotations for weird, low-level methods
like find_bit(), then we might be able to live with it.

The aliasing warnings can also find real bugs and uncleanlinesses.

So I'm really of two minds regarding this.

Thanks,

	Ingo

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

* Re: [GIT PULL 0/2] perf/urgent fixes
  2014-02-28 21:25 [GIT PULL 0/2] perf/urgent fixes Arnaldo Carvalho de Melo
  2014-02-28 21:25 ` [PATCH 1/2] perf tools: fix BFD detection on opensuse Arnaldo Carvalho de Melo
  2014-02-28 21:25 ` [PATCH 2/2] perf tools: Fix strict alias issue for find_first_bit Arnaldo Carvalho de Melo
@ 2014-03-01  9:14 ` Ingo Molnar
  2 siblings, 0 replies; 8+ messages in thread
From: Ingo Molnar @ 2014-03-01  9:14 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter, Andi Kleen,
	Corey Ashford, David Ahern, Frederic Weisbecker, Jiri Olsa,
	Namhyung Kim, Paul Mackerras, Peter Zijlstra,
	Arnaldo Carvalho de Melo


* Arnaldo Carvalho de Melo <acme@infradead.org> wrote:

> From: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
> 
> Hi Ingo,
> 
> 	Please consider pulling,
> 
> - Arnaldo
> 
> The following changes since commit b6e53f321ee6f4b237d8cc54fbace3217fa96e05:
> 
>   Merge tag 'perf-urgent-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent (2014-02-27 12:47:59 +0100)
> 
> are available in the git repository at:
> 
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux tags/perf-urgent-for-mingo
> 
> for you to fetch changes up to b39c2a57a00a841f057a75b41df4c26173288b66:
> 
>   perf tools: Fix strict alias issue for find_first_bit (2014-02-28 10:39:40 -0300)
> 
> ----------------------------------------------------------------
> perf/urgent build fixes:
> 
> . Problem on recent gcc on x86-32 related to strict alias issue for
>   find_first_bit (Jiri Olsa).
> 
> . OpenSuSE: BFD detection problems related to not explicitely listing all
>   required libraries (Andi Kleen)
> 
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> 
> ----------------------------------------------------------------
> Andi Kleen (1):
>       perf tools: fix BFD detection on opensuse
> 
> Jiri Olsa (1):
>       perf tools: Fix strict alias issue for find_first_bit
> 
>  tools/perf/config/Makefile                | 2 +-
>  tools/perf/config/feature-checks/Makefile | 2 +-
>  tools/perf/util/include/linux/bitops.h    | 4 +++-
>  3 files changed, 5 insertions(+), 3 deletions(-)

Pulled, thanks a lot Arnaldo!

	Ingo

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

* Re: [PATCH 2/2] perf tools: Fix strict alias issue for find_first_bit
  2014-02-28 21:29   ` Peter Zijlstra
  2014-03-01  0:03     ` David Ahern
@ 2014-03-06 20:46     ` Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 8+ messages in thread
From: Arnaldo Carvalho de Melo @ 2014-03-06 20:46 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Ingo Molnar, linux-kernel, Jiri Olsa, Corey Ashford, David Ahern,
	Frederic Weisbecker, Ingo Molnar, Namhyung Kim, Paul Mackerras

Em Fri, Feb 28, 2014 at 10:29:23PM +0100, Peter Zijlstra escreveu:
> On Fri, Feb 28, 2014 at 06:25:51PM -0300, Arnaldo Carvalho de Melo wrote:
> > From: Jiri Olsa <jolsa@redhat.com>

> > The gcc documentation offers workaround for valid aliasing by using
> > __may_alias__ attribute:

> >   http://gcc.gnu.org/onlinedocs/gcc-4.4.0/gcc/Type-Attributes.html

> > Using this workaround for the find_first_bit function.

> Hurm; didn't I suggest using -fno-strict-aliasing just like the kernel
> does? Because the C aliasing rules are bonghits heavy?

Either way would solve the problem at hand, I just used the smaller
hammer offered.

I thought that Ingo had something against this, but only reference I
could find now about it was this:

--------------------------------------------

commit 65014ab36196f6d86edc9ee23759d6930b9d89a8
Author: Ingo Molnar <mingo@elte.hu>
Date:   Wed Sep 2 14:55:55 2009 +0200

    perf tools: Work around strict aliasing related warnings
    
    Older versions of GCC are rather stupid about strict aliasing:

<SNIP>

    Make it clear to GCC that we intend with those pointers, by passing
    them through via an explicit (void *) cast.
    
    We might want to add -fno-strict-aliasing as well, like the kernel
    itself does.
    
    Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
    Cc: Mike Galbraith <efault@gmx.de>
    Cc: Paul Mackerras <paulus@samba.org>
    Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
    Cc: Frederic Weisbecker <fweisbec@gmail.com>
    LKML-Reference: <new-submission>
    Signed-off-by: Ingo Molnar <mingo@elte.hu>
--------------------------------------------

Jiri's bandaid is for _newer_ compilers, so...

- Arnaldo

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

end of thread, other threads:[~2014-03-06 20:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-28 21:25 [GIT PULL 0/2] perf/urgent fixes Arnaldo Carvalho de Melo
2014-02-28 21:25 ` [PATCH 1/2] perf tools: fix BFD detection on opensuse Arnaldo Carvalho de Melo
2014-02-28 21:25 ` [PATCH 2/2] perf tools: Fix strict alias issue for find_first_bit Arnaldo Carvalho de Melo
2014-02-28 21:29   ` Peter Zijlstra
2014-03-01  0:03     ` David Ahern
2014-03-01  9:12       ` Ingo Molnar
2014-03-06 20:46     ` Arnaldo Carvalho de Melo
2014-03-01  9:14 ` [GIT PULL 0/2] perf/urgent fixes Ingo Molnar

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