linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [GIT PULL 00/15] perf/core improvements and fixes
@ 2016-07-18 23:33 Arnaldo Carvalho de Melo
  2016-07-18 23:33 ` [PATCH 01/15] perf jit: Add missing curly braces Arnaldo Carvalho de Melo
                   ` (15 more replies)
  0 siblings, 16 replies; 18+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-07-18 23:33 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter,
	Alexander Shishkin, Dan Carpenter, David Ahern, He Kuang,
	Jiri Olsa, Jiri Pirko, Josh Poimboeuf, Kan Liang, Mark Rutland,
	Masami Hiramatsu, Namhyung Kim, Peter Zijlstra, Stephane Eranian,
	Steven Rostedt, Wang Nan

From: Arnaldo Carvalho de Melo <acme@redhat.com>

Hi Ingo,

	Please consider pulling,

- Arnaldo

Build stats:

[root@jouet 5]# perf stat dm
alpine:3.4: Ok
android-ndk:r12b: Ok
centos:5: Ok
centos:6: Ok
centos:7: Ok
debian:7: Ok
debian:8: Ok
debian:experimental: Ok
fedora:21: Ok
fedora:22: Ok
fedora:23: Ok
fedora:24: Ok
fedora:rawhide: Ok
mageia:5: Ok
opensuse:13.2: Ok
opensuse:42.1: Ok
ubuntu:14.04.4: Ok
ubuntu:15.10: Ok
ubuntu:16.04: Ok
ubuntu:16.04-x-armhf: Ok

 Performance counter stats for 'dm':

       1896.227285      task-clock (msec)         #    0.002 CPUs utilized          
            76,145      context-switches          #    0.040 M/sec                  
             9,323      cpu-migrations            #    0.005 M/sec                  
            53,894      page-faults               #    0.028 M/sec                  
     5,497,625,679      cycles                    #    2.899 GHz                    
     5,110,226,458      instructions              #    0.93  insn per cycle         
       950,036,839      branches                  #  501.014 M/sec                  
        16,978,253      branch-misses             #    1.79% of all branches        

     767.910393301 seconds time elapsed

[root@jouet 5]#

The following changes since commit 09211e2530ab4905ec16edecc27022d6b247419d:

  Merge tag 'perf-core-for-mingo-20160715' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2016-07-16 22:36:42 +0200)

are available in the git repository at:

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

for you to fetch changes up to 988dd774dcbd9151c2a643fc7284c5c3c4d0adb7:

  perf tests: Add is_printable_array test (2016-07-18 19:50:35 -0300)

----------------------------------------------------------------
perf/core improvements and fixes:

User visible:

- Properly report when a function wildcard produces no matches in 'perf probe'
  (Masami Hiramatsu)

- Balance opening and reading events in 'perf stat', which could cause
  it to get stuck trying to close invalid file descriptors (Mark Rutland)

Infrastructure:

- Copy more headers from the kernel, this time for headers that
  were just including the contents of its kernel counterparts, should
  help resolving the problems with linux-next, where some uapi related
  patches seem to be breaking tools/object/ build.

  Some more combing will be done, but at least it is possible to build
  perf out of tree, via a detached tarball (make help | grep perf)
  without including kernel files in its MANIFEST (Arnaldo Carvalho de Melo)

- Fix smatch found errors that were not causing problems, but are
  mistakes nonetheless (Dan Carpenter)

- Fix string vs byte array resolving in the python script code (Jiri Olsa)

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

----------------------------------------------------------------
Arnaldo Carvalho de Melo (7):
      perf tools: Add missing linux/compiler.h include to perf-sys.h
      perf tools: Remove tools/perf/util/include/asm/byteorder.h
      perf tools: Remove tools/perf/util/include/linux/const.h
      Remove: kernel unistd*h files from perf's MANIFEST, not used
      tools: Copy the bitops files accessed from the kernel and check for drift
      perf tools: Remove include/linux/list.h from perf's MANIFEST
      tools: Copy linux/{hash,poison}.h and check for drift

Dan Carpenter (2):
      perf jit: Add missing curly braces
      perf jit: Remove some no-op error handling

Jiri Olsa (3):
      perf script python: Fix string vs byte array resolving
      perf tools: Make is_printable_array global
      perf tests: Add is_printable_array test

Mark Rutland (2):
      perf stat: Balance opening and reading events
      perf cpu_map: Add more helpers

Masami Hiramatsu (1):
      perf probe: Warn unmatched function filter correctly

 tools/include/asm-generic/bitops/__fls.h           |  44 ++++++++-
 tools/include/asm-generic/bitops/arch_hweight.h    |  26 ++++-
 tools/include/asm-generic/bitops/const_hweight.h   |  44 ++++++++-
 tools/include/asm-generic/bitops/fls.h             |  42 ++++++++-
 tools/include/asm-generic/bitops/fls64.h           |  37 +++++++-
 tools/include/linux/hash.h                         | 105 ++++++++++++++++++++-
 tools/include/linux/poison.h                       |  91 +++++++++++++++++-
 tools/perf/MANIFEST                                |  13 ---
 tools/perf/Makefile.perf                           |  18 ++++
 tools/perf/builtin-stat.c                          |   8 +-
 tools/perf/jvmti/jvmti_agent.c                     |  10 +-
 tools/perf/perf-sys.h                              |   1 +
 tools/perf/tests/Build                             |   1 +
 tools/perf/tests/builtin-test.c                    |   4 +
 tools/perf/tests/is_printable_array.c              |  36 +++++++
 tools/perf/tests/tests.h                           |   1 +
 tools/perf/util/cpumap.c                           |  14 ++-
 tools/perf/util/cpumap.h                           |   2 +
 tools/perf/util/include/asm/byteorder.h            |   2 -
 tools/perf/util/include/linux/const.h              |   1 -
 tools/perf/util/map.c                              |   3 +
 tools/perf/util/probe-event.c                      |  12 ++-
 tools/perf/util/python.c                           |  12 ---
 .../util/scripting-engines/trace-event-python.c    |  25 +++--
 tools/perf/util/util.c                             |  16 ++++
 tools/perf/util/util.h                             |   1 +
 26 files changed, 512 insertions(+), 57 deletions(-)
 create mode 100644 tools/perf/tests/is_printable_array.c
 delete mode 100644 tools/perf/util/include/asm/byteorder.h
 delete mode 100644 tools/perf/util/include/linux/const.h

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

* [PATCH 01/15] perf jit: Add missing curly braces
  2016-07-18 23:33 [GIT PULL 00/15] perf/core improvements and fixes Arnaldo Carvalho de Melo
@ 2016-07-18 23:33 ` Arnaldo Carvalho de Melo
  2016-07-18 23:33 ` [PATCH 02/15] perf jit: Remove some no-op error handling Arnaldo Carvalho de Melo
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-07-18 23:33 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Dan Carpenter, Adrian Hunter, Alexander Shishkin,
	Peter Zijlstra, Stephane Eranian, kernel-janitors,
	Arnaldo Carvalho de Melo

From: Dan Carpenter <dan.carpenter@oracle.com>

It doesn't change the runtime behavior, but my static checker complains
that curly braces were intended.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: kernel-janitors@vger.kernel.org
Link: http://lkml.kernel.org/r/20160715210712.GA19522@mwanda
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/jvmti/jvmti_agent.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/jvmti/jvmti_agent.c b/tools/perf/jvmti/jvmti_agent.c
index 3573f315f955..91bf333a366a 100644
--- a/tools/perf/jvmti/jvmti_agent.c
+++ b/tools/perf/jvmti/jvmti_agent.c
@@ -491,10 +491,11 @@ jvmti_write_debug_info(void *agent, uint64_t code, const char *file,
 		if (sret != 1)
 			goto error;
 	}
-	if (padding_count)
+	if (padding_count) {
 		sret = fwrite_unlocked(pad_bytes, padding_count, 1, fp);
 		if (sret != 1)
 			goto error;
+	}
 
 	funlockfile(fp);
 	return 0;
-- 
2.7.4

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

