Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf stat: Use nftw() instead of ftw()

ftw() has been obsolete for about 12 years now.

Committer notes:

Further notes provided by the patch author:

"NOTE: Not runtime-tested, I have no idea what I need to do in perf
to test this. But at least it compiles now with my uClibc-based
toolchain."

I looked at the nftw()/ftw() man page and for the use made with cgroups
in 'perf stat' the end result is equivalent.

Fixes: bb1c15b60b98 ("perf stat: Support regex pattern in --for-each-cgroup")
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: od@zcrc.me
Cc: stable@vger.kernel.org
Link: http://lore.kernel.org/lkml/20210208181157.1324550-1-paul@crapouillou.net
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Paul Cercueil and committed by
Arnaldo Carvalho de Melo
a81fbb87 7d91e818

+4 -4
+4 -4
tools/perf/util/cgroup.c
··· 161 161 162 162 /* helper function for ftw() in match_cgroups and list_cgroups */ 163 163 static int add_cgroup_name(const char *fpath, const struct stat *sb __maybe_unused, 164 - int typeflag) 164 + int typeflag, struct FTW *ftwbuf __maybe_unused) 165 165 { 166 166 struct cgroup_name *cn; 167 167 ··· 209 209 if (!s) 210 210 return -1; 211 211 /* pretend if it's added by ftw() */ 212 - ret = add_cgroup_name(s, NULL, FTW_D); 212 + ret = add_cgroup_name(s, NULL, FTW_D, NULL); 213 213 free(s); 214 214 if (ret) 215 215 return -1; 216 216 } else { 217 - if (add_cgroup_name("", NULL, FTW_D) < 0) 217 + if (add_cgroup_name("", NULL, FTW_D, NULL) < 0) 218 218 return -1; 219 219 } 220 220 ··· 247 247 prefix_len = strlen(mnt); 248 248 249 249 /* collect all cgroups in the cgroup_list */ 250 - if (ftw(mnt, add_cgroup_name, 20) < 0) 250 + if (nftw(mnt, add_cgroup_name, 20, 0) < 0) 251 251 return -1; 252 252 253 253 for (;;) {