[1/3] perf tools: Set debug_peo_args and redirect_to_stderr to correct values in perf_quiet_option

Message ID 20221220035702.188413-2-yangjihong1@huawei.com
State New
Headers
Series Fixes for debug variables |

Commit Message

Yang Jihong Dec. 20, 2022, 3:57 a.m. UTC
  When perf uses quiet mode, perf_quiet_option sets debug_peo_args to -1,
and display_attr incorrectly determines the value of debug_peo_args.
As a result, unexpected information is displayed.

Before:
  # perf record --quiet -- ls > /dev/null
  ------------------------------------------------------------
  perf_event_attr:
    size                             128
    { sample_period, sample_freq }   4000
    sample_type                      IP|TID|TIME|PERIOD
    read_format                      ID|LOST
    disabled                         1
    inherit                          1
    mmap                             1
    comm                             1
    freq                             1
    enable_on_exec                   1
    task                             1
    precise_ip                       3
    sample_id_all                    1
    exclude_guest                    1
    mmap2                            1
    comm_exec                        1
    ksymbol                          1
    bpf_event                        1
  ------------------------------------------------------------
  ...

After:
  # perf record --quiet -- ls > /dev/null
  #

redirect_to_stderr is a similar problem.

Fixes: f78eaef0e049 ("perf tools: Allow to force redirect pr_debug to stderr.")
Fixes: ccd26741f5e6 ("perf tool: Provide an option to print perf_event_open args and return value")
Suggested-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Yang Jihong <yangjihong1@huawei.com>
---
 tools/perf/util/debug.c | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

Adrian Hunter Dec. 20, 2022, 7:35 a.m. UTC | #1
On 20/12/22 05:57, Yang Jihong wrote:
> When perf uses quiet mode, perf_quiet_option sets debug_peo_args to -1,
> and display_attr incorrectly determines the value of debug_peo_args.
> As a result, unexpected information is displayed.
> 
> Before:
>   # perf record --quiet -- ls > /dev/null
>   ------------------------------------------------------------
>   perf_event_attr:
>     size                             128
>     { sample_period, sample_freq }   4000
>     sample_type                      IP|TID|TIME|PERIOD
>     read_format                      ID|LOST
>     disabled                         1
>     inherit                          1
>     mmap                             1
>     comm                             1
>     freq                             1
>     enable_on_exec                   1
>     task                             1
>     precise_ip                       3
>     sample_id_all                    1
>     exclude_guest                    1
>     mmap2                            1
>     comm_exec                        1
>     ksymbol                          1
>     bpf_event                        1
>   ------------------------------------------------------------
>   ...
> 
> After:
>   # perf record --quiet -- ls > /dev/null
>   #
> 
> redirect_to_stderr is a similar problem.
> 
> Fixes: f78eaef0e049 ("perf tools: Allow to force redirect pr_debug to stderr.")
> Fixes: ccd26741f5e6 ("perf tool: Provide an option to print perf_event_open args and return value")
> Suggested-by: Adrian Hunter <adrian.hunter@intel.com>
> Signed-off-by: Yang Jihong <yangjihong1@huawei.com>

Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
>  tools/perf/util/debug.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c
> index 65e6c22f38e4..190e818a0717 100644
> --- a/tools/perf/util/debug.c
> +++ b/tools/perf/util/debug.c
> @@ -241,6 +241,10 @@ int perf_quiet_option(void)
>  		opt++;
>  	}
>  
> +	/* For debug variables that are used as bool types, set to 0. */
> +	redirect_to_stderr = 0;
> +	debug_peo_args = 0;
> +
>  	return 0;
>  }
>
  
Arnaldo Carvalho de Melo Dec. 20, 2022, 6:17 p.m. UTC | #2
Em Tue, Dec 20, 2022 at 09:35:36AM +0200, Adrian Hunter escreveu:
> On 20/12/22 05:57, Yang Jihong wrote:
> > When perf uses quiet mode, perf_quiet_option sets debug_peo_args to -1,
> > and display_attr incorrectly determines the value of debug_peo_args.
> > As a result, unexpected information is displayed.
> > 
> > Before:
> >   # perf record --quiet -- ls > /dev/null
> >   ------------------------------------------------------------
> >   perf_event_attr:
> >     size                             128
> >     { sample_period, sample_freq }   4000
> >     sample_type                      IP|TID|TIME|PERIOD
> >     read_format                      ID|LOST
> >     disabled                         1
> >     inherit                          1
> >     mmap                             1
> >     comm                             1
> >     freq                             1
> >     enable_on_exec                   1
> >     task                             1
> >     precise_ip                       3
> >     sample_id_all                    1
> >     exclude_guest                    1
> >     mmap2                            1
> >     comm_exec                        1
> >     ksymbol                          1
> >     bpf_event                        1
> >   ------------------------------------------------------------
> >   ...
> > 
> > After:
> >   # perf record --quiet -- ls > /dev/null
> >   #
> > 
> > redirect_to_stderr is a similar problem.
> > 
> > Fixes: f78eaef0e049 ("perf tools: Allow to force redirect pr_debug to stderr.")
> > Fixes: ccd26741f5e6 ("perf tool: Provide an option to print perf_event_open args and return value")
> > Suggested-by: Adrian Hunter <adrian.hunter@intel.com>
> > Signed-off-by: Yang Jihong <yangjihong1@huawei.com>
> 
> Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>

Thanks, applied all patches in this series.

- Arnaldo
  

Patch

diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c
index 65e6c22f38e4..190e818a0717 100644
--- a/tools/perf/util/debug.c
+++ b/tools/perf/util/debug.c
@@ -241,6 +241,10 @@  int perf_quiet_option(void)
 		opt++;
 	}
 
+	/* For debug variables that are used as bool types, set to 0. */
+	redirect_to_stderr = 0;
+	debug_peo_args = 0;
+
 	return 0;
 }