* [PATCH 02/15] perf jit: Remove some no-op error handling
  2016-07-18 23:33 [GIT PULL 00/15] perf/core improvements and fixes Arnaldo Carvalho de Melo
  2016-07-18 23:33 ` [PATCH 01/15] perf jit: Add missing curly braces Arnaldo Carvalho de Melo
@ 2016-07-18 23:33 ` Arnaldo Carvalho de Melo
  2016-07-18 23:33 ` [PATCH 03/15] perf tools: Add missing linux/compiler.h include to perf-sys.h Arnaldo Carvalho de Melo
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-07-18 23:33 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Dan Carpenter, Adrian Hunter, Alexander Shishkin,
	Peter Zijlstra, Stephane Eranian, kernel-janitors,
	Arnaldo Carvalho de Melo

From: Dan Carpenter <dan.carpenter@oracle.com>

The 'info.e_machine' struct member is an uint16_t so 'm' is never less
than zero.  It looks like this was maybe left over code from earlier
versions so I've just removed it.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: kernel-janitors@vger.kernel.org
Link: http://lkml.kernel.org/r/20160715210836.GB19522@mwanda
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/jvmti/jvmti_agent.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/tools/perf/jvmti/jvmti_agent.c b/tools/perf/jvmti/jvmti_agent.c
index 91bf333a366a..55daefff0d54 100644
--- a/tools/perf/jvmti/jvmti_agent.c
+++ b/tools/perf/jvmti/jvmti_agent.c
@@ -59,7 +59,6 @@ static int get_e_machine(struct jitheader *hdr)
 	ssize_t sret;
 	char id[16];
 	int fd, ret = -1;
-	int m = -1;
 	struct {
 		uint16_t e_type;
 		uint16_t e_machine;
@@ -81,11 +80,7 @@ static int get_e_machine(struct jitheader *hdr)
 	if (sret != sizeof(info))
 		goto error;
 
-	m = info.e_machine;
-	if (m < 0)
-		m = 0; /* ELF EM_NONE */
-
-	hdr->elf_mach = m;
+	hdr->elf_mach = info.e_machine;
 	ret = 0;
 error:
 	close(fd);
-- 
2.7.4

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

* [PATCH 03/15] perf tools: Add missing linux/compiler.h include to perf-sys.h
  2016-07-18 23:33 [GIT PULL 00/15] perf/core improvements and fixes Arnaldo Carvalho de Melo
  2016-07-18 23:33 ` [PATCH 01/15] perf jit: Add missing curly braces Arnaldo Carvalho de Melo
  2016-07-18 23:33 ` [PATCH 02/15] perf jit: Remove some no-op error handling Arnaldo Carvalho de Melo
@ 2016-07-18 23:33 ` Arnaldo Carvalho de Melo
  2016-07-18 23:33 ` [PATCH 04/15] perf tools: Remove tools/perf/util/include/asm/byteorder.h Arnaldo Carvalho de Melo
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-07-18 23:33 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter,
	David Ahern, Jiri Olsa, Namhyung Kim, Wang Nan

From: Arnaldo Carvalho de Melo <acme@redhat.com>

It uses the likely/unlikely macros, so need to include
<linux/compiler.h>.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-p0xrhgbkicsii9ohmhhprqpi@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/perf-sys.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/perf-sys.h b/tools/perf/perf-sys.h
index 5cee8a3d0455..7ed72a475c57 100644
--- a/tools/perf/perf-sys.h
+++ b/tools/perf/perf-sys.h
@@ -5,6 +5,7 @@
 #include <sys/types.h>
 #include <sys/syscall.h>
 #include <linux/types.h>
+#include <linux/compiler.h>
 #include <linux/perf_event.h>
 #include <asm/barrier.h>
 
-- 
2.7.4

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

* [PATCH 04/15] perf tools: Remove tools/perf/util/include/asm/byteorder.h
  2016-07-18 23:33 [GIT PULL 00/15] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (2 preceding siblings ...)
  2016-07-18 23:33 ` [PATCH 03/15] perf tools: Add missing linux/compiler.h include to perf-sys.h Arnaldo Carvalho de Melo
@ 2016-07-18 23:33 ` Arnaldo Carvalho de Melo
  2016-07-18 23:33 ` [PATCH 05/15] perf tools: Remove tools/perf/util/include/linux/const.h Arnaldo Carvalho de Melo
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-07-18 23:33 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter,
	David Ahern, Jiri Olsa, Namhyung Kim, Wang Nan

From: Arnaldo Carvalho de Melo <acme@redhat.com>

Not used anymore. This also stops include linux/swab.h directly
from the kernel sources, remove that reference from the MANIFEST.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/MANIFEST                     | 2 --
 tools/perf/util/include/asm/byteorder.h | 2 --
 2 files changed, 4 deletions(-)
 delete mode 100644 tools/perf/util/include/asm/byteorder.h

diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST
index 923eda2e7d52..4790f191e705 100644
--- a/tools/perf/MANIFEST
+++ b/tools/perf/MANIFEST
@@ -84,10 +84,8 @@ include/asm-generic/bitops/__fls.h
 include/asm-generic/bitops/fls.h
 include/linux/list.h
 include/linux/hash.h
-include/linux/swab.h
 arch/*/include/asm/unistd*.h
 arch/*/include/uapi/asm/unistd*.h
 tools/arch/*/include/uapi/asm/perf_regs.h
 include/linux/poison.h
 include/uapi/linux/const.h
-include/uapi/linux/swab.h
diff --git a/tools/perf/util/include/asm/byteorder.h b/tools/perf/util/include/asm/byteorder.h
deleted file mode 100644
index 2a9bdc066307..000000000000
--- a/tools/perf/util/include/asm/byteorder.h
+++ /dev/null
@@ -1,2 +0,0 @@
-#include <asm/types.h>
-#include "../../../../include/uapi/linux/swab.h"
-- 
2.7.4

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

* [PATCH 05/15] perf tools: Remove tools/perf/util/include/linux/const.h
  2016-07-18 23:33 [GIT PULL 00/15] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (3 preceding siblings ...)
  2016-07-18 23:33 ` [PATCH 04/15] perf tools: Remove tools/perf/util/include/asm/byteorder.h Arnaldo Carvalho de Melo
@ 2016-07-18 23:33 ` Arnaldo Carvalho de Melo
  2016-07-18 23:33 ` [PATCH 06/15] Remove: kernel unistd*h files from perf's MANIFEST, not used Arnaldo Carvalho de Melo
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-07-18 23:33 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter,
	David Ahern, Jiri Olsa, Namhyung Kim, Wang Nan

From: Arnaldo Carvalho de Melo <acme@redhat.com>

Not used anymore, remove one more file referencing kernel sources, i.e.
outside of tools/

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-ykfjt3t8l0npxfwmekiwwyu6@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/MANIFEST                   | 1 -
 tools/perf/util/include/linux/const.h | 1 -
 2 files changed, 2 deletions(-)
 delete mode 100644 tools/perf/util/include/linux/const.h

diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST
index 4790f191e705..d059b72bf7e7 100644
--- a/tools/perf/MANIFEST
+++ b/tools/perf/MANIFEST
@@ -88,4 +88,3 @@ arch/*/include/asm/unistd*.h
 arch/*/include/uapi/asm/unistd*.h
 tools/arch/*/include/uapi/asm/perf_regs.h
 include/linux/poison.h
-include/uapi/linux/const.h
diff --git a/tools/perf/util/include/linux/const.h b/tools/perf/util/include/linux/const.h
deleted file mode 100644
index c10a35e1afb8..000000000000
--- a/tools/perf/util/include/linux/const.h
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../../../include/uapi/linux/const.h"
-- 
2.7.4

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

* [PATCH 06/15] Remove: kernel unistd*h files from perf's MANIFEST, not used
  2016-07-18 23:33 [GIT PULL 00/15] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (4 preceding siblings ...)
  2016-07-18 23:33 ` [PATCH 05/15] perf tools: Remove tools/perf/util/include/linux/const.h Arnaldo Carvalho de Melo
@ 2016-07-18 23:33 ` Arnaldo Carvalho de Melo
  2016-07-18 23:33 ` [PATCH 07/15] tools: Copy the bitops files accessed from the kernel and check for drift Arnaldo Carvalho de Melo
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-07-18 23:33 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter,
	David Ahern, Jiri Olsa, Namhyung Kim, Wang Nan

From: Arnaldo Carvalho de Melo <acme@redhat.com>

No need to copy it to a detached tarball as they aren't used anymore

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-lopmaqi439ke10g1j9cxrxwt@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/MANIFEST | 2 --
 1 file changed, 2 deletions(-)

diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST
index d059b72bf7e7..e18df995bd3c 100644
--- a/tools/perf/MANIFEST
+++ b/tools/perf/MANIFEST
@@ -84,7 +84,5 @@ include/asm-generic/bitops/__fls.h
 include/asm-generic/bitops/fls.h
 include/linux/list.h
 include/linux/hash.h
-arch/*/include/asm/unistd*.h
-arch/*/include/uapi/asm/unistd*.h
 tools/arch/*/include/uapi/asm/perf_regs.h
 include/linux/poison.h
-- 
2.7.4

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

* [PATCH 07/15] tools: Copy the bitops files accessed from the kernel and check for drift
  2016-07-18 23:33 [GIT PULL 00/15] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (5 preceding siblings ...)
  2016-07-18 23:33 ` [PATCH 06/15] Remove: kernel unistd*h files from perf's MANIFEST, not used Arnaldo Carvalho de Melo
@ 2016-07-18 23:33 ` Arnaldo Carvalho de Melo
  2016-07-18 23:33 ` [PATCH 08/15] perf tools: Remove include/linux/list.h from perf's MANIFEST Arnaldo Carvalho de Melo
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-07-18 23:33 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter,
	David Ahern, Jiri Olsa, Namhyung Kim, Wang Nan

From: Arnaldo Carvalho de Melo <acme@redhat.com>

copy some more kernel files accessed from tools/, check for drift.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-omz8xdyvvxgjiuqzwj6ecm6j@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/include/asm-generic/bitops/__fls.h         | 44 +++++++++++++++++++++++-
 tools/include/asm-generic/bitops/arch_hweight.h  | 26 +++++++++++++-
 tools/include/asm-generic/bitops/const_hweight.h | 44 +++++++++++++++++++++++-
 tools/include/asm-generic/bitops/fls.h           | 42 +++++++++++++++++++++-
 tools/include/asm-generic/bitops/fls64.h         | 37 +++++++++++++++++++-
 tools/perf/MANIFEST                              |  5 ---
 tools/perf/Makefile.perf                         | 15 ++++++++
 7 files changed, 203 insertions(+), 10 deletions(-)

