From patchwork Tue Dec 20 03:57:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Jihong X-Patchwork-Id: 34898 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp2760404wrn; Mon, 19 Dec 2022 20:02:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf7wPJ7FytnJIeRGCwOjM5mZBzJWSx9mpYTnjgcJafRfvmadZswhGVUAlQX+KoXPabGZutdB X-Received: by 2002:a17:906:a886:b0:7c1:8f53:83a0 with SMTP id ha6-20020a170906a88600b007c18f5383a0mr21737129ejb.13.1671508960948; Mon, 19 Dec 2022 20:02:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671508960; cv=none; d=google.com; s=arc-20160816; b=V+kB+nFDb/IfbRRzjggObMyVFEpyp5lO5/XplWzyWL9wvtYFelwj5bnoMuNDUs2Whk Ja5LK2ZPLK7U/R8Xt/BJ8Ip8bdSflQvrwQubu3Stqd6/yqkOIJFOm02Z4TvPdh/aYaRD WZFuCZEfHMwUKtsGqclAop1huD0hB0SKoC/JXVaCZ+PGPZrBvDQJrgm1Jx4+p50JKltc lH0DE8oMjeTL76s/T7eGd4hFRSQ3Nm85oaojsSe9qTAbJPo96PblcKOagPVg/FS5IWVc hR7tZ8QOPW31gZy1Nsp57LdGZM+sE1ZmeUmobN0RGWtZY20LCmhcNNg6X/VTlc2ivj7w 4rug== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=snOSs9Kb7QYxYt/LqO4n3OLaMMhIujp3Qjwb8oLgHrE=; b=sT8xTgbcP8Fq54pqnxAgwaxLAjeHoC25lWdEXWfPwd6g/73Va4RcKfxa5t53SVEOT6 t4qtdyMmhEuf+N+3Ws5jW3rtrv5V/LL9tySZxh9Fr/xAiFJydg69VNo39xG66XSkhHFK 00XVKUzEvN4ReGQVKm1ua6hwwwZO4bc97+K0L8HjKmgdewmuIzub+OgwtsNHUYZyzNIs w6mpWmKNiJ6Swk89jQAyzrnClOtok7m6cEtrcou9X1FS7WghTeGEKPwJNTS51Scxxm6F DnIEFdY7OZHsSMV0KyGMBmutoHufF8z/UYjvbmbX+ALVWpxH38xELUwmHUrk9AXgP8Ed jioQ== 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 hx9-20020a170906846900b00711da52c6e4si8174673ejc.309.2022.12.19.20.02.17; Mon, 19 Dec 2022 20:02:40 -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 S233028AbiLTD74 (ORCPT + 99 others); Mon, 19 Dec 2022 22:59:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229571AbiLTD7w (ORCPT ); Mon, 19 Dec 2022 22:59:52 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFABF632B; Mon, 19 Dec 2022 19:59:50 -0800 (PST) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NbjVd67sbzJqV7; Tue, 20 Dec 2022 11:58:49 +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; Tue, 20 Dec 2022 11:59:48 +0800 From: Yang Jihong To: , , , , , , , , , , , , , , , , CC: Subject: [PATCH 1/3] perf tools: Set debug_peo_args and redirect_to_stderr to correct values in perf_quiet_option Date: Tue, 20 Dec 2022 11:57:00 +0800 Message-ID: <20221220035702.188413-2-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT In-Reply-To: <20221220035702.188413-1-yangjihong1@huawei.com> References: <20221220035702.188413-1-yangjihong1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.174.61] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752704180098665552?= X-GMAIL-MSGID: =?utf-8?q?1752704180098665552?= 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 Signed-off-by: Yang Jihong Reviewed-by: Adrian Hunter --- 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; } From patchwork Tue Dec 20 03:57:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Jihong X-Patchwork-Id: 34900 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp2770388wrn; Mon, 19 Dec 2022 20:38:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf60Q74a7ks8aopNqKymyCUF9jWByM8+kUiAwUTDAHJ35v3dzB1wWRMvUM51qvwb0Bg3zt1+ X-Received: by 2002:a17:906:60c9:b0:7c1:b65:14c1 with SMTP id f9-20020a17090660c900b007c10b6514c1mr37985814ejk.10.1671511109065; Mon, 19 Dec 2022 20:38:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671511109; cv=none; d=google.com; s=arc-20160816; b=JbLoFJdXZvi9+xz7zWzjDrowZbqfCM6w29iFxiTcn7IJpjlxC4ERS35e/yxc9+UaDa WKxQImAMHRhc2ZiLMg5NRszyYgb2sz9YO6l5rZ6QwJ5sTSPi0OM63r2t4wXMgR+0Sdzg mgmVzf7teTQdu4T7zcSNmEQ6eJyOUD2+1St7ok6CXASPyhhTMdsofP4SRfn8fYOCSdBm ARjbMN9vI6pUQwbyZgziEIOGkm+E7IgtBwAtWV7QBU7zkmzFyZZr3WHljSy9euCVIXpD lspO111AU3gH+xoAmgWf8jcv6OhQBXIYHHAQhXijbY3xSDdaCbZkWP1nPhGdanM057df CkdA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=dIHAW5h6swPbLhoGkv2AOUar+EwfMAsTBSd/WSEyVUE=; b=mdKMQHlXbXrayqFRzdAXYhCGDmLnWfyMx4sr5xfa+eujBXTuPtO7MDg0IIyqBAd3ik XfmHD43No14NY1aQctidrf+q8RJzOAnbfbsYqY4Z7WMsdWHYBQ3SEPz6NxtSRzWQzG0f TMKbhGXgiZnddWm21jhYBoC8KpJaaAHdL0NXLlVc2mEevemf+1dSoLWH8sqxDSoP/876 R1ZpXZz12hqEokxWZRYsc3So2LEf8s40ygfspFB4wMklTum9kgHu53rNNllm79g4dIi+ ZlNtDX9wZ5of/5hhOIhzeo7EPzCOtSG6IctxJ/RpMxWglY++vM+OO7LhWdBfIwpZ9x3p brNg== 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 qw16-20020a170906fcb000b007af0ca23299si681996ejb.841.2022.12.19.20.38.05; Mon, 19 Dec 2022 20:38:29 -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 S233058AbiLTD76 (ORCPT + 99 others); Mon, 19 Dec 2022 22:59:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232938AbiLTD7x (ORCPT ); Mon, 19 Dec 2022 22:59:53 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB04911A08; Mon, 19 Dec 2022 19:59:51 -0800 (PST) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4NbjRT3jw0zHqXB; Tue, 20 Dec 2022 11:56:05 +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; Tue, 20 Dec 2022 11:59:49 +0800 From: Yang Jihong To: , , , , , , , , , , , , , , , , CC: Subject: [PATCH 2/3] perf tools: Fix usage of the verbose variable Date: Tue, 20 Dec 2022 11:57:01 +0800 Message-ID: <20221220035702.188413-3-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT In-Reply-To: <20221220035702.188413-1-yangjihong1@huawei.com> References: <20221220035702.188413-1-yangjihong1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.174.61] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752706432265266266?= X-GMAIL-MSGID: =?utf-8?q?1752706432265266266?= The data type of the verbose variable is integer and can be negative, replace improperly used cases in a unified manner: 1. if (verbose) => if (verbose > 0) 2. if (!verbose) => if (verbose <= 0) 3. if (XX && verbose) => if (XX && verbose > 0) 4. if (XX && !verbose) => if (XX && verbose <= 0) Signed-off-by: Yang Jihong Reviewed-by: Adrian Hunter --- tools/perf/builtin-lock.c | 6 +++--- tools/perf/builtin-record.c | 4 ++-- tools/perf/builtin-script.c | 2 +- tools/perf/builtin-stat.c | 4 ++-- tools/perf/dlfilters/dlfilter-test-api-v0.c | 2 +- tools/perf/tests/builtin-test.c | 2 +- tools/perf/tests/dlfilter-test.c | 2 +- tools/perf/util/bpf_lock_contention.c | 2 +- tools/perf/util/dlfilter.c | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index 25c0a5e5051f..6276dfbc94a1 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -1029,7 +1029,7 @@ static int report_lock_contention_begin_event(struct evsel *evsel, if (!ls) return -ENOMEM; - if (aggr_mode == LOCK_AGGR_CALLER && verbose) { + if (aggr_mode == LOCK_AGGR_CALLER && verbose > 0) { ls->callstack = get_callstack(sample, max_stack_depth); if (ls->callstack == NULL) return -ENOMEM; @@ -1214,7 +1214,7 @@ static void print_bad_events(int bad, int total) for (i = 0; i < BROKEN_MAX; i++) broken += bad_hist[i]; - if (quiet || (broken == 0 && !verbose)) + if (quiet || (broken == 0 && verbose <= 0)) return; pr_info("\n=== output for debug===\n\n"); @@ -1529,7 +1529,7 @@ static void print_contention_result(struct lock_contention *con) break; } - if (aggr_mode == LOCK_AGGR_CALLER && verbose) { + if (aggr_mode == LOCK_AGGR_CALLER && verbose > 0) { struct map *kmap; struct symbol *sym; char buf[128]; diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 8ecffa696ce3..29dcd454b8e2 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -3629,7 +3629,7 @@ static int record__init_thread_cpu_masks(struct record *rec, struct perf_cpu_map for (t = 0; t < rec->nr_threads; t++) { __set_bit(perf_cpu_map__cpu(cpus, t).cpu, rec->thread_masks[t].maps.bits); __set_bit(perf_cpu_map__cpu(cpus, t).cpu, rec->thread_masks[t].affinity.bits); - if (verbose) { + if (verbose > 0) { pr_debug("thread_masks[%d]: ", t); mmap_cpu_mask__scnprintf(&rec->thread_masks[t].maps, "maps"); pr_debug("thread_masks[%d]: ", t); @@ -3726,7 +3726,7 @@ static int record__init_thread_masks_spec(struct record *rec, struct perf_cpu_ma } rec->thread_masks = thread_masks; rec->thread_masks[t] = thread_mask; - if (verbose) { + if (verbose > 0) { pr_debug("thread_masks[%d]: ", t); mmap_cpu_mask__scnprintf(&rec->thread_masks[t].maps, "maps"); pr_debug("thread_masks[%d]: ", t); diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 88888fb885c8..69394ac0a20d 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -2233,7 +2233,7 @@ static void process_event(struct perf_script *script, if (PRINT_FIELD(METRIC)) perf_sample__fprint_metric(script, thread, evsel, sample, fp); - if (verbose) + if (verbose > 0) fflush(fp); } diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index bf640abc9c41..9f3e4b257516 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -266,7 +266,7 @@ static void evlist__check_cpu_maps(struct evlist *evlist) evsel__group_desc(leader, buf, sizeof(buf)); pr_warning(" %s\n", buf); - if (verbose) { + if (verbose > 0) { cpu_map__snprint(leader->core.cpus, buf, sizeof(buf)); pr_warning(" %s: %s\n", leader->name, buf); cpu_map__snprint(evsel->core.cpus, buf, sizeof(buf)); @@ -2493,7 +2493,7 @@ int cmd_stat(int argc, const char **argv) if (iostat_mode == IOSTAT_LIST) { iostat_list(evsel_list, &stat_config); goto out; - } else if (verbose) + } else if (verbose > 0) iostat_list(evsel_list, &stat_config); if (iostat_mode == IOSTAT_RUN && !target__has_cpu(&target)) target.system_wide = true; diff --git a/tools/perf/dlfilters/dlfilter-test-api-v0.c b/tools/perf/dlfilters/dlfilter-test-api-v0.c index b17eb52a0694..b1f51efd67d6 100644 --- a/tools/perf/dlfilters/dlfilter-test-api-v0.c +++ b/tools/perf/dlfilters/dlfilter-test-api-v0.c @@ -119,7 +119,7 @@ struct perf_dlfilter_fns perf_dlfilter_fns; static int verbose; #define pr_debug(fmt, ...) do { \ - if (verbose) \ + if (verbose > 0) \ fprintf(stderr, fmt, ##__VA_ARGS__); \ } while (0) diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index f6c16ad8ed50..cfa61493c750 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -305,7 +305,7 @@ static int shell_test__run(struct test_suite *test, int subdir __maybe_unused) path__join(script, sizeof(script) - 3, st->dir, st->file); - if (verbose) + if (verbose > 0) strncat(script, " -v", sizeof(script) - strlen(script) - 1); err = system(script); diff --git a/tools/perf/tests/dlfilter-test.c b/tools/perf/tests/dlfilter-test.c index 99aa72e425e4..086fd2179e41 100644 --- a/tools/perf/tests/dlfilter-test.c +++ b/tools/perf/tests/dlfilter-test.c @@ -88,7 +88,7 @@ static __printf(1, 2) int system_cmd(const char *fmt, ...) if (ret <= 0 || ret >= MAXCMD) return -1; - if (!verbose) + if (verbose <= 0) strcat(cmd, REDIRECT_TO_DEV_NULL); pr_debug("Command: %s\n", cmd); diff --git a/tools/perf/util/bpf_lock_contention.c b/tools/perf/util/bpf_lock_contention.c index 8e1b791dc58f..df8dbb5191b4 100644 --- a/tools/perf/util/bpf_lock_contention.c +++ b/tools/perf/util/bpf_lock_contention.c @@ -215,7 +215,7 @@ int lock_contention_read(struct lock_contention *con) break; } - if (verbose) { + if (verbose > 0) { st->callstack = memdup(stack_trace, stack_size); if (st->callstack == NULL) break; diff --git a/tools/perf/util/dlfilter.c b/tools/perf/util/dlfilter.c index 54e4d4495e00..37beb7530288 100644 --- a/tools/perf/util/dlfilter.c +++ b/tools/perf/util/dlfilter.c @@ -579,7 +579,7 @@ static void list_filters(const char *dirname) if (!get_filter_desc(dirname, entry->d_name, &desc, &long_desc)) continue; printf(" %-36s %s\n", entry->d_name, desc ? desc : ""); - if (verbose) { + if (verbose > 0) { char *p = long_desc; char *line; From patchwork Tue Dec 20 03:57:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Jihong X-Patchwork-Id: 34899 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp2765791wrn; Mon, 19 Dec 2022 20:22:15 -0800 (PST) X-Google-Smtp-Source: AMrXdXv3rMpnFBl8k36FnfDGbTzgdsVtUR18QQJmkQYZNGJL0ASok8Fzb8KZYYVYFbMHcfu72YhI X-Received: by 2002:a17:906:468d:b0:812:d53e:11f6 with SMTP id a13-20020a170906468d00b00812d53e11f6mr629757ejr.70.1671510134935; Mon, 19 Dec 2022 20:22:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671510134; cv=none; d=google.com; s=arc-20160816; b=cM0p8kjRSqUHHaHaPLKjiCQ6k/9eu51b8Zc7aSf78BFikmkCOvBcejLf15UTcuAXhC LsnX68FWnEsrWHbHUatF48mq9pqYjxwnC3wzuG2NkvPzzBPt/tjCtpTV5mtC3DbnCx5l +Anm1CxWFrOy6/XwHkdXzNxirGqugkgNn8ONT24OQlXnZN/OgkihXWa5QvLW/3JIR//w X8EyNJZNo18i0PM6l4+6zhdfM4B6FPfLKQeZ4DRAzrVmLILVo2Iui6gbeaECZXN50nvN w7p5j13x2N152LRyKWPgIVy3P/1yuOdpBKkVyBxKPJCJrGXhUvg/cZYQnbRcTo1fYwoh eaXQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=72tEFgv/+w4y8SxpSnAeKXvCHK/PzXkRPXP7tnCOgdg=; b=J2fErslSLOqcp5LllOKyeQHSmWbfF1+9Wp3yQHUKpNqlDfjCH1+WWWiPUEreLL82Vc hK2ll3JcC8m8DnP9Ue0P6U+fwPhmIQbrG3lwt8SAj8/xdbptU209alA3WFqez8lawC5x tNJyYcfZ6PI0Ov4PY8nFlU02OWxFAyYjEDVoUmOEen7TRPPtx370ll7fSkSUXy2kQ/QM A5FRgcWaPJWVA3OXieMEBvwXgeIJp5/081P93XmjqbSU/dgb4Jgx49QaDBSB2dfeVe41 zJTLq2nK7WOsKtJlzFMZeGPGzgyo6V3tYdWPRzBcFKL9lnj+LwF1uqWqeO8L4mEnikZd Tycw== 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 hc44-20020a17090716ac00b007bd6264c2dbsi11204100ejc.28.2022.12.19.20.21.50; Mon, 19 Dec 2022 20:22:14 -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 S233101AbiLTEAB (ORCPT + 99 others); Mon, 19 Dec 2022 23:00:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232989AbiLTD7x (ORCPT ); Mon, 19 Dec 2022 22:59:53 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E03D13E04; Mon, 19 Dec 2022 19:59:52 -0800 (PST) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NbjQk62wKzqT7Z; Tue, 20 Dec 2022 11:55:26 +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; Tue, 20 Dec 2022 11:59:49 +0800 From: Yang Jihong To: , , , , , , , , , , , , , , , , CC: Subject: [PATCH 3/3] perf probe: Check -v and -q options in the right place Date: Tue, 20 Dec 2022 11:57:02 +0800 Message-ID: <20221220035702.188413-4-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT In-Reply-To: <20221220035702.188413-1-yangjihong1@huawei.com> References: <20221220035702.188413-1-yangjihong1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.174.61] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752705411346877443?= X-GMAIL-MSGID: =?utf-8?q?1752705411346877443?= Check the -q and -v options first to return earlier on error. Before: # perf probe -q -v test probe-definition(0): test symbol:test file:(null) line:0 offset:0 return:0 lazy:(null) 0 arguments Error: -v and -q are exclusive. After: # perf probe -q -v test Error: -v and -q are exclusive. Fixes: 5e17b28f1e24 ("perf probe: Add --quiet option to suppress output result message") Signed-off-by: Yang Jihong Reviewed-by: Adrian Hunter --- tools/perf/builtin-probe.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c index 2ae50fc9e597..ed73d0b89ca2 100644 --- a/tools/perf/builtin-probe.c +++ b/tools/perf/builtin-probe.c @@ -612,6 +612,15 @@ __cmd_probe(int argc, const char **argv) argc = parse_options(argc, argv, options, probe_usage, PARSE_OPT_STOP_AT_NON_OPTION); + + if (quiet) { + if (verbose != 0) { + pr_err(" Error: -v and -q are exclusive.\n"); + return -EINVAL; + } + verbose = -1; + } + if (argc > 0) { if (strcmp(argv[0], "-") == 0) { usage_with_options_msg(probe_usage, options, @@ -633,14 +642,6 @@ __cmd_probe(int argc, const char **argv) if (ret) return ret; - if (quiet) { - if (verbose != 0) { - pr_err(" Error: -v and -q are exclusive.\n"); - return -EINVAL; - } - verbose = -1; - } - if (probe_conf.max_probes == 0) probe_conf.max_probes = MAX_PROBES;