Skip to content

Commit

Permalink
Merge tag 'perf-core-for-mingo-5.3-20190709' of git://git.kernel.org/…
Browse files Browse the repository at this point in the history
…pub/scm/linux/kernel/git/acme/linux into perf/urgent

Pull perf/core improvements and fixes:

Intel PT:

  Adrian Hunter:

  - Fix DROP VIEW power_events_view in the postgresql and sqlite export-db
    python scripts.

perf script:

  Song Liu:

  - Assume native_arch for pipe mode, fixing a segfault.

perf inject:

  Arnaldo Carvalho de Melo:

  - The tool->read() call may pass a NULL evsel, handle it.

core:

  Arnaldo Carvalho de Melo:

  - Move zalloc/zfree.c to tools/lib, further eroding tools/perf/util.[ch]

  - Use zfree() where applicable instead of open coded equivalent.

  - Add stdlib.h and some other headers to places where its needed and were
    getting via util.h, that doesn't need that anymore.

  - Use list_del_init() more thoroughly.

Miscellaneous:

  Leo Yan:

  - Fix use after free and potential NULL pointer derefs detected by the
    smatch tool in various places.

  Luke Mujica:

  - Remove a couple unused variables in the parse-events code.

  Numfor Mbiziwo-Tiapo:

  - Initialize variable to suppress memory sanitizer warning in the
    mmap-thread-lookup 'perf test' entry.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Ingo Molnar committed Jul 13, 2019
2 parents f632a81 + 323fd74 commit e5eb08a
Show file tree
Hide file tree
Showing 147 changed files with 375 additions and 279 deletions.
12 changes: 12 additions & 0 deletions tools/include/linux/zalloc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: LGPL-2.1
#ifndef __TOOLS_LINUX_ZALLOC_H
#define __TOOLS_LINUX_ZALLOC_H

#include <stddef.h>

void *zalloc(size_t size);
void __zfree(void **ptr);

#define zfree(ptr) __zfree((void **)(ptr))

#endif // __TOOLS_LINUX_ZALLOC_H
15 changes: 15 additions & 0 deletions tools/lib/zalloc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: LGPL-2.1

#include <stdlib.h>
#include <linux/zalloc.h>

void *zalloc(size_t size)
{
return calloc(1, size);
}

void __zfree(void **ptr)
{
free(*ptr);
*ptr = NULL;
}
1 change: 1 addition & 0 deletions tools/perf/MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ tools/lib/find_bit.c
tools/lib/bitmap.c
tools/lib/str_error_r.c
tools/lib/vsprintf.c
tools/lib/zalloc.c
1 change: 1 addition & 0 deletions tools/perf/arch/arm/annotate/instructions.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include <linux/compiler.h>
#include <linux/zalloc.h>
#include <sys/types.h>
#include <regex.h>

Expand Down
1 change: 1 addition & 0 deletions tools/perf/arch/arm/util/auxtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <stdbool.h>
#include <linux/coresight-pmu.h>
#include <linux/zalloc.h>

#include "../../util/auxtrace.h"
#include "../../util/evlist.h"
Expand Down
1 change: 1 addition & 0 deletions tools/perf/arch/arm/util/cs-etm.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <linux/kernel.h>
#include <linux/log2.h>
#include <linux/types.h>
#include <linux/zalloc.h>

#include "cs-etm.h"
#include "../../perf.h"
Expand Down
1 change: 1 addition & 0 deletions tools/perf/arch/arm64/util/arm-spe.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <linux/types.h>
#include <linux/bitops.h>
#include <linux/log2.h>
#include <linux/zalloc.h>
#include <time.h>

#include "../../util/cpumap.h"
Expand Down
3 changes: 2 additions & 1 deletion tools/perf/arch/common.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// SPDX-License-Identifier: GPL-2.0
#include <stdio.h>
#include <stdlib.h>
#include "common.h"
#include "../util/env.h"
#include "../util/util.h"
#include "../util/debug.h"
#include <linux/zalloc.h>