diff --git a/tools/include/asm-generic/bitops/__fls.h b/tools/include/asm-generic/bitops/__fls.h
index 494c9c615d1c..a60a7ccb6782 100644
--- a/tools/include/asm-generic/bitops/__fls.h
+++ b/tools/include/asm-generic/bitops/__fls.h
@@ -1 +1,43 @@
-#include "../../../../include/asm-generic/bitops/__fls.h"
+#ifndef _ASM_GENERIC_BITOPS___FLS_H_
+#define _ASM_GENERIC_BITOPS___FLS_H_
+
+#include <asm/types.h>
+
+/**
+ * __fls - find last (most-significant) set bit in a long word
+ * @word: the word to search
+ *
+ * Undefined if no set bit exists, so code should check against 0 first.
+ */
+static __always_inline unsigned long __fls(unsigned long word)
+{
+	int num = BITS_PER_LONG - 1;
+
+#if BITS_PER_LONG == 64
+	if (!(word & (~0ul << 32))) {
+		num -= 32;
+		word <<= 32;
+	}
+#endif
+	if (!(word & (~0ul << (BITS_PER_LONG-16)))) {
+		num -= 16;
+		word <<= 16;
+	}
+	if (!(word & (~0ul << (BITS_PER_LONG-8)))) {
+		num -= 8;
+		word <<= 8;
+	}
+	if (!(word & (~0ul << (BITS_PER_LONG-4)))) {
+		num -= 4;
+		word <<= 4;
+	}
+	if (!(word & (~0ul << (BITS_PER_LONG-2)))) {
+		num -= 2;
+		word <<= 2;
+	}
+	if (!(word & (~0ul << (BITS_PER_LONG-1))))
+		num -= 1;
+	return num;
+}
+
+#endif /* _ASM_GENERIC_BITOPS___FLS_H_ */
diff --git a/tools/include/asm-generic/bitops/arch_hweight.h b/tools/include/asm-generic/bitops/arch_hweight.h
index 318bb2b202b0..6a211f40665c 100644
--- a/tools/include/asm-generic/bitops/arch_hweight.h
+++ b/tools/include/asm-generic/bitops/arch_hweight.h
@@ -1 +1,25 @@
-#include "../../../../include/asm-generic/bitops/arch_hweight.h"
+#ifndef _ASM_GENERIC_BITOPS_ARCH_HWEIGHT_H_
+#define _ASM_GENERIC_BITOPS_ARCH_HWEIGHT_H_
+
+#include <asm/types.h>
+
+static inline unsigned int __arch_hweight32(unsigned int w)
+{
+	return __sw_hweight32(w);
+}
+
+static inline unsigned int __arch_hweight16(unsigned int w)
+{
+	return __sw_hweight16(w);
+}
+
+static inline unsigned int __arch_hweight8(unsigned int w)
+{
+	return __sw_hweight8(w);
+}
+
+static inline unsigned long __arch_hweight64(__u64 w)
+{
+	return __sw_hweight64(w);
+}
+#endif /* _ASM_GENERIC_BITOPS_HWEIGHT_H_ */
diff --git a/tools/include/asm-generic/bitops/const_hweight.h b/tools/include/asm-generic/bitops/const_hweight.h
index 0afd644aff83..0a7e06623470 100644
--- a/tools/include/asm-generic/bitops/const_hweight.h
+++ b/tools/include/asm-generic/bitops/const_hweight.h
@@ -1 +1,43 @@
-#include "../../../../include/asm-generic/bitops/const_hweight.h"
+#ifndef _ASM_GENERIC_BITOPS_CONST_HWEIGHT_H_
+#define _ASM_GENERIC_BITOPS_CONST_HWEIGHT_H_
+
+/*
+ * Compile time versions of __arch_hweightN()
+ */
+#define __const_hweight8(w)		\
+	((unsigned int)			\
+	 ((!!((w) & (1ULL << 0))) +	\
+	  (!!((w) & (1ULL << 1))) +	\
+	  (!!((w) & (1ULL << 2))) +	\
+	  (!!((w) & (1ULL << 3))) +	\
+	  (!!((w) & (1ULL << 4))) +	\
+	  (!!((w) & (1ULL << 5))) +	\
+	  (!!((w) & (1ULL << 6))) +	\
+	  (!!((w) & (1ULL << 7)))))
+
+#define __const_hweight16(w) (__const_hweight8(w)  + __const_hweight8((w)  >> 8 ))
+#define __const_hweight32(w) (__const_hweight16(w) + __const_hweight16((w) >> 16))
+#define __const_hweight64(w) (__const_hweight32(w) + __const_hweight32((w) >> 32))
+
+/*
+ * Generic interface.
+ */
+#define hweight8(w)  (__builtin_constant_p(w) ? __const_hweight8(w)  : __arch_hweight8(w))
+#define hweight16(w) (__builtin_constant_p(w) ? __const_hweight16(w) : __arch_hweight16(w))
+#define hweight32(w) (__builtin_constant_p(w) ? __const_hweight32(w) : __arch_hweight32(w))
+#define hweight64(w) (__builtin_constant_p(w) ? __const_hweight64(w) : __arch_hweight64(w))
+
+/*
+ * Interface for known constant arguments
+ */
+#define HWEIGHT8(w)  (BUILD_BUG_ON_ZERO(!__builtin_constant_p(w)) + __const_hweight8(w))
+#define HWEIGHT16(w) (BUILD_BUG_ON_ZERO(!__builtin_constant_p(w)) + __const_hweight16(w))
+#define HWEIGHT32(w) (BUILD_BUG_ON_ZERO(!__builtin_constant_p(w)) + __const_hweight32(w))
+#define HWEIGHT64(w) (BUILD_BUG_ON_ZERO(!__builtin_constant_p(w)) + __const_hweight64(w))
+
+/*
+ * Type invariant interface to the compile time constant hweight functions.
+ */
+#define HWEIGHT(w)   HWEIGHT64((u64)w)
+
+#endif /* _ASM_GENERIC_BITOPS_CONST_HWEIGHT_H_ */
diff --git a/tools/include/asm-generic/bitops/fls.h b/tools/include/asm-generic/bitops/fls.h
index 0e4995fa0248..0576d1f42f43 100644
--- a/tools/include/asm-generic/bitops/fls.h
+++ b/tools/include/asm-generic/bitops/fls.h
@@ -1 +1,41 @@
-#include "../../../../include/asm-generic/bitops/fls.h"
+#ifndef _ASM_GENERIC_BITOPS_FLS_H_
+#define _ASM_GENERIC_BITOPS_FLS_H_
+
+/**
+ * fls - find last (most-significant) bit set
+ * @x: the word to search
+ *
+ * This is defined the same way as ffs.
+ * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
+ */
+
+static __always_inline int fls(int x)
+{
+	int r = 32;
+
+	if (!x)
+		return 0;
+	if (!(x & 0xffff0000u)) {
+		x <<= 16;
+		r -= 16;
+	}
+	if (!(x & 0xff000000u)) {
+		x <<= 8;
+		r -= 8;
+	}
+	if (!(x & 0xf0000000u)) {
+		x <<= 4;
+		r -= 4;
+	}
+	if (!(x & 0xc0000000u)) {
+		x <<= 2;
+		r -= 2;
+	}
+	if (!(x & 0x80000000u)) {
+		x <<= 1;
+		r -= 1;
+	}
+	return r;
+}
+
+#endif /* _ASM_GENERIC_BITOPS_FLS_H_ */
diff --git a/tools/include/asm-generic/bitops/fls64.h b/tools/include/asm-generic/bitops/fls64.h
index 35bee0071e78..b097cf8444e3 100644
--- a/tools/include/asm-generic/bitops/fls64.h
+++ b/tools/include/asm-generic/bitops/fls64.h
@@ -1 +1,36 @@
-#include "../../../../include/asm-generic/bitops/fls64.h"
+#ifndef _ASM_GENERIC_BITOPS_FLS64_H_
+#define _ASM_GENERIC_BITOPS_FLS64_H_
+
+#include <asm/types.h>
+
+/**
+ * fls64 - find last set bit in a 64-bit word
+ * @x: the word to search
+ *
+ * This is defined in a similar way as the libc and compiler builtin
+ * ffsll, but returns the position of the most significant set bit.
+ *
+ * fls64(value) returns 0 if value is 0 or the position of the last
+ * set bit if value is nonzero. The last (most significant) bit is
+ * at position 64.
+ */
+#if BITS_PER_LONG == 32
+static __always_inline int fls64(__u64 x)
+{
+	__u32 h = x >> 32;
+	if (h)
+		return fls(h) + 32;
+	return fls(x);
+}
+#elif BITS_PER_LONG == 64
+static __always_inline int fls64(__u64 x)
+{
+	if (x == 0)
+		return 0;
+	return __fls(x) + 1;
+}
+#else
+#error BITS_PER_LONG not 32 or 64
+#endif
+
+#endif /* _ASM_GENERIC_BITOPS_FLS64_H_ */
diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST
index e18df995bd3c..eeb2fdc3392f 100644
--- a/tools/perf/MANIFEST
+++ b/tools/perf/MANIFEST
@@ -77,11 +77,6 @@ tools/include/linux/stringify.h
 tools/include/linux/types.h
 tools/include/linux/err.h
 tools/include/linux/bitmap.h
