summaryrefslogtreecommitdiffstats
path: root/tools/perf/util
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2019-07-04 16:32:27 +0200
committerArnaldo Carvalho de Melo <acme@redhat.com>2019-07-09 15:13:26 +0200
commit7f7c536f23e6afaa5d5d4b0e0958b0be8922491f (patch)
tree961ca1cb94ac6ea74be5859ca6c9881b260ea479 /tools/perf/util
parentperf tools: Move get_current_dir_name() cond prototype out of util.h (diff)
downloadlinux-7f7c536f23e6afaa5d5d4b0e0958b0be8922491f.tar.xz
linux-7f7c536f23e6afaa5d5d4b0e0958b0be8922491f.zip
tools lib: Adopt zalloc()/zfree() from tools/perf
Eroding a bit more the tools/perf/util/util.h hodpodge header. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: https://lkml.kernel.org/n/tip-natazosyn9rwjka25tvcnyi0@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
-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
64 files changed, 71 insertions, 55 deletions
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
perf-y += libstring.o
perf-y += bitmap.o
perf-y += hweight.o
+perf-y += zalloc.o
perf-y += smt.o
perf-y += strbuf.o
perf-y += string.o
@@ -241,3 +242,7 @@ $(OUTPUT)util/hweight.o: ../lib/hweight.c FORCE
$(OUTPUT)util/vsprintf.o: ../lib/vsprintf.c FORCE
$(call rule_mkdir)
$(call if_changed_dep,cc_o_c)
+
+$(OUTPUT)util/zalloc.o: ../lib/zalloc.c FORCE
+ $(call rule_mkdir)
+ $(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 @@
#include <linux/types.h>
#include <linux/bitops.h>
#include <linux/log2.h>
+#include <linux/zalloc.h>
#include "cpumap.h"
#include "color.h"
@@ -19,7 +20,6 @@
#include "evlist.h"
#include "machine.h"
#include "session.h"
-#include "util.h"
#include "thread.h"
#include "debug.h"
#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 @@
#include <stdlib.h>
#include <stdio.h>
#include <linux/list.h>
+#include <linux/zalloc.h>
#include "../perf.h"
-#include "util.h"
#include "evlist.h"
#include "dso.h"
#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 @@
#include <linux/err.h>
#include <linux/kernel.h>
#include <linux/string.h>
+#include <linux/zalloc.h>
#include <errno.h>
#include "perf.h"
#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 @@
#include "strlist.h"
#include <linux/ctype.h>
+#include <linux/zalloc.h>
static bool no_buildid_cache;
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 @@
#include <linux/rbtree.h>
#include <linux/list.h>
+#include <linux/zalloc.h>
+#include <stdlib.h>
-#include "util.h"
#include "call-path.h"
static 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 @@
#include <stdbool.h>
#include <errno.h>
#include <math.h>
+#include <linux/zalloc.h>
#include "asm/bug.h"
#include "hist.h"
-#include "util.h"
#include "sort.h"
#include "machine.h"
#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 @@
// SPDX-License-Identifier: GPL-2.0
-#include "util.h"
#include "../perf.h"
#include <subcmd/parse-options.h>
#include "evsel.h"
#include "cgroup.h"
#include "evlist.h"
#include <linux/stringify.h>
+#include <linux/zalloc.h>
#include <sys/types.h>
#include <sys/stat.h>
#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 @@
// SPDX-License-Identifier: GPL-2.0
#include "comm.h"
-#include "util.h"
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <linux/refcount.h>
#include <linux/rbtree.h>
+#include <linux/zalloc.h>
#include "rwsem.h"
struct 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 @@
*/
#include <errno.h>
#include <sys/param.h>
-#include "util.h"
#include "cache.h"
#include "callchain.h"
#include <subcmd/exec-cmd.h>
@@ -23,7 +22,7 @@
#include <sys/stat.h>
#include <unistd.h>
#include <linux/string.h>
-
+#include <linux/zalloc.h>
#include <linux/ctype.h>
#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 @@
#include <stdlib.h>
#include "evsel.h"
#include "counts.h"
-#include "util.h"
+#include <linux/zalloc.h>
struct perf_counts *perf_counts__new(int ncpus, int nthreads)
{
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 @@
// SPDX-License-Identifier: GPL-2.0
-#include "util.h"
#include <api/fs/fs.h>
#include "../perf.h"
#include "cpumap.h"
@@ -11,6 +10,7 @@
#include "asm/bug.h"
#include <linux/ctype.h>
+#include <linux/zalloc.h>
static int max_cpu_num;
static 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 @@
#include <inttypes.h>
#include <stdlib.h>
#include <api/fs/fs.h>
+#include <linux/zalloc.h>
#include "cputopo.h"
#include "cpumap.h"
-#include "util.h"
#include "env.h"
#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 @@
#include <linux/err.h>
#include <linux/list.h>
+#include <linux/zalloc.h>
#include <stdlib.h>
#include <opencsd/c_api/opencsd_c_api.h>
#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 @@
#include <linux/kernel.h>
#include <linux/log2.h>
#include <linux/types.h>
+#include <linux/zalloc.h>
#include <opencsd/ocsd_if_types.h>
#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 @@
#include <inttypes.h>
#include <linux/compiler.h>
#include <linux/kernel.h>
+#include <linux/zalloc.h>
#include <babeltrace/ctf-writer/writer.h>
#include <babeltrace/ctf-writer/clock.h>
#include <babeltrace/ctf-writer/stream.h>
@@ -22,7 +23,6 @@
#include "asm/bug.h"
#include "data-convert-bt.h"
#include "session.h"
-#include "util.h"
#include "debug.h"
#include "tool.h"
#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 @@
// SPDX-License-Identifier: GPL-2.0
#include <linux/compiler.h>
#include <linux/kernel.h>
+#include <linux/zalloc.h>
#include <sys/types.h>
#include <sys/stat.h>
#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 @@
#include "symbol.h"
#include "map.h"
#include "event.h"
-#include "util.h"
#include "thread-stack.h"
#include "callchain.h"
#include "call-path.h"
#include "db-export.h"
+#include <linux/zalloc.h>
struct deferred_export {
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 @@
#include <asm/bug.h>
#include <linux/kernel.h>
#include <linux/string.h>
+#include <linux/zalloc.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/types.h>
@@ -21,7 +22,7 @@
#include "dso.h"
#include "machine.h"
#include "auxtrace.h"
-#include "util.h"
+#include "util.h" /* O_CLOEXEC for older systems */
#include "debug.h"
#include "string2.h"
#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 @@
#include "cpumap.h"
#include "env.h"
#include <linux/ctype.h>
-#include "util.h"
+#include <linux/zalloc.h>
#include "bpf-event.h"
#include <errno.h>
#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 @@
#include <uapi/linux/mman.h> /* To get things like MAP_HUGETLB even on older libc headers */
#include <api/fs/fs.h>
#include <linux/perf_event.h>
+#include <linux/zalloc.h>
#include "event.h"
#include "debug.h"
#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 @@
* Parts came from builtin-{top,stat,record}.c, see those files for further
* copyright notes.
*/
-#include "util.h"
#include <api/fs/fs.h>
#include <errno.h>
#include <inttypes.h>
@@ -33,6 +32,7 @@
#include <linux/hash.h>
#include <linux/log2.h>
#include <linux/err.h>
+#include <linux/zalloc.h>
#ifdef LACKS_SIGQUEUE_PROTOTYPE
int 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 @@
#include <linux/perf_event.h>
#include <linux/compiler.h>
#include <linux/err.h>
+#include <linux/zalloc.h>
#include <sys/ioctl.h>
#include <sys/resource.h>
#include <sys/types.h>
@@ -27,7 +28,6 @@
#include "event.h"
#include "evsel.h"
#include "evlist.h"
-#include "util.h"
#include "cpumap.h"
#include "thread_map.h"
#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 @@
// SPDX-License-Identifier: GPL-2.0
#include <errno.h>
#include <inttypes.h>
-#include "util.h"
#include "string2.h"
#include <sys/param.h>
#include <sys/types.h>
@@ -15,6 +14,7 @@
#include <linux/bitops.h>
#include <linux/string.h>
#include <linux/stringify.h>
+#include <linux/zalloc.h>
#include <sys/stat.h>
#include <sys/utsname.h>
#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 @@
#include "config.h"
#include <poll.h>
#include <stdio.h>
+#include <stdlib.h>
#include <subcmd/help.h>
#include "../builtin.h"
#include "levenshtein.h"
+#include <linux/zalloc.h>
static int autocorrect;
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 @@
// SPDX-License-Identifier: GPL-2.0
#include "callchain.h"
-#include "util.h"
#include "build-id.h"
#include "hist.h"
#include "map.h"
@@ -20,6 +19,7 @@
#include <inttypes.h>
#include <sys/param.h>
#include <linux/time64.h>
+#include <linux/zalloc.h>
static bool hists__filter_entry_by_dso(struct hists *hists,
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 @@
#include <linux/types.h>
#include <linux/bitops.h>
#include <linux/log2.h>
+#include <linux/zalloc.h>
#include "cpumap.h"
#include "color.h"
@@ -21,7 +22,6 @@
#include "map.h"
#include "symbol.h"
#include "session.h"
-#include "util.h"
#include "thread.h"
#include "thread-stack.h"
#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 @@
#include <stdint.h>
#include <inttypes.h>
#include <linux/compiler.h>
+#include <linux/zalloc.h>
#include "../cache.h"
-#include "../util.h"
#include "../auxtrace.h"
#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 @@
#include <errno.h>
#include <linux/kernel.h>
#include <linux/types.h>
+#include <linux/zalloc.h>
#include "../perf.h"
#include "session.h"
@@ -22,7 +23,6 @@
#include "evsel.h"
#include "map.h"
#include "color.h"
-#include "util.h"
#include "thread.h"
#include "thread-stack.h"
#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 @@
#include <stdio.h>
#include <stdlib.h>
#include <linux/err.h>
+#include <linux/zalloc.h>
#include "debug.h"
#include "llvm-utils.h"
#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 @@
#include "strlist.h"
#include "thread.h"
#include "vdso.h"
-#include "util.h"
#include <stdbool.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -28,6 +27,7 @@
#include <linux/ctype.h>
#include <symbol/kallsyms.h>
#include <linux/mman.h>
+#include <linux/zalloc.h>
static void __machine__remove_thread(struct machine *machine, struct thread *th, bool lock);
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 @@
#include "thread.h"
#include "vdso.h"
#include "build-id.h"
-#include "util.h"
#include "debug.h"
#include "machine.h"
#include <linux/string.h>
+#include <linux/zalloc.h>
#include "srcline.h"
#include "namespaces.h"
#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 @@
#include <errno.h>
#include <inttypes.h>
#include <linux/bitmap.h>
+#include <linux/zalloc.h>
#include "mem2node.h"
-#include "util.h"
struct phys_entry {
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 @@
#include <sys/mman.h>
#include <inttypes.h>
#include <asm/bug.h>
+#include <linux/zalloc.h>
#ifdef HAVE_LIBNUMA_SUPPORT
#include <numaif.h>
#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 @@
*/
#include "namespaces.h"
-#include "util.h"
#include "event.h"
#include "get_current_dir_name.h"
#include <sys/types.h>
@@ -18,6 +17,7 @@
#include <string.h>
#include <unistd.h>
#include <asm/bug.h>
+#include <linux/zalloc.h>
struct namespaces *namespaces__new(struct namespaces_event *event)
{
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 @@
// SPDX-License-Identifier: GPL-2.0
#include <linux/hw_breakpoint.h>
#include <linux/err.h>
+#include <linux/zalloc.h>
#include <dirent.h>
#include <errno.h>
#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 @@
#include <linux/list.h>
#include <linux/compiler.h>
#include <linux/string.h>
+#include <linux/zalloc.h>
#include <sys/types.h>
#include <errno.h>
#include <fcntl.h>
@@ -14,7 +15,6 @@
#include <api/fs/fs.h>
#include <locale.h>
#include <regex.h>
-#include "util.h"
#include "pmu.h"
#include "parse-events.h"
#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 @@
#include <limits.h>
#include <elf.h>
-#include "util.h"
#include "event.h"
#include "namespaces.h"
#include "strlist.h"
@@ -40,6 +39,7 @@
#include "string2.h"
#include <linux/ctype.h>
+#include <linux/zalloc.h>
#define PERFPROBE_GROUP "probe"
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 @@
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
+#include <linux/zalloc.h>
#include "namespaces.h"
-#include "util.h"
#include "event.h"
#include "strlist.h"
#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 @@
#include <dwarf-regs.h>
#include <linux/bitops.h>
+#include <linux/zalloc.h>
#include "event.h"
#include "dso.h"
#include "debug.h"
#include "intlist.h"
-#include "util.h"
#include "strlist.h"
#include "symbol.h"
#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 @@
* (c) 2010 Arnaldo Carvalho de Melo <acme@redhat.com>
*/
-#include "util.h"
#include "pstack.h"
#include "debug.h"
#include <linux/kernel.h>
+#include <linux/zalloc.h>
#include <stdlib.h>
struct 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
../lib/hweight.c
../lib/string.c
../lib/vsprintf.c
+../lib/zalloc.c
util/thread_map.c
util/util.c
util/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 @@
#include <linux/types.h>
#include <linux/bitops.h>
#include <linux/log2.h>
+#include <linux/zalloc.h>
#include <sys/stat.h>
#include <sys/types.h>
@@ -156,7 +157,6 @@
#include "evlist.h"
#include "machine.h"
#include "session.h"
-#include "util.h"
#include "thread.h"
#include "debug.h"
#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 @@
#include <errno.h>
#include <inttypes.h>
#include <linux/kernel.h>
+#include <linux/zalloc.h>
#include <traceevent/event-parse.h>
#include <api/fs/fs.h>
@@ -18,7 +19,6 @@
#include "session.h"
#include "tool.h"
#include "sort.h"
-#include "util.h"
#include "cpumap.h"
#include "perf_regs.h"
#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 @@
#include <linux/kernel.h>
#include <linux/string.h>
+#include <linux/zalloc.h>
#include "util/dso.h"
-#include "util/util.h"
#include "util/debug.h"
#include "util/callchain.h"
#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 @@
#include "evlist.h"
#include "evsel.h"
#include "thread_map.h"
+#include <linux/zalloc.h>
void update_stats(struct stats *stats, u64 val)
{
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 @@
// SPDX-License-Identifier: GPL-2.0
#include "debug.h"
-#include "util.h"
#include <linux/kernel.h>
+#include <linux/zalloc.h>
#include <errno.h>
#include <stdlib.h>
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 @@
// SPDX-License-Identifier: GPL-2.0
-#include "util.h"
#include "string2.h"
#include "strfilter.h"
#include <errno.h>
+#include <stdlib.h>
#include <linux/ctype.h>
#include <linux/string.h>
+#include <linux/zalloc.h>
/* Operators */
static 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 @@
*/
#include "strlist.h"
-#include "util.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <linux/zalloc.h>
static
struct 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 @@
#include <string.h>
#include <linux/bitmap.h>
#include <linux/time64.h>
+#include <linux/zalloc.h>
#include "perf.h"
#include "svghelper.h"
-#include "util.h"
#include "cpumap.h"
static 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 @@
#include "debug.h"
#include "util.h"
#include <linux/ctype.h>
+#include <linux/zalloc.h>
#include <symbol/kallsyms.h>
#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 @@
#include <stdlib.h>
#include <byteswap.h>
#include <sys/stat.h>
-
+#include <linux/zalloc.h>
static bool check_need_swap(int file_endian)
{
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 @@
#include "header.h"
#include "path.h"
#include <linux/ctype.h>
+#include <linux/zalloc.h>
#include <elf.h>
#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 @@
#include <linux/compiler.h>
#ifdef HAVE_SYSCALL_TABLE_SUPPORT
+#include <linux/zalloc.h>
#include <string.h>
#include "string2.h"
-#include "util.h"
#if defined(__x86_64__)
#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 @@
#include <linux/rbtree.h>
#include <linux/list.h>
#include <linux/log2.h>
+#include <linux/zalloc.h>
#include <errno.h>
#include <stdlib.h>
#include "thread.h"
#include "event.h"
#include "machine.h"
#include "env.h"
-#include "util.h"
#include "debug.h"
#include "symbol.h"
#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 @@
#include <stdio.h>
#include <string.h>
#include <linux/kernel.h>
+#include <linux/zalloc.h>
#include "session.h"
#include "thread.h"
#include "thread-stack.h"
-#include "util.h"
#include "debug.h"
#include "namespaces.h"
#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 @@
#include <string.h>
#include <api/fs/fs.h>
#include <linux/string.h>
+#include <linux/zalloc.h>
#include "asm/bug.h"
#include "thread_map.h"
-#include "util.h"
#include "debug.h"
#include "event.h"
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 @@
#include <stdbool.h>
#include <linux/list.h>
#include <linux/kernel.h>
+#include <linux/zalloc.h>
#include "../perf.h"
#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 @@
#include "../perf.h"
#include "debug.h"
-#include "util.h"
#include "trace-event.h"
+#include <linux/zalloc.h>
struct scripting_context *scripting_context;
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 @@
#include "symbol.h"
#include "thread.h"
#include <linux/types.h>
+#include <linux/zalloc.h>
#include "event.h"
#include "perf_regs.h"
#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 @@
#include <fcntl.h>
#include <stdbool.h>
#include <stddef.h>
-#include <stdlib.h>
-#include <stdarg.h>
#include <linux/compiler.h>
#include <sys/types.h>
@@ -18,13 +16,6 @@
void usage(const char *err) __noreturn;
void die(const char *err, ...) __noreturn __printf(1, 2);
-static inline void *zalloc(size_t size)
-{
- return calloc(1, size);
-}
-
-#define zfree(ptr) ({ free(*ptr); *ptr = NULL; })
-
struct dirent;
struct nsinfo;
struct 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 @@
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
+#include <linux/zalloc.h>
-#include "util.h"
#include "values.h"
#include "debug.h"
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 @@
#include "machine.h"
#include "thread.h"
#include "linux/string.h"
+#include <linux/zalloc.h>
#include "debug.h"
/*
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 @@
// SPDX-License-Identifier: GPL-2.0
#include "xyarray.h"
-#include "util.h"
#include <stdlib.h>
#include <string.h>
+#include <linux/zalloc.h>
struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size)
{