aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-09-13 15:24:20 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-09-13 15:24:20 -0400
commit46c1e79fee417f151547aa46fae04ab06cb666f4 (patch)
tree560f0024d88788656cc48cba8afd4b0b8406d607 /tools
parentec846ecd6350857a8b8b9a6b78c763d45e0f09b8 (diff)
parentb130a699c07155a1d6ef7d971a5f3bf0e3818d5a (diff)
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf fixes from Ingo Molnar: "A handful of tooling fixes" * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: perf stat: Wait for the correct child perf tools: Support running perf binaries with a dash in their name perf config: Check not only section->from_system_config but also item's perf ui progress: Fix progress update perf ui progress: Make sure we always define step value perf tools: Open perf.data with O_CLOEXEC flag tools lib api: Fix make DEBUG=1 build perf tests: Fix compile when libunwind's unwind.h is available tools include linux: Guard against redefinition of some macros
Diffstat (limited to 'tools')
-rw-r--r--tools/include/linux/compiler-gcc.h9
-rw-r--r--tools/lib/api/Makefile8
-rw-r--r--tools/perf/builtin-config.c2
-rw-r--r--tools/perf/builtin-stat.c2
-rw-r--r--tools/perf/perf.c14
-rw-r--r--tools/perf/tests/dwarf-unwind.c2
-rw-r--r--tools/perf/ui/progress.c9
-rw-r--r--tools/perf/util/data.c13
8 files changed, 45 insertions, 14 deletions
diff --git a/tools/include/linux/compiler-gcc.h b/tools/include/linux/compiler-gcc.h
index bd39b2090ad1..3723b9f8f964 100644
--- a/tools/include/linux/compiler-gcc.h
+++ b/tools/include/linux/compiler-gcc.h
@@ -21,11 +21,14 @@
21#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0])) 21#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
22 22
23#define noinline __attribute__((noinline)) 23#define noinline __attribute__((noinline))
24 24#ifndef __packed
25#define __packed __attribute__((packed)) 25#define __packed __attribute__((packed))
26 26#endif
27#ifndef __noreturn
27#define __noreturn __attribute__((noreturn)) 28#define __noreturn __attribute__((noreturn))
28 29#endif
30#ifndef __aligned
29#define __aligned(x) __attribute__((aligned(x))) 31#define __aligned(x) __attribute__((aligned(x)))
32#endif
30#define __printf(a, b) __attribute__((format(printf, a, b))) 33#define __printf(a, b) __attribute__((format(printf, a, b)))
31#define __scanf(a, b) __attribute__((format(scanf, a, b))) 34#define __scanf(a, b) __attribute__((format(scanf, a, b)))
diff --git a/tools/lib/api/Makefile b/tools/lib/api/Makefile
index 4563ba7ede6f..1e83e3c07448 100644
--- a/tools/lib/api/Makefile
+++ b/tools/lib/api/Makefile
@@ -17,13 +17,19 @@ MAKEFLAGS += --no-print-directory
17LIBFILE = $(OUTPUT)libapi.a 17LIBFILE = $(OUTPUT)libapi.a
18 18
19CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) 19CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
20CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC 20CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -U_FORTIFY_SOURCE -fPIC
21 21
22ifeq ($(DEBUG),0)
22ifeq ($(CC_NO_CLANG), 0) 23ifeq ($(CC_NO_CLANG), 0)
23 CFLAGS += -O3 24 CFLAGS += -O3
24else 25else
25 CFLAGS += -O6 26 CFLAGS += -O6
26endif 27endif
28endif
29
30ifeq ($(DEBUG),0)
31 CFLAGS += -D_FORTIFY_SOURCE
32endif
27 33
28# Treat warnings as errors unless directed not to 34# Treat warnings as errors unless directed not to
29ifneq ($(WERROR),0) 35ifneq ($(WERROR),0)
diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
index 3ddcc6e2abeb..a1d82e33282c 100644
--- a/tools/perf/builtin-config.c
+++ b/tools/perf/builtin-config.c
@@ -59,7 +59,7 @@ static int set_config(struct perf_config_set *set, const char *file_name,
59 fprintf(fp, "[%s]\n", section->name); 59 fprintf(fp, "[%s]\n", section->name);
60 60
61 perf_config_items__for_each_entry(&section->items, item) { 61 perf_config_items__for_each_entry(&section->items, item) {
62 if (!use_system_config && section->from_system_config) 62 if (!use_system_config && item->from_system_config)
63 continue; 63 continue;
64 if (item->value) 64 if (item->value)
65 fprintf(fp, "\t%s = %s\n", 65 fprintf(fp, "\t%s = %s\n",
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 85e992d9215b..69523ed55894 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -707,7 +707,7 @@ try_again:
707 process_interval(); 707 process_interval();
708 } 708 }
709 } 709 }
710 wait(&status); 710 waitpid(child_pid, &status, 0);
711 711
712 if (workload_exec_errno) { 712 if (workload_exec_errno) {
713 const char *emsg = str_error_r(workload_exec_errno, msg, sizeof(msg)); 713 const char *emsg = str_error_r(workload_exec_errno, msg, sizeof(msg));
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index e0279babe0c0..2f19e03c5c40 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -467,15 +467,21 @@ int main(int argc, const char **argv)
467 * - cannot execute it externally (since it would just do 467 * - cannot execute it externally (since it would just do
468 * the same thing over again) 468 * the same thing over again)
469 * 469 *
470 * So we just directly call the internal command handler, and 470 * So we just directly call the internal command handler. If that one
471 * die if that one cannot handle it. 471 * fails to handle this, then maybe we just run a renamed perf binary
472 * that contains a dash in its name. To handle this scenario, we just
473 * fall through and ignore the "xxxx" part of the command string.
472 */ 474 */
473 if (strstarts(cmd, "perf-")) { 475 if (strstarts(cmd, "perf-")) {
474 cmd += 5; 476 cmd += 5;
475 argv[0] = cmd; 477 argv[0] = cmd;
476 handle_internal_command(argc, argv); 478 handle_internal_command(argc, argv);
477 fprintf(stderr, "cannot handle %s internally", cmd); 479 /*
478 goto out; 480 * If the command is handled, the above function does not
481 * return undo changes and fall through in such a case.
482 */
483 cmd -= 5;
484 argv[0] = cmd;
479 } 485 }
480 if (strstarts(cmd, "trace")) { 486 if (strstarts(cmd, "trace")) {
481#ifdef HAVE_LIBAUDIT_SUPPORT 487#ifdef HAVE_LIBAUDIT_SUPPORT
diff --git a/tools/perf/tests/dwarf-unwind.c b/tools/perf/tests/dwarf-unwind.c
index 2a7b9b47bbcb..9ba1d216a89f 100644
--- a/tools/perf/tests/dwarf-unwind.c
+++ b/tools/perf/tests/dwarf-unwind.c
@@ -6,7 +6,7 @@
6#include "debug.h" 6#include "debug.h"
7#include "machine.h" 7#include "machine.h"
8#include "event.h" 8#include "event.h"
9#include "unwind.h" 9#include "../util/unwind.h"
10#include "perf_regs.h" 10#include "perf_regs.h"
11#include "map.h" 11#include "map.h"
12#include "thread.h" 12#include "thread.h"
diff --git a/tools/perf/ui/progress.c b/tools/perf/ui/progress.c
index a0f24c7115c5..ae91c8148edf 100644
--- a/tools/perf/ui/progress.c
+++ b/tools/perf/ui/progress.c
@@ -1,3 +1,4 @@
1#include <linux/kernel.h>
1#include "../cache.h" 2#include "../cache.h"
2#include "progress.h" 3#include "progress.h"
3 4
@@ -14,10 +15,14 @@ struct ui_progress_ops *ui_progress__ops = &null_progress__ops;
14 15
15void ui_progress__update(struct ui_progress *p, u64 adv) 16void ui_progress__update(struct ui_progress *p, u64 adv)
16{ 17{
18 u64 last = p->curr;
19
17 p->curr += adv; 20 p->curr += adv;
18 21
19 if (p->curr >= p->next) { 22 if (p->curr >= p->next) {
20 p->next += p->step; 23 u64 nr = DIV_ROUND_UP(p->curr - last, p->step);
24
25 p->next += nr * p->step;
21 ui_progress__ops->update(p); 26 ui_progress__ops->update(p);
22 } 27 }
23} 28}
@@ -25,7 +30,7 @@ void ui_progress__update(struct ui_progress *p, u64 adv)
25void ui_progress__init(struct ui_progress *p, u64 total, const char *title) 30void ui_progress__init(struct ui_progress *p, u64 total, const char *title)
26{ 31{
27 p->curr = 0; 32 p->curr = 0;
28 p->next = p->step = total / 16; 33 p->next = p->step = total / 16 ?: 1;
29 p->total = total; 34 p->total = total;
30 p->title = title; 35 p->title = title;
31 36
diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c
index e84bbc8ec058..263f5a906ba5 100644
--- a/tools/perf/util/data.c
+++ b/tools/perf/util/data.c
@@ -10,6 +10,16 @@
10#include "util.h" 10#include "util.h"
11#include "debug.h" 11#include "debug.h"
12 12
13#ifndef O_CLOEXEC
14#ifdef __sparc__
15#define O_CLOEXEC 0x400000
16#elif defined(__alpha__) || defined(__hppa__)
17#define O_CLOEXEC 010000000
18#else
19#define O_CLOEXEC 02000000
20#endif
21#endif
22
13static bool check_pipe(struct perf_data_file *file) 23static bool check_pipe(struct perf_data_file *file)
14{ 24{
15 struct stat st; 25 struct stat st;
@@ -96,7 +106,8 @@ static int open_file_write(struct perf_data_file *file)
96 if (check_backup(file)) 106 if (check_backup(file))
97 return -1; 107 return -1;
98 108
99 fd = open(file->path, O_CREAT|O_RDWR|O_TRUNC, S_IRUSR|S_IWUSR); 109 fd = open(file->path, O_CREAT|O_RDWR|O_TRUNC|O_CLOEXEC,
110 S_IRUSR|S_IWUSR);
100 111
101 if (fd < 0) 112 if (fd < 0)
102 pr_err("failed to open %s : %s\n", file->path, 113 pr_err("failed to open %s : %s\n", file->path,