-include/asm-generic/bitops/arch_hweight.h
-include/asm-generic/bitops/const_hweight.h
-include/asm-generic/bitops/fls64.h
-include/asm-generic/bitops/__fls.h
-include/asm-generic/bitops/fls.h
 include/linux/list.h
 include/linux/hash.h
 tools/arch/*/include/uapi/asm/perf_regs.h
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index a129fbc1ed37..580f4e208c7a 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -411,6 +411,21 @@ $(PERF_IN): prepare FORCE
 	@(test -f ../../arch/arm64/include/uapi/asm/kvm.h && ( \
         (diff -B ../arch/arm64/include/uapi/asm/kvm.h ../../arch/arm64/include/uapi/asm/kvm.h >/dev/null) \
         || echo "Warning: tools/arch/arm64/include/uapi/asm/kvm.h differs from kernel" >&2 )) || true
+	@(test -f ../../include/asm-generic/bitops/arch_hweight.h && ( \
+        (diff -B ../include/asm-generic/bitops/arch_hweight.h ../../include/asm-generic/bitops/arch_hweight.h >/dev/null) \
+        || echo "Warning: tools/include/asm-generic/bitops/arch_hweight.h differs from kernel" >&2 )) || true
+	@(test -f ../../include/asm-generic/bitops/const_hweight.h && ( \
+        (diff -B ../include/asm-generic/bitops/const_hweight.h ../../include/asm-generic/bitops/const_hweight.h >/dev/null) \
+        || echo "Warning: tools/include/asm-generic/bitops/const_hweight.h differs from kernel" >&2 )) || true
+	@(test -f ../../include/asm-generic/bitops/__fls.h && ( \
+        (diff -B ../include/asm-generic/bitops/__fls.h ../../include/asm-generic/bitops/__fls.h >/dev/null) \
+        || echo "Warning: tools/include/asm-generic/bitops/__fls.h differs from kernel" >&2 )) || true
+	@(test -f ../../include/asm-generic/bitops/fls.h && ( \
+        (diff -B ../include/asm-generic/bitops/fls.h ../../include/asm-generic/bitops/fls.h >/dev/null) \
+        || echo "Warning: tools/include/asm-generic/bitops/fls.h differs from kernel" >&2 )) || true
+	@(test -f ../../include/asm-generic/bitops/fls64.h && ( \
+        (diff -B ../include/asm-generic/bitops/fls64.h ../../include/asm-generic/bitops/fls64.h >/dev/null) \
+        || echo "Warning: tools/include/asm-generic/bitops/fls64.h differs from kernel" >&2 )) || true
 	$(Q)$(MAKE) $(build)=perf
 
 $(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $(LIBTRACEEVENT_DYNAMIC_LIST)
-- 
2.7.4

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

* [PATCH 08/15] perf tools: Remove include/linux/list.h from perf's MANIFEST
  2016-07-18 23:33 [GIT PULL 00/15] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (6 preceding siblings ...)
  2016-07-18 23:33 ` [PATCH 07/15] tools: Copy the bitops files accessed from the kernel and check for drift Arnaldo Carvalho de Melo
@ 2016-07-18 23:33 ` Arnaldo Carvalho de Melo
  2016-07-18 23:33 ` [PATCH 09/15] tools: Copy linux/{hash,poison}.h and check for drift Arnaldo Carvalho de Melo
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-07-18 23:33 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter,
	David Ahern, Jiri Olsa, Josh Poimboeuf, Namhyung Kim, Wang Nan

From: Arnaldo Carvalho de Melo <acme@redhat.com>

It hasn't been used since we made tools/ self sufficiente wrt list.h.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Fixes: d1b39d41ebec ("tools: Make list.h self-sufficient")
Link: http://lkml.kernel.org/n/tip-w20ueqlf22kh7ctjqo0zjpig@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/MANIFEST | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST
index eeb2fdc3392f..3ac7f8dff47f 100644
--- a/tools/perf/MANIFEST
+++ b/tools/perf/MANIFEST
@@ -77,7 +77,6 @@ tools/include/linux/stringify.h
 tools/include/linux/types.h
 tools/include/linux/err.h
 tools/include/linux/bitmap.h
-include/linux/list.h
 include/linux/hash.h
 tools/arch/*/include/uapi/asm/perf_regs.h
 include/linux/poison.h
-- 
2.7.4

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

