Some perf user space improvements
These two patches fix two problems in the "perf" tool I ran into recently. The main one is fixing the compilation on gcc 4.0, which one of my test boxes still uses (that's actually an old patch submitted some time ago, but never got applied)
-Andi
PATCH 1/2 perf: Fix compilation on gcc 4.0.2
From: Andi Kleen <[email protected]>
--- tools/perf/Makefile | 4 ++-- tools/perf/util/include/linux/bitops.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-)
tools/perf/Makefile +2 -2
@@ -201,13 +201,13 @@ EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wshadow EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Winit-self EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wpacked EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wredundant-decls -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstack-protector +#EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstack-protector EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-aliasing=3 EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-default EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-enum EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wno-system-headers EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wundef -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wvolatile-register-var +#EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wvolatile-register-var EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wwrite-strings EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wbad-function-cast EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wmissing-declarations
tools/perf/util/include/linux/bitops.h +1 -0
@@ -2,6 +2,7 @@#define _PERF_LINUX_BITOPS_H_#include <linux/kernel.h> +#include <linux/compiler.h> #include <asm/hweight.h> #define BITS_PER_LONG __WORDSIZE
Signature · 1 line
1.7.1
Re: [PATCH 1/2] perf: Fix compilation on gcc 4.0.2
Quoted 13 lines · Andi Kleen
From: Andi Kleen <[email protected]>
Signed-off-by Andi Kleen <[email protected]>--- tools/perf/Makefile | 4 ++-- tools/perf/util/include/linux/bitops.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-)tools/perf/Makefile +0
-0
tools/perf/Makefile EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wshadow · line 204
Quoted 5 lines
tools/perf/Makefile +1
-1@@ -201,13 +201,13 @@ EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wshadow EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Winit-self EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wpacked EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wredundant-decls -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstack-protector +#EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstack-protector
Should we be using more of the kernel makefile magic to detect this?
Re: [PATCH 1/2] perf: Fix compilation on gcc 4.0.2
Quoted 1 line
Should we be using more of the kernel makefile magic to detect this?
In theory yes, but the two warnings didn't seem to be too useful to me so it's probably not worth it just for those two.
-Andi
Signature · 1 line
[email protected] -- Speaking for myself only.
Re: [PATCH 1/2] perf: Fix compilation on gcc 4.0.2
Quoted 7 lines · Andi Kleen
Quoted 1 line
Should we be using more of the kernel makefile magic to detect this?
In theory yes, but the two warnings didn't seem to be too useful to me so it's probably not worth it just for those two.
-Andi
Is the second case because of the __always_inline in util/include/linux/bitops.h ?
Not sure why its needed for test_bit() ?
tools/perf/util/include/linux/bitops.h +1 -1
@@ -13,7 +13,7 @@ static inline void set_bit(int nr, unsigned long *addr) addr[nr /BITS_PER_LONG ] |=1UL << (nr %BITS_PER_LONG ); } -static __always_inline int test_bit(unsigned int nr, const unsigned long *addr) +static inline int test_bit (unsigned int nr,const unsigned long *addr) {return ((1UL << (nr %BITS_PER_LONG )) & (((unsigned long *)addr)[nr /BITS_PER_LONG ])) !=0 ;
Re: [PATCH 1/2] perf: Fix compilation on gcc 4.0.2
Quoted 11 lines · Eric Dumazet
Quoted 7 lines · Andi Kleen
Quoted 1 line
Should we be using more of the kernel makefile magic to detect this?
In theory yes, but the two warnings didn't seem to be too useful to me so it's probably not worth it just for those two.
-Andi
Is the second case because of the
__always_inlineinutil/include/linux/bitops.h?
I think so.
Quoted 2 lines
Not sure why its needed for
test_bit()?
Because it generates terrible code when not inlined and apparently some gcc versions of times past didn't in some cases.
-Andi
PATCH 1/2 perf: Fix compilation on gcc 4.0.2 v2
In reply to Peter Zijlstra[Updated version, this time using the try-cc command. I remove the useless -Wvolatile-register-var warning. I don't think any kernel coder will really do such a thing in the first place.]
- Fix includes
- Remove useless -Wvolatile-register-var
- Move -Wstack-protector into stack protector test
tools/perf/Makefile +2 -4
@@ -201,13 +201,11 @@ EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wshadow EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Winit-self EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wpacked EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wredundant-decls -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstack-protector EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-aliasing=3 EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-default EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-enum EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wno-system-headers EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wundef -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wvolatile-register-var EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wwrite-strings EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wbad-function-cast EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wmissing-declarations
@@ -287,8 +285,8 @@ endif -include feature-tests.mak -ifeq ($(call try-cc,$(SOURCE_HELLO),-Werror -fstack-protector-all),y) - CFLAGS := $(CFLAGS) -fstack-protector-all +ifeq ($(call try-cc,$(SOURCE_HELLO),-Werror -fstack-protector-all -Wstack-protector),y) + CFLAGS := $(CFLAGS) -fstack-protector-all -Wstack-protector endif
tools/perf/util/include/linux/bitops.h +1 -0
@@ -1,6 +1,7 @@#ifndef _PERF_LINUX_BITOPS_H_#define _PERF_LINUX_BITOPS_H_ +#include <linux/compiler.h> #include <linux/kernel.h> #include <asm/hweight.h>
Signature · 1 line
[email protected] -- Speaking for myself only.
Re: [PATCH 1/2] perf: Fix compilation on gcc 4.0.2
In reply to Andi KleenQuoted 13 lines · Andi Kleen
From: Andi Kleen <[email protected]>
Signed-off-by Andi Kleen <[email protected]>--- tools/perf/Makefile | 4 ++-- tools/perf/util/include/linux/bitops.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-)tools/perf/Makefile +0
-0
tools/perf/Makefile EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wshadow · line 204
Quoted 5 lines
tools/perf/Makefile +1
-1@@ -201,13 +201,13 @@ EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wshadow EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Winit-self EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wpacked EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wredundant-decls -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstack-protector +#EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstack-protector
Hmm, can we make that autodetected ?
Thanks,
tglx
PATCH 2/2 perf: Handle perf-versionnumber
In reply to Andi KleenFrom: Andi Kleen <[email protected]>
Sometimes it's useful to have multiple perfs with version number around. This was defeated by the internal command code. Don't try to handle a number as a internal command.
--- tools/perf/perf.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
tools/perf/perf.c +4 -1
@@ -444,8 +444,11 @@ int main(int argc, const char **argv)* * So we just directly call the internal command handler, and * die if that one cannot handle it. +* +* If there is a number after the - don't do this. Assume it's +* a perf-VERSIONNUMBER */ -if (!prefixcmp (cmd,"perf-" )) { +if (!prefixcmp (cmd,"perf-" ) && !isdigit (cmd[5 ])) { cmd +=5 ; argv[0 ] = cmd;handle_internal_command (argc, argv);
Signature · 1 line
1.7.1