const char *const arc_triplets[] = {
"arc-linux-",
Expand Down
4 changes: 3 additions & 1 deletion tools/perf/arch/powerpc/util/perf_regs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
#include <errno.h>
#include <string.h>
#include <regex.h>
#include <linux/zalloc.h>

#include "../../perf.h"
#include "../../util/util.h"
#include "../../util/perf_regs.h"
#include "../../util/debug.h"

#include <linux/kernel.h>

const struct sample_reg sample_reg_masks[] = {
SMPL_REG(r0, PERF_REG_POWERPC_R0),
SMPL_REG(r1, PERF_REG_POWERPC_R1),
Expand Down
1 change: 1 addition & 0 deletions tools/perf/arch/s390/util/auxtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <linux/types.h>
#include <linux/bitops.h>
#include <linux/log2.h>
#include <linux/zalloc.h>

#include "../../util/evlist.h"
#include "../../util/auxtrace.h"
Expand Down
3 changes: 2 additions & 1 deletion tools/perf/arch/s390/util/header.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
#include <stdio.h>
#include <string.h>
#include <linux/ctype.h>
#include <linux/kernel.h>
#include <linux/zalloc.h>

#include "../../util/header.h"
#include "../../util/util.h"

#define SYSINFO_MANU "Manufacturer:"
#define SYSINFO_TYPE "Type:"
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/arch/x86/util/event.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// SPDX-License-Identifier: GPL-2.0
#include <linux/types.h>
#include <linux/string.h>
#include <linux/zalloc.h>

#include "../../util/machine.h"
#include "../../util/tool.h"
#include "../../util/map.h"
#include "../../util/util.h"
#include "../../util/debug.h"

#if defined(__x86_64__)
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/arch/x86/util/intel-bts.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
#include <linux/types.h>
#include <linux/bitops.h>
#include <linux/log2.h>
#include <linux/zalloc.h>

#include "../../util/cpumap.h"
#include "../../util/evsel.h"
#include "../../util/evlist.h"
#include "../../util/session.h"
#include "../../util/util.h"
#include "../../util/pmu.h"
#include "../../util/debug.h"
#include "../../util/tsc.h"
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/arch/x86/util/intel-pt.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <linux/types.h>
#include <linux/bitops.h>
#include <linux/log2.h>
#include <linux/zalloc.h>
#include <cpuid.h>

#include "../../perf.h"
Expand All @@ -25,7 +26,6 @@
#include "../../util/auxtrace.h"
#include "../../util/tsc.h"
#include "../../util/intel-pt.h"
#include "../../util/util.h"

#define KiB(x) ((x) * 1024)
#define MiB(x) ((x) * 1024 * 1024)
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/arch/x86/util/perf_regs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#include <errno.h>
#include <string.h>
#include <regex.h>
#include <linux/zalloc.h>

#include "../../perf.h"
#include "../../util/util.h"
#include "../../util/perf_regs.h"
#include "../../util/debug.h"

Expand Down
3 changes: 2 additions & 1 deletion tools/perf/bench/futex-hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <stdlib.h>
#include <linux/compiler.h>
#include <linux/kernel.h>
#include <linux/zalloc.h>
#include <sys/time.h>

#include "../util/stat.h"
Expand Down Expand Up @@ -214,7 +215,7 @@ int bench_futex_hash(int argc, const char **argv)
&worker[i].futex[nfutexes-1], t);
}

free(worker[i].futex);
zfree(&worker[i].futex);
}

print_summary();
Expand Down
3 changes: 2 additions & 1 deletion tools/perf/bench/futex-lock-pi.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <subcmd/parse-options.h>
#include <linux/compiler.h>
#include <linux/kernel.h>
#include <linux/zalloc.h>
#include <errno.h>
#include "bench.h"
#include "futex.h"
Expand Down Expand Up @@ -217,7 +218,7 @@ int bench_futex_lock_pi(int argc, const char **argv)
worker[i].tid, worker[i].futex, t);

if (multi)
free(worker[i].futex);
zfree(&worker[i].futex);
}