* [PATCH 09/15] tools: Copy linux/{hash,poison}.h and check for drift
  2016-07-18 23:33 [GIT PULL 00/15] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (7 preceding siblings ...)
  2016-07-18 23:33 ` [PATCH 08/15] perf tools: Remove include/linux/list.h from perf's MANIFEST Arnaldo Carvalho de Melo
@ 2016-07-18 23:33 ` Arnaldo Carvalho de Melo
  2016-07-18 23:33 ` [PATCH 10/15] perf stat: Balance opening and reading events Arnaldo Carvalho de Melo
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-07-18 23:33 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter,
	David Ahern, Jiri Olsa, Namhyung Kim, Wang Nan

From: Arnaldo Carvalho de Melo <acme@redhat.com>

We were also using this directly from the kernel sources, the two last
cases, fix it.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-7o14xvacqcjc5llc7gvjjyl8@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/include/linux/hash.h   | 105 +++++++++++++++++++++++++++++++++++++++++--
 tools/include/linux/poison.h |  91 ++++++++++++++++++++++++++++++++++++-
 tools/perf/MANIFEST          |   2 -
 tools/perf/Makefile.perf     |   3 ++
 4 files changed, 195 insertions(+), 6 deletions(-)

diff --git a/tools/include/linux/hash.h b/tools/include/linux/hash.h
index d026c6573018..ad6fa21d977b 100644
--- a/tools/include/linux/hash.h
+++ b/tools/include/linux/hash.h
@@ -1,5 +1,104 @@
-#include "../../../include/linux/hash.h"
+#ifndef _LINUX_HASH_H
+#define _LINUX_HASH_H
+/* Fast hashing routine for ints,  longs and pointers.
+   (C) 2002 Nadia Yvette Chambers, IBM */
 
-#ifndef _TOOLS_LINUX_HASH_H
-#define _TOOLS_LINUX_HASH_H
+#include <asm/types.h>
+#include <linux/compiler.h>
+
+/*
+ * The "GOLDEN_RATIO_PRIME" is used in ifs/btrfs/brtfs_inode.h and
+ * fs/inode.c.  It's not actually prime any more (the previous primes
+ * were actively bad for hashing), but the name remains.
+ */
+#if BITS_PER_LONG == 32
+#define GOLDEN_RATIO_PRIME GOLDEN_RATIO_32
+#define hash_long(val, bits) hash_32(val, bits)
+#elif BITS_PER_LONG == 64
+#define hash_long(val, bits) hash_64(val, bits)
+#define GOLDEN_RATIO_PRIME GOLDEN_RATIO_64
+#else
+#error Wordsize not 32 or 64
+#endif
+
+/*
+ * This hash multiplies the input by a large odd number and takes the
+ * high bits.  Since multiplication propagates changes to the most
+ * significant end only, it is essential that the high bits of the
+ * product be used for the hash value.
+ *
+ * Chuck Lever verified the effectiveness of this technique:
+ * http://www.citi.umich.edu/techreports/reports/citi-tr-00-1.pdf
+ *
+ * Although a random odd number will do, it turns out that the golden
+ * ratio phi = (sqrt(5)-1)/2, or its negative, has particularly nice
+ * properties.  (See Knuth vol 3, section 6.4, exercise 9.)
+ *
+ * These are the negative, (1 - phi) = phi**2 = (3 - sqrt(5))/2,
+ * which is very slightly easier to multiply by and makes no
+ * difference to the hash distribution.
+ */
+#define GOLDEN_RATIO_32 0x61C88647
+#define GOLDEN_RATIO_64 0x61C8864680B583EBull
+
+#ifdef CONFIG_HAVE_ARCH_HASH
+/* This header may use the GOLDEN_RATIO_xx constants */
+#include <asm/hash.h>
+#endif
+
+/*
+ * The _generic versions exist only so lib/test_hash.c can compare
+ * the arch-optimized versions with the generic.
+ *
+ * Note that if you change these, any <asm/hash.h> that aren't updated
+ * to match need to have their HAVE_ARCH_* define values updated so the
+ * self-test will not false-positive.
+ */
+#ifndef HAVE_ARCH__HASH_32
+#define __hash_32 __hash_32_generic
+#endif
+static inline u32 __hash_32_generic(u32 val)
+{
+	return val * GOLDEN_RATIO_32;
+}
+
+#ifndef HAVE_ARCH_HASH_32
+#define hash_32 hash_32_generic
 #endif
+static inline u32 hash_32_generic(u32 val, unsigned int bits)
+{
+	/* High bits are more random, so use them. */
+	return __hash_32(val) >> (32 - bits);
+}
+
+#ifndef HAVE_ARCH_HASH_64
+#define hash_64 hash_64_generic
+#endif
+static __always_inline u32 hash_64_generic(u64 val, unsigned int bits)
+{
+#if BITS_PER_LONG == 64
+	/* 64x64-bit multiply is efficient on all 64-bit processors */
+	return val * GOLDEN_RATIO_64 >> (64 - bits);
+#else
+	/* Hash 64 bits using only 32x32-bit multiply. */
+	return hash_32((u32)val ^ __hash_32(val >> 32), bits);
+#endif
+}
+
+static inline u32 hash_ptr(const void *ptr, unsigned int bits)
+{
+	return hash_long((unsigned long)ptr, bits);
+}
+
+/* This really should be called fold32_ptr; it does no hashing to speak of. */
+static inline u32 hash32_ptr(const void *ptr)
+{
+	unsigned long val = (unsigned long)ptr;
+
+#if BITS_PER_LONG == 64
+	val ^= (val >> 32);
+#endif
+	return (u32)val;
+}
+
+#endif /* _LINUX_HASH_H */
diff --git a/tools/include/linux/poison.h b/tools/include/linux/poison.h
index 0c27bdf14233..51334edec506 100644
--- a/tools/include/linux/poison.h
+++ b/tools/include/linux/poison.h
@@ -1 +1,90 @@
-#include "../../../include/linux/poison.h"
+#ifndef _LINUX_POISON_H
+#define _LINUX_POISON_H
+
+/********** include/linux/list.h **********/
+
+/*
+ * Architectures might want to move the poison pointer offset
+ * into some well-recognized area such as 0xdead000000000000,
+ * that is also not mappable by user-space exploits:
+ */
+#ifdef CONFIG_ILLEGAL_POINTER_VALUE
+# define POISON_POINTER_DELTA _AC(CONFIG_ILLEGAL_POINTER_VALUE, UL)
+#else
+# define POISON_POINTER_DELTA 0
+#endif
+
+/*
+ * These are non-NULL pointers that will result in page faults
+ * under normal circumstances, used to verify that nobody uses
+ * non-initialized list entries.
+ */
+#define LIST_POISON1  ((void *) 0x100 + POISON_POINTER_DELTA)
+#define LIST_POISON2  ((void *) 0x200 + POISON_POINTER_DELTA)
+
+/********** include/linux/timer.h **********/
+/*
+ * Magic number "tsta" to indicate a static timer initializer
+ * for the object debugging code.
+ */
+#define TIMER_ENTRY_STATIC	((void *) 0x300 + POISON_POINTER_DELTA)
+
+/********** mm/debug-pagealloc.c **********/
+#ifdef CONFIG_PAGE_POISONING_ZERO
+#define PAGE_POISON 0x00
+#else
+#define PAGE_POISON 0xaa
+#endif
+
+/********** mm/page_alloc.c ************/
+
+#define TAIL_MAPPING	((void *) 0x400 + POISON_POINTER_DELTA)
+
+/********** mm/slab.c **********/
+/*
+ * Magic nums for obj red zoning.
+ * Placed in the first word before and the first word after an obj.
+ */
+#define	RED_INACTIVE	0x09F911029D74E35BULL	/* when obj is inactive */
+#define	RED_ACTIVE	0xD84156C5635688C0ULL	/* when obj is active */
+
+#define SLUB_RED_INACTIVE	0xbb
+#define SLUB_RED_ACTIVE		0xcc
+
+/* ...and for poisoning */
+#define	POISON_INUSE	0x5a	/* for use-uninitialised poisoning */
+#define POISON_FREE	0x6b	/* for use-after-free poisoning */
+#define	POISON_END	0xa5	/* end-byte of poisoning */
+
+/********** arch/$ARCH/mm/init.c **********/
+#define POISON_FREE_INITMEM	0xcc
+
+/********** arch/ia64/hp/common/sba_iommu.c **********/
+/*
+ * arch/ia64/hp/common/sba_iommu.c uses a 16-byte poison string with a
+ * value of "SBAIOMMU POISON\0" for spill-over poisoning.
+ */
+
+/********** fs/jbd/journal.c **********/
+#define JBD_POISON_FREE		0x5b
+#define JBD2_POISON_FREE	0x5c
+
+/********** drivers/base/dmapool.c **********/
+#define	POOL_POISON_FREED	0xa7	/* !inuse */
+#define	POOL_POISON_ALLOCATED	0xa9	/* !initted */
+
+/********** drivers/atm/ **********/
+#define ATM_POISON_FREE		0x12
+#define ATM_POISON		0xdeadbeef
+
+/********** kernel/mutexes **********/
+#define MUTEX_DEBUG_INIT	0x11
+#define MUTEX_DEBUG_FREE	0x22
+
+/********** lib/flex_array.c **********/
+#define FLEX_ARRAY_FREE	0x6c	/* for use-after-free poisoning */
+
+/********** security/ **********/
+#define KEY_DESTROY		0xbd
+
+#endif
diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST
index 3ac7f8dff47f..ad2534df4ba6 100644
--- a/tools/perf/MANIFEST
+++ b/tools/perf/MANIFEST
@@ -77,6 +77,4 @@ tools/include/linux/stringify.h
 tools/include/linux/types.h
 tools/include/linux/err.h
 tools/include/linux/bitmap.h
-include/linux/hash.h
 tools/arch/*/include/uapi/asm/perf_regs.h
-include/linux/poison.h
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 580f4e208c7a..6641abb97f0a 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -351,6 +351,9 @@ $(PERF_IN): prepare FORCE
 	@(test -f ../../include/uapi/linux/perf_event.h && ( \
         (diff -B ../include/uapi/linux/perf_event.h ../../include/uapi/linux/perf_event.h >/dev/null) \
         || echo "Warning: tools/include/uapi/linux/perf_event.h differs from kernel" >&2 )) || true
+	@(test -f ../../include/linux/hash.h && ( \
+        (diff -B ../include/linux/hash.h ../../include/linux/hash.h >/dev/null) \
+        || echo "Warning: tools/include/linux/hash.h differs from kernel" >&2 )) || true
 	@(test -f ../../include/uapi/linux/hw_breakpoint.h && ( \
         (diff -B ../include/uapi/linux/hw_breakpoint.h ../../include/uapi/linux/hw_breakpoint.h >/dev/null) \
         || echo "Warning: tools/include/uapi/linux/hw_breakpoint.h differs from kernel" >&2 )) || true
-- 
2.7.4

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

* [PATCH 10/15] perf stat: Balance opening and reading events
  2016-07-18 23:33 [GIT PULL 00/15] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (8 preceding siblings ...)
  2016-07-18 23:33 ` [PATCH 09/15] tools: Copy linux/{hash,poison}.h and check for drift Arnaldo Carvalho de Melo
@ 2016-07-18 23:33 ` Arnaldo Carvalho de Melo
  2016-07-18 23:33 ` [PATCH 11/15] perf cpu_map: Add more helpers Arnaldo Carvalho de Melo
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-07-18 23:33 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Mark Rutland, Adrian Hunter, Alexander Shishkin,
	He Kuang, Kan Liang, Peter Zijlstra, Wang Nan,
	Arnaldo Carvalho de Melo

From: Mark Rutland <mark.rutland@arm.com>

In create_perf_stat_counter, when a target CPU has not been provided, we
call __perf_evsel__open with empty_cpu_map, and open a single FD per
thread. However, in read_counter we assume that we opened events for the
product of threads and CPUs described in the evsel's cpu_map.

Thus, if an evsel has a cpu_map with more than one entry, we will
attempt to access FDs that we didn't open. This could result in a number
of problems (e.g. blocking while reading from STDIN if the fd memory
happened to be initialised to zero).

