Message ID | 20221219024911.62741-1-yangjihong1@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp2169398wrn; Sun, 18 Dec 2022 19:17:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf6AcJjF62WC2G8o4qBjTra4QNBn9Y6LmwuyqaRdnu5wIWVf/uikhbluCPbCho4JMVFk3zN4 X-Received: by 2002:a05:6a20:43a5:b0:9d:efd3:66be with SMTP id i37-20020a056a2043a500b0009defd366bemr51042889pzl.5.1671419873366; Sun, 18 Dec 2022 19:17:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671419873; cv=none; d=google.com; s=arc-20160816; b=IA2l3diM4Z33Yq6jmZgqZ9MMX08h+HzaCh5rJZKlkN29jG8cNw+0b9tvlX6m8igpAw iKXsIvZkp55ORRM5VEgA0C8v8YWcKOgWU934aq5Mdhs8EiFFnEW5vJj3YsBUd7GWUaIf 9F4McAKSRHJBmEJFWxG/EQLJdrUioZrESgpgsHlvEbpugaMHwOiEWbHynQ3+lobXojq0 9AG65Ft+JGRAF29s/y+lGVbzEl6xBBV47hAIXPrSYdWA0g+bOQ8vsTQ/WqS/7gj75xZV 0AxUTudZPC7m9tdG9GshBSy4H/7JDmOSl0xLn6ZRTuIeR7x4Vu6V9I3cXj0mIXBmZTv6 9NZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=vyydlnSmEnAXs1ohkGKKPx4qX8NO8urdzjaubIHBIDI=; b=ctM5gEfGcsZE6fC3+8kKNKr4jsn9v7GF4xLPLljENyrQWQA7wnB9HBYpe+nMLkA7ES Dw7mcGN3GLvbwimLmIBFNVaErtBM1okiESVoOyYorc3SEpXyQ8x0TcjSDCSVqtZzVOSO X2a1iQg54KtZJ4/Sz7vNW56iLB3D30SOpL3bKeE65jW8l2znlDlg8FUg1cDOd/fv9tD2 0sgT5RJkds7Lp6jCs41p19eqak2AMwBaezd/2OgXmhJs+VE2Fd96Yl6GcXeFgMIoqT95 nZWBuQPFugQws4xiMLCNgXc35DchN8lK6y21fsYjVy+zxBWD93kqTgYr0rmcFB5+NmsK YhjA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j3-20020a632303000000b00476e3bafe6dsi9506184pgj.481.2022.12.18.19.17.29; Sun, 18 Dec 2022 19:17:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231130AbiLSCwE (ORCPT <rfc822;peekingduck44@gmail.com> + 99 others); Sun, 18 Dec 2022 21:52:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229611AbiLSCwC (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 18 Dec 2022 21:52:02 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 554C16474; Sun, 18 Dec 2022 18:52:00 -0800 (PST) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Nb42q6KpWzJqZv; Mon, 19 Dec 2022 10:50:59 +0800 (CST) Received: from ubuntu1804.huawei.com (10.67.174.61) by kwepemm600003.china.huawei.com (7.193.23.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 19 Dec 2022 10:51:57 +0800 From: Yang Jihong <yangjihong1@huawei.com> To: <peterz@infradead.org>, <mingo@redhat.com>, <acme@kernel.org>, <mark.rutland@arm.com>, <alexander.shishkin@linux.intel.com>, <jolsa@kernel.org>, <namhyung@kernel.org>, <irogers@google.com>, <adrian.hunter@intel.com>, <kan.liang@linux.intel.com>, <kim.phillips@amd.com>, <german.gomez@arm.com>, <ravi.bangoria@amd.com>, <linux-perf-users@vger.kernel.org>, <linux-kernel@vger.kernel.org> CC: <yangjihong1@huawei.com> Subject: [PATCH] perf tool: Fix output unexpected messages in quiet mode Date: Mon, 19 Dec 2022 10:49:11 +0800 Message-ID: <20221219024911.62741-1-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.174.61] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemm600003.china.huawei.com (7.193.23.202) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752610765418221723?= X-GMAIL-MSGID: =?utf-8?q?1752610765418221723?= |
Series |
perf tool: Fix output unexpected messages in quiet mode
|
|
Commit Message
Yang Jihong
Dec. 19, 2022, 2:49 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
#
Fixes: ccd26741f5e6 ("perf tool: Provide an option to print perf_event_open args and return value")
Signed-off-by: Yang Jihong <yangjihong1@huawei.com>
---
tools/perf/util/debug.h | 2 +-
tools/perf/util/evsel.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
Comments
On 19/12/22 04:49, Yang Jihong wrote: > When perf uses quiet mode, perf_quiet_option sets debug_peo_args to -1, Seems like redirect_to_stderr has similar issue? > 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 > # > > Fixes: ccd26741f5e6 ("perf tool: Provide an option to print perf_event_open args and return value") > Signed-off-by: Yang Jihong <yangjihong1@huawei.com> Reviewed-by: Adrian Hunter <adrian.hunter@intel.com> > --- > tools/perf/util/debug.h | 2 +- > tools/perf/util/evsel.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h > index f99468a7f681..f6ab84c93ec0 100644 > --- a/tools/perf/util/debug.h > +++ b/tools/perf/util/debug.h > @@ -41,7 +41,7 @@ extern int debug_data_convert; > > /* Special macro to print perf_event_open arguments/return value. */ > #define pr_debug2_peo(fmt, ...) { \ > - if (debug_peo_args) \ > + if (debug_peo_args > 0) \ > pr_debugN(0, pr_fmt(fmt), ##__VA_ARGS__); \ > else \ > pr_debugN(2, pr_fmt(fmt), ##__VA_ARGS__); \ > diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c > index 999dd1700502..45cf144c5d5d 100644 > --- a/tools/perf/util/evsel.c > +++ b/tools/perf/util/evsel.c > @@ -1775,7 +1775,7 @@ static int __open_attr__fprintf(FILE *fp, const char *name, const char *val, > > static void display_attr(struct perf_event_attr *attr) > { > - if (verbose >= 2 || debug_peo_args) { > + if (verbose >= 2 || debug_peo_args > 0) { > fprintf(stderr, "%.60s\n", graph_dotted_line); > fprintf(stderr, "perf_event_attr:\n"); > perf_event_attr__fprintf(stderr, attr, __open_attr__fprintf, NULL);
Hello, On 2022/12/19 14:59, Adrian Hunter wrote: > On 19/12/22 04:49, Yang Jihong wrote: >> When perf uses quiet mode, perf_quiet_option sets debug_peo_args to -1, > > Seems like redirect_to_stderr has similar issue? The redirect_to_stderr is used only in the veprintf function: int veprintf(int level, int var, const char *fmt, va_list args) { int ret = 0; if (var >= level) { if (use_browser >= 1 && redirect_to_stderr <= 0) { ui_helpline__vshow(fmt, args); } else { ret = fprintf_time(debug_file); ret += vfprintf(debug_file, fmt, args); } } return ret; } If use quiet mode, verbose sets to -1. (also assigned in the perf_quiet_option function) Because "var >= level" is false, veprintf function returns directly, which avoids this problem. However, there are cases where: # perf --debug stderr=-1 report -vvv 2>/tmp/debug If stderr is -1, should we redirect pr_debug in this case? Because I'm not sure if this is a problem, if redirect_to_stderr needs to be fixed as well, let me know and I'll submit a patch to fix it. > >> 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 >> # >> >> Fixes: ccd26741f5e6 ("perf tool: Provide an option to print perf_event_open args and return value") >> Signed-off-by: Yang Jihong <yangjihong1@huawei.com> > > Reviewed-by: Adrian Hunter <adrian.hunter@intel.com> > Thanks for reviewed-by. Thanks, Yang
On 19/12/22 11:28, Yang Jihong wrote: > Hello, > > On 2022/12/19 14:59, Adrian Hunter wrote: >> On 19/12/22 04:49, Yang Jihong wrote: >>> When perf uses quiet mode, perf_quiet_option sets debug_peo_args to -1, >> >> Seems like redirect_to_stderr has similar issue? > The redirect_to_stderr is used only in the veprintf function: > > int veprintf(int level, int var, const char *fmt, va_list args) > { > int ret = 0; > > if (var >= level) { > if (use_browser >= 1 && redirect_to_stderr <= 0) { > ui_helpline__vshow(fmt, args); > } else { > ret = fprintf_time(debug_file); > ret += vfprintf(debug_file, fmt, args); > } > } > > return ret; > } > > If use quiet mode, verbose sets to -1. (also assigned in the perf_quiet_option function) > Because "var >= level" is false, veprintf function returns directly, which avoids this problem. > > However, there are cases where: > # perf --debug stderr=-1 report -vvv 2>/tmp/debug > > If stderr is -1, should we redirect pr_debug in this case? tools/perf/Documentation/perf.txt says debug variables are in value range (0, 10), so -1 is invalid anyway. > > Because I'm not sure if this is a problem, > if redirect_to_stderr needs to be fixed as well, > let me know and I'll submit a patch to fix it. perf_quiet_option() sets redirect_to_stderr = -1 with the intention that it turns it off, but it doesn't, although it gets turned of by verbose = -1. Perhaps set redirect_to_stderr = 0 in perf_quiet_option() ? I see we have another problem as well: places that check "if (verbose)" instead of "if (verbose > 0)" > >> >>> 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 >>> # >>> >>> Fixes: ccd26741f5e6 ("perf tool: Provide an option to print perf_event_open args and return value") >>> Signed-off-by: Yang Jihong <yangjihong1@huawei.com> >> >> Reviewed-by: Adrian Hunter <adrian.hunter@intel.com> >> > Thanks for reviewed-by. > > Thanks, > Yang
Hello, On 2022/12/19 18:28, Adrian Hunter wrote: > On 19/12/22 11:28, Yang Jihong wrote: >> Hello, >> >> On 2022/12/19 14:59, Adrian Hunter wrote: >>> On 19/12/22 04:49, Yang Jihong wrote: >>>> When perf uses quiet mode, perf_quiet_option sets debug_peo_args to -1, >>> >>> Seems like redirect_to_stderr has similar issue? >> The redirect_to_stderr is used only in the veprintf function: >> >> int veprintf(int level, int var, const char *fmt, va_list args) >> { >> int ret = 0; >> >> if (var >= level) { >> if (use_browser >= 1 && redirect_to_stderr <= 0) { >> ui_helpline__vshow(fmt, args); >> } else { >> ret = fprintf_time(debug_file); >> ret += vfprintf(debug_file, fmt, args); >> } >> } >> >> return ret; >> } >> >> If use quiet mode, verbose sets to -1. (also assigned in the perf_quiet_option function) >> Because "var >= level" is false, veprintf function returns directly, which avoids this problem. >> >> However, there are cases where: >> # perf --debug stderr=-1 report -vvv 2>/tmp/debug >> >> If stderr is -1, should we redirect pr_debug in this case? > > tools/perf/Documentation/perf.txt says debug variables are in value > range (0, 10), so -1 is invalid anyway. > Okay, I see. >> >> Because I'm not sure if this is a problem, >> if redirect_to_stderr needs to be fixed as well, >> let me know and I'll submit a patch to fix it. > > perf_quiet_option() sets redirect_to_stderr = -1 with the intention > that it turns it off, but it doesn't, although it gets turned of by > verbose = -1. Perhaps set redirect_to_stderr = 0 in perf_quiet_option() ? > I think it's better to fix redirect_to_stderr and debug_peo_args in the same way (because they're similar): Solution A: diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c index 65e6c22f38e4..908b26e579e5 100644 --- a/tools/perf/util/debug.c +++ b/tools/perf/util/debug.c @@ -68,7 +68,7 @@ int veprintf(int level, int var, const char *fmt, va_list args) int ret = 0; if (var >= level) { - if (use_browser >= 1 && !redirect_to_stderr) { + if (use_browser >= 1 && redirect_to_stderr <= 0) { ui_helpline__vshow(fmt, args); } else { ret = fprintf_time(debug_file); diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h index f99468a7f681..f6ab84c93ec0 100644 --- a/tools/perf/util/debug.h +++ b/tools/perf/util/debug.h @@ -41,7 +41,7 @@ extern int debug_data_convert; /* Special macro to print perf_event_open arguments/return value. */ #define pr_debug2_peo(fmt, ...) { \ - if (debug_peo_args) \ + if (debug_peo_args > 0) \ pr_debugN(0, pr_fmt(fmt), ##__VA_ARGS__); \ else \ pr_debugN(2, pr_fmt(fmt), ##__VA_ARGS__); \ diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 999dd1700502..45cf144c5d5d 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -1775,7 +1775,7 @@ static int __open_attr__fprintf(FILE *fp, const char *name, const char *val, static void display_attr(struct perf_event_attr *attr) { - if (verbose >= 2 || debug_peo_args) { + if (verbose >= 2 || debug_peo_args > 0) { fprintf(stderr, "%.60s\n", graph_dotted_line); fprintf(stderr, "perf_event_attr:\n"); perf_event_attr__fprintf(stderr, attr, __open_attr__fprintf, NULL); or Solution B: diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c index 908b26e579e5..e3acc213edd1 100644 --- a/tools/perf/util/debug.c +++ b/tools/perf/util/debug.c @@ -241,6 +241,9 @@ int perf_quiet_option(void) opt++; } + redirect_to_stderr = 0; + debug_peo_args = 0; + > I see we have another problem as well: places that check "if (verbose)" > instead of "if (verbose > 0)" Yes, places that "if (verbose)" also have problems, I'll submit a patch to change them to "if (verbose > 0)" In addition, I found another problem, perf lock/stat/probe does not call the perf_quiet_option function when quiet is true. Thanks, Yang
On 19/12/22 15:14, Yang Jihong wrote: > Hello, > > On 2022/12/19 18:28, Adrian Hunter wrote: >> On 19/12/22 11:28, Yang Jihong wrote: >>> Hello, >>> >>> On 2022/12/19 14:59, Adrian Hunter wrote: >>>> On 19/12/22 04:49, Yang Jihong wrote: >>>>> When perf uses quiet mode, perf_quiet_option sets debug_peo_args to -1, >>>> >>>> Seems like redirect_to_stderr has similar issue? >>> The redirect_to_stderr is used only in the veprintf function: >>> >>> int veprintf(int level, int var, const char *fmt, va_list args) >>> { >>> int ret = 0; >>> >>> if (var >= level) { >>> if (use_browser >= 1 && redirect_to_stderr <= 0) { >>> ui_helpline__vshow(fmt, args); >>> } else { >>> ret = fprintf_time(debug_file); >>> ret += vfprintf(debug_file, fmt, args); >>> } >>> } >>> >>> return ret; >>> } >>> >>> If use quiet mode, verbose sets to -1. (also assigned in the perf_quiet_option function) >>> Because "var >= level" is false, veprintf function returns directly, which avoids this problem. >>> >>> However, there are cases where: >>> # perf --debug stderr=-1 report -vvv 2>/tmp/debug >>> >>> If stderr is -1, should we redirect pr_debug in this case? >> >> tools/perf/Documentation/perf.txt says debug variables are in value >> range (0, 10), so -1 is invalid anyway. >> > Okay, I see. >>> >>> Because I'm not sure if this is a problem, >>> if redirect_to_stderr needs to be fixed as well, >>> let me know and I'll submit a patch to fix it. >> >> perf_quiet_option() sets redirect_to_stderr = -1 with the intention >> that it turns it off, but it doesn't, although it gets turned of by >> verbose = -1. Perhaps set redirect_to_stderr = 0 in perf_quiet_option() ? >> > I think it's better to fix redirect_to_stderr and debug_peo_args in the same way (because they're similar): > > Solution A: > diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c > index 65e6c22f38e4..908b26e579e5 100644 > --- a/tools/perf/util/debug.c > +++ b/tools/perf/util/debug.c > @@ -68,7 +68,7 @@ int veprintf(int level, int var, const char *fmt, va_list args) > int ret = 0; > > if (var >= level) { > - if (use_browser >= 1 && !redirect_to_stderr) { > + if (use_browser >= 1 && redirect_to_stderr <= 0) { > ui_helpline__vshow(fmt, args); > } else { > ret = fprintf_time(debug_file); > diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h > index f99468a7f681..f6ab84c93ec0 100644 > --- a/tools/perf/util/debug.h > +++ b/tools/perf/util/debug.h > @@ -41,7 +41,7 @@ extern int debug_data_convert; > > /* Special macro to print perf_event_open arguments/return value. */ > #define pr_debug2_peo(fmt, ...) { \ > - if (debug_peo_args) \ > + if (debug_peo_args > 0) \ > pr_debugN(0, pr_fmt(fmt), ##__VA_ARGS__); \ > else \ > pr_debugN(2, pr_fmt(fmt), ##__VA_ARGS__); \ > diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c > index 999dd1700502..45cf144c5d5d 100644 > --- a/tools/perf/util/evsel.c > +++ b/tools/perf/util/evsel.c > @@ -1775,7 +1775,7 @@ static int __open_attr__fprintf(FILE *fp, const char *name, const char *val, > > static void display_attr(struct perf_event_attr *attr) > { > - if (verbose >= 2 || debug_peo_args) { > + if (verbose >= 2 || debug_peo_args > 0) { > fprintf(stderr, "%.60s\n", graph_dotted_line); > fprintf(stderr, "perf_event_attr:\n"); > perf_event_attr__fprintf(stderr, attr, __open_attr__fprintf, NULL); > > or > Solution B: > > diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c > index 908b26e579e5..e3acc213edd1 100644 > --- a/tools/perf/util/debug.c > +++ b/tools/perf/util/debug.c > @@ -241,6 +241,9 @@ int perf_quiet_option(void) > opt++; > } > > + redirect_to_stderr = 0; > + debug_peo_args = 0; > + That seems good to me. > >> I see we have another problem as well: places that check "if (verbose)" >> instead of "if (verbose > 0)" > Yes, places that "if (verbose)" also have problems, I'll submit a patch to change them to "if (verbose > 0)" Thank you! > > In addition, I found another problem, perf lock/stat/probe does not call the perf_quiet_option function when quiet is true. > > Thanks, > Yang
diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h index f99468a7f681..f6ab84c93ec0 100644 --- a/tools/perf/util/debug.h +++ b/tools/perf/util/debug.h @@ -41,7 +41,7 @@ extern int debug_data_convert; /* Special macro to print perf_event_open arguments/return value. */ #define pr_debug2_peo(fmt, ...) { \ - if (debug_peo_args) \ + if (debug_peo_args > 0) \ pr_debugN(0, pr_fmt(fmt), ##__VA_ARGS__); \ else \ pr_debugN(2, pr_fmt(fmt), ##__VA_ARGS__); \ diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 999dd1700502..45cf144c5d5d 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -1775,7 +1775,7 @@ static int __open_attr__fprintf(FILE *fp, const char *name, const char *val, static void display_attr(struct perf_event_attr *attr) { - if (verbose >= 2 || debug_peo_args) { + if (verbose >= 2 || debug_peo_args > 0) { fprintf(stderr, "%.60s\n", graph_dotted_line); fprintf(stderr, "perf_event_attr:\n"); perf_event_attr__fprintf(stderr, attr, __open_attr__fprintf, NULL);