stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf stat: Use nftw() instead of ftw()
@ 2021-02-08 18:11 Paul Cercueil
  2021-02-08 19:29 ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Cercueil @ 2021-02-08 18:11 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Jiri Olsa
  Cc: Ingo Molnar, Peter Zijlstra, Mark Rutland, Alexander Shishkin,
	Namhyung Kim, od, linux-kernel, Paul Cercueil, stable

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

Fixes: bb1c15b60b98 ("perf stat: Support regex pattern in --for-each-cgroup")
CC: stable@vger.kernel.org
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---

Notes:
    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.

 tools/perf/util/cgroup.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/cgroup.c b/tools/perf/util/cgroup.c
index 5dff7e489921..f24ab4585553 100644
--- a/tools/perf/util/cgroup.c
+++ b/tools/perf/util/cgroup.c
@@ -161,7 +161,7 @@ void evlist__set_default_cgroup(struct evlist *evlist, struct cgroup *cgroup)
 
 /* helper function for ftw() in match_cgroups and list_cgroups */
 static int add_cgroup_name(const char *fpath, const struct stat *sb __maybe_unused,
-			   int typeflag)
+			   int typeflag, struct FTW *ftwbuf __maybe_unused)
 {
 	struct cgroup_name *cn;
 
@@ -209,12 +209,12 @@ static int list_cgroups(const char *str)
 			if (!s)
 				return -1;
 			/* pretend if it's added by ftw() */
-			ret = add_cgroup_name(s, NULL, FTW_D);
+			ret = add_cgroup_name(s, NULL, FTW_D, NULL);
 			free(s);
 			if (ret)
 				return -1;
 		} else {
-			if (add_cgroup_name("", NULL, FTW_D) < 0)
+			if (add_cgroup_name("", NULL, FTW_D, NULL) < 0)
 				return -1;
 		}
 
@@ -247,7 +247,7 @@ static int match_cgroups(const char *str)
 	prefix_len = strlen(mnt);
 
 	/* collect all cgroups in the cgroup_list */
-	if (ftw(mnt, add_cgroup_name, 20) < 0)
+	if (nftw(mnt, add_cgroup_name, 20, 0) < 0)
 		return -1;
 
 	for (;;) {
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf stat: Use nftw() instead of ftw()
  2021-02-08 18:11 [PATCH] perf stat: Use nftw() instead of ftw() Paul Cercueil
@ 2021-02-08 19:29 ` Arnaldo Carvalho de Melo
  2021-02-10  9:14   ` Namhyung Kim
  0 siblings, 1 reply; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-02-08 19:29 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Jiri Olsa, Ingo Molnar, Peter Zijlstra, Mark Rutland,
	Alexander Shishkin, Namhyung Kim, od, linux-kernel, stable

Em Mon, Feb 08, 2021 at 06:11:57PM +0000, Paul Cercueil escreveu:
> ftw() has been obsolete for about 12 years now.
> 
> Fixes: bb1c15b60b98 ("perf stat: Support regex pattern in --for-each-cgroup")
> CC: stable@vger.kernel.org
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> ---
> 
> Notes:
>     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.

Seems safe from reading the nftw() man page, the only typeflag that this
code is using is FTW_D and that is present in both ftw() and nftw().

Applying,

- Arnaldo
 
>  tools/perf/util/cgroup.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/perf/util/cgroup.c b/tools/perf/util/cgroup.c
> index 5dff7e489921..f24ab4585553 100644
> --- a/tools/perf/util/cgroup.c
> +++ b/tools/perf/util/cgroup.c
> @@ -161,7 +161,7 @@ void evlist__set_default_cgroup(struct evlist *evlist, struct cgroup *cgroup)
>  
>  /* helper function for ftw() in match_cgroups and list_cgroups */
>  static int add_cgroup_name(const char *fpath, const struct stat *sb __maybe_unused,
> -			   int typeflag)
> +			   int typeflag, struct FTW *ftwbuf __maybe_unused)
>  {
>  	struct cgroup_name *cn;
>  
> @@ -209,12 +209,12 @@ static int list_cgroups(const char *str)
>  			if (!s)
>  				return -1;
>  			/* pretend if it's added by ftw() */
> -			ret = add_cgroup_name(s, NULL, FTW_D);
> +			ret = add_cgroup_name(s, NULL, FTW_D, NULL);
>  			free(s);
>  			if (ret)
>  				return -1;
>  		} else {
> -			if (add_cgroup_name("", NULL, FTW_D) < 0)
> +			if (add_cgroup_name("", NULL, FTW_D, NULL) < 0)
>  				return -1;
>  		}
>  
> @@ -247,7 +247,7 @@ static int match_cgroups(const char *str)
>  	prefix_len = strlen(mnt);
>  
>  	/* collect all cgroups in the cgroup_list */
> -	if (ftw(mnt, add_cgroup_name, 20) < 0)
> +	if (nftw(mnt, add_cgroup_name, 20, 0) < 0)
>  		return -1;
>  
>  	for (;;) {
> -- 
> 2.30.0
> 

-- 

- Arnal

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf stat: Use nftw() instead of ftw()
  2021-02-08 19:29 ` Arnaldo Carvalho de Melo
@ 2021-02-10  9:14   ` Namhyung Kim
  0 siblings, 0 replies; 3+ messages in thread
From: Namhyung Kim @ 2021-02-10  9:14 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Paul Cercueil, Jiri Olsa, Ingo Molnar, Peter Zijlstra,
	Mark Rutland, Alexander Shishkin, od, linux-kernel,
	stable # 4 . 5

Hi,

On Tue, Feb 9, 2021 at 4:29 AM Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
>
> Em Mon, Feb 08, 2021 at 06:11:57PM +0000, Paul Cercueil escreveu:
> > ftw() has been obsolete for about 12 years now.
> >
> > Fixes: bb1c15b60b98 ("perf stat: Support regex pattern in --for-each-cgroup")
> > CC: stable@vger.kernel.org
> > Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> > ---
> >
> > Notes:
> >     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.
>
> Seems safe from reading the nftw() man page, the only typeflag that this
> code is using is FTW_D and that is present in both ftw() and nftw().
>
> Applying,

Didn't notice it was obsolete.

Acked-by: Namhyung Kim <namhyung@kernel.org>

Thanks,
Namhyung

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-02-10  9:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-08 18:11 [PATCH] perf stat: Use nftw() instead of ftw() Paul Cercueil
2021-02-08 19:29 ` Arnaldo Carvalho de Melo
2021-02-10  9:14   ` Namhyung Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).