aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/MANIFEST1
-rw-r--r--tools/perf/arch/arm/annotate/instructions.c1
-rw-r--r--tools/perf/arch/arm/util/auxtrace.c1
-rw-r--r--tools/perf/arch/arm/util/cs-etm.c1
-rw-r--r--tools/perf/arch/arm64/util/arm-spe.c1
-rw-r--r--tools/perf/arch/common.c2
-rw-r--r--tools/perf/arch/powerpc/util/perf_regs.c2
-rw-r--r--tools/perf/arch/s390/util/auxtrace.c1
-rw-r--r--tools/perf/arch/s390/util/header.c2
-rw-r--r--tools/perf/arch/x86/util/event.c2
-rw-r--r--tools/perf/arch/x86/util/intel-bts.c2
-rw-r--r--tools/perf/arch/x86/util/intel-pt.c2
-rw-r--r--tools/perf/arch/x86/util/perf_regs.c2
-rw-r--r--tools/perf/bench/mem-functions.c2
-rw-r--r--tools/perf/bench/numa.c2
-rw-r--r--tools/perf/builtin-annotate.c2
-rw-r--r--tools/perf/builtin-bench.c2
-rw-r--r--tools/perf/builtin-c2c.c2
-rw-r--r--tools/perf/builtin-diff.c2
-rw-r--r--tools/perf/builtin-help.c1
-rw-r--r--tools/perf/builtin-kmem.c2
-rw-r--r--tools/perf/builtin-kvm.c2
-rw-r--r--tools/perf/builtin-lock.c2
-rw-r--r--tools/perf/builtin-probe.c2
-rw-r--r--tools/perf/builtin-report.c2
-rw-r--r--tools/perf/builtin-sched.c2
-rw-r--r--tools/perf/builtin-script.c2
-rw-r--r--tools/perf/builtin-stat.c2
-rw-r--r--tools/perf/builtin-timechart.c4
-rw-r--r--tools/perf/builtin-trace.c1
-rw-r--r--tools/perf/perf.c2
-rw-r--r--tools/perf/tests/switch-tracking.c1
-rw-r--r--tools/perf/ui/browser.c2
-rw-r--r--tools/perf/ui/browsers/annotate.c2
-rw-r--r--tools/perf/ui/browsers/hists.c2
-rw-r--r--tools/perf/ui/gtk/util.c3
-rw-r--r--tools/perf/ui/stdio/hist.c2
-rw-r--r--tools/perf/util/Build5
-rw-r--r--tools/perf/util/arm-spe.c2
-rw-r--r--tools/perf/util/auxtrace.c2
-rw-r--r--tools/perf/util/bpf-loader.c1
-rw-r--r--tools/perf/util/build-id.c1
-rw-r--r--tools/perf/util/call-path.c3
-rw-r--r--tools/perf/util/callchain.c2
-rw-r--r--tools/perf/util/cgroup.c2
-rw-r--r--tools/perf/util/comm.c2
-rw-r--r--tools/perf/util/config.c3
-rw-r--r--tools/perf/util/counts.c2
-rw-r--r--tools/perf/util/cpumap.c2
-rw-r--r--tools/perf/util/cputopo.c2
-rw-r--r--tools/perf/util/cs-etm-decoder/cs-etm-decoder.c1
-rw-r--r--tools/perf/util/cs-etm.c1
-rw-r--r--tools/perf/util/data-convert-bt.c2
-rw-r--r--tools/perf/util/data.c1
-rw-r--r--tools/perf/util/db-export.c2
-rw-r--r--tools/perf/util/dso.c3
-rw-r--r--tools/perf/util/env.c2
-rw-r--r--tools/perf/util/event.c1
-rw-r--r--tools/perf/util/evlist.c2
-rw-r--r--tools/perf/util/evsel.c2
-rw-r--r--tools/perf/util/header.c2
-rw-r--r--tools/perf/util/help-unknown-cmd.c2
-rw-r--r--tools/perf/util/hist.c2
-rw-r--r--tools/perf/util/intel-bts.c2
-rw-r--r--tools/perf/util/intel-pt-decoder/intel-pt-decoder.c2
-rw-r--r--tools/perf/util/intel-pt.c2
-rw-r--r--tools/perf/util/llvm-utils.c1
-rw-r--r--tools/perf/util/machine.c2
-rw-r--r--tools/perf/util/map.c2
-rw-r--r--tools/perf/util/mem2node.c2
-rw-r--r--tools/perf/util/mmap.c1
-rw-r--r--tools/perf/util/namespaces.c2
-rw-r--r--tools/perf/util/parse-events.c1
-rw-r--r--tools/perf/util/pmu.c2
-rw-r--r--tools/perf/util/probe-event.c2
-rw-r--r--tools/perf/util/probe-file.c2
-rw-r--r--tools/perf/util/probe-finder.c2
-rw-r--r--tools/perf/util/pstack.c2
-rw-r--r--tools/perf/util/python-ext-sources1
-rw-r--r--tools/perf/util/s390-cpumsf.c2
-rw-r--r--tools/perf/util/session.c2
-rw-r--r--tools/perf/util/srcline.c2
-rw-r--r--tools/perf/util/stat.c1
-rw-r--r--tools/perf/util/strbuf.c2
-rw-r--r--tools/perf/util/strfilter.c3
-rw-r--r--tools/perf/util/strlist.c2
-rw-r--r--tools/perf/util/svghelper.c2
-rw-r--r--tools/perf/util/symbol-elf.c1
-rw-r--r--tools/perf/util/symbol-minimal.c2
-rw-r--r--tools/perf/util/symbol.c1
-rw-r--r--tools/perf/util/syscalltbl.c2
-rw-r--r--tools/perf/util/thread-stack.c2
-rw-r--r--tools/perf/util/thread.c2
-rw-r--r--tools/perf/util/thread_map.c2
-rw-r--r--tools/perf/util/trace-event-info.c1
-rw-r--r--tools/perf/util/trace-event-scripting.c2
-rw-r--r--tools/perf/util/unwind-libdw.c1
-rw-r--r--tools/perf/util/util.h9
-rw-r--r--tools/perf/util/values.c2
-rw-r--r--tools/perf/util/vdso.c1
-rw-r--r--tools/perf/util/xyarray.c2
101 files changed, 108 insertions, 86 deletions
diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST
index 6a5de44b2de9..70f1ff4e2eb4 100644
--- a/tools/perf/MANIFEST
+++ b/tools/perf/MANIFEST
@@ -18,3 +18,4 @@ tools/lib/find_bit.c
18tools/lib/bitmap.c 18tools/lib/bitmap.c
19tools/lib/str_error_r.c 19tools/lib/str_error_r.c
20tools/lib/vsprintf.c 20tools/lib/vsprintf.c
21tools/lib/zalloc.c
diff --git a/tools/perf/arch/arm/annotate/instructions.c b/tools/perf/arch/arm/annotate/instructions.c
index f64516d5b23e..c7d1a69b894f 100644
--- a/tools/perf/arch/arm/annotate/instructions.c
+++ b/tools/perf/arch/arm/annotate/instructions.c
@@ -1,5 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2#include <linux/compiler.h> 2#include <linux/compiler.h>
3#include <linux/zalloc.h>
3#include <sys/types.h> 4#include <sys/types.h>
4#include <regex.h> 5#include <regex.h>
5 6
diff --git a/tools/perf/arch/arm/util/auxtrace.c b/tools/perf/arch/arm/util/auxtrace.c
index 1ce6bdbda561..02014740a1aa 100644
--- a/tools/perf/arch/arm/util/auxtrace.c
+++ b/tools/perf/arch/arm/util/auxtrace.c
@@ -6,6 +6,7 @@
6 6
7#include <stdbool.h> 7#include <stdbool.h>
8#include <linux/coresight-pmu.h> 8#include <linux/coresight-pmu.h>
9#include <linux/zalloc.h>
9 10
10#include "../../util/auxtrace.h" 11#include "../../util/auxtrace.h"
11#include "../../util/evlist.h" 12#include "../../util/evlist.h"
diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c
index 2b83cc8e4796..4208974c24f8 100644
--- a/tools/perf/arch/arm/util/cs-etm.c
+++ b/tools/perf/arch/arm/util/cs-etm.c
@@ -12,6 +12,7 @@
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/log2.h> 13#include <linux/log2.h>
14#include <linux/types.h> 14#include <linux/types.h>
15#include <linux/zalloc.h>
15 16
16#include "cs-etm.h" 17#include "cs-etm.h"
17#include "../../perf.h" 18#include "../../perf.h"
diff --git a/tools/perf/arch/arm64/util/arm-spe.c b/tools/perf/arch/arm64/util/arm-spe.c
index 5ccfce87e693..2c009aa74633 100644
--- a/tools/perf/arch/arm64/util/arm-spe.c
+++ b/tools/perf/arch/arm64/util/arm-spe.c
@@ -8,6 +8,7 @@
8#include <linux/types.h> 8#include <linux/types.h>
9#include <linux/bitops.h> 9#include <linux/bitops.h>
10#include <linux/log2.h> 10#include <linux/log2.h>
11#include <linux/zalloc.h>
11#include <time.h> 12#include <time.h>
12 13
13#include "../../util/cpumap.h" 14#include "../../util/cpumap.h"
diff --git a/tools/perf/arch/common.c b/tools/perf/arch/common.c
index 1bc329412bcf..1a9e22f78c22 100644
--- a/tools/perf/arch/common.c
+++ b/tools/perf/arch/common.c
@@ -3,8 +3,8 @@
3#include <stdlib.h> 3#include <stdlib.h>
4#include "common.h" 4#include "common.h"
5#include "../util/env.h" 5#include "../util/env.h"
6#include "../util/util.h"
7#include "../util/debug.h" 6#include "../util/debug.h"
7#include <linux/zalloc.h>
8 8
9const char *const arc_triplets[] = { 9const char *const arc_triplets[] = {
10 "arc-linux-", 10 "arc-linux-",
diff --git a/tools/perf/arch/powerpc/util/perf_regs.c b/tools/perf/arch/powerpc/util/perf_regs.c
index 64f65c296d3e..f14102b85509 100644
--- a/tools/perf/arch/powerpc/util/perf_regs.c
+++ b/tools/perf/arch/powerpc/util/perf_regs.c
@@ -2,9 +2,9 @@
2#include <errno.h> 2#include <errno.h>
3#include <string.h> 3#include <string.h>
4#include <regex.h> 4#include <regex.h>
5#include <linux/zalloc.h>
5 6
6#include "../../perf.h" 7#include "../../perf.h"
7#include "../../util/util.h"
8#include "../../util/perf_regs.h" 8#include "../../util/perf_regs.h"
9#include "../../util/debug.h" 9#include "../../util/debug.h"
10 10
diff --git a/tools/perf/arch/s390/util/auxtrace.c b/tools/perf/arch/s390/util/auxtrace.c
index 44c857388897..0fe1be93f375 100644
--- a/tools/perf/arch/s390/util/auxtrace.c
+++ b/tools/perf/arch/s390/util/auxtrace.c
@@ -3,6 +3,7 @@
3#include <linux/types.h> 3#include <linux/types.h>
4#include <linux/bitops.h> 4#include <linux/bitops.h>
5#include <linux/log2.h> 5#include <linux/log2.h>
6#include <linux/zalloc.h>
6 7
7#include "../../util/evlist.h" 8#include "../../util/evlist.h"
8#include "../../util/auxtrace.h" 9#include "../../util/auxtrace.h"
diff --git a/tools/perf/arch/s390/util/header.c b/tools/perf/arch/s390/util/header.c
index 165c51435e72..8b0b018d896a 100644
--- a/tools/perf/arch/s390/util/header.c
+++ b/tools/perf/arch/s390/util/header.c
@@ -13,9 +13,9 @@
13#include <string.h> 13#include <string.h>
14#include <linux/ctype.h> 14#include <linux/ctype.h>
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/zalloc.h>
16 17
17#include "../../util/header.h" 18#include "../../util/header.h"
18#include "../../util/util.h"
19 19
20#define SYSINFO_MANU "Manufacturer:" 20#define SYSINFO_MANU "Manufacturer:"
21#define SYSINFO_TYPE "Type:" 21#define SYSINFO_TYPE "Type:"
diff --git a/tools/perf/arch/x86/util/event.c b/tools/perf/arch/x86/util/event.c
index 675a0213044d..a3a0b6884779 100644
--- a/tools/perf/arch/x86/util/event.c
+++ b/tools/perf/arch/x86/util/event.c
@@ -1,11 +1,11 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2#include <linux/types.h> 2#include <linux/types.h>
3#include <linux/string.h> 3#include <linux/string.h>
4#include <linux/zalloc.h>
4 5
5#include "../../util/machine.h" 6#include "../../util/machine.h"
6#include "../../util/tool.h" 7#include "../../util/tool.h"
7#include "../../util/map.h" 8#include "../../util/map.h"
8#include "../../util/util.h"
9#include "../../util/debug.h" 9#include "../../util/debug.h"
10 10
11#if defined(__x86_64__) 11#if defined(__x86_64__)
diff --git a/tools/perf/arch/x86/util/intel-bts.c b/tools/perf/arch/x86/util/intel-bts.c
index e6d4d9591c79..ec5c1bb84095 100644
--- a/tools/perf/arch/x86/util/intel-bts.c
+++ b/tools/perf/arch/x86/util/intel-bts.c
@@ -9,12 +9,12 @@
9#include <linux/types.h> 9#include <linux/types.h>
10#include <linux/bitops.h> 10#include <linux/bitops.h>
11#include <linux/log2.h> 11#include <linux/log2.h>
12#include <linux/zalloc.h>
12 13
13#include "../../util/cpumap.h" 14#include "../../util/cpumap.h"
14#include "../../util/evsel.h" 15#include "../../util/evsel.h"
15#include "../../util/evlist.h" 16#include "../../util/evlist.h"
16#include "../../util/session.h" 17#include "../../util/session.h"
17#include "../../util/util.h"
18#include "../../util/pmu.h" 18#include "../../util/pmu.h"
19#include "../../util/debug.h" 19#include "../../util/debug.h"
20#include "../../util/tsc.h" 20#include "../../util/tsc.h"
diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c
index 9804098dcefb..609088c01e3a 100644
--- a/tools/perf/arch/x86/util/intel-pt.c
+++ b/tools/perf/arch/x86/util/intel-pt.c
@@ -10,6 +10,7 @@
10#include <linux/types.h> 10#include <linux/types.h>
11#include <linux/bitops.h> 11#include <linux/bitops.h>
12#include <linux/log2.h> 12#include <linux/log2.h>
13#include <linux/zalloc.h>
13#include <cpuid.h> 14#include <cpuid.h>
14 15
15#include "../../perf.h" 16#include "../../perf.h"
@@ -25,7 +26,6 @@
25#include "../../util/auxtrace.h" 26#include "../../util/auxtrace.h"
26#include "../../util/tsc.h" 27#include "../../util/tsc.h"
27#include "../../util/intel-pt.h" 28#include "../../util/intel-pt.h"
28#include "../../util/util.h"
29 29
30#define KiB(x) ((x) * 1024) 30#define KiB(x) ((x) * 1024)
31#define MiB(x) ((x) * 1024 * 1024) 31#define MiB(x) ((x) * 1024 * 1024)
diff --git a/tools/perf/arch/x86/util/perf_regs.c b/tools/perf/arch/x86/util/perf_regs.c
index 3666c0076df9..0d7b77ff0ae6 100644
--- a/tools/perf/arch/x86/util/perf_regs.c
+++ b/tools/perf/arch/x86/util/perf_regs.c
@@ -2,9 +2,9 @@
2#include <errno.h> 2#include <errno.h>
3#include <string.h> 3#include <string.h>
4#include <regex.h> 4#include <regex.h>
5#include <linux/zalloc.h>
5 6
6#include "../../perf.h" 7#include "../../perf.h"
7#include "../../util/util.h"
8#include "../../util/perf_regs.h" 8#include "../../util/perf_regs.h"
9#include "../../util/debug.h" 9#include "../../util/debug.h"
10 10
diff --git a/tools/perf/bench/mem-functions.c b/tools/perf/bench/mem-functions.c
index 0251dd348124..64dc994c72ea 100644
--- a/tools/perf/bench/mem-functions.c
+++ b/tools/perf/bench/mem-functions.c
@@ -9,7 +9,6 @@
9 9
10#include "debug.h" 10#include "debug.h"
11#include "../perf.h" 11#include "../perf.h"
12#include "../util/util.h"
13#include <subcmd/parse-options.h> 12#include <subcmd/parse-options.h>
14#include "../util/header.h" 13#include "../util/header.h"
15#include "../util/cloexec.h" 14#include "../util/cloexec.h"
@@ -24,6 +23,7 @@
24#include <sys/time.h> 23#include <sys/time.h>
25#include <errno.h> 24#include <errno.h>
26#include <linux/time64.h> 25#include <linux/time64.h>
26#include <linux/zalloc.h>
27 27
28#define K 1024 28#define K 1024
29 29
diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c
index a7784554a80d..a640ca7aaada 100644
--- a/tools/perf/bench/numa.c
+++ b/tools/perf/bench/numa.c
@@ -11,7 +11,6 @@
11 11
12#include "../perf.h" 12#include "../perf.h"
13#include "../builtin.h" 13#include "../builtin.h"
14#include "../util/util.h"
15#include <subcmd/parse-options.h> 14#include <subcmd/parse-options.h>
16#include "../util/cloexec.h" 15#include "../util/cloexec.h"
17 16
@@ -35,6 +34,7 @@
35#include <linux/kernel.h> 34#include <linux/kernel.h>
36#include <linux/time64.h> 35#include <linux/time64.h>
37#include <linux/numa.h> 36#include <linux/numa.h>
37#include <linux/zalloc.h>
38 38
39#include <numa.h> 39#include <numa.h>
40#include <numaif.h> 40#include <numaif.h>
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 77deb3a40596..e0aa14faf2b5 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -8,11 +8,11 @@
8 */ 8 */
9#include "builtin.h" 9#include "builtin.h"
10 10
11#include "util/util.h"
12#include "util/color.h" 11#include "util/color.h"
13#include <linux/list.h> 12#include <linux/list.h>
14#include "util/cache.h" 13#include "util/cache.h"
15#include <linux/rbtree.h> 14#include <linux/rbtree.h>
15#include <linux/zalloc.h>
16#include "util/symbol.h" 16#include "util/symbol.h"
17 17
18#include "perf.h" 18#include "perf.h"
diff --git a/tools/perf/builtin-bench.c b/tools/perf/builtin-bench.c
index 334c77ffc1d9..b8e7c38ef221 100644
--- a/tools/perf/builtin-bench.c
+++ b/tools/perf/builtin-bench.c
@@ -17,7 +17,6 @@
17 * epoll ... Event poll performance 17 * epoll ... Event poll performance
18 */ 18 */
19#include "perf.h" 19#include "perf.h"
20#include "util/util.h"
21#include <subcmd/parse-options.h> 20#include <subcmd/parse-options.h>
22#include "builtin.h" 21#include "builtin.h"
23#include "bench/bench.h" 22#include "bench/bench.h"
@@ -26,6 +25,7 @@
26#include <stdlib.h> 25#include <stdlib.h>
27#include <string.h> 26#include <string.h>
28#include <sys/prctl.h> 27#include <sys/prctl.h>
28#include <linux/zalloc.h>
29 29
30typedef int (*bench_fn_t)(int argc, const char **argv); 30typedef int (*bench_fn_t)(int argc, const char **argv);
31 31
diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
index 9e6cc868bdb4..e3776f5c2e01 100644
--- a/tools/perf/builtin-c2c.c
+++ b/tools/perf/builtin-c2c.c
@@ -15,9 +15,9 @@
15#include <linux/compiler.h> 15#include <linux/compiler.h>
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/stringify.h> 17#include <linux/stringify.h>
18#include <linux/zalloc.h>
18#include <asm/bug.h> 19#include <asm/bug.h>
19#include <sys/param.h> 20#include <sys/param.h>
20#include "util.h"
21#include "debug.h" 21#include "debug.h"
22#include "builtin.h" 22#include "builtin.h"
23#include <subcmd/parse-options.h> 23#include <subcmd/parse-options.h>
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index f924b46910b5..f6f5dd15bea7 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -16,12 +16,12 @@
16#include "util/tool.h" 16#include "util/tool.h"
17#include "util/sort.h" 17#include "util/sort.h"
18#include "util/symbol.h" 18#include "util/symbol.h"
19#include "util/util.h"
20#include "util/data.h" 19#include "util/data.h"
21#include "util/config.h" 20#include "util/config.h"
22#include "util/time-utils.h" 21#include "util/time-utils.h"
23#include "util/annotate.h" 22#include "util/annotate.h"
24#include "util/map.h" 23#include "util/map.h"
24#include <linux/zalloc.h>
25 25
26#include <errno.h> 26#include <errno.h>
27#include <inttypes.h> 27#include <inttypes.h>
diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c
index 6a1cab547043..a83af92fb0d1 100644
--- a/tools/perf/builtin-help.c
+++ b/tools/perf/builtin-help.c
@@ -14,6 +14,7 @@
14#include <subcmd/help.h> 14#include <subcmd/help.h>
15#include "util/debug.h" 15#include "util/debug.h"
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/zalloc.h>
17#include <errno.h> 18#include <errno.h>
18#include <stdio.h> 19#include <stdio.h>
19#include <stdlib.h> 20#include <stdlib.h>
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 9bd3829de76d..9e5e60898083 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -4,7 +4,6 @@
4 4
5#include "util/evlist.h" 5#include "util/evlist.h"
6#include "util/evsel.h" 6#include "util/evsel.h"
7#include "util/util.h"
8#include "util/config.h" 7#include "util/config.h"
9#include "util/map.h" 8#include "util/map.h"
10#include "util/symbol.h" 9#include "util/symbol.h"
@@ -26,6 +25,7 @@
26#include <linux/kernel.h> 25#include <linux/kernel.h>
27#include <linux/rbtree.h> 26#include <linux/rbtree.h>
28#include <linux/string.h> 27#include <linux/string.h>
28#include <linux/zalloc.h>
29#include <errno.h> 29#include <errno.h>
30#include <inttypes.h> 30#include <inttypes.h>
31#include <locale.h> 31#include <locale.h>
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index dbb6f737a3e2..b33c83489120 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -5,7 +5,6 @@
5#include "util/evsel.h" 5#include "util/evsel.h"
6#include "util/evlist.h" 6#include "util/evlist.h"
7#include "util/term.h" 7#include "util/term.h"
8#include "util/util.h"
9#include "util/cache.h" 8#include "util/cache.h"
10#include "util/symbol.h" 9#include "util/symbol.h"
11#include "util/thread.h" 10#include "util/thread.h"
@@ -32,6 +31,7 @@
32 31
33#include <linux/kernel.h> 32#include <linux/kernel.h>
34#include <linux/time64.h> 33#include <linux/time64.h>
34#include <linux/zalloc.h>
35#include <errno.h> 35#include <errno.h>
36#include <inttypes.h> 36#include <inttypes.h>
37#include <poll.h> 37#include <poll.h>
diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
index b9810a8d350a..c0be44e65e9d 100644
--- a/tools/perf/builtin-lock.c
+++ b/tools/perf/builtin-lock.c
@@ -6,7 +6,6 @@
6 6
7#include "util/evlist.h" 7#include "util/evlist.h"
8#include "util/evsel.h" 8#include "util/evsel.h"
9#include "util/util.h"
10#include "util/cache.h" 9#include "util/cache.h"
11#include "util/symbol.h" 10#include "util/symbol.h"
12#include "util/thread.h" 11#include "util/thread.h"
@@ -30,6 +29,7 @@
30#include <linux/list.h> 29#include <linux/list.h>
31#include <linux/hash.h> 30#include <linux/hash.h>
32#include <linux/kernel.h> 31#include <linux/kernel.h>
32#include <linux/zalloc.h>
33 33
34static struct perf_session *session; 34static struct perf_session *session;
35 35
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index 8bb124e55c6d..6418782951a4 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -19,7 +19,6 @@
19#include "perf.h" 19#include "perf.h"
20#include "builtin.h" 20#include "builtin.h"
21#include "namespaces.h" 21#include "namespaces.h"
22#include "util/util.h"
23#include "util/strlist.h" 22#include "util/strlist.h"
24#include "util/strfilter.h" 23#include "util/strfilter.h"
25#include "util/symbol.h" 24#include "util/symbol.h"
@@ -28,6 +27,7 @@
28#include "util/probe-finder.h" 27#include "util/probe-finder.h"
29#include "util/probe-event.h" 28#include "util/probe-event.h"
30#include "util/probe-file.h" 29#include "util/probe-file.h"
30#include <linux/zalloc.h>
31 31
32#define DEFAULT_VAR_FILTER "!__k???tab_* & !__crc_*" 32#define DEFAULT_VAR_FILTER "!__k???tab_* & !__crc_*"
33#define DEFAULT_FUNC_FILTER "!_*" 33#define DEFAULT_FUNC_FILTER "!_*"
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 93d4b12e248e..abf0b9b8f566 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -8,7 +8,6 @@
8 */ 8 */
9#include "builtin.h" 9#include "builtin.h"
10 10
11#include "util/util.h"
12#include "util/config.h" 11#include "util/config.h"
13 12
14#include "util/annotate.h" 13#include "util/annotate.h"
@@ -16,6 +15,7 @@
16#include <linux/list.h> 15#include <linux/list.h>
17#include <linux/rbtree.h> 16#include <linux/rbtree.h>
18#include <linux/err.h> 17#include <linux/err.h>
18#include <linux/zalloc.h>
19#include "util/map.h" 19#include "util/map.h"
20#include "util/symbol.h" 20#include "util/symbol.h"
21#include "util/callchain.h" 21#include "util/callchain.h"
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 1519989961ff..56d1907b1215 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -2,7 +2,6 @@
2#include "builtin.h" 2#include "builtin.h"
3#include "perf.h" 3#include "perf.h"
4 4
5#include "util/util.h"
6#include "util/evlist.h" 5#include "util/evlist.h"
7#include "util/cache.h" 6#include "util/cache.h"
8#include "util/evsel.h" 7#include "util/evsel.h"
@@ -26,6 +25,7 @@
26 25
27#include <linux/kernel.h> 26#include <linux/kernel.h>
28#include <linux/log2.h> 27#include <linux/log2.h>
28#include <linux/zalloc.h>
29#include <sys/prctl.h> 29#include <sys/prctl.h>
30#include <sys/resource.h> 30#include <sys/resource.h>
31#include <inttypes.h> 31#include <inttypes.h>
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 2f6232f1bfdc..b3536820f9a8 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -14,7 +14,6 @@
14#include "util/symbol.h" 14#include "util/symbol.h"
15#include "util/thread.h" 15#include "util/thread.h"
16#include "util/trace-event.h" 16#include "util/trace-event.h"
17#include "util/util.h"
18#include "util/evlist.h" 17#include "util/evlist.h"
19#include "util/evsel.h" 18#include "util/evsel.h"
20#include "util/sort.h" 19#include "util/sort.h"
@@ -34,6 +33,7 @@
34#include <linux/kernel.h> 33#include <linux/kernel.h>
35#include <linux/stringify.h> 34#include <linux/stringify.h>
36#include <linux/time64.h> 35#include <linux/time64.h>
36#include <linux/zalloc.h>
37#include <sys/utsname.h> 37#include <sys/utsname.h>
38#include "asm/bug.h" 38#include "asm/bug.h"
39#include "util/mem-events.h" 39#include "util/mem-events.h"
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index b81f7b197d24..c72f4a0831a8 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -43,7 +43,6 @@
43#include "perf.h" 43#include "perf.h"
44#include "builtin.h" 44#include "builtin.h"
45#include "util/cgroup.h" 45#include "util/cgroup.h"
46#include "util/util.h"
47#include <subcmd/parse-options.h> 46#include <subcmd/parse-options.h>
48#include "util/parse-events.h" 47#include "util/parse-events.h"
49#include "util/pmu.h" 48#include "util/pmu.h"
@@ -67,6 +66,7 @@
67#include "asm/bug.h" 66#include "asm/bug.h"
68 67
69#include <linux/time64.h> 68#include <linux/time64.h>
69#include <linux/zalloc.h>
70#include <api/fs/fs.h> 70#include <api/fs/fs.h>
71#include <errno.h> 71#include <errno.h>
72#include <signal.h> 72#include <signal.h>
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index 145a19668114..4bde3fa245d1 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -13,9 +13,6 @@
13#include <traceevent/event-parse.h> 13#include <traceevent/event-parse.h>
14 14
15#include "builtin.h" 15#include "builtin.h"
16
17#include "util/util.h"
18
19#include "util/color.h" 16#include "util/color.h"
20#include <linux/list.h> 17#include <linux/list.h>
21#include "util/cache.h" 18#include "util/cache.h"
@@ -24,6 +21,7 @@
24#include <linux/kernel.h> 21#include <linux/kernel.h>
25#include <linux/rbtree.h> 22#include <linux/rbtree.h>
26#include <linux/time64.h> 23#include <linux/time64.h>
24#include <linux/zalloc.h>
27#include "util/symbol.h" 25#include "util/symbol.h"
28#include "util/thread.h" 26#include "util/thread.h"
29#include "util/callchain.h" 27#include "util/callchain.h"
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index e3fc9062f136..1aa2ed096f65 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -61,6 +61,7 @@
61#include <linux/random.h> 61#include <linux/random.h>
62#include <linux/stringify.h> 62#include <linux/stringify.h>
63#include <linux/time64.h> 63#include <linux/time64.h>
64#include <linux/zalloc.h>
64#include <fcntl.h> 65#include <fcntl.h>
65#include <sys/sysmacros.h> 66#include <sys/sysmacros.h>
66 67
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 2123b3cc4dcf..97e2628ea5dd 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -18,7 +18,6 @@
18#include "util/bpf-loader.h" 18#include "util/bpf-loader.h"
19#include "util/debug.h" 19#include "util/debug.h"
20#include "util/event.h" 20#include "util/event.h"
21#include "util/util.h"
22#include <api/fs/fs.h> 21#include <api/fs/fs.h>
23#include <api/fs/tracing_path.h> 22#include <api/fs/tracing_path.h>
24#include <errno.h> 23#include <errno.h>
@@ -30,6 +29,7 @@
30#include <sys/stat.h> 29#include <sys/stat.h>
31#include <unistd.h> 30#include <unistd.h>
32#include <linux/kernel.h> 31#include <linux/kernel.h>
32#include <linux/zalloc.h>
33 33
34const char perf_usage_string[] = 34const char perf_usage_string[] =
35 "perf [--version] [--help] [OPTIONS] COMMAND [ARGS]"; 35 "perf [--version] [--help] [OPTIONS] COMMAND [ARGS]";
diff --git a/tools/perf/tests/switch-tracking.c b/tools/perf/tests/switch-tracking.c
index 9b5be51e5e7b..744409dce65f 100644
--- a/tools/perf/tests/switch-tracking.c
+++ b/tools/perf/tests/switch-tracking.c
@@ -4,6 +4,7 @@
4#include <errno.h> 4#include <errno.h>
5#include <time.h> 5#include <time.h>
6#include <stdlib.h> 6#include <stdlib.h>
7#include <linux/zalloc.h>
7 8
8#include "parse-events.h" 9#include "parse-events.h"
9#include "evlist.h" 10#include "evlist.h"
diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c
index 55ff05a46e0b..f80c51d53565 100644
--- a/tools/perf/ui/browser.c
+++ b/tools/perf/ui/browser.c
@@ -1,5 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2#include "../util.h"
3#include "../string2.h" 2#include "../string2.h"
4#include "../config.h" 3#include "../config.h"
5#include "../../perf.h" 4#include "../../perf.h"
@@ -17,6 +16,7 @@
17#include "keysyms.h" 16#include "keysyms.h"
18#include "../color.h" 17#include "../color.h"
19#include <linux/ctype.h> 18#include <linux/ctype.h>
19#include <linux/zalloc.h>
20 20
21static int ui_browser__percent_color(struct ui_browser *browser, 21static int ui_browser__percent_color(struct ui_browser *browser,
22 double percent, bool current) 22 double percent, bool current)
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index b0d089a95dac..e67880bf1efe 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -1,5 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2#include "../../util/util.h"
3#include "../browser.h" 2#include "../browser.h"
4#include "../helpline.h" 3#include "../helpline.h"
5#include "../ui.h" 4#include "../ui.h"
@@ -15,6 +14,7 @@
15#include <pthread.h> 14#include <pthread.h>
16#include <linux/kernel.h> 15#include <linux/kernel.h>
17#include <linux/string.h> 16#include <linux/string.h>
17#include <linux/zalloc.h>
18#include <sys/ttydefaults.h> 18#include <sys/ttydefaults.h>
19#include <asm/bug.h> 19#include <asm/bug.h>
20 20
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 33e67aa91347..85581cfb9112 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -9,6 +9,7 @@
9#include <linux/string.h> 9#include <linux/string.h>
10#include <sys/ttydefaults.h> 10#include <sys/ttydefaults.h>
11#include <linux/time64.h> 11#include <linux/time64.h>
12#include <linux/zalloc.h>
12 13
13#include "../../util/callchain.h" 14#include "../../util/callchain.h"
14#include "../../util/evsel.h" 15#include "../../util/evsel.h"
@@ -18,7 +19,6 @@
18#include "../../util/symbol.h" 19#include "../../util/symbol.h"
19#include "../../util/pstack.h" 20#include "../../util/pstack.h"
20#include "../../util/sort.h" 21#include "../../util/sort.h"
21#include "../../util/util.h"
22#include "../../util/top.h" 22#include "../../util/top.h"
23#include "../../util/thread.h" 23#include "../../util/thread.h"
24#include "../../arch/common.h" 24#include "../../arch/common.h"
diff --git a/tools/perf/ui/gtk/util.c b/tools/perf/ui/gtk/util.c
index 7250d8101c8f..c28bdb7517ac 100644
--- a/tools/perf/ui/gtk/util.c
+++ b/tools/perf/ui/gtk/util.c
@@ -1,11 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2#include "../util.h" 2#include "../util.h"
3#include "../../util/util.h"
4#include "../../util/debug.h" 3#include "../../util/debug.h"
5#include "gtk.h" 4#include "gtk.h"
6 5
7#include <string.h> 6#include <string.h>
8 7#include <linux/zalloc.h>
9 8
10struct perf_gtk_context *pgctx; 9struct perf_gtk_context *pgctx;
11 10
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index 89393c79d870..ee7ea6deed21 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -3,7 +3,6 @@
3#include <linux/string.h> 3#include <linux/string.h>
4 4
5#include "../../util/callchain.h" 5#include "../../util/callchain.h"
6#include "../../util/util.h"
7#include "../../util/hist.h" 6#include "../../util/hist.h"
8#include "../../util/map.h" 7#include "../../util/map.h"
9#include "../../util/map_groups.h" 8#include "../../util/map_groups.h"
@@ -14,6 +13,7 @@
14#include "../../util/string2.h" 13#include "../../util/string2.h"
15#include "../../util/thread.h" 14#include "../../util/thread.h"
16#include <linux/ctype.h> 15#include <linux/ctype.h>
16#include <linux/zalloc.h>
17 17
18static size_t callchain__fprintf_left_margin(FILE *fp, int left_margin) 18static size_t callchain__fprintf_left_margin(FILE *fp, int left_margin)
19{ 19{
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index d3408a463060..d7e3b008a613 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -25,6 +25,7 @@ perf-y += rbtree.o
25perf-y += libstring.o 25perf-y += libstring.o
26perf-y += bitmap.o 26perf-y += bitmap.o
27perf-y += hweight.o 27perf-y += hweight.o
28perf-y += zalloc.o
28perf-y += smt.o 29perf-y += smt.o
29perf-y += strbuf.o 30perf-y += strbuf.o
30perf-y += string.o 31perf-y += string.o
@@ -241,3 +242,7 @@ $(OUTPUT)util/hweight.o: ../lib/hweight.c FORCE
241$(OUTPUT)util/vsprintf.o: ../lib/vsprintf.c FORCE 242$(OUTPUT)util/vsprintf.o: ../lib/vsprintf.c FORCE
242 $(call rule_mkdir) 243 $(call rule_mkdir)
243 $(call if_changed_dep,cc_o_c) 244 $(call if_changed_dep,cc_o_c)
245
246$(OUTPUT)util/zalloc.o: ../lib/zalloc.c FORCE
247 $(call rule_mkdir)
248 $(call if_changed_dep,cc_o_c)
diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c
index 6067267cc76c..a314e5b26e9d 100644
--- a/tools/perf/util/arm-spe.c
+++ b/tools/perf/util/arm-spe.c
@@ -12,6 +12,7 @@
12#include <linux/types.h> 12#include <linux/types.h>
13#include <linux/bitops.h> 13#include <linux/bitops.h>
14#include <linux/log2.h> 14#include <linux/log2.h>
15#include <linux/zalloc.h>
15 16
16#include "cpumap.h" 17#include "cpumap.h"
17#include "color.h" 18#include "color.h"
@@ -19,7 +20,6 @@
19#include "evlist.h" 20#include "evlist.h"
20#include "machine.h" 21#include "machine.h"
21#include "session.h" 22#include "session.h"
22#include "util.h"
23#include "thread.h" 23#include "thread.h"
24#include "debug.h" 24#include "debug.h"
25#include "auxtrace.h" 25#include "auxtrace.h"
diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
index bc215fe0b4b4..0812a11a0dbe 100644
--- a/tools/perf/util/auxtrace.c
+++ b/tools/perf/util/auxtrace.c
@@ -24,9 +24,9 @@
24#include <stdlib.h> 24#include <stdlib.h>
25#include <stdio.h> 25#include <stdio.h>
26#include <linux/list.h> 26#include <linux/list.h>
27#include <linux/zalloc.h>
27 28
28#include "../perf.h" 29#include "../perf.h"
29#include "util.h"
30#include "evlist.h" 30#include "evlist.h"
31#include "dso.h" 31#include "dso.h"
32#include "map.h" 32#include "map.h"
diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
index 251d9ea6252f..93d0f239ad4f 100644
--- a/tools/perf/util/bpf-loader.c
+++ b/tools/perf/util/bpf-loader.c
@@ -12,6 +12,7 @@
12#include <linux/err.h> 12#include <linux/err.h>
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/string.h> 14#include <linux/string.h>
15#include <linux/zalloc.h>
15#include <errno.h> 16#include <errno.h>
16#include "perf.h" 17#include "perf.h"
17#include "debug.h" 18#include "debug.h"
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
index 89c6913dfc25..f1abfab7aa8c 100644
--- a/tools/perf/util/build-id.c
+++ b/tools/perf/util/build-id.c
@@ -30,6 +30,7 @@
30#include "strlist.h" 30#include "strlist.h"
31 31
32#include <linux/ctype.h> 32#include <linux/ctype.h>
33#include <linux/zalloc.h>
33 34
34static bool no_buildid_cache; 35static bool no_buildid_cache;
35 36
diff --git a/tools/perf/util/call-path.c b/tools/perf/util/call-path.c
index c5b90300304d..e8a80c41cba3 100644
--- a/tools/perf/util/call-path.c
+++ b/tools/perf/util/call-path.c
@@ -6,8 +6,9 @@
6 6
7#include <linux/rbtree.h> 7#include <linux/rbtree.h>
8#include <linux/list.h> 8#include <linux/list.h>
9#include <linux/zalloc.h>
10#include <stdlib.h>
9 11
10#include "util.h"
11#include "call-path.h" 12#include "call-path.h"
12 13
13static void call_path__init(struct call_path *cp, struct call_path *parent, 14static void call_path__init(struct call_path *cp, struct call_path *parent,
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index abb608b09269..b4af25dca5eb 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -16,11 +16,11 @@
16#include <stdbool.h> 16#include <stdbool.h>
17#include <errno.h> 17#include <errno.h>
18#include <math.h> 18#include <math.h>
19#include <linux/zalloc.h>
19 20
20#include "asm/bug.h" 21#include "asm/bug.h"
21 22
22#include "hist.h" 23#include "hist.h"
23#include "util.h"
24#include "sort.h" 24#include "sort.h"
25#include "machine.h" 25#include "machine.h"
26#include "map.h" 26#include "map.h"
diff --git a/tools/perf/util/cgroup.c b/tools/perf/util/cgroup.c
index ccd02634a616..f505d78f059b 100644
--- a/tools/perf/util/cgroup.c
+++ b/tools/perf/util/cgroup.c
@@ -1,11 +1,11 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2#include "util.h"
3#include "../perf.h" 2#include "../perf.h"
4#include <subcmd/parse-options.h> 3#include <subcmd/parse-options.h>
5#include "evsel.h" 4#include "evsel.h"
6#include "cgroup.h" 5#include "cgroup.h"
7#include "evlist.h" 6#include "evlist.h"
8#include <linux/stringify.h> 7#include <linux/stringify.h>
8#include <linux/zalloc.h>
9#include <sys/types.h> 9#include <sys/types.h>
10#include <sys/stat.h> 10#include <sys/stat.h>
11#include <fcntl.h> 11#include <fcntl.h>
diff --git a/tools/perf/util/comm.c b/tools/perf/util/comm.c
index 1066de92af12..afb8d4fd2644 100644
--- a/tools/perf/util/comm.c
+++ b/tools/perf/util/comm.c
@@ -1,12 +1,12 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2#include "comm.h" 2#include "comm.h"
3#include "util.h"
4#include <errno.h> 3#include <errno.h>
5#include <stdlib.h> 4#include <stdlib.h>
6#include <stdio.h> 5#include <stdio.h>
7#include <string.h> 6#include <string.h>
8#include <linux/refcount.h> 7#include <linux/refcount.h>
9#include <linux/rbtree.h> 8#include <linux/rbtree.h>
9#include <linux/zalloc.h>
10#include "rwsem.h" 10#include "rwsem.h"
11 11
12struct comm_str { 12struct comm_str {
diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
index 752cce853e51..042ffbc8c53f 100644
--- a/tools/perf/util/config.c
+++ b/tools/perf/util/config.c
@@ -11,7 +11,6 @@
11 */ 11 */
12#include <errno.h> 12#include <errno.h>
13#include <sys/param.h> 13#include <sys/param.h>
14#include "util.h"
15#include "cache.h" 14#include "cache.h"
16#include "callchain.h" 15#include "callchain.h"
17#include <subcmd/exec-cmd.h> 16#include <subcmd/exec-cmd.h>
@@ -23,7 +22,7 @@
23#include <sys/stat.h> 22#include <sys/stat.h>
24#include <unistd.h> 23#include <unistd.h>
25#include <linux/string.h> 24#include <linux/string.h>
26 25#include <linux/zalloc.h>
27#include <linux/ctype.h> 26#include <linux/ctype.h>
28 27
29#define MAXNAME (256) 28#define MAXNAME (256)
diff --git a/tools/perf/util/counts.c b/tools/perf/util/counts.c
index 03032b410c29..88be9c4365e0 100644
--- a/tools/perf/util/counts.c
+++ b/tools/perf/util/counts.c
@@ -3,7 +3,7 @@
3#include <stdlib.h> 3#include <stdlib.h>
4#include "evsel.h" 4#include "evsel.h"
5#include "counts.h" 5#include "counts.h"
6#include "util.h" 6#include <linux/zalloc.h>
7 7
8struct perf_counts *perf_counts__new(int ncpus, int nthreads) 8struct perf_counts *perf_counts__new(int ncpus, int nthreads)
9{ 9{
diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c
index 0d8fbedf7bd5..3acfbe34ebaf 100644
--- a/tools/perf/util/cpumap.c
+++ b/tools/perf/util/cpumap.c
@@ -1,5 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2#include "util.h"
3#include <api/fs/fs.h> 2#include <api/fs/fs.h>
4#include "../perf.h" 3#include "../perf.h"
5#include "cpumap.h" 4#include "cpumap.h"
@@ -11,6 +10,7 @@
11#include "asm/bug.h" 10#include "asm/bug.h"
12 11
13#include <linux/ctype.h> 12#include <linux/ctype.h>
13#include <linux/zalloc.h>
14 14
15static int max_cpu_num; 15static int max_cpu_num;
16static int max_present_cpu_num; 16static int max_present_cpu_num;
diff --git a/tools/perf/util/cputopo.c b/tools/perf/util/cputopo.c
index d3b2bd258b9e..fa1778aee5d6 100644
--- a/tools/perf/util/cputopo.c
+++ b/tools/perf/util/cputopo.c
@@ -4,10 +4,10 @@
4#include <inttypes.h> 4#include <inttypes.h>
5#include <stdlib.h> 5#include <stdlib.h>
6#include <api/fs/fs.h> 6#include <api/fs/fs.h>
7#include <linux/zalloc.h>
7 8
8#include "cputopo.h" 9#include "cputopo.h"
9#include "cpumap.h" 10#include "cpumap.h"
10#include "util.h"
11#include "env.h" 11#include "env.h"
12 12
13#define CORE_SIB_FMT \ 13#define CORE_SIB_FMT \
diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c
index bb45e23018ee..37d7c492b155 100644
--- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c
+++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c
@@ -8,6 +8,7 @@
8 8
9#include <linux/err.h> 9#include <linux/err.h>
10#include <linux/list.h> 10#include <linux/list.h>
11#include <linux/zalloc.h>
11#include <stdlib.h> 12#include <stdlib.h>
12#include <opencsd/c_api/opencsd_c_api.h> 13#include <opencsd/c_api/opencsd_c_api.h>
13#include <opencsd/etmv4/trc_pkt_types_etmv4.h> 14#include <opencsd/etmv4/trc_pkt_types_etmv4.h>
diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
index 0c7776b51045..d92516edbead 100644
--- a/tools/perf/util/cs-etm.c
+++ b/tools/perf/util/cs-etm.c
@@ -11,6 +11,7 @@
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/log2.h> 12#include <linux/log2.h>
13#include <linux/types.h> 13#include <linux/types.h>
14#include <linux/zalloc.h>
14 15
15#include <opencsd/ocsd_if_types.h> 16#include <opencsd/ocsd_if_types.h>
16#include <stdlib.h> 17#include <stdlib.h>
diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c
index 7b06e7373b9e..1e93f2e94c40 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -10,6 +10,7 @@
10#include <inttypes.h> 10#include <inttypes.h>
11#include <linux/compiler.h> 11#include <linux/compiler.h>
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/zalloc.h>
13#include <babeltrace/ctf-writer/writer.h> 14#include <babeltrace/ctf-writer/writer.h>
14#include <babeltrace/ctf-writer/clock.h> 15#include <babeltrace/ctf-writer/clock.h>
15#include <babeltrace/ctf-writer/stream.h> 16#include <babeltrace/ctf-writer/stream.h>
@@ -22,7 +23,6 @@
22#include "asm/bug.h" 23#include "asm/bug.h"
23#include "data-convert-bt.h" 24#include "data-convert-bt.h"
24#include "session.h" 25#include "session.h"
25#include "util.h"
26#include "debug.h" 26#include "debug.h"
27#include "tool.h" 27#include "tool.h"
28#include "evlist.h" 28#include "evlist.h"
diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c
index 6a64f713710d..df7e000e19ea 100644
--- a/tools/perf/util/data.c
+++ b/tools/perf/util/data.c
@@ -1,6 +1,7 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2#include <linux/compiler.h> 2#include <linux/compiler.h>
3#include <linux/kernel.h> 3#include <linux/kernel.h>
4#include <linux/zalloc.h>
4#include <sys/types.h> 5#include <sys/types.h>
5#include <sys/stat.h> 6#include <sys/stat.h>
6#include <errno.h> 7#include <errno.h>
diff --git a/tools/perf/util/db-export.c b/tools/perf/util/db-export.c
index 4cdd1f579156..3f2694ccfac7 100644
--- a/tools/perf/util/db-export.c
+++ b/tools/perf/util/db-export.c
@@ -14,11 +14,11 @@
14#include "symbol.h" 14#include "symbol.h"
15#include "map.h" 15#include "map.h"
16#include "event.h" 16#include "event.h"
17#include "util.h"
18#include "thread-stack.h" 17#include "thread-stack.h"
19#include "callchain.h" 18#include "callchain.h"
20#include "call-path.h" 19#include "call-path.h"
21#include "db-export.h" 20#include "db-export.h"
21#include <linux/zalloc.h>
22 22
23struct deferred_export { 23struct deferred_export {
24 struct list_head node; 24 struct list_head node;
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index c7fde04400f7..ebacf07fc9ee 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -2,6 +2,7 @@
2#include <asm/bug.h> 2#include <asm/bug.h>
3#include <linux/kernel.h> 3#include <linux/kernel.h>
4#include <linux/string.h> 4#include <linux/string.h>
5#include <linux/zalloc.h>
5#include <sys/time.h> 6#include <sys/time.h>
6#include <sys/resource.h> 7#include <sys/resource.h>
7#include <sys/types.h> 8#include <sys/types.h>
@@ -21,7 +22,7 @@
21#include "dso.h" 22#include "dso.h"
22#include "machine.h" 23#include "machine.h"
23#include "auxtrace.h" 24#include "auxtrace.h"
24#include "util.h" 25#include "util.h" /* O_CLOEXEC for older systems */
25#include "debug.h" 26#include "debug.h"
26#include "string2.h" 27#include "string2.h"
27#include "vdso.h" 28#include "vdso.h"
diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c
index 7d317d49d207..f92d992bd2db 100644
--- a/tools/perf/util/env.c
+++ b/tools/perf/util/env.c
@@ -2,7 +2,7 @@
2#include "cpumap.h" 2#include "cpumap.h"
3#include "env.h" 3#include "env.h"
4#include <linux/ctype.h> 4#include <linux/ctype.h>
5#include "util.h" 5#include <linux/zalloc.h>
6#include "bpf-event.h" 6#include "bpf-event.h"
7#include <errno.h> 7#include <errno.h>
8#include <sys/utsname.h> 8#include <sys/utsname.h>
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index e1d0c5ba1f92..7524bda5140b 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -11,6 +11,7 @@
11#include <uapi/linux/mman.h> /* To get things like MAP_HUGETLB even on older libc headers */ 11#include <uapi/linux/mman.h> /* To get things like MAP_HUGETLB even on older libc headers */
12#include <api/fs/fs.h> 12#include <api/fs/fs.h>
13#include <linux/perf_event.h> 13#include <linux/perf_event.h>
14#include <linux/zalloc.h>
14#include "event.h" 15#include "event.h"
15#include "debug.h" 16#include "debug.h"
16#include "hist.h" 17#include "hist.h"
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index a474ede17cd6..b0364d923f76 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -5,7 +5,6 @@
5 * Parts came from builtin-{top,stat,record}.c, see those files for further 5 * Parts came from builtin-{top,stat,record}.c, see those files for further
6 * copyright notes. 6 * copyright notes.
7 */ 7 */
8#include "util.h"
9#include <api/fs/fs.h> 8#include <api/fs/fs.h>
10#include <errno.h> 9#include <errno.h>
11#include <inttypes.h> 10#include <inttypes.h>
@@ -33,6 +32,7 @@
33#include <linux/hash.h> 32#include <linux/hash.h>
34#include <linux/log2.h> 33#include <linux/log2.h>
35#include <linux/err.h> 34#include <linux/err.h>
35#include <linux/zalloc.h>
36 36
37#ifdef LACKS_SIGQUEUE_PROTOTYPE 37#ifdef LACKS_SIGQUEUE_PROTOTYPE
38int sigqueue(pid_t pid, int sig, const union sigval value); 38int sigqueue(pid_t pid, int sig, const union sigval value);
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 7fb4ae82f34c..7ede674edf07 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -17,6 +17,7 @@
17#include <linux/perf_event.h> 17#include <linux/perf_event.h>
18#include <linux/compiler.h> 18#include <linux/compiler.h>
19#include <linux/err.h> 19#include <linux/err.h>
20#include <linux/zalloc.h>
20#include <sys/ioctl.h> 21#include <sys/ioctl.h>
21#include <sys/resource.h> 22#include <sys/resource.h>
22#include <sys/types.h> 23#include <sys/types.h>
@@ -27,7 +28,6 @@
27#include "event.h" 28#include "event.h"
28#include "evsel.h" 29#include "evsel.h"
29#include "evlist.h" 30#include "evlist.h"
30#include "util.h"
31#include "cpumap.h" 31#include "cpumap.h"
32#include "thread_map.h" 32#include "thread_map.h"
33#include "target.h" 33#include "target.h"
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 6a93ff5d8db5..4e2efaa50c2f 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -1,7 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2#include <errno.h> 2#include <errno.h>
3#include <inttypes.h> 3#include <inttypes.h>
4#include "util.h"
5#include "string2.h" 4#include "string2.h"
6#include <sys/param.h> 5#include <sys/param.h>
7#include <sys/types.h> 6#include <sys/types.h>
@@ -15,6 +14,7 @@
15#include <linux/bitops.h> 14#include <linux/bitops.h>
16#include <linux/string.h> 15#include <linux/string.h>
17#include <linux/stringify.h> 16#include <linux/stringify.h>
17#include <linux/zalloc.h>
18#include <sys/stat.h> 18#include <sys/stat.h>
19#include <sys/utsname.h> 19#include <sys/utsname.h>
20#include <linux/time64.h> 20#include <linux/time64.h>
diff --git a/tools/perf/util/help-unknown-cmd.c b/tools/perf/util/help-unknown-cmd.c
index 4f07a5ba5030..ab9e16123626 100644
--- a/tools/perf/util/help-unknown-cmd.c
+++ b/tools/perf/util/help-unknown-cmd.c
@@ -3,9 +3,11 @@
3#include "config.h" 3#include "config.h"
4#include <poll.h> 4#include <poll.h>
5#include <stdio.h> 5#include <stdio.h>
6#include <stdlib.h>
6#include <subcmd/help.h> 7#include <subcmd/help.h>
7#include "../builtin.h" 8#include "../builtin.h"
8#include "levenshtein.h" 9#include "levenshtein.h"
10#include <linux/zalloc.h>
9 11
10static int autocorrect; 12static int autocorrect;
11 13
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 27cecb59f866..bb1d77331add 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1,6 +1,5 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2#include "callchain.h" 2#include "callchain.h"
3#include "util.h"
4#include "build-id.h" 3#include "build-id.h"
5#include "hist.h" 4#include "hist.h"
6#include "map.h" 5#include "map.h"
@@ -20,6 +19,7 @@
20#include <inttypes.h> 19#include <inttypes.h>
21#include <sys/param.h> 20#include <sys/param.h>
22#include <linux/time64.h> 21#include <linux/time64.h>
22#include <linux/zalloc.h>
23 23
24static bool hists__filter_entry_by_dso(struct hists *hists, 24static bool hists__filter_entry_by_dso(struct hists *hists,
25 struct hist_entry *he); 25 struct hist_entry *he);
diff --git a/tools/perf/util/intel-bts.c b/tools/perf/util/intel-bts.c
index e32dbffebb2f..5a21bcdb8ef7 100644
--- a/tools/perf/util/intel-bts.c
+++ b/tools/perf/util/intel-bts.c
@@ -12,6 +12,7 @@
12#include <linux/types.h> 12#include <linux/types.h>
13#include <linux/bitops.h> 13#include <linux/bitops.h>
14#include <linux/log2.h> 14#include <linux/log2.h>
15#include <linux/zalloc.h>
15 16
16#include "cpumap.h" 17#include "cpumap.h"
17#include "color.h" 18#include "color.h"
@@ -21,7 +22,6 @@
21#include "map.h" 22#include "map.h"
22#include "symbol.h" 23#include "symbol.h"
23#include "session.h" 24#include "session.h"
24#include "util.h"
25#include "thread.h" 25#include "thread.h"
26#include "thread-stack.h" 26#include "thread-stack.h"
27#include "debug.h" 27#include "debug.h"
diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
index 4d14e78c5927..3bfdf2b7a96a 100644
--- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
+++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
@@ -14,9 +14,9 @@
14#include <stdint.h> 14#include <stdint.h>
15#include <inttypes.h> 15#include <inttypes.h>
16#include <linux/compiler.h> 16#include <linux/compiler.h>
17#include <linux/zalloc.h>
17 18
18#include "../cache.h" 19#include "../cache.h"
19#include "../util.h"
20#include "../auxtrace.h" 20#include "../auxtrace.h"
21 21
22#include "intel-pt-insn-decoder.h" 22#include "intel-pt-insn-decoder.h"
diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index 470aaae9d930..c76a96f777fb 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -10,6 +10,7 @@
10#include <errno.h> 10#include <errno.h>
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/types.h> 12#include <linux/types.h>
13#include <linux/zalloc.h>
13 14
14#include "../perf.h" 15#include "../perf.h"
15#include "session.h" 16#include "session.h"
@@ -22,7 +23,6 @@
22#include "evsel.h" 23#include "evsel.h"
23#include "map.h" 24#include "map.h"
24#include "color.h" 25#include "color.h"
25#include "util.h"
26#include "thread.h" 26#include "thread.h"
27#include "thread-stack.h" 27#include "thread-stack.h"
28#include "symbol.h" 28#include "symbol.h"
diff --git a/tools/perf/util/llvm-utils.c b/tools/perf/util/llvm-utils.c
index 5b0b60f00275..b9fddb809d58 100644
--- a/tools/perf/util/llvm-utils.c
+++ b/tools/perf/util/llvm-utils.c
@@ -9,6 +9,7 @@
9#include <stdio.h> 9#include <stdio.h>
10#include <stdlib.h> 10#include <stdlib.h>
11#include <linux/err.h> 11#include <linux/err.h>
12#include <linux/zalloc.h>
12#include "debug.h" 13#include "debug.h"
13#include "llvm-utils.h" 14#include "llvm-utils.h"
14#include "config.h" 15#include "config.h"
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 147ed85ea2bc..f523da3009e4 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -15,7 +15,6 @@
15#include "strlist.h" 15#include "strlist.h"
16#include "thread.h" 16#include "thread.h"
17#include "vdso.h" 17#include "vdso.h"
18#include "util.h"
19#include <stdbool.h> 18#include <stdbool.h>
20#include <sys/types.h> 19#include <sys/types.h>
21#include <sys/stat.h> 20#include <sys/stat.h>
@@ -28,6 +27,7 @@
28#include <linux/ctype.h> 27#include <linux/ctype.h>
29#include <symbol/kallsyms.h> 28#include <symbol/kallsyms.h>
30#include <linux/mman.h> 29#include <linux/mman.h>
30#include <linux/zalloc.h>
31 31
32static void __machine__remove_thread(struct machine *machine, struct thread *th, bool lock); 32static void __machine__remove_thread(struct machine *machine, struct thread *th, bool lock);
33 33
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 5f87975d2562..668410b1d426 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -12,10 +12,10 @@
12#include "thread.h" 12#include "thread.h"
13#include "vdso.h" 13#include "vdso.h"
14#include "build-id.h" 14#include "build-id.h"
15#include "util.h"
16#include "debug.h" 15#include "debug.h"
17#include "machine.h" 16#include "machine.h"
18#include <linux/string.h> 17#include <linux/string.h>
18#include <linux/zalloc.h>
19#include "srcline.h" 19#include "srcline.h"
20#include "namespaces.h" 20#include "namespaces.h"
21#include "unwind.h" 21#include "unwind.h"
diff --git a/tools/perf/util/mem2node.c b/tools/perf/util/mem2node.c
index c6fd81c02586..cacc2fc4dcbd 100644
--- a/tools/perf/util/mem2node.c
+++ b/tools/perf/util/mem2node.c
@@ -1,8 +1,8 @@
1#include <errno.h> 1#include <errno.h>
2#include <inttypes.h> 2#include <inttypes.h>
3#include <linux/bitmap.h> 3#include <linux/bitmap.h>
4#include <linux/zalloc.h>
4#include "mem2node.h" 5#include "mem2node.h"
5#include "util.h"
6 6
7struct phys_entry { 7struct phys_entry {
8 struct rb_node rb_node; 8 struct rb_node rb_node;
diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c
index 768c632b0d82..9f0b6391af33 100644
--- a/tools/perf/util/mmap.c
+++ b/tools/perf/util/mmap.c
@@ -9,6 +9,7 @@
9#include <sys/mman.h> 9#include <sys/mman.h>
10#include <inttypes.h> 10#include <inttypes.h>
11#include <asm/bug.h> 11#include <asm/bug.h>
12#include <linux/zalloc.h>
12#ifdef HAVE_LIBNUMA_SUPPORT 13#ifdef HAVE_LIBNUMA_SUPPORT
13#include <numaif.h> 14#include <numaif.h>
14#endif 15#endif
diff --git a/tools/perf/util/namespaces.c b/tools/perf/util/namespaces.c
index fda2fa1e8819..46d3a7754897 100644
--- a/tools/perf/util/namespaces.c
+++ b/tools/perf/util/namespaces.c
@@ -5,7 +5,6 @@
5 */ 5 */
6 6
7#include "namespaces.h" 7#include "namespaces.h"
8#include "util.h"
9#include "event.h" 8#include "event.h"
10#include "get_current_dir_name.h" 9#include "get_current_dir_name.h"
11#include <sys/types.h> 10#include <sys/types.h>
@@ -18,6 +17,7 @@
18#include <string.h> 17#include <string.h>
19#include <unistd.h> 18#include <unistd.h>
20#include <asm/bug.h> 19#include <asm/bug.h>
20#include <linux/zalloc.h>
21 21
22struct namespaces *namespaces__new(struct namespaces_event *event) 22struct namespaces *namespaces__new(struct namespaces_event *event)
23{ 23{
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index cf0b9b81c5aa..aa439853f20a 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -1,6 +1,7 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2#include <linux/hw_breakpoint.h> 2#include <linux/hw_breakpoint.h>
3#include <linux/err.h> 3#include <linux/err.h>
4#include <linux/zalloc.h>
4#include <dirent.h> 5#include <dirent.h>
5#include <errno.h> 6#include <errno.h>
6#include <sys/ioctl.h> 7#include <sys/ioctl.h>
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 55f4de6442e3..12b677902fbc 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -2,6 +2,7 @@
2#include <linux/list.h> 2#include <linux/list.h>
3#include <linux/compiler.h> 3#include <linux/compiler.h>
4#include <linux/string.h> 4#include <linux/string.h>
5#include <linux/zalloc.h>
5#include <sys/types.h> 6#include <sys/types.h>
6#include <errno.h> 7#include <errno.h>
7#include <fcntl.h> 8#include <fcntl.h>
@@ -14,7 +15,6 @@
14#include <api/fs/fs.h> 15#include <api/fs/fs.h>
15#include <locale.h> 16#include <locale.h>
16#include <regex.h> 17#include <regex.h>
17#include "util.h"
18#include "pmu.h" 18#include "pmu.h"
19#include "parse-events.h" 19#include "parse-events.h"
20#include "cpumap.h" 20#include "cpumap.h"
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 6f24eaf6e504..80c0eca0f1ee 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -19,7 +19,6 @@
19#include <limits.h> 19#include <limits.h>
20#include <elf.h> 20#include <elf.h>
21 21
22#include "util.h"
23#include "event.h" 22#include "event.h"
24#include "namespaces.h" 23#include "namespaces.h"
25#include "strlist.h" 24#include "strlist.h"
@@ -40,6 +39,7 @@
40#include "string2.h" 39#include "string2.h"
41 40
42#include <linux/ctype.h> 41#include <linux/ctype.h>
42#include <linux/zalloc.h>
43 43
44#define PERFPROBE_GROUP "probe" 44#define PERFPROBE_GROUP "probe"
45 45
diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c
index 0ed1900454eb..c2998f90b23c 100644
--- a/tools/perf/util/probe-file.c
+++ b/tools/perf/util/probe-file.c
@@ -10,8 +10,8 @@
10#include <sys/types.h> 10#include <sys/types.h>
11#include <sys/uio.h> 11#include <sys/uio.h>
12#include <unistd.h> 12#include <unistd.h>
13#include <linux/zalloc.h>
13#include "namespaces.h" 14#include "namespaces.h"
14#include "util.h"
15#include "event.h" 15#include "event.h"
16#include "strlist.h" 16#include "strlist.h"
17#include "strfilter.h" 17#include "strfilter.h"
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 6b40cc691a2d..7d8c99734928 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -19,11 +19,11 @@
19#include <dwarf-regs.h> 19#include <dwarf-regs.h>
20 20
21#include <linux/bitops.h> 21#include <linux/bitops.h>
22#include <linux/zalloc.h>
22#include "event.h" 23#include "event.h"
23#include "dso.h" 24#include "dso.h"
24#include "debug.h" 25#include "debug.h"
25#include "intlist.h" 26#include "intlist.h"
26#include "util.h"
27#include "strlist.h" 27#include "strlist.h"
28#include "symbol.h" 28#include "symbol.h"
29#include "probe-finder.h" 29#include "probe-finder.h"
diff --git a/tools/perf/util/pstack.c b/tools/perf/util/pstack.c
index 797fe1ae2d2e..28de8a4c2ce8 100644
--- a/tools/perf/util/pstack.c
+++ b/tools/perf/util/pstack.c
@@ -5,10 +5,10 @@
5 * (c) 2010 Arnaldo Carvalho de Melo <acme@redhat.com> 5 * (c) 2010 Arnaldo Carvalho de Melo <acme@redhat.com>
6 */ 6 */
7 7
8#include "util.h"
9#include "pstack.h" 8#include "pstack.h"
10#include "debug.h" 9#include "debug.h"
11#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/zalloc.h>
12#include <stdlib.h> 12#include <stdlib.h>
13 13
14struct pstack { 14struct pstack {
diff --git a/tools/perf/util/python-ext-sources b/tools/perf/util/python-ext-sources
index 2237bac9fadb..ceb8afdf9a89 100644
--- a/tools/perf/util/python-ext-sources
+++ b/tools/perf/util/python-ext-sources
@@ -18,6 +18,7 @@ util/namespaces.c
18../lib/hweight.c 18../lib/hweight.c
19../lib/string.c 19../lib/string.c
20../lib/vsprintf.c 20../lib/vsprintf.c
21../lib/zalloc.c
21util/thread_map.c 22util/thread_map.c
22util/util.c 23util/util.c
23util/xyarray.c 24util/xyarray.c
diff --git a/tools/perf/util/s390-cpumsf.c b/tools/perf/util/s390-cpumsf.c
index 10d36d9b7909..ea669702825d 100644
--- a/tools/perf/util/s390-cpumsf.c
+++ b/tools/perf/util/s390-cpumsf.c
@@ -146,6 +146,7 @@
146#include <linux/types.h> 146#include <linux/types.h>
147#include <linux/bitops.h> 147#include <linux/bitops.h>
148#include <linux/log2.h> 148#include <linux/log2.h>
149#include <linux/zalloc.h>
149 150
150#include <sys/stat.h> 151#include <sys/stat.h>
151#include <sys/types.h> 152#include <sys/types.h>
@@ -156,7 +157,6 @@
156#include "evlist.h" 157#include "evlist.h"
157#include "machine.h" 158#include "machine.h"
158#include "session.h" 159#include "session.h"
159#include "util.h"
160#include "thread.h" 160#include "thread.h"
161#include "debug.h" 161#include "debug.h"
162#include "auxtrace.h" 162#include "auxtrace.h"
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index e3463df18493..d0fd6c614e68 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -2,6 +2,7 @@
2#include <errno.h> 2#include <errno.h>
3#include <inttypes.h> 3#include <inttypes.h>
4#include <linux/kernel.h> 4#include <linux/kernel.h>
5#include <linux/zalloc.h>
5#include <traceevent/event-parse.h> 6#include <traceevent/event-parse.h>
6#include <api/fs/fs.h> 7#include <api/fs/fs.h>
7 8
@@ -18,7 +19,6 @@
18#include "session.h" 19#include "session.h"
19#include "tool.h" 20#include "tool.h"
20#include "sort.h" 21#include "sort.h"
21#include "util.h"
22#include "cpumap.h" 22#include "cpumap.h"
23#include "perf_regs.h" 23#include "perf_regs.h"
24#include "asm/bug.h" 24#include "asm/bug.h"
diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c
index dcad75daf5e4..6ccf6f6d09df 100644
--- a/tools/perf/util/srcline.c
+++ b/tools/perf/util/srcline.c
@@ -6,9 +6,9 @@
6 6
7#include <linux/kernel.h> 7#include <linux/kernel.h>
8#include <linux/string.h> 8#include <linux/string.h>
9#include <linux/zalloc.h>
9 10
10#include "util/dso.h" 11#include "util/dso.h"
11#include "util/util.h"
12#include "util/debug.h" 12#include "util/debug.h"
13#include "util/callchain.h" 13#include "util/callchain.h"
14#include "util/symbol_conf.h" 14#include "util/symbol_conf.h"
diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
index d91fe754b6d2..c967715c1d4c 100644
--- a/tools/perf/util/stat.c
+++ b/tools/perf/util/stat.c
@@ -6,6 +6,7 @@
6#include "evlist.h" 6#include "evlist.h"
7#include "evsel.h" 7#include "evsel.h"
8#include "thread_map.h" 8#include "thread_map.h"
9#include <linux/zalloc.h>
9 10
10void update_stats(struct stats *stats, u64 val) 11void update_stats(struct stats *stats, u64 val)
11{ 12{
diff --git a/tools/perf/util/strbuf.c b/tools/perf/util/strbuf.c
index 54336df089df..2ce0dc887364 100644
--- a/tools/perf/util/strbuf.c
+++ b/tools/perf/util/strbuf.c
@@ -1,7 +1,7 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2#include "debug.h" 2#include "debug.h"
3#include "util.h"
4#include <linux/kernel.h> 3#include <linux/kernel.h>
4#include <linux/zalloc.h>
5#include <errno.h> 5#include <errno.h>
6#include <stdlib.h> 6#include <stdlib.h>
7 7
diff --git a/tools/perf/util/strfilter.c b/tools/perf/util/strfilter.c
index 90ea2b209cbb..78aa4c3b990d 100644
--- a/tools/perf/util/strfilter.c
+++ b/tools/perf/util/strfilter.c
@@ -1,11 +1,12 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2#include "util.h"
3#include "string2.h" 2#include "string2.h"
4#include "strfilter.h" 3#include "strfilter.h"
5 4
6#include <errno.h> 5#include <errno.h>
6#include <stdlib.h>
7#include <linux/ctype.h> 7#include <linux/ctype.h>
8#include <linux/string.h> 8#include <linux/string.h>
9#include <linux/zalloc.h>
9 10
10/* Operators */ 11/* Operators */
11static const char *OP_and = "&"; /* Logical AND */ 12static const char *OP_and = "&"; /* Logical AND */
diff --git a/tools/perf/util/strlist.c b/tools/perf/util/strlist.c
index af45c6fd97db..8a868cbeffae 100644
--- a/tools/perf/util/strlist.c
+++ b/tools/perf/util/strlist.c
@@ -4,12 +4,12 @@
4 */ 4 */
5 5
6#include "strlist.h" 6#include "strlist.h"
7#include "util.h"
8#include <errno.h> 7#include <errno.h>
9#include <stdio.h> 8#include <stdio.h>
10#include <stdlib.h> 9#include <stdlib.h>
11#include <string.h> 10#include <string.h>
12#include <unistd.h> 11#include <unistd.h>
12#include <linux/zalloc.h>
13 13
14static 14static
15struct rb_node *strlist__node_new(struct rblist *rblist, const void *entry) 15struct rb_node *strlist__node_new(struct rblist *rblist, const void *entry)
diff --git a/tools/perf/util/svghelper.c b/tools/perf/util/svghelper.c
index fab8a048d31b..76cc54000483 100644
--- a/tools/perf/util/svghelper.c
+++ b/tools/perf/util/svghelper.c
@@ -15,10 +15,10 @@
15#include <string.h> 15#include <string.h>
16#include <linux/bitmap.h> 16#include <linux/bitmap.h>
17#include <linux/time64.h> 17#include <linux/time64.h>
18#include <linux/zalloc.h>
18 19
19#include "perf.h" 20#include "perf.h"
20#include "svghelper.h" 21#include "svghelper.h"
21#include "util.h"
22#include "cpumap.h" 22#include "cpumap.h"
23 23
24static u64 first_time, last_time; 24static u64 first_time, last_time;
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 429920978cb0..ad683fbe9678 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -17,6 +17,7 @@
17#include "debug.h" 17#include "debug.h"
18#include "util.h" 18#include "util.h"
19#include <linux/ctype.h> 19#include <linux/ctype.h>
20#include <linux/zalloc.h>
20#include <symbol/kallsyms.h> 21#include <symbol/kallsyms.h>
21 22
22#ifndef EM_AARCH64 23#ifndef EM_AARCH64
diff --git a/tools/perf/util/symbol-minimal.c b/tools/perf/util/symbol-minimal.c
index c8b7cadbc9c4..3bc8b7e3300e 100644
--- a/tools/perf/util/symbol-minimal.c
+++ b/tools/perf/util/symbol-minimal.c
@@ -10,7 +10,7 @@
10#include <stdlib.h> 10#include <stdlib.h>
11#include <byteswap.h> 11#include <byteswap.h>
12#include <sys/stat.h> 12#include <sys/stat.h>
13 13#include <linux/zalloc.h>
14 14
15static bool check_need_swap(int file_endian) 15static bool check_need_swap(int file_endian)
16{ 16{
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index ae2ce255e848..173f3378aaa0 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -26,6 +26,7 @@
26#include "header.h" 26#include "header.h"
27#include "path.h" 27#include "path.h"
28#include <linux/ctype.h> 28#include <linux/ctype.h>
29#include <linux/zalloc.h>
29 30
30#include <elf.h> 31#include <elf.h>
31#include <limits.h> 32#include <limits.h>
diff --git a/tools/perf/util/syscalltbl.c b/tools/perf/util/syscalltbl.c
index c2037ac533f3..022a9c670338 100644
--- a/tools/perf/util/syscalltbl.c
+++ b/tools/perf/util/syscalltbl.c
@@ -10,9 +10,9 @@
10#include <linux/compiler.h> 10#include <linux/compiler.h>
11 11
12#ifdef HAVE_SYSCALL_TABLE_SUPPORT 12#ifdef HAVE_SYSCALL_TABLE_SUPPORT
13#include <linux/zalloc.h>
13#include <string.h> 14#include <string.h>
14#include "string2.h" 15#include "string2.h"
15#include "util.h"
16 16
17#if defined(__x86_64__) 17#if defined(__x86_64__)
18#include <asm/syscalls_64.c> 18#include <asm/syscalls_64.c>
diff --git a/tools/perf/util/thread-stack.c b/tools/perf/util/thread-stack.c
index 48d585a0175c..15134ac9b8f1 100644
--- a/tools/perf/util/thread-stack.c
+++ b/tools/perf/util/thread-stack.c
@@ -7,13 +7,13 @@
7#include <linux/rbtree.h> 7#include <linux/rbtree.h>
8#include <linux/list.h> 8#include <linux/list.h>
9#include <linux/log2.h> 9#include <linux/log2.h>
10#include <linux/zalloc.h>
10#include <errno.h> 11#include <errno.h>
11#include <stdlib.h> 12#include <stdlib.h>
12#include "thread.h" 13#include "thread.h"
13#include "event.h" 14#include "event.h"
14#include "machine.h" 15#include "machine.h"
15#include "env.h" 16#include "env.h"
16#include "util.h"
17#include "debug.h" 17#include "debug.h"
18#include "symbol.h" 18#include "symbol.h"
19#include "comm.h" 19#include "comm.h"
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index 3e29a4e8b5e6..bbfb9c767f5f 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -5,10 +5,10 @@
5#include <stdio.h> 5#include <stdio.h>
6#include <string.h> 6#include <string.h>
7#include <linux/kernel.h> 7#include <linux/kernel.h>
8#include <linux/zalloc.h>
8#include "session.h" 9#include "session.h"
9#include "thread.h" 10#include "thread.h"
10#include "thread-stack.h" 11#include "thread-stack.h"
11#include "util.h"
12#include "debug.h" 12#include "debug.h"
13#include "namespaces.h" 13#include "namespaces.h"
14#include "comm.h" 14#include "comm.h"
diff --git a/tools/perf/util/thread_map.c b/tools/perf/util/thread_map.c
index 281bf06f10f2..c291874352cf 100644
--- a/tools/perf/util/thread_map.c
+++ b/tools/perf/util/thread_map.c
@@ -13,9 +13,9 @@
13#include <string.h> 13#include <string.h>
14#include <api/fs/fs.h> 14#include <api/fs/fs.h>
15#include <linux/string.h> 15#include <linux/string.h>
16#include <linux/zalloc.h>
16#include "asm/bug.h" 17#include "asm/bug.h"
17#include "thread_map.h" 18#include "thread_map.h"
18#include "util.h"
19#include "debug.h" 19#include "debug.h"
20#include "event.h" 20#include "event.h"
21 21
diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c
index 806a11b334d3..4550015b9d5d 100644
--- a/tools/perf/util/trace-event-info.c
+++ b/tools/perf/util/trace-event-info.c
@@ -18,6 +18,7 @@
18#include <stdbool.h> 18#include <stdbool.h>
19#include <linux/list.h> 19#include <linux/list.h>
20#include <linux/kernel.h> 20#include <linux/kernel.h>
21#include <linux/zalloc.h>
21 22
22#include "../perf.h" 23#include "../perf.h"
23#include "trace-event.h" 24#include "trace-event.h"
diff --git a/tools/perf/util/trace-event-scripting.c b/tools/perf/util/trace-event-scripting.c
index b023db136ef3..ba58f69777a1 100644
--- a/tools/perf/util/trace-event-scripting.c
+++ b/tools/perf/util/trace-event-scripting.c
@@ -12,8 +12,8 @@
12 12
13#include "../perf.h" 13#include "../perf.h"
14#include "debug.h" 14#include "debug.h"
15#include "util.h"
16#include "trace-event.h" 15#include "trace-event.h"
16#include <linux/zalloc.h>
17 17
18struct scripting_context *scripting_context; 18struct scripting_context *scripting_context;
19 19
diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c
index 407d0167b942..28f71ca6ce1c 100644
--- a/tools/perf/util/unwind-libdw.c
+++ b/tools/perf/util/unwind-libdw.c
@@ -12,6 +12,7 @@
12#include "symbol.h" 12#include "symbol.h"
13#include "thread.h" 13#include "thread.h"
14#include <linux/types.h> 14#include <linux/types.h>
15#include <linux/zalloc.h>
15#include "event.h" 16#include "event.h"
16#include "perf_regs.h" 17#include "perf_regs.h"
17#include "callchain.h" 18#include "callchain.h"
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index cfc4d85bbd42..dc7a469921e9 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -9,8 +9,6 @@
9#include <fcntl.h> 9#include <fcntl.h>
10#include <stdbool.h> 10#include <stdbool.h>
11#include <stddef.h> 11#include <stddef.h>
12#include <stdlib.h>
13#include <stdarg.h>
14#include <linux/compiler.h> 12#include <linux/compiler.h>
15#include <sys/types.h> 13#include <sys/types.h>
16 14
@@ -18,13 +16,6 @@
18void usage(const char *err) __noreturn; 16void usage(const char *err) __noreturn;
19void die(const char *err, ...) __noreturn __printf(1, 2); 17void die(const char *err, ...) __noreturn __printf(1, 2);
20 18
21static inline void *zalloc(size_t size)
22{
23 return calloc(1, size);
24}
25
26#define zfree(ptr) ({ free(*ptr); *ptr = NULL; })
27
28struct dirent; 19struct dirent;
29struct nsinfo; 20struct nsinfo;
30struct strlist; 21struct strlist;
diff --git a/tools/perf/util/values.c b/tools/perf/util/values.c
index 4b7a303e4ba8..c59154e2d124 100644
--- a/tools/perf/util/values.c
+++ b/tools/perf/util/values.c
@@ -3,8 +3,8 @@
3#include <stdio.h> 3#include <stdio.h>
4#include <stdlib.h> 4#include <stdlib.h>
5#include <errno.h> 5#include <errno.h>
6#include <linux/zalloc.h>
6 7
7#include "util.h"
8#include "values.h" 8#include "values.h"
9#include "debug.h" 9#include "debug.h"
10 10
diff --git a/tools/perf/util/vdso.c b/tools/perf/util/vdso.c
index 5031b7b22bbd..7f427bab6c12 100644
--- a/tools/perf/util/vdso.c
+++ b/tools/perf/util/vdso.c
@@ -16,6 +16,7 @@
16#include "machine.h" 16#include "machine.h"
17#include "thread.h" 17#include "thread.h"
18#include "linux/string.h" 18#include "linux/string.h"
19#include <linux/zalloc.h>
19#include "debug.h" 20#include "debug.h"
20 21
21/* 22/*
diff --git a/tools/perf/util/xyarray.c b/tools/perf/util/xyarray.c
index dc95154f5646..86889ebc3514 100644
--- a/tools/perf/util/xyarray.c
+++ b/tools/perf/util/xyarray.c
@@ -1,8 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2#include "xyarray.h" 2#include "xyarray.h"
3#include "util.h"
4#include <stdlib.h> 3#include <stdlib.h>
5#include <string.h> 4#include <string.h>
5#include <linux/zalloc.h>
6 6
7struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size) 7struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size)
8{ 8{