This is problematic for systems were a logical CPU PMU covers some
arbitrary subset of CPUs. The cpu_map of any evsel for that PMU will be
initialised based on the cpumask exposed through sysfs, even if the user
requests per-thread events.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1468577293-19667-2-git-send-email-mark.rutland@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-stat.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 8c5a3bfdfdd7..0c16d20d7e32 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -290,8 +290,12 @@ perf_evsel__write_stat_event(struct perf_evsel *counter, u32 cpu, u32 thread,
 static int read_counter(struct perf_evsel *counter)
 {
 	int nthreads = thread_map__nr(evsel_list->threads);
-	int ncpus = perf_evsel__nr_cpus(counter);
-	int cpu, thread;
+	int ncpus, cpu, thread;
+
+	if (target__has_cpu(&target))
+		ncpus = perf_evsel__nr_cpus(counter);
+	else
+		ncpus = 1;
 
 	if (!counter->supported)
 		return -ENOENT;
-- 
2.7.4

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

* [PATCH 11/15] perf cpu_map: Add more helpers
  2016-07-18 23:33 [GIT PULL 00/15] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (9 preceding siblings ...)
  2016-07-18 23:33 ` [PATCH 10/15] perf stat: Balance opening and reading events Arnaldo Carvalho de Melo
@ 2016-07-18 23:33 ` Arnaldo Carvalho de Melo
  2016-07-18 23:33 ` [PATCH 12/15] perf probe: Warn unmatched function filter correctly Arnaldo Carvalho de Melo
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-07-18 23:33 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Mark Rutland, Adrian Hunter, Alexander Shishkin,
	He Kuang, Kan Liang, Peter Zijlstra, Wang Nan,
	Arnaldo Carvalho de Melo

From: Mark Rutland <mark.rutland@arm.com>

In some cases it's necessry to figure out the map-local index of a given
Linux logical CPU ID. Add a new helper, cpu_map__idx, to acquire this.
As the logic is largely the same as the existing cpu_map__has, this is
rewritten in terms of the new helper.

At the same time, add the inverse operation, cpu_map__cpu, which yields
the logical CPU id for a map-local index. While this can be performed
manually, wrapping this in a helper can make code more legible.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1468577293-19667-3-git-send-email-mark.rutland@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/cpumap.c | 14 ++++++++++++--
 tools/perf/util/cpumap.h |  2 ++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c
index 15f83acac1b8..2c0b52264a46 100644
--- a/tools/perf/util/cpumap.c
+++ b/tools/perf/util/cpumap.c
@@ -589,14 +589,24 @@ int cpu__setup_cpunode_map(void)
 
 bool cpu_map__has(struct cpu_map *cpus, int cpu)
 {
+	return cpu_map__idx(cpus, cpu) != -1;
+}
+
+int cpu_map__idx(struct cpu_map *cpus, int cpu)
+{
 	int i;
 
 	for (i = 0; i < cpus->nr; ++i) {
 		if (cpus->map[i] == cpu)
-			return true;
+			return i;
 	}
 
-	return false;
+	return -1;
+}
+
+int cpu_map__cpu(struct cpu_map *cpus, int idx)
+{
+	return cpus->map[idx];
 }
 
 size_t cpu_map__snprint(struct cpu_map *map, char *buf, size_t size)
diff --git a/tools/perf/util/cpumap.h b/tools/perf/util/cpumap.h
index 206dc550354a..06bd689f5989 100644
--- a/tools/perf/util/cpumap.h
+++ b/tools/perf/util/cpumap.h
@@ -68,5 +68,7 @@ int cpu_map__build_map(struct cpu_map *cpus, struct cpu_map **res,
 		       int (*f)(struct cpu_map *map, int cpu, void *data),
 		       void *data);
 
+int cpu_map__cpu(struct cpu_map *cpus, int idx);
 bool cpu_map__has(struct cpu_map *cpus, int cpu);
+int cpu_map__idx(struct cpu_map *cpus, int cpu);
 #endif /* __PERF_CPUMAP_H */
-- 
2.7.4

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

* [PATCH 12/15] perf probe: Warn unmatched function filter correctly
  2016-07-18 23:33 [GIT PULL 00/15] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (10 preceding siblings ...)
  2016-07-18 23:33 ` [PATCH 11/15] perf cpu_map: Add more helpers Arnaldo Carvalho de Melo
@ 2016-07-18 23:33 ` Arnaldo Carvalho de Melo
  2016-07-18 23:33 ` [PATCH 13/15] perf script python: Fix string vs byte array resolving Arnaldo Carvalho de Melo
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-07-18 23:33 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Masami Hiramatsu, Namhyung Kim, Peter Zijlstra,
	Arnaldo Carvalho de Melo

From: Masami Hiramatsu <mhiramat@kernel.org>

Warn unmatched function filter correctly instead of warning
"symbol-loading error", since that can be a filter issue.

>From the technical point of view, this adds a filter chech in map__load
and if there is a filter, it returns -2 (filter-out), instead of -1
(error), and perf-probe checks it and change message.

E.g. without this fix:

  # perf probe -F rt_sp*
  no symbols found in [kernel.kallsyms], maybe install a debug package?
  Failed to load symbols in kernel

With this fix:

  # perf probe -F rt_sp*
  no symbols passed the given filter.
  Failed to find symbols matched to "rt_sp*"
    Error: Failed to show functions.

Reported-and-Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/146885835596.16106.2293540792775552481.stgit@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/map.c         |  3 +++
 tools/perf/util/probe-event.c | 12 ++++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index b39b12a1208d..728129ac653a 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -312,6 +312,9 @@ int map__load(struct map *map, symbol_filter_t filter)
 			pr_warning("%.*s was updated (is prelink enabled?). "
 				"Restart the long running apps that use it!\n",
 				   (int)real_len, name);
+		} else if (filter) {
+			pr_warning("no symbols passed the given filter.\n");
+			return -2;	/* Empty but maybe by the filter */
 		} else {
 			pr_warning("no symbols found in %s, maybe install "
 				   "a debug package?\n", name);
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index d4f8835c0a27..953dc1ab2ed7 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -3312,8 +3312,16 @@ int show_available_funcs(const char *target, struct strfilter *_filter,
 
 	/* Load symbols with given filter */
 	available_func_filter = _filter;
-	if (map__load(map, filter_available_functions)) {
-		pr_err("Failed to load symbols in %s\n", (target) ? : "kernel");
+	ret = map__load(map, filter_available_functions);
+	if (ret) {
+		if (ret == -2) {
+			char *str = strfilter__string(_filter);
+			pr_err("Failed to find symbols matched to \"%s\"\n",
+			       str);
+			free(str);
+		} else
+			pr_err("Failed to load symbols in %s\n",
+			       (target) ? : "kernel");
 		goto end;
 	}
 	if (!dso__sorted_by_name(map->dso, map->type))
-- 
2.7.4

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

* [PATCH 13/15] perf script python: Fix string vs byte array resolving
  2016-07-18 23:33 [GIT PULL 00/15] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (11 preceding siblings ...)
  2016-07-18 23:33 ` [PATCH 12/15] perf probe: Warn unmatched function filter correctly Arnaldo Carvalho de Melo
@ 2016-07-18 23:33 ` Arnaldo Carvalho de Melo
  2016-07-28 18:42   ` Steven Rostedt
  2016-07-18 23:33 ` [PATCH 14/15] perf tools: Make is_printable_array global Arnaldo Carvalho de Melo
                   ` (2 subsequent siblings)
  15 siblings, 1 reply; 18+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-07-18 23:33 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Jiri Olsa, David Ahern, Namhyung Kim,
	Peter Zijlstra, Steven Rostedt, Arnaldo Carvalho de Melo

From: Jiri Olsa <jolsa@kernel.org>

Jirka reported that python code returns all arrays as strings.  This
makes impossible to get all items for byte array tracepoint field
containing 0x00 value item.

Fixing this by scanning full length of the array and returning it as
PyByteArray object in case non printable byte is found.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Reported-and-Tested-by: Jiri Pirko <jiri@mellanox.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1468685480-18951-2-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 .../util/scripting-engines/trace-event-python.c    | 39 ++++++++++++++++++----
 1 file changed, 33 insertions(+), 6 deletions(-)

diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index 6ac6b7a33f42..7bd6da80533e 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -386,6 +386,21 @@ exit:
 	return pylist;
 }
 
+static int is_printable_array(char *p, unsigned int len)
+{
+	unsigned int i;
+
+	if (!p || !len || p[len - 1] != 0)
+		return 0;
+
+	len--;
+
+	for (i = 0; i < len; i++) {
+		if (!isprint(p[i]) && !isspace(p[i]))
+			return 0;
+	}
+	return 1;
+}
 
 static void python_process_tracepoint(struct perf_sample *sample,
 				      struct perf_evsel *evsel,
@@ -457,14 +472,26 @@ static void python_process_tracepoint(struct perf_sample *sample,
 		pydict_set_item_string_decref(dict, "common_callchain", callchain);
 	}
 	for (field = event->format.fields; field; field = field->next) {
-		if (field->flags & FIELD_IS_STRING) {
-			int offset;
+		unsigned int offset, len;
+		unsigned long long val;
+
+		if (field->flags & FIELD_IS_ARRAY) {
+			offset = field->offset;
+			len    = field->size;
 			if (field->flags & FIELD_IS_DYNAMIC) {
-				offset = *(int *)(data + field->offset);
+				val     = pevent_read_number(scripting_context->pevent,
+							     data + offset, len);
+				offset  = val;
+				len     = offset >> 16;
 				offset &= 0xffff;
-			} else
-				offset = field->offset;
-			obj = PyString_FromString((char *)data + offset);
+			}
+			if (field->flags & FIELD_IS_STRING &&
+			    is_printable_array(data + offset, len)) {
+				obj = PyString_FromString((char *) data + offset);
+			} else {
+				obj = PyByteArray_FromStringAndSize((const char *) data + offset, len);
+				field->flags &= ~FIELD_IS_STRING;
+			}
 		} else { /* FIELD_IS_NUMERIC */
 			obj = get_field_numeric_entry(event, field, data);
 		}
-- 
2.7.4

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

* [PATCH 14/15] perf tools: Make is_printable_array global
  2016-07-18 23:33 [GIT PULL 00/15] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (12 preceding siblings ...)
  2016-07-18 23:33 ` [PATCH 13/15] perf script python: Fix string vs byte array resolving Arnaldo Carvalho de Melo
@ 2016-07-18 23:33 ` Arnaldo Carvalho de Melo
  2016-07-18 23:33 ` [PATCH 15/15] perf tests: Add is_printable_array test Arnaldo Carvalho de Melo
  2016-07-19  6:46 ` [GIT PULL 00/15] perf/core improvements and fixes Ingo Molnar
  15 siblings, 0 replies; 18+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-07-18 23:33 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Jiri Olsa, David Ahern, Jiri Pirko, Namhyung Kim,
	Peter Zijlstra, Steven Rostedt, Arnaldo Carvalho de Melo

From: Jiri Olsa <jolsa@kernel.org>

It's used from 2 objects in perf, so it's better to keep just one copy.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Pirko <jiri@mellanox.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1468685480-18951-3-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/python.c                               | 12 ------------
 tools/perf/util/scripting-engines/trace-event-python.c | 16 ----------------
 tools/perf/util/util.c                                 | 16 ++++++++++++++++
 tools/perf/util/util.h                                 |  1 +
 4 files changed, 17 insertions(+), 28 deletions(-)

diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index d32f97033718..a5fbc012e3df 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -295,18 +295,6 @@ static bool is_tracepoint(struct pyrf_event *pevent)
 	return pevent->evsel->attr.type == PERF_TYPE_TRACEPOINT;
 }
 
-static int is_printable_array(char *p, unsigned int len)
-{
-	unsigned int i;
-
-	for (i = 0; i < len; i++) {
-		if (!isprint(p[i]) && !isspace(p[i]))
-			return 0;
-	}
-
-	return 1;
-}
-
 static PyObject*
 tracepoint_field(struct pyrf_event *pe, struct format_field *field)
 {
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index 7bd6da80533e..e0203b979474 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -386,22 +386,6 @@ exit:
 	return pylist;
 }
 
-static int is_printable_array(char *p, unsigned int len)
-{
-	unsigned int i;
-
-	if (!p || !len || p[len - 1] != 0)
-		return 0;
-
-	len--;
-
-	for (i = 0; i < len; i++) {
-		if (!isprint(p[i]) && !isspace(p[i]))
-			return 0;
-	}
-	return 1;
-}
-
 static void python_process_tracepoint(struct perf_sample *sample,
 				      struct perf_evsel *evsel,
 				      struct addr_location *al)
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 5f44a21955cd..cee559d8c9e8 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -746,3 +746,19 @@ void print_binary(unsigned char *data, size_t len,
 	}
 	printer(BINARY_PRINT_DATA_END, -1, extra);
 }
+
+int is_printable_array(char *p, unsigned int len)
+{
+	unsigned int i;
+
+	if (!p || !len || p[len - 1] != 0)
+		return 0;
+
+	len--;
+
+	for (i = 0; i < len; i++) {
+		if (!isprint(p[i]) && !isspace(p[i]))
+			return 0;
+	}
+	return 1;
+}
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 843cbba8f9d3..e5f55477491d 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -364,4 +364,5 @@ void print_binary(unsigned char *data, size_t len,
 extern int sched_getcpu(void);
 #endif
 
+int is_printable_array(char *p, unsigned int len);
 #endif /* GIT_COMPAT_UTIL_H */
-- 
2.7.4

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

* [PATCH 15/15] perf tests: Add is_printable_array test
  2016-07-18 23:33 [GIT PULL 00/15] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (13 preceding siblings ...)
  2016-07-18 23:33 ` [PATCH 14/15] perf tools: Make is_printable_array global Arnaldo Carvalho de Melo
@ 2016-07-18 23:33 ` Arnaldo Carvalho de Melo
  2016-07-19  6:46 ` [GIT PULL 00/15] perf/core improvements and fixes Ingo Molnar
  15 siblings, 0 replies; 18+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-07-18 23:33 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Jiri Olsa, David Ahern, Jiri Pirko, Namhyung Kim,
	Peter Zijlstra, Steven Rostedt, Arnaldo Carvalho de Melo

From: Jiri Olsa <jolsa@kernel.org>

Add automated test for is_printable_array function.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Pirko <jiri@mellanox.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1468685480-18951-4-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/tests/Build                |  1 +
 tools/perf/tests/builtin-test.c       |  4 ++++
 tools/perf/tests/is_printable_array.c | 36 +++++++++++++++++++++++++++++++++++
 tools/perf/tests/tests.h              |  1 +
 4 files changed, 42 insertions(+)
 create mode 100644 tools/perf/tests/is_printable_array.c

diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build
index 4158422cc2a6..cb20ae1c0d35 100644
--- a/tools/perf/tests/Build
+++ b/tools/perf/tests/Build
@@ -40,6 +40,7 @@ perf-y += event_update.o
 perf-y += event-times.o
 perf-y += backward-ring-buffer.o
 perf-y += sdt.o
+perf-y += is_printable_array.o
 
 $(OUTPUT)tests/llvm-src-base.c: tests/bpf-script-example.c tests/Build
 	$(call rule_mkdir)
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 4dd2d050788a..10eb30686c9c 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -222,6 +222,10 @@ static struct test generic_tests[] = {
 		.func = test__sdt_event,
 	},
 	{
+		.desc = "Test is_printable_array function",
+		.func = test__is_printable_array,
+	},
+	{
 		.func = NULL,
 	},
 };
diff --git a/tools/perf/tests/is_printable_array.c b/tools/perf/tests/is_printable_array.c
new file mode 100644
index 000000000000..42e13393e502
--- /dev/null
+++ b/tools/perf/tests/is_printable_array.c
@@ -0,0 +1,36 @@
+#include <linux/compiler.h>
+#include "tests.h"
+#include "debug.h"
+#include "util.h"
+
+int test__is_printable_array(int subtest __maybe_unused)
+{
+	char buf1[] = { 'k', 'r', 4, 'v', 'a', 0 };
+	char buf2[] = { 'k', 'r', 'a', 'v', 4, 0 };
+	struct {
+		char		*buf;
+		unsigned int	 len;
+		int		 ret;
+	} t[] = {
+		{ (char *) "krava",	sizeof("krava"),	1 },
+		{ (char *) "krava",	sizeof("krava") - 1,	0 },
+		{ (char *) "",		sizeof(""),		1 },
+		{ (char *) "",		0,			0 },
+		{ NULL,			0,			0 },
+		{ buf1,			sizeof(buf1),		0 },
+		{ buf2,			sizeof(buf2),		0 },
+	};
+	unsigned int i;
+
+	for (i = 0; i < ARRAY_SIZE(t); i++) {
+		int ret;
+
+		ret = is_printable_array((char *) t[i].buf, t[i].len);
+		if (ret != t[i].ret) {
+			pr_err("failed: test %u\n", i);
+			return TEST_FAIL;
+		}
+	}
+
+	return TEST_OK;
+}
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index a0288f8092b2..9bfc0e06c61a 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -89,6 +89,7 @@ int test__event_times(int subtest);
 int test__backward_ring_buffer(int subtest);
 int test__cpu_map_print(int subtest);
 int test__sdt_event(int subtest);
+int test__is_printable_array(int subtest);
 
 #if defined(__arm__) || defined(__aarch64__)
 #ifdef HAVE_DWARF_UNWIND_SUPPORT
-- 
2.7.4

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

* Re: [GIT PULL 00/15] perf/core improvements and fixes
  2016-07-18 23:33 [GIT PULL 00/15] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (14 preceding siblings ...)
  2016-07-18 23:33 ` [PATCH 15/15] perf tests: Add is_printable_array test Arnaldo Carvalho de Melo
@ 2016-07-19  6:46 ` Ingo Molnar
  15 siblings, 0 replies; 18+ messages in thread
From: Ingo Molnar @ 2016-07-19  6:46 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter,
	Alexander Shishkin, Dan Carpenter, David Ahern, He Kuang,
	Jiri Olsa, Jiri Pirko, Josh Poimboeuf, Kan Liang, Mark Rutland,
	Masami Hiramatsu, Namhyung Kim, Peter Zijlstra, Stephane Eranian,
	Steven Rostedt, Wang Nan


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

> From: Arnaldo Carvalho de Melo <acme@redhat.com>
> 
> Hi Ingo,
> 
> 	Please consider pulling,
> 
> - Arnaldo
> 
> Build stats:
> 
> [root@jouet 5]# perf stat dm
> alpine:3.4: Ok
> android-ndk:r12b: Ok
> centos:5: Ok
> centos:6: Ok
> centos:7: Ok
> debian:7: Ok
> debian:8: Ok
> debian:experimental: Ok
> fedora:21: Ok
> fedora:22: Ok
> fedora:23: Ok
> fedora:24: Ok
> fedora:rawhide: Ok
> mageia:5: Ok
> opensuse:13.2: Ok
> opensuse:42.1: Ok
> ubuntu:14.04.4: Ok
> ubuntu:15.10: Ok
> ubuntu:16.04: Ok
> ubuntu:16.04-x-armhf: Ok
> 
>  Performance counter stats for 'dm':
> 
>        1896.227285      task-clock (msec)         #    0.002 CPUs utilized          
>             76,145      context-switches          #    0.040 M/sec                  
>              9,323      cpu-migrations            #    0.005 M/sec                  
>             53,894      page-faults               #    0.028 M/sec                  
>      5,497,625,679      cycles                    #    2.899 GHz                    
>      5,110,226,458      instructions              #    0.93  insn per cycle         
>        950,036,839      branches                  #  501.014 M/sec                  
>         16,978,253      branch-misses             #    1.79% of all branches        
> 
>      767.910393301 seconds time elapsed
> 
> [root@jouet 5]#
> 
> The following changes since commit 09211e2530ab4905ec16edecc27022d6b247419d:
> 
>   Merge tag 'perf-core-for-mingo-20160715' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2016-07-16 22:36:42 +0200)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo-20160718
> 
> for you to fetch changes up to 988dd774dcbd9151c2a643fc7284c5c3c4d0adb7:
> 
>   perf tests: Add is_printable_array test (2016-07-18 19:50:35 -0300)
> 
> ----------------------------------------------------------------
> perf/core improvements and fixes:
> 
> User visible:
> 
> - Properly report when a function wildcard produces no matches in 'perf probe'
>   (Masami Hiramatsu)
> 
> - Balance opening and reading events in 'perf stat', which could cause
>   it to get stuck trying to close invalid file descriptors (Mark Rutland)
> 
> Infrastructure:
> 
> - Copy more headers from the kernel, this time for headers that
>   were just including the contents of its kernel counterparts, should
>   help resolving the problems with linux-next, where some uapi related
>   patches seem to be breaking tools/object/ build.
> 
>   Some more combing will be done, but at least it is possible to build
>   perf out of tree, via a detached tarball (make help | grep perf)
>   without including kernel files in its MANIFEST (Arnaldo Carvalho de Melo)
> 
> - Fix smatch found errors that were not causing problems, but are
>   mistakes nonetheless (Dan Carpenter)
> 
> - Fix string vs byte array resolving in the python script code (Jiri Olsa)
> 
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> 
> ----------------------------------------------------------------
> Arnaldo Carvalho de Melo (7):
>       perf tools: Add missing linux/compiler.h include to perf-sys.h
>       perf tools: Remove tools/perf/util/include/asm/byteorder.h
>       perf tools: Remove tools/perf/util/include/linux/const.h
>       Remove: kernel unistd*h files from perf's MANIFEST, not used
>       tools: Copy the bitops files accessed from the kernel and check for drift
>       perf tools: Remove include/linux/list.h from perf's MANIFEST
>       tools: Copy linux/{hash,poison}.h and check for drift
> 
> Dan Carpenter (2):
>       perf jit: Add missing curly braces
>       perf jit: Remove some no-op error handling
> 
> Jiri Olsa (3):
>       perf script python: Fix string vs byte array resolving
>       perf tools: Make is_printable_array global
>       perf tests: Add is_printable_array test
> 
> Mark Rutland (2):
>       perf stat: Balance opening and reading events
>       perf cpu_map: Add more helpers
> 
> Masami Hiramatsu (1):
>       perf probe: Warn unmatched function filter correctly
> 
>  tools/include/asm-generic/bitops/__fls.h           |  44 ++++++++-
>  tools/include/asm-generic/bitops/arch_hweight.h    |  26 ++++-
>  tools/include/asm-generic/bitops/const_hweight.h   |  44 ++++++++-
>  tools/include/asm-generic/bitops/fls.h             |  42 ++++++++-
>  tools/include/asm-generic/bitops/fls64.h           |  37 +++++++-
>  tools/include/linux/hash.h                         | 105 ++++++++++++++++++++-
>  tools/include/linux/poison.h                       |  91 +++++++++++++++++-
>  tools/perf/MANIFEST                                |  13 ---
>  tools/perf/Makefile.perf                           |  18 ++++
>  tools/perf/builtin-stat.c                          |   8 +-
>  tools/perf/jvmti/jvmti_agent.c                     |  10 +-
>  tools/perf/perf-sys.h                              |   1 +
>  tools/perf/tests/Build                             |   1 +
>  tools/perf/tests/builtin-test.c                    |   4 +
>  tools/perf/tests/is_printable_array.c              |  36 +++++++
>  tools/perf/tests/tests.h                           |   1 +
>  tools/perf/util/cpumap.c                           |  14 ++-
>  tools/perf/util/cpumap.h                           |   2 +
>  tools/perf/util/include/asm/byteorder.h            |   2 -
>  tools/perf/util/include/linux/const.h              |   1 -
>  tools/perf/util/map.c                              |   3 +
>  tools/perf/util/probe-event.c                      |  12 ++-
>  tools/perf/util/python.c                           |  12 ---
>  .../util/scripting-engines/trace-event-python.c    |  25 +++--
>  tools/perf/util/util.c                             |  16 ++++
>  tools/perf/util/util.h                             |   1 +
>  26 files changed, 512 insertions(+), 57 deletions(-)
>  create mode 100644 tools/perf/tests/is_printable_array.c
>  delete mode 100644 tools/perf/util/include/asm/byteorder.h
>  delete mode 100644 tools/perf/util/include/linux/const.h

Pulled, thanks a lot Arnaldo!

	Ingo

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

* Re: [PATCH 13/15] perf script python: Fix string vs byte array resolving
  2016-07-18 23:33 ` [PATCH 13/15] perf script python: Fix string vs byte array resolving Arnaldo Carvalho de Melo
@ 2016-07-28 18:42   ` Steven Rostedt
  0 siblings, 0 replies; 18+ messages in thread
From: Steven Rostedt @ 2016-07-28 18:42 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, linux-kernel, Jiri Olsa, David Ahern, Namhyung Kim,
	Peter Zijlstra, Arnaldo Carvalho de Melo

On Mon, 18 Jul 2016 20:33:16 -0300
Arnaldo Carvalho de Melo <acme@kernel.org> wrote:

> From: Jiri Olsa <jolsa@kernel.org>
> 
> Jirka reported that python code returns all arrays as strings.  This
> makes impossible to get all items for byte array tracepoint field
> containing 0x00 value item.
> 
> Fixing this by scanning full length of the array and returning it as
> PyByteArray object in case non printable byte is found.
> 
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> Reported-and-Tested-by: Jiri Pirko <jiri@mellanox.com>
> Cc: David Ahern <dsahern@gmail.com>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Link: http://lkml.kernel.org/r/1468685480-18951-2-git-send-email-jolsa@kernel.org
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> ---
>  .../util/scripting-engines/trace-event-python.c    | 39 ++++++++++++++++++----
>  1 file changed, 33 insertions(+), 6 deletions(-)
> 
> diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
> index 6ac6b7a33f42..7bd6da80533e 100644
> --- a/tools/perf/util/scripting-engines/trace-event-python.c
> +++ b/tools/perf/util/scripting-engines/trace-event-python.c
> @@ -386,6 +386,21 @@ exit:
>  	return pylist;
>  }
>  
> +static int is_printable_array(char *p, unsigned int len)
> +{
> +	unsigned int i;
> +
> +	if (!p || !len || p[len - 1] != 0)
> +		return 0;
> +
> +	len--;
> +
> +	for (i = 0; i < len; i++) {
> +		if (!isprint(p[i]) && !isspace(p[i]))
> +			return 0;
> +	}
> +	return 1;
> +}
>  

Darn, I never got to add my Reviewed-by tag, as I had lots of comments
on this function. Oh well, that's what happens when you go off to
volcanoes.

-- Steve

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

end of thread, other threads:[~2016-07-28 18:42 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-18 23:33 [GIT PULL 00/15] perf/core improvements and fixes Arnaldo Carvalho de Melo
2016-07-18 23:33 ` [PATCH 01/15] perf jit: Add missing curly braces Arnaldo Carvalho de Melo
2016-07-18 23:33 ` [PATCH 02/15] perf jit: Remove some no-op error handling Arnaldo Carvalho de Melo
2016-07-18 23:33 ` [PATCH 03/15] perf tools: Add missing linux/compiler.h include to perf-sys.h Arnaldo Carvalho de Melo
2016-07-18 23:33 ` [PATCH 04/15] perf tools: Remove tools/perf/util/include/asm/byteorder.h Arnaldo Carvalho de Melo
2016-07-18 23:33 ` [PATCH 05/15] perf tools: Remove tools/perf/util/include/linux/const.h Arnaldo Carvalho de Melo
2016-07-18 23:33 ` [PATCH 06/15] Remove: kernel unistd*h files from perf's MANIFEST, not used Arnaldo Carvalho de Melo
2016-07-18 23:33 ` [PATCH 07/15] tools: Copy the bitops files accessed from the kernel and check for drift Arnaldo Carvalho de Melo
2016-07-18 23:33 ` [PATCH 08/15] perf tools: Remove include/linux/list.h from perf's MANIFEST Arnaldo Carvalho de Melo
2016-07-18 23:33 ` [PATCH 09/15] tools: Copy linux/{hash,poison}.h and check for drift Arnaldo Carvalho de Melo
2016-07-18 23:33 ` [PATCH 10/15] perf stat: Balance opening and reading events Arnaldo Carvalho de Melo
2016-07-18 23:33 ` [PATCH 11/15] perf cpu_map: Add more helpers Arnaldo Carvalho de Melo
2016-07-18 23:33 ` [PATCH 12/15] perf probe: Warn unmatched function filter correctly Arnaldo Carvalho de Melo
2016-07-18 23:33 ` [PATCH 13/15] perf script python: Fix string vs byte array resolving Arnaldo Carvalho de Melo
2016-07-28 18:42   ` Steven Rostedt
2016-07-18 23:33 ` [PATCH 14/15] perf tools: Make is_printable_array global Arnaldo Carvalho de Melo
2016-07-18 23:33 ` [PATCH 15/15] perf tests: Add is_printable_array test Arnaldo Carvalho de Melo
2016-07-19  6:46 ` [GIT PULL 00/15] perf/core improvements and 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).