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>

+45 -14
+6 -3
tools/include/linux/compiler-gcc.h
··· 21 21 #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0])) 22 22 23 23 #define noinline __attribute__((noinline)) 24 - 24 + #ifndef __packed 25 25 #define __packed __attribute__((packed)) 26 - 26 + #endif 27 + #ifndef __noreturn 27 28 #define __noreturn __attribute__((noreturn)) 28 - 29 + #endif 30 + #ifndef __aligned 29 31 #define __aligned(x) __attribute__((aligned(x))) 32 + #endif 30 33 #define __printf(a, b) __attribute__((format(printf, a, b))) 31 34 #define __scanf(a, b) __attribute__((format(scanf, a, b)))
+7 -1
tools/lib/api/Makefile
··· 17 17 LIBFILE = $(OUTPUT)libapi.a 18 18 19 19 CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) 20 - CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC 20 + CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -U_FORTIFY_SOURCE -fPIC 21 21 22 + ifeq ($(DEBUG),0) 22 23 ifeq ($(CC_NO_CLANG), 0) 23 24 CFLAGS += -O3 24 25 else 25 26 CFLAGS += -O6 27 + endif 28 + endif 29 + 30 + ifeq ($(DEBUG),0) 31 + CFLAGS += -D_FORTIFY_SOURCE 26 32 endif 27 33 28 34 # Treat warnings as errors unless directed not to
+1 -1
tools/perf/builtin-config.c
··· 59 59 fprintf(fp, "[%s]\n", section->name); 60 60 61 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 63 continue; 64 64 if (item->value) 65 65 fprintf(fp, "\t%s = %s\n",
+1 -1
tools/perf/builtin-stat.c
··· 707 707 process_interval(); 708 708 } 709 709 } 710 - wait(&status); 710 + waitpid(child_pid, &status, 0); 711 711 712 712 if (workload_exec_errno) { 713 713 const char *emsg = str_error_r(workload_exec_errno, msg, sizeof(msg));
+10 -4
tools/perf/perf.c
··· 467 467 * - cannot execute it externally (since it would just do 468 468 * the same thing over again) 469 469 * 470 - * So we just directly call the internal command handler, and 471 - * die if that one cannot handle it. 470 + * So we just directly call the internal command handler. If that one 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 475 if (strstarts(cmd, "perf-")) { 474 476 cmd += 5; 475 477 argv[0] = cmd; 476 478 handle_internal_command(argc, argv); 477 - fprintf(stderr, "cannot handle %s internally", cmd); 478 - goto out; 479 + /* 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 486 if (strstarts(cmd, "trace")) { 481 487 #ifdef HAVE_LIBAUDIT_SUPPORT
+1 -1
tools/perf/tests/dwarf-unwind.c
··· 6 6 #include "debug.h" 7 7 #include "machine.h" 8 8 #include "event.h" 9 - #include "unwind.h" 9 + #include "../util/unwind.h" 10 10 #include "perf_regs.h" 11 11 #include "map.h" 12 12 #include "thread.h"
+7 -2
tools/perf/ui/progress.c
··· 1 + #include <linux/kernel.h> 1 2 #include "../cache.h" 2 3 #include "progress.h" 3 4 ··· 15 14 16 15 void ui_progress__update(struct ui_progress *p, u64 adv) 17 16 { 17 + u64 last = p->curr; 18 + 18 19 p->curr += adv; 19 20 20 21 if (p->curr >= p->next) { 21 - p->next += p->step; 22 + u64 nr = DIV_ROUND_UP(p->curr - last, p->step); 23 + 24 + p->next += nr * p->step; 22 25 ui_progress__ops->update(p); 23 26 } 24 27 } ··· 30 25 void ui_progress__init(struct ui_progress *p, u64 total, const char *title) 31 26 { 32 27 p->curr = 0; 33 - p->next = p->step = total / 16; 28 + p->next = p->step = total / 16 ?: 1; 34 29 p->total = total; 35 30 p->title = title; 36 31
+12 -1
tools/perf/util/data.c
··· 10 10 #include "util.h" 11 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 + 13 23 static bool check_pipe(struct perf_data_file *file) 14 24 { 15 25 struct stat st; ··· 106 96 if (check_backup(file)) 107 97 return -1; 108 98 109 - fd = open(file->path, O_CREAT|O_RDWR|O_TRUNC, S_IRUSR|S_IWUSR); 99 + fd = open(file->path, O_CREAT|O_RDWR|O_TRUNC|O_CLOEXEC, 100 + S_IRUSR|S_IWUSR); 110 101 111 102 if (fd < 0) 112 103 pr_err("failed to open %s : %s\n", file->path,