print_summary();
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/bench/mem-functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#include "debug.h"
#include "../perf.h"
#include "../util/util.h"
#include <subcmd/parse-options.h>
#include "../util/header.h"
#include "../util/cloexec.h"
Expand All @@ -24,6 +23,7 @@
#include <sys/time.h>
#include <errno.h>
#include <linux/time64.h>
#include <linux/zalloc.h>

#define K 1024

Expand Down
2 changes: 1 addition & 1 deletion tools/perf/bench/numa.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

#include "../perf.h"
#include "../builtin.h"
#include "../util/util.h"
#include <subcmd/parse-options.h>
#include "../util/cloexec.h"

Expand All @@ -35,6 +34,7 @@
#include <linux/kernel.h>
#include <linux/time64.h>
#include <linux/numa.h>
#include <linux/zalloc.h>

#include <numa.h>
#include <numaif.h>
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
*/
#include "builtin.h"

#include "util/util.h"
#include "util/color.h"
#include <linux/list.h>
#include "util/cache.h"
#include <linux/rbtree.h>
#include <linux/zalloc.h>
#include "util/symbol.h"

#include "perf.h"
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-bench.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* epoll ... Event poll performance
*/
#include "perf.h"
#include "util/util.h"
#include <subcmd/parse-options.h>
#include "builtin.h"
#include "bench/bench.h"
Expand All @@ -26,6 +25,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/prctl.h>
#include <linux/zalloc.h>

typedef int (*bench_fn_t)(int argc, const char **argv);

Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-c2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
#include <linux/compiler.h>
#include <linux/kernel.h>
#include <linux/stringify.h>
#include <linux/zalloc.h>
#include <asm/bug.h>
#include <sys/param.h>
#include "util.h"
#include "debug.h"
#include "builtin.h"
#include <subcmd/parse-options.h>
Expand Down
1 change: 1 addition & 0 deletions tools/perf/builtin-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "util/debug.h"
#include "util/config.h"
#include <linux/string.h>
#include <stdlib.h>

static bool use_system_config, use_user_config;

Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
#include "util/tool.h"
#include "util/sort.h"
#include "util/symbol.h"
#include "util/util.h"
#include "util/data.h"
#include "util/config.h"
#include "util/time-utils.h"
#include "util/annotate.h"
#include "util/map.h"
#include <linux/zalloc.h>

#include <errno.h>
#include <inttypes.h>
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ static void delete_filter_func(struct list_head *head)
struct filter_entry *pos, *tmp;

list_for_each_entry_safe(pos, tmp, head, list) {
list_del(&pos->list);
list_del_init(&pos->list);
free(pos);
}
}
Expand Down
2 changes: 2 additions & 0 deletions tools/perf/builtin-help.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
#include <subcmd/help.h>
#include "util/debug.h"
#include <linux/kernel.h>
#include <linux/zalloc.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-inject.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ static int perf_event__repipe_sample(struct perf_tool *tool,
struct perf_evsel *evsel,
struct machine *machine)
{
if (evsel->handler) {
if (evsel && evsel->handler) {
inject_handler f = evsel->handler;
return f(tool, event, sample, evsel, machine);
}
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-kmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include "util/evlist.h"
#include "util/evsel.h"
#include "util/util.h"
#include "util/config.h"
#include "util/map.h"
#include "util/symbol.h"
Expand All @@ -26,6 +25,7 @@
#include <linux/kernel.h>
#include <linux/rbtree.h>
#include <linux/string.h>
#include <linux/zalloc.h>
#include <errno.h>
#include <inttypes.h>
#include <locale.h>
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "util/evsel.h"
#include "util/evlist.h"
#include "util/term.h"
#include "util/util.h"
#include "util/cache.h"
#include "util/symbol.h"
#include "util/thread.h"
Expand All @@ -32,6 +31,7 @@

#include <linux/kernel.h>
#include <linux/time64.h>
#include <linux/zalloc.h>
#include <errno.h>
#include <inttypes.h>
#include <poll.h>
Expand Down
Loading

0 comments on commit e5eb08a

Please sign in to comment.