All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf stat: Do not allow --for-each-cgroup without cpu
@ 2021-08-30 17:02 Namhyung Kim
  2021-08-30 18:51 ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 2+ messages in thread
From: Namhyung Kim @ 2021-08-30 17:02 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Jiri Olsa
  Cc: Ingo Molnar, Peter Zijlstra, LKML, Andi Kleen, Ian Rogers

The cgroup mode should work with cpu events.  Warn if --for-each-cgroup
option is used with a task target like existing -G option.

  # perf stat --for-each-cgroup . sleep 1
  both cgroup and no-aggregation modes only available in system-wide mode

   Usage: perf stat [<options>] [<command>]

      -G, --cgroup <name>   monitor event in cgroup name only
      -A, --no-aggr         disable CPU count aggregation
      -a, --all-cpus        system-wide collection from all CPUs
          --for-each-cgroup <name>
                            expand events for each cgroup

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/builtin-stat.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 84de61795e67..1a64aebc0d2f 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -2386,7 +2386,8 @@ int cmd_stat(int argc, const char **argv)
 	 * --per-thread is aggregated per thread, we dont mix it with cpu mode
 	 */
 	if (((stat_config.aggr_mode != AGGR_GLOBAL &&
-	      stat_config.aggr_mode != AGGR_THREAD) || nr_cgroups) &&
+	      stat_config.aggr_mode != AGGR_THREAD) ||
+	     (nr_cgroups || stat_config.cgroup_list)) &&
 	    !target__has_cpu(&target)) {
 		fprintf(stderr, "both cgroup and no-aggregation "
 			"modes only available in system-wide mode\n");
@@ -2394,6 +2395,7 @@ int cmd_stat(int argc, const char **argv)
 		parse_options_usage(stat_usage, stat_options, "G", 1);
 		parse_options_usage(NULL, stat_options, "A", 1);
 		parse_options_usage(NULL, stat_options, "a", 1);
+		parse_options_usage(NULL, stat_options, "for-each-cgroup", 0);
 		goto out;
 	}
 
-- 
2.33.0.259.gc128427fd7-goog


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

* Re: [PATCH] perf stat: Do not allow --for-each-cgroup without cpu
  2021-08-30 17:02 [PATCH] perf stat: Do not allow --for-each-cgroup without cpu Namhyung Kim
@ 2021-08-30 18:51 ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 2+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-08-30 18:51 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Jiri Olsa, Ingo Molnar, Peter Zijlstra, LKML, Andi Kleen, Ian Rogers

Em Mon, Aug 30, 2021 at 10:02:00AM -0700, Namhyung Kim escreveu:
> The cgroup mode should work with cpu events.  Warn if --for-each-cgroup
> option is used with a task target like existing -G option.
> 
>   # perf stat --for-each-cgroup . sleep 1
>   both cgroup and no-aggregation modes only available in system-wide mode
> 
>    Usage: perf stat [<options>] [<command>]
> 
>       -G, --cgroup <name>   monitor event in cgroup name only
>       -A, --no-aggr         disable CPU count aggregation
>       -a, --all-cpus        system-wide collection from all CPUs
>           --for-each-cgroup <name>
>                             expand events for each cgroup

Thanks, applied.

- Arnaldo

 
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  tools/perf/builtin-stat.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
> index 84de61795e67..1a64aebc0d2f 100644
> --- a/tools/perf/builtin-stat.c
> +++ b/tools/perf/builtin-stat.c
> @@ -2386,7 +2386,8 @@ int cmd_stat(int argc, const char **argv)
>  	 * --per-thread is aggregated per thread, we dont mix it with cpu mode
>  	 */
>  	if (((stat_config.aggr_mode != AGGR_GLOBAL &&
> -	      stat_config.aggr_mode != AGGR_THREAD) || nr_cgroups) &&
> +	      stat_config.aggr_mode != AGGR_THREAD) ||
> +	     (nr_cgroups || stat_config.cgroup_list)) &&
>  	    !target__has_cpu(&target)) {
>  		fprintf(stderr, "both cgroup and no-aggregation "
>  			"modes only available in system-wide mode\n");
> @@ -2394,6 +2395,7 @@ int cmd_stat(int argc, const char **argv)
>  		parse_options_usage(stat_usage, stat_options, "G", 1);
>  		parse_options_usage(NULL, stat_options, "A", 1);
>  		parse_options_usage(NULL, stat_options, "a", 1);
> +		parse_options_usage(NULL, stat_options, "for-each-cgroup", 0);
>  		goto out;
>  	}
>  
> -- 
> 2.33.0.259.gc128427fd7-goog

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

end of thread, other threads:[~2021-08-30 18:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-30 17:02 [PATCH] perf stat: Do not allow --for-each-cgroup without cpu Namhyung Kim
2021-08-30 18:51 ` Arnaldo Carvalho de Melo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.