aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2017-09-13 03:25:10 -0400
committerIngo Molnar <mingo@kernel.org>2017-09-13 03:25:10 -0400
commitb130a699c07155a1d6ef7d971a5f3bf0e3818d5a (patch)
tree403633d5161cedcf86d353ec21e1ee339bc41fb7 /tools/perf
parent6d8ef53e8b2fed8b0f91df0c6da7cc92747d934a (diff)
parentdfc9eec7716cc0a9f7eb743c703d74cd2d6085a0 (diff)
Merge tag 'perf-urgent-for-mingo-4.14-20170912' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
Pull perf/urgent fixes from Arnaldo Carvalho de Melo: - Fix TUI progress bar when delta from new total from that of the previous update is greater than the progress "step" (screen width progress bar block)) (Jiri Olsa) - Make tools/lib/api make DEBUG=1 build use -D_FORTIFY_SOURCE=2 not to cripple debuginfo, just like tools/perf/ does (Jiri Olsa) - Avoid leaking the 'perf.data' file to workloads started from the 'perf record' command line by using the O_CLOEXEC open flag (Jiri Olsa) - Fix building when libunwind's 'unwind.h' file is present in the include path, clashing with tools/perf/util/unwind.h (Milian Wolff) - Check per .perfconfig section entry flag, not just per section (Taeung Song) - Support running perf binaries with a dash in their name, needed to run perf as an AppImage (Milian Wolff) - Wait for the right child by using waitpid() when running workloads from 'perf stat', also to fix using perf as an AppImage (Milian Wolff) Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/perf')
-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
6 files changed, 32 insertions, 10 deletions
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,