From patchwork Thu Sep 12 19:03:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13802494 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 927D9EEB59D for ; Thu, 12 Sep 2024 19:08:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Nv46Pxr4RqOiUfocd6lnckQ6oaO49PAAJVzHx2iL/LI=; b=to6CYtjXUSP/wnayrdz+NyZPcE OPkR5xCkvVS4USB6EJ9JXv6v+wv9u8AzA6GmxbPtdzo709djb8nJ+Y1J5NcnpWibwe/mOTy7Qtveb 1sp0xSYazAVFQtAc+liQPvqQUoRrpksZokr+o4+ZzLFDxzVlFnW50olk83BuGSvna7+ntojgi4FDd JOrRGRa7F31qw2duJ9kVJ5ViW05N5LvznpsnNkVMEirY6Xx2kvsSjcqIF+lWYbou7y6Ltrdx9LDIe XeLa+EAN0mk6TnTRJ+5LJm/6DhjUw+GqWKeKZQWAAnOLBIvoExmwfbS+2oiRfGVvAC4fXjMjDhPpT SrKzlKoA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sopAy-0000000E0j1-27zJ; Thu, 12 Sep 2024 19:08:20 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sop6j-0000000Dza9-3mcw for linux-arm-kernel@lists.infradead.org; Thu, 12 Sep 2024 19:03:59 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-6d73dd8ac65so4905407b3.1 for ; Thu, 12 Sep 2024 12:03:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726167836; x=1726772636; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=Nv46Pxr4RqOiUfocd6lnckQ6oaO49PAAJVzHx2iL/LI=; b=V4LypLWF5OkbbrN+76hivEw5/Az8gp6RkFnLkpwCBeeCz8nk5XBvCXhuEIN7N8l3OM uYBziK2wplowtYzZUmXtpV2ZxQCQdaxyg6buDMdPxGI0f4gK6CnuVfiTpq48raJ77u2Q YXU+RBEyeFPZ6fDgMfw0KseLMWDXI2b/YCWgiY+KGlcj9/frw6isAxS9t81Nu0ZVjBGv d4KDGCWe7HMWqTX7pK/Up5d+s3iYKGdZKMLgUbigahLtlyVCu5F+bEMhJT9EpoKZds1t sAlBn7Q/CQQ5oU22PXL6KaMCnEa+jzu+es6bQZOKWXWvm+rpTiQQdMlkzsqGX/h+wZ9X QvhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726167836; x=1726772636; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Nv46Pxr4RqOiUfocd6lnckQ6oaO49PAAJVzHx2iL/LI=; b=ZoH9NU0sK/DXyXlMDm0IjxOHDgudHLrG2bqZgrmZBrWvNnizjLOyjoe2vNr1YHMhKn IfQ0kKbtszE54+VmtY0EgahY8riWICI3s3fX1QhuAn/CEzO6nhODw9tpjrWmM2YvJVdX DBqGlfgqb6mblRPz2J7AO9rQOPGFNwK/OsL0VGeUI9WOQJCaVUM/15aZfDL9hFurj7SX G6Lb+u9O9j7WkSheBNSiVsFbIfmI9cS5n2Bo6JNp490VaN+IuZB8RB9a1k5VGe0CMe2s 8dKziovyer5my/VRZ1tzEmf/S3dfAsUdIYFRUpYlI8Ndyp4qBye1Mg8cSWuVbz6tnUy8 C6pA== X-Forwarded-Encrypted: i=1; AJvYcCV+IefuuTK8bJnK9B9oYxTYOnMPX0pmi0TsSLONEzClyKnV8w/Np5nm7DcHziUiSSHQ+SQ7Iy04mUGKgr7JciK+@lists.infradead.org X-Gm-Message-State: AOJu0YwCFyb0j2//x4MBTwVeuZhKD/02q4EEbeC7CT2v+hxQy8qtQ51n KWyy05Kc+LYUc6QN2atJnmoQWU+Vpt5ZMRyFYvOrZwRMh26eNKrpC2ARYNCS3QpfJBcdZ3W93Nw K/4eVFA== X-Google-Smtp-Source: AGHT+IFHO09bW2w4OpHfnI1mvLyMuz+jqvEx61veclezxCDRJ5X1P4hSJYcP6uZSfsVCOzJE/dx5n6NbJdWI X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:cf0e:7a99:e672:3862]) (user=irogers job=sendgmr) by 2002:a0d:c641:0:b0:6c1:298e:5a7 with SMTP id 00721157ae682-6dbcc584e0emr97147b3.5.1726167836594; Thu, 12 Sep 2024 12:03:56 -0700 (PDT) Date: Thu, 12 Sep 2024 12:03:30 -0700 In-Reply-To: <20240912190341.919229-1-irogers@google.com> Message-Id: <20240912190341.919229-4-irogers@google.com> Mime-Version: 1.0 References: <20240912190341.919229-1-irogers@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Subject: [PATCH v2 03/13] perf parse-events: Expose/rename config_term_name From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Ravi Bangoria , Weilin Wang , Jing Zhang , Xu Yang , Sandipan Das , Benjamin Gray , Athira Jajeev , Howard Chu , Dominique Martinet , Yang Jihong , Colin Ian King , Veronika Molnarova , "Dr. David Alan Gilbert" , Oliver Upton , Changbin Du , Ze Gao , Andi Kleen , " =?utf-8?q?Cl=C3=A9ment_Le_Goffic?= " , Sun Haiyong , Junhao He , Tiezhu Yang , Yicong Yang , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240912_120357_964021_BA4DDB7D X-CRM114-Status: GOOD ( 17.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Expose config_term_name as parse_events__term_type_str so that PMUs not in pmu.c may access it. Signed-off-by: Ian Rogers --- tools/perf/util/parse-events.c | 20 +++++++++++--------- tools/perf/util/parse-events.h | 2 ++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 26bbc6f603ab..776812460dad 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -794,7 +794,7 @@ static int check_type_val(struct parse_events_term *term, static bool config_term_shrinked; -static const char *config_term_name(enum parse_events__term_type term_type) +const char *parse_events__term_type_str(enum parse_events__term_type term_type) { /* * Update according to parse-events.l @@ -880,7 +880,7 @@ config_term_avail(enum parse_events__term_type term_type, struct parse_events_er /* term_type is validated so indexing is safe */ if (asprintf(&err_str, "'%s' is not usable in 'perf stat'", - config_term_name(term_type)) >= 0) + parse_events__term_type_str(term_type)) >= 0) parse_events_error__handle(err, -1, err_str, NULL); return false; } @@ -1004,7 +1004,7 @@ do { \ case PARSE_EVENTS__TERM_TYPE_HARDWARE: default: parse_events_error__handle(err, term->err_term, - strdup(config_term_name(term->type_term)), + strdup(parse_events__term_type_str(term->type_term)), parse_events_formats_error_string(NULL)); return -EINVAL; } @@ -1127,8 +1127,9 @@ static int config_term_tracepoint(struct perf_event_attr *attr, default: if (err) { parse_events_error__handle(err, term->err_term, - strdup(config_term_name(term->type_term)), - strdup("valid terms: call-graph,stack-size\n")); + strdup(parse_events__term_type_str(term->type_term)), + strdup("valid terms: call-graph,stack-size\n") + ); } return -EINVAL; } @@ -2568,7 +2569,7 @@ int parse_events_term__num(struct parse_events_term **term, struct parse_events_term temp = { .type_val = PARSE_EVENTS__TERM_TYPE_NUM, .type_term = type_term, - .config = config ? : strdup(config_term_name(type_term)), + .config = config ? : strdup(parse_events__term_type_str(type_term)), .no_value = no_value, .err_term = loc_term ? loc_term->first_column : 0, .err_val = loc_val ? loc_val->first_column : 0, @@ -2602,7 +2603,7 @@ int parse_events_term__term(struct parse_events_term **term, void *loc_term, void *loc_val) { return parse_events_term__str(term, term_lhs, NULL, - strdup(config_term_name(term_rhs)), + strdup(parse_events__term_type_str(term_rhs)), loc_term, loc_val); } @@ -2709,7 +2710,8 @@ int parse_events_terms__to_strbuf(const struct parse_events_terms *terms, struct if (ret < 0) return ret; } else if ((unsigned int)term->type_term < __PARSE_EVENTS__TERM_TYPE_NR) { - ret = strbuf_addf(sb, "%s=", config_term_name(term->type_term)); + ret = strbuf_addf(sb, "%s=", + parse_events__term_type_str(term->type_term)); if (ret < 0) return ret; } @@ -2729,7 +2731,7 @@ static void config_terms_list(char *buf, size_t buf_sz) buf[0] = '\0'; for (i = 0; i < __PARSE_EVENTS__TERM_TYPE_NR; i++) { - const char *name = config_term_name(i); + const char *name = parse_events__term_type_str(i); if (!config_term_avail(i, NULL)) continue; diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h index 10cc9c433116..bbe6c5700828 100644 --- a/tools/perf/util/parse-events.h +++ b/tools/perf/util/parse-events.h @@ -162,6 +162,8 @@ struct parse_events_state { bool wild_card_pmus; }; +const char *parse_events__term_type_str(enum parse_events__term_type term_type); + bool parse_events__filter_pmu(const struct parse_events_state *parse_state, const struct perf_pmu *pmu); void parse_events__shrink_config_terms(void);