From patchwork Wed Oct 2 03:20:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13819280 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 90577CF318F for ; Wed, 2 Oct 2024 03:25:34 +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=39T+6noF1HDYHixFiWW8nys9E5rCFMsxZqBd3BPaByY=; b=H59bsddzmBCGOJcFKlMjKhp1+h yMPtL6WlSgAbaY1hH3blYmGLYjMeaoh08la0bUiHJH/K0ZX+05FHFIdGNw11yLxTrirGMdwxOkOLF Y1jKOGLuUJ13Rjlgtk2BFlLllDRD3PcLYgh/t34WUeXxBJpGaitqLuqMK4S2haNTC6WvcQiyQYVH0 d4l9Uh5H45evvPS0zYA+w0/ioAkBrY/0hZdgGCltBWgeHi7RFEs/i07NyCLCsLK1F9CuBxB3hL117 TSoacgOqlCIEcHCzR2EYsClsknL1E/UmQjAL8HykaEQnMoWjjbXrVvwB4oSPDViVwLuCiVPpJoYR+ RJk0XzOQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1svpzR-00000004gwh-2HQZ; Wed, 02 Oct 2024 03:25:25 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1svpuh-00000004g2T-1TMX for linux-arm-kernel@lists.infradead.org; Wed, 02 Oct 2024 03:20:32 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e035949cc4eso9201472276.1 for ; Tue, 01 Oct 2024 20:20:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1727839229; x=1728444029; 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=39T+6noF1HDYHixFiWW8nys9E5rCFMsxZqBd3BPaByY=; b=B7RjK5vk3Tcm5w9iEUG8b/FObEKzFCAvYbymMNR0zySWI+Zs8hGEfiDijTL6/unugS O5ooJqvX+ictAwMhSUxS7Cf1ZfLT1Qu1CCPpSMBmQTEhkkj76Vz79+q1aL3suhVe0P6R f1UhE6Y72yCXHYkcwusYXN7+1hh3jjSsPiJ4L5jWCZUU6/F0nq8lF+DxJIgFFg8Qcp5H 0O/R9Mt9n81oAV4n/6k5UdMQP7WA0DNhCAHTSX1mQypKM1RkbQZqqTMwu4FCwpSc4aGg FK72cl4ebiLZBYPW6qSLnOEBVFr5UMQuGz6aaDOTerultlrCvpE8VMlewuc8VCfUMo4N PDQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727839229; x=1728444029; 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=39T+6noF1HDYHixFiWW8nys9E5rCFMsxZqBd3BPaByY=; b=hUuQmGFKi0dJAifUcBN5gLRGSsl4elsoicEaz0f0CUm59lXSG/UyRgYs3z4ICTCCJ9 avuEN/CW1IcAWtU2SCsqvNB0CPWgSV4Jvyd1lbBq74qKpxJbqhdQ5KNtOPUIGvEOwV/n ps5F8JGcqOlaoPdBZH9mB2nhmmnjFR+cf9CAWcq6ppXYT1XFa5bNZURhqwwewQBQfHmD gghdZYqCqU6hgcBx3UQgUwn4M0SN+GAeByzBbk4Vay5NJfT2FSHpsnOioo/D7tgKZCe/ X+uJMO5diKXPlND7fEsM7A+1HTWWDe8BinocL1gRVr7fPZUQfjr2pZ20BGYMfAIgcKX+ Ctyg== X-Forwarded-Encrypted: i=1; AJvYcCUsnERYM/3Hy3GEQN9SDTIy/3VGSvB5LpQ/Y3WkLvjVFMoZir8Z1JFpV3B1XGF3v4pBEuquyw/Vt2oQaomoLFQZ@lists.infradead.org X-Gm-Message-State: AOJu0YzrWvHabBH9H4h5rLC8m5R8Vgxtm5Giq6I+PxQ/eE9bxtLrBb/5 95oXmu/U6+Q059W/qX2ZIwNumANEFszZXNJ0GHyhZ9kebmKtn72U9kHnlIsaXUjho/ju8hBd2d2 9Ud3tXQ== X-Google-Smtp-Source: AGHT+IGGXpz7W1T1yyjYa2QLFOERmH1YOJwoLGSUEPWG+E5FM/tlDieHSEHZd2aGX20w6HMLgZUOd0Zysatg X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:ffa1:6d00:2acb:535f]) (user=irogers job=sendgmr) by 2002:a25:bc8d:0:b0:e25:e5b9:8114 with SMTP id 3f1490d57ef6-e26383e33d0mr5567276.4.1727839229299; Tue, 01 Oct 2024 20:20:29 -0700 (PDT) Date: Tue, 1 Oct 2024 20:20:06 -0700 In-Reply-To: <20241002032016.333748-1-irogers@google.com> Message-Id: <20241002032016.333748-4-irogers@google.com> Mime-Version: 1.0 References: <20241002032016.333748-1-irogers@google.com> X-Mailer: git-send-email 2.46.1.824.gd892dcdcdd-goog Subject: [PATCH v3 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 , Weilin Wang , Ravi Bangoria , Sandipan Das , Xu Yang , Benjamin Gray , Athira Jajeev , Howard Chu , Veronika Molnarova , "Dr. David Alan Gilbert" , Oliver Upton , Changbin Du , "Steinar H. Gunderson" , Ze Gao , Dominique Martinet , " =?utf-8?q?Cl=C3=A9ment_Le_?= =?utf-8?q?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-20241001_202031_412290_07376FF4 X-CRM114-Status: GOOD ( 16.85 ) 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 Acked-by: Namhyung Kim --- 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 6ae611e70fae..228ae469d44a 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -800,7 +800,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 @@ -886,7 +886,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; } @@ -1010,7 +1010,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; } @@ -1134,8 +1134,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; } @@ -2582,7 +2583,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, @@ -2616,7 +2617,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); } @@ -2723,7 +2724,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; } @@ -2743,7 +2745,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 2b52f8d6aa29..ac1feaaeb8d5 100644 --- a/tools/perf/util/parse-events.h +++ b/tools/perf/util/parse-events.h @@ -168,6 +168,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);