Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4031337rdh; Tue, 28 Nov 2023 09:56:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IFNgsw07LdtWPX5g6VtGsV+hTPF4q7i8D7USk748C0sjtFtaN+Db9faKdoSPVQmKubX3xzM X-Received: by 2002:a05:6a00:3991:b0:6cb:6407:defb with SMTP id fi17-20020a056a00399100b006cb6407defbmr16875197pfb.26.1701194190602; Tue, 28 Nov 2023 09:56:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701194190; cv=none; d=google.com; s=arc-20160816; b=WHVLUQKUcPgkuRUsfw6qUiqsnF2sSnUFc4B/Ax4BKto2aqRfMLDBxevoHRgt3U7O+E cfQFHrmIMji3DEgrPqYyW2HEsjc02GgvYnAB8htogHYO/doSUJPVT1X5PuZ6n8WzcIUJ SS7TWWm8xTjGFKpnn3pTl6Ei7fPQttYrX8NVdikn/BYMHL61P88G6uxHYe9D22JBvGjB obekoqL/UT6ObdTZqLgr6ljLvWCgQg/mn710wJRLFL/BKYHIrrdo0gbZD0S866sTI/0J ZppKB8FTdcaMIJfzlTxQoOBhr+6BxgPJ7zbFZjJLlthf2NlYh1NuVrFjSp+xnlSjh4Dp 5qzQ== 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:sender :dkim-signature; bh=O5g8LvRyYgkffKCHyddw+qlPQpUJhijbXPKeT9Y2vQY=; fh=/TViaxNXj9Ubl1KVZseJCqJutBKG0dvzf3DPkf/1G64=; b=MjZ8Waf5ehZtdB4ns2CGaPaY3cyHkk+Vn5KLsRKLVVh08J5eLHjUExkQ/p1vblw8Gg uNWKYRYDtMzQ9AZSDQOV7CtadboGJii0TOFjOGezzdDJoyBQb6LCFj5GAQkDhM7YWep/ Jsbt6w9U48t3Gz1BxBgohIUAJu3g8vYjOWqOoAzXIQxkfF38rtM1VCW1tRYvT70SJUVK ibmJ3gJinT+zOnnFcs6EkG5PgisPek+RERnti0H6aw2QJ50hoe3tE1O3M7V3EszzKKRW +oDxbfaI8zt6qiumb2z7kWM8W/UFrtvsllAgqao1SlDF3+ZR+CKF7SUO2VEH0Ef+dIQC z1tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fv04DDEv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id e4-20020a654784000000b005c1b5aa3f16si12410858pgs.777.2023.11.28.09.56.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 09:56:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fv04DDEv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 41E00807C56B; Tue, 28 Nov 2023 09:56:19 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346899AbjK1RzU (ORCPT + 99 others); Tue, 28 Nov 2023 12:55:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346706AbjK1Ryy (ORCPT ); Tue, 28 Nov 2023 12:54:54 -0500 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 133E310C3; Tue, 28 Nov 2023 09:54:56 -0800 (PST) Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-6cd8ce7bf7fso2437236b3a.0; Tue, 28 Nov 2023 09:54:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701194095; x=1701798895; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=O5g8LvRyYgkffKCHyddw+qlPQpUJhijbXPKeT9Y2vQY=; b=fv04DDEv/Pd6sUrV78Q8XmvVi1h5+mUD2B59ixCkuFV1I4vF0esED0P4N894yVXlj5 O/LXU1VnvAx9+gBfBNjqr7MjSdxmJxDKMKxoy0muTXj32hjG/8mHAUV/obYDfm2ITebE oa5q1uhyGDFDui8Hs+ybZ4kTuWHls5PZY6NIze4rODefvJkTJWlQfda4hLvkwL+bmIDY HV/lL/Nt/X7RbZBKXSFMkzGSEBEAyP0EP68bss9mKPSpqNnLBEc31qcC9J1FTBP4H2t4 y0+/Gk/xfoGcE9uwwI+ptIbIvUUGq1xOHW5fB/6JYMwzdKzsWQ4DjoZDSLN0WIpf+xAr pLNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701194095; x=1701798895; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=O5g8LvRyYgkffKCHyddw+qlPQpUJhijbXPKeT9Y2vQY=; b=JhVUvzKf8SDCV3JpHdhMrnhfESlmUQYA+jjYA8qKlFT4f0hdm0fsfONNHwoXhJF9dp Ec4KQkoLHbwnjy/cORc0KPxxym6RpZ1tU20PqQ3yinl8CzPYPEoJgqVDRW+JdoS90pWm NcADTxoqW9sTjWOZaiHTP/uoriNVvxA8dN8xC5MuKrM6nCTRzHKbPrA6e4A1QNVtHfry pPx6EI38gwkK1MyH94KPv8xfvvxT2acu/r/+u46ojqvZnBttH8abKNu9wB/+g5Lmu91F 6Cz6Ug4QXYJLKHADRU3E2I5JfIOs+X9LNUC9DCy7uV+CTc4rSJ2w0EMLwNZ9M0a8qOj3 uOCA== X-Gm-Message-State: AOJu0Yzp4S6VbYwoabTPKB0WQ6ULSG/PDrhX0b+7zxCmo0e5G3KPbB6T p3/HErhqnLIyyDAxXiHp8VLURIeauN8pZg== X-Received: by 2002:a05:6a00:14c6:b0:6c4:dc5b:5b2b with SMTP id w6-20020a056a0014c600b006c4dc5b5b2bmr17534517pfu.20.1701194095420; Tue, 28 Nov 2023 09:54:55 -0800 (PST) Received: from bangji.corp.google.com ([2620:15c:2c0:5:146f:6347:3bb4:8cf4]) by smtp.gmail.com with ESMTPSA id y2-20020aa78042000000b006cbbc07a1c0sm9224721pfm.156.2023.11.28.09.54.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 09:54:54 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ian Rogers , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org Subject: [PATCH 6/8] perf annotate: Ensure init/exit for global options Date: Tue, 28 Nov 2023 09:54:39 -0800 Message-ID: <20231128175441.721579-7-namhyung@kernel.org> X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog In-Reply-To: <20231128175441.721579-1-namhyung@kernel.org> References: <20231128175441.721579-1-namhyung@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 28 Nov 2023 09:56:19 -0800 (PST) Now it only cares about the global options so it can just handle it without the argument. Signed-off-by: Namhyung Kim --- tools/perf/builtin-annotate.c | 8 ++++---- tools/perf/builtin-report.c | 8 ++++---- tools/perf/builtin-top.c | 8 ++++---- tools/perf/util/annotate.c | 19 +++++++++++-------- tools/perf/util/annotate.h | 8 ++++---- 5 files changed, 27 insertions(+), 24 deletions(-) diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 87af95634879..9b3dd456a1ee 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -616,13 +616,13 @@ int cmd_annotate(int argc, const char **argv) set_option_flag(options, 0, "show-total-period", PARSE_OPT_EXCLUSIVE); set_option_flag(options, 0, "show-nr-samples", PARSE_OPT_EXCLUSIVE); - annotation_options__init(&annotate_opts); + annotation_options__init(); ret = hists__init(); if (ret < 0) return ret; - annotation_config__init(&annotate_opts); + annotation_config__init(); argc = parse_options(argc, argv, options, annotate_usage, 0); if (argc) { @@ -652,7 +652,7 @@ int cmd_annotate(int argc, const char **argv) return -ENOMEM; } - if (annotate_check_args(&annotate_opts) < 0) + if (annotate_check_args() < 0) return -EINVAL; #ifdef HAVE_GTK2_SUPPORT @@ -733,7 +733,7 @@ int cmd_annotate(int argc, const char **argv) #ifndef NDEBUG perf_session__delete(annotate.session); #endif - annotation_options__exit(&annotate_opts); + annotation_options__exit(); return ret; } diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index bc0d986c1e0c..17fb171e898b 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -1430,7 +1430,7 @@ int cmd_report(int argc, const char **argv) */ symbol_conf.keep_exited_threads = true; - annotation_options__init(&annotate_opts); + annotation_options__init(); ret = perf_config(report__config, &report); if (ret) @@ -1464,7 +1464,7 @@ int cmd_report(int argc, const char **argv) return -ENOMEM; } - if (annotate_check_args(&annotate_opts) < 0) { + if (annotate_check_args() < 0) { ret = -EINVAL; goto exit; } @@ -1696,7 +1696,7 @@ int cmd_report(int argc, const char **argv) */ symbol_conf.priv_size += sizeof(u32); } - annotation_config__init(&annotate_opts); + annotation_config__init(); } if (symbol__init(&session->header.env) < 0) @@ -1750,7 +1750,7 @@ int cmd_report(int argc, const char **argv) zstd_fini(&(session->zstd_data)); perf_session__delete(session); exit: - annotation_options__exit(&annotate_opts); + annotation_options__exit(); free(sort_order_help); free(field_order_help); return ret; diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 60399e4233ee..0de963ca3196 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -1608,7 +1608,7 @@ int cmd_top(int argc, const char **argv) if (status < 0) return status; - annotation_options__init(&annotate_opts); + annotation_options__init(); annotate_opts.min_pcnt = 5; annotate_opts.context = 4; @@ -1660,7 +1660,7 @@ int cmd_top(int argc, const char **argv) if (status) goto out_delete_evlist; - if (annotate_check_args(&annotate_opts) < 0) + if (annotate_check_args() < 0) goto out_delete_evlist; if (!top.evlist->core.nr_entries) { @@ -1786,7 +1786,7 @@ int cmd_top(int argc, const char **argv) if (status < 0) goto out_delete_evlist; - annotation_config__init(&annotate_opts); + annotation_config__init(); symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name == NULL); status = symbol__init(NULL); @@ -1839,7 +1839,7 @@ int cmd_top(int argc, const char **argv) out_delete_evlist: evlist__delete(top.evlist); perf_session__delete(top.session); - annotation_options__exit(&annotate_opts); + annotation_options__exit(); return status; } diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index daff9af552f4..626ff3baeb85 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -3416,8 +3416,10 @@ static int annotation__config(const char *var, const char *value, void *data) return 0; } -void annotation_options__init(struct annotation_options *opt) +void annotation_options__init(void) { + struct annotation_options *opt = &annotate_opts; + memset(opt, 0, sizeof(*opt)); /* Default values. */ @@ -3428,16 +3430,15 @@ void annotation_options__init(struct annotation_options *opt) opt->percent_type = PERCENT_PERIOD_LOCAL; } - -void annotation_options__exit(struct annotation_options *opt) +void annotation_options__exit(void) { - zfree(&opt->disassembler_style); - zfree(&opt->objdump_path); + zfree(&annotate_opts.disassembler_style); + zfree(&annotate_opts.objdump_path); } -void annotation_config__init(struct annotation_options *opt) +void annotation_config__init(void) { - perf_config(annotation__config, opt); + perf_config(annotation__config, &annotate_opts); } static unsigned int parse_percent_type(char *str1, char *str2) @@ -3491,8 +3492,10 @@ int annotate_parse_percent_type(const struct option *opt __maybe_unused, const c return err; } -int annotate_check_args(struct annotation_options *args) +int annotate_check_args(void) { + struct annotation_options *args = &annotate_opts; + if (args->prefix_strip && !args->prefix) { pr_err("--prefix-strip requires --prefix\n"); return -1; diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index 857c5fa0e6b1..4283eb4522b2 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -428,14 +428,14 @@ static inline int symbol__tui_annotate(struct map_symbol *ms __maybe_unused, } #endif -void annotation_options__init(struct annotation_options *opt); -void annotation_options__exit(struct annotation_options *opt); +void annotation_options__init(void); +void annotation_options__exit(void); -void annotation_config__init(struct annotation_options *opt); +void annotation_config__init(void); int annotate_parse_percent_type(const struct option *opt, const char *_str, int unset); -int annotate_check_args(struct annotation_options *args); +int annotate_check_args(void); #endif /* __PERF_ANNOTATE_H */ -- 2.43.0.rc1.413.gea7ed67945-goog