Commit 798048f8 authored by Ingo Molnar's avatar Ingo Molnar

Merge tag 'perf-urgent-for-mingo-5.6-20200306' of...

Merge tag 'perf-urgent-for-mingo-5.6-20200306' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent

Pull perf/urgent fixes from Arnaldo Carvalho de Melo:

perf top:

  Tommi Rantala:

  - Fix stdio interface input handling with glibc 2.28+.

perf bench:

  Tommi Rantala:

  - Restore thread count default to online CPU count in futex-wake bench.

perf jevents:

  John Garry:

  - Fix leak of mapfile memory.

perf diff:

  Nick Desaulniers:

  - Fix undefined string comparision spotted by clang's -Wstring-compare.

misc:

  Ian Rogers:

  - Fix off-by 1 relative directory includes.
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parents b95b4d5e 441b62ac
/* SPDX-License-Identifier: GPL-2.0 */ /* SPDX-License-Identifier: GPL-2.0 */
#if defined(__i386__) || defined(__x86_64__) #if defined(__i386__) || defined(__x86_64__)
#include "../../arch/x86/include/uapi/asm/errno.h" #include "../../../arch/x86/include/uapi/asm/errno.h"
#elif defined(__powerpc__) #elif defined(__powerpc__)
#include "../../arch/powerpc/include/uapi/asm/errno.h" #include "../../../arch/powerpc/include/uapi/asm/errno.h"
#elif defined(__sparc__) #elif defined(__sparc__)
#include "../../arch/sparc/include/uapi/asm/errno.h" #include "../../../arch/sparc/include/uapi/asm/errno.h"
#elif defined(__alpha__) #elif defined(__alpha__)
#include "../../arch/alpha/include/uapi/asm/errno.h" #include "../../../arch/alpha/include/uapi/asm/errno.h"
#elif defined(__mips__) #elif defined(__mips__)
#include "../../arch/mips/include/uapi/asm/errno.h" #include "../../../arch/mips/include/uapi/asm/errno.h"
#elif defined(__ia64__) #elif defined(__ia64__)
#include "../../arch/ia64/include/uapi/asm/errno.h" #include "../../../arch/ia64/include/uapi/asm/errno.h"
#elif defined(__xtensa__) #elif defined(__xtensa__)
#include "../../arch/xtensa/include/uapi/asm/errno.h" #include "../../../arch/xtensa/include/uapi/asm/errno.h"
#else #else
#include <asm-generic/errno.h> #include <asm-generic/errno.h>
#endif #endif
...@@ -11,17 +11,17 @@ ...@@ -11,17 +11,17 @@
#include <linux/zalloc.h> #include <linux/zalloc.h>
#include <time.h> #include <time.h>
#include "../../util/cpumap.h" #include "../../../util/cpumap.h"
#include "../../util/event.h" #include "../../../util/event.h"
#include "../../util/evsel.h" #include "../../../util/evsel.h"
#include "../../util/evlist.h" #include "../../../util/evlist.h"
#include "../../util/session.h" #include "../../../util/session.h"
#include <internal/lib.h> // page_size #include <internal/lib.h> // page_size
#include "../../util/pmu.h" #include "../../../util/pmu.h"
#include "../../util/debug.h" #include "../../../util/debug.h"
#include "../../util/auxtrace.h" #include "../../../util/auxtrace.h"
#include "../../util/record.h" #include "../../../util/record.h"
#include "../../util/arm-spe.h" #include "../../../util/arm-spe.h"
#define KiB(x) ((x) * 1024) #define KiB(x) ((x) * 1024)
#define MiB(x) ((x) * 1024 * 1024) #define MiB(x) ((x) * 1024 * 1024)
......
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#include "../../util/perf_regs.h" #include "../../../util/perf_regs.h"
const struct sample_reg sample_reg_masks[] = { const struct sample_reg sample_reg_masks[] = {
SMPL_REG_END SMPL_REG_END
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
#include <regex.h> #include <regex.h>
#include <linux/zalloc.h> #include <linux/zalloc.h>
#include "../../util/perf_regs.h" #include "../../../util/perf_regs.h"
#include "../../util/debug.h" #include "../../../util/debug.h"
#include <linux/kernel.h> #include <linux/kernel.h>
......
...@@ -7,13 +7,13 @@ ...@@ -7,13 +7,13 @@
#include <errno.h> #include <errno.h>
#include <stdbool.h> #include <stdbool.h>
#include "../../util/header.h" #include "../../../util/header.h"
#include "../../util/debug.h" #include "../../../util/debug.h"
#include "../../util/pmu.h" #include "../../../util/pmu.h"
#include "../../util/auxtrace.h" #include "../../../util/auxtrace.h"
#include "../../util/intel-pt.h" #include "../../../util/intel-pt.h"
#include "../../util/intel-bts.h" #include "../../../util/intel-bts.h"
#include "../../util/evlist.h" #include "../../../util/evlist.h"
static static
struct auxtrace_record *auxtrace_record__init_intel(struct evlist *evlist, struct auxtrace_record *auxtrace_record__init_intel(struct evlist *evlist,
......
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
#include <linux/string.h> #include <linux/string.h>
#include <linux/zalloc.h> #include <linux/zalloc.h>
#include "../../util/event.h" #include "../../../util/event.h"
#include "../../util/synthetic-events.h" #include "../../../util/synthetic-events.h"
#include "../../util/machine.h" #include "../../../util/machine.h"
#include "../../util/tool.h" #include "../../../util/tool.h"
#include "../../util/map.h" #include "../../../util/map.h"
#include "../../util/debug.h" #include "../../../util/debug.h"
#if defined(__x86_64__) #if defined(__x86_64__)
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
#include <string.h> #include <string.h>
#include <regex.h> #include <regex.h>
#include "../../util/debug.h" #include "../../../util/debug.h"
#include "../../util/header.h" #include "../../../util/header.h"
static inline void static inline void
cpuid(unsigned int op, unsigned int *a, unsigned int *b, unsigned int *c, cpuid(unsigned int op, unsigned int *a, unsigned int *b, unsigned int *c,
......
...@@ -11,18 +11,18 @@ ...@@ -11,18 +11,18 @@
#include <linux/log2.h> #include <linux/log2.h>
#include <linux/zalloc.h> #include <linux/zalloc.h>
#include "../../util/cpumap.h" #include "../../../util/cpumap.h"
#include "../../util/event.h" #include "../../../util/event.h"
#include "../../util/evsel.h" #include "../../../util/evsel.h"
#include "../../util/evlist.h" #include "../../../util/evlist.h"
#include "../../util/mmap.h" #include "../../../util/mmap.h"
#include "../../util/session.h" #include "../../../util/session.h"
#include "../../util/pmu.h" #include "../../../util/pmu.h"
#include "../../util/debug.h" #include "../../../util/debug.h"
#include "../../util/record.h" #include "../../../util/record.h"
#include "../../util/tsc.h" #include "../../../util/tsc.h"
#include "../../util/auxtrace.h" #include "../../../util/auxtrace.h"
#include "../../util/intel-bts.h" #include "../../../util/intel-bts.h"
#include <internal/lib.h> // page_size #include <internal/lib.h> // page_size
#define KiB(x) ((x) * 1024) #define KiB(x) ((x) * 1024)
......
...@@ -13,23 +13,23 @@ ...@@ -13,23 +13,23 @@
#include <linux/zalloc.h> #include <linux/zalloc.h>
#include <cpuid.h> #include <cpuid.h>
#include "../../util/session.h" #include "../../../util/session.h"
#include "../../util/event.h" #include "../../../util/event.h"
#include "../../util/evlist.h" #include "../../../util/evlist.h"
#include "../../util/evsel.h" #include "../../../util/evsel.h"
#include "../../util/evsel_config.h" #include "../../../util/evsel_config.h"
#include "../../util/cpumap.h" #include "../../../util/cpumap.h"
#include "../../util/mmap.h" #include "../../../util/mmap.h"
#include <subcmd/parse-options.h> #include <subcmd/parse-options.h>
#include "../../util/parse-events.h" #include "../../../util/parse-events.h"
#include "../../util/pmu.h" #include "../../../util/pmu.h"
#include "../../util/debug.h" #include "../../../util/debug.h"
#include "../../util/auxtrace.h" #include "../../../util/auxtrace.h"
#include "../../util/record.h" #include "../../../util/record.h"
#include "../../util/target.h" #include "../../../util/target.h"
#include "../../util/tsc.h" #include "../../../util/tsc.h"
#include <internal/lib.h> // page_size #include <internal/lib.h> // page_size
#include "../../util/intel-pt.h" #include "../../../util/intel-pt.h"
#define KiB(x) ((x) * 1024) #define KiB(x) ((x) * 1024)
#define MiB(x) ((x) * 1024 * 1024) #define MiB(x) ((x) * 1024 * 1024)
......
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <internal/lib.h> // page_size #include <internal/lib.h> // page_size
#include "../../util/machine.h" #include "../../../util/machine.h"
#include "../../util/map.h" #include "../../../util/map.h"
#include "../../util/symbol.h" #include "../../../util/symbol.h"
#include <linux/ctype.h> #include <linux/ctype.h>
#include <symbol/kallsyms.h> #include <symbol/kallsyms.h>
......
...@@ -5,10 +5,10 @@ ...@@ -5,10 +5,10 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/zalloc.h> #include <linux/zalloc.h>
#include "../../perf-sys.h" #include "../../../perf-sys.h"
#include "../../util/perf_regs.h" #include "../../../util/perf_regs.h"
#include "../../util/debug.h" #include "../../../util/debug.h"
#include "../../util/event.h" #include "../../../util/event.h"
const struct sample_reg sample_reg_masks[] = { const struct sample_reg sample_reg_masks[] = {
SMPL_REG(AX, PERF_REG_X86_AX), SMPL_REG(AX, PERF_REG_X86_AX),
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
#include <linux/stddef.h> #include <linux/stddef.h>
#include <linux/perf_event.h> #include <linux/perf_event.h>
#include "../../util/intel-pt.h" #include "../../../util/intel-pt.h"
#include "../../util/intel-bts.h" #include "../../../util/intel-bts.h"
#include "../../util/pmu.h" #include "../../../util/pmu.h"
struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu __maybe_unused) struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu __maybe_unused)
{ {
......
...@@ -312,6 +312,7 @@ int bench_epoll_ctl(int argc, const char **argv) ...@@ -312,6 +312,7 @@ int bench_epoll_ctl(int argc, const char **argv)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
memset(&act, 0, sizeof(act));
sigfillset(&act.sa_mask); sigfillset(&act.sa_mask);
act.sa_sigaction = toggle_done; act.sa_sigaction = toggle_done;
sigaction(SIGINT, &act, NULL); sigaction(SIGINT, &act, NULL);
......
...@@ -426,6 +426,7 @@ int bench_epoll_wait(int argc, const char **argv) ...@@ -426,6 +426,7 @@ int bench_epoll_wait(int argc, const char **argv)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
memset(&act, 0, sizeof(act));
sigfillset(&act.sa_mask); sigfillset(&act.sa_mask);
act.sa_sigaction = toggle_done; act.sa_sigaction = toggle_done;
sigaction(SIGINT, &act, NULL); sigaction(SIGINT, &act, NULL);
......
...@@ -137,6 +137,7 @@ int bench_futex_hash(int argc, const char **argv) ...@@ -137,6 +137,7 @@ int bench_futex_hash(int argc, const char **argv)
if (!cpu) if (!cpu)
goto errmem; goto errmem;
memset(&act, 0, sizeof(act));
sigfillset(&act.sa_mask); sigfillset(&act.sa_mask);
act.sa_sigaction = toggle_done; act.sa_sigaction = toggle_done;
sigaction(SIGINT, &act, NULL); sigaction(SIGINT, &act, NULL);
......
...@@ -160,6 +160,7 @@ int bench_futex_lock_pi(int argc, const char **argv) ...@@ -160,6 +160,7 @@ int bench_futex_lock_pi(int argc, const char **argv)
if (!cpu) if (!cpu)
err(EXIT_FAILURE, "calloc"); err(EXIT_FAILURE, "calloc");
memset(&act, 0, sizeof(act));
sigfillset(&act.sa_mask); sigfillset(&act.sa_mask);
act.sa_sigaction = toggle_done; act.sa_sigaction = toggle_done;
sigaction(SIGINT, &act, NULL); sigaction(SIGINT, &act, NULL);
......
...@@ -128,6 +128,7 @@ int bench_futex_requeue(int argc, const char **argv) ...@@ -128,6 +128,7 @@ int bench_futex_requeue(int argc, const char **argv)
if (!cpu) if (!cpu)
err(EXIT_FAILURE, "cpu_map__new"); err(EXIT_FAILURE, "cpu_map__new");
memset(&act, 0, sizeof(act));
sigfillset(&act.sa_mask); sigfillset(&act.sa_mask);
act.sa_sigaction = toggle_done; act.sa_sigaction = toggle_done;
sigaction(SIGINT, &act, NULL); sigaction(SIGINT, &act, NULL);
......
...@@ -234,6 +234,7 @@ int bench_futex_wake_parallel(int argc, const char **argv) ...@@ -234,6 +234,7 @@ int bench_futex_wake_parallel(int argc, const char **argv)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
memset(&act, 0, sizeof(act));
sigfillset(&act.sa_mask); sigfillset(&act.sa_mask);
act.sa_sigaction = toggle_done; act.sa_sigaction = toggle_done;
sigaction(SIGINT, &act, NULL); sigaction(SIGINT, &act, NULL);
......
...@@ -43,7 +43,7 @@ static bool done = false, silent = false, fshared = false; ...@@ -43,7 +43,7 @@ static bool done = false, silent = false, fshared = false;
static pthread_mutex_t thread_lock; static pthread_mutex_t thread_lock;
static pthread_cond_t thread_parent, thread_worker; static pthread_cond_t thread_parent, thread_worker;
static struct stats waketime_stats, wakeup_stats; static struct stats waketime_stats, wakeup_stats;
static unsigned int ncpus, threads_starting, nthreads = 0; static unsigned int threads_starting, nthreads = 0;
static int futex_flag = 0; static int futex_flag = 0;
static const struct option options[] = { static const struct option options[] = {
...@@ -136,12 +136,13 @@ int bench_futex_wake(int argc, const char **argv) ...@@ -136,12 +136,13 @@ int bench_futex_wake(int argc, const char **argv)
if (!cpu) if (!cpu)
err(EXIT_FAILURE, "calloc"); err(EXIT_FAILURE, "calloc");
memset(&act, 0, sizeof(act));
sigfillset(&act.sa_mask); sigfillset(&act.sa_mask);
act.sa_sigaction = toggle_done; act.sa_sigaction = toggle_done;
sigaction(SIGINT, &act, NULL); sigaction(SIGINT, &act, NULL);
if (!nthreads) if (!nthreads)
nthreads = ncpus; nthreads = cpu->nr;
worker = calloc(nthreads, sizeof(*worker)); worker = calloc(nthreads, sizeof(*worker));
if (!worker) if (!worker)
......
...@@ -1312,7 +1312,8 @@ static int cycles_printf(struct hist_entry *he, struct hist_entry *pair, ...@@ -1312,7 +1312,8 @@ static int cycles_printf(struct hist_entry *he, struct hist_entry *pair,
end_line = map__srcline(he->ms.map, bi->sym->start + bi->end, end_line = map__srcline(he->ms.map, bi->sym->start + bi->end,
he->ms.sym); he->ms.sym);
if ((start_line != SRCLINE_UNKNOWN) && (end_line != SRCLINE_UNKNOWN)) { if ((strncmp(start_line, SRCLINE_UNKNOWN, strlen(SRCLINE_UNKNOWN)) != 0) &&
(strncmp(end_line, SRCLINE_UNKNOWN, strlen(SRCLINE_UNKNOWN)) != 0)) {
scnprintf(buf, sizeof(buf), "[%s -> %s] %4ld", scnprintf(buf, sizeof(buf), "[%s -> %s] %4ld",
start_line, end_line, block_he->diff.cycles); start_line, end_line, block_he->diff.cycles);
} else { } else {
......
...@@ -684,6 +684,8 @@ static void *display_thread(void *arg) ...@@ -684,6 +684,8 @@ static void *display_thread(void *arg)
delay_msecs = top->delay_secs * MSEC_PER_SEC; delay_msecs = top->delay_secs * MSEC_PER_SEC;
set_term_quiet_input(&save); set_term_quiet_input(&save);
/* trash return*/ /* trash return*/
clearerr(stdin);
if (poll(&stdin_poll, 1, 0) > 0)
getc(stdin); getc(stdin);
while (!done) { while (!done) {
......
...@@ -1082,10 +1082,9 @@ static int process_one_file(const char *fpath, const struct stat *sb, ...@@ -1082,10 +1082,9 @@ static int process_one_file(const char *fpath, const struct stat *sb,
*/ */
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int rc; int rc, ret = 0;
int maxfds; int maxfds;
char ldirname[PATH_MAX]; char ldirname[PATH_MAX];
const char *arch; const char *arch;
const char *output_file; const char *output_file;
const char *start_dirname; const char *start_dirname;
...@@ -1156,7 +1155,8 @@ int main(int argc, char *argv[]) ...@@ -1156,7 +1155,8 @@ int main(int argc, char *argv[])
/* Make build fail */ /* Make build fail */
fclose(eventsfp); fclose(eventsfp);
free_arch_std_events(); free_arch_std_events();
return 1; ret = 1;
goto out_free_mapfile;
} else if (rc) { } else if (rc) {
goto empty_map; goto empty_map;
} }
...@@ -1174,14 +1174,17 @@ int main(int argc, char *argv[]) ...@@ -1174,14 +1174,17 @@ int main(int argc, char *argv[])
/* Make build fail */ /* Make build fail */
fclose(eventsfp); fclose(eventsfp);
free_arch_std_events(); free_arch_std_events();
return 1; ret = 1;
} }
return 0;
goto out_free_mapfile;
empty_map: empty_map:
fclose(eventsfp); fclose(eventsfp);
create_empty_mapping(output_file); create_empty_mapping(output_file);
free_arch_std_events(); free_arch_std_events();
return 0; out_free_mapfile:
free(mapfile);
return ret;
} }
...@@ -295,7 +295,8 @@ static int block_range_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, ...@@ -295,7 +295,8 @@ static int block_range_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
end_line = map__srcline(he->ms.map, bi->sym->start + bi->end, end_line = map__srcline(he->ms.map, bi->sym->start + bi->end,
he->ms.sym); he->ms.sym);
if ((start_line != SRCLINE_UNKNOWN) && (end_line != SRCLINE_UNKNOWN)) { if ((strncmp(start_line, SRCLINE_UNKNOWN, strlen(SRCLINE_UNKNOWN)) != 0) &&
(strncmp(end_line, SRCLINE_UNKNOWN, strlen(SRCLINE_UNKNOWN)) != 0)) {
scnprintf(buf, sizeof(buf), "[%s -> %s]", scnprintf(buf, sizeof(buf), "[%s -> %s]",
start_line, end_line); start_line, end_line);
} else { } else {
......
...@@ -431,7 +431,7 @@ int map__fprintf_srcline(struct map *map, u64 addr, const char *prefix, ...@@ -431,7 +431,7 @@ int map__fprintf_srcline(struct map *map, u64 addr, const char *prefix,
if (map && map->dso) { if (map && map->dso) {
char *srcline = map__srcline(map, addr, NULL); char *srcline = map__srcline(map, addr, NULL);
if (srcline != SRCLINE_UNKNOWN) if (strncmp(srcline, SRCLINE_UNKNOWN, strlen(SRCLINE_UNKNOWN)) != 0)
ret = fprintf(fp, "%s%s", prefix, srcline); ret = fprintf(fp, "%s%s", prefix, srcline);
free_srcline(srcline); free_srcline(srcline);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment