Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp756050pxb; Fri, 22 Apr 2022 10:28:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3tQANVZeHm+VjeMUgQtsJ+7Llv4Q2d8gMvdOoKUBF3u+2kA03+nMeKkwhvEKRGJWilANC X-Received: by 2002:a63:e5d:0:b0:3aa:3c53:537e with SMTP id 29-20020a630e5d000000b003aa3c53537emr4819638pgo.622.1650648496675; Fri, 22 Apr 2022 10:28:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650648496; cv=none; d=google.com; s=arc-20160816; b=P0XQvEQnEbf3dAV0cJlKhCDCqXbIuk2P9JhwIoDNeSF3dlWFIX+Mkk8bPquSOmTvhc Jw+orjnvRDCgUWEcGgbb40qOsP+DmpawdjT229qNGHyaf/r74yEAZKBxB90Z+nhNN8SS ojBag0xRGXAFGdOgAW+9XJXD1czmb7qDdckcv7dR19z8m2zYmqb4+tai39a4iYZB5sye vhNdQh4tk+g6qzQuFI4kF4dK3KemVVpEGlScptvfVskEBADtfl/8Wm9G7xTEwqzUKvNr v35SZx2ABxRCB4zLSaX/h4TELAvN/33e1ilYoGbC/f+2AlWTtHrIj6YKQDhSGhmN0EY5 pR1A== 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=DpKyEZBKGBHSlPzAXhCljVDDvpiazrroPnlrIDGYhLA=; b=HcQFmYCCXVk18EDkaV+hbxQu5xmyCh6QOz+SShX2LhQfFwQEVVUrrP4fCv0RkxyQPM Z7Ydqjmc81h5gpOXHLt7wZ8rOMJK2AUe9b7MCiA8Br9q/b2Ou1wZH05kmkmeF2DfUTuJ P/+hEysBJLc76mpMcbhAPI1g8Lk2s7gsgTnflP5V0p3gb+v/4JBXoU+MEZcYDnEsZY1n TonaM1vMp6oobPOlMngYYKegIzT9vsE7cND+salcRwS1dVit8eUobK5MbJ+VLxKQSuJb Qhqb86HoI34a9DyCUAVXQgUg2YBggKg3L5hROigDRvTZeIqFGTZR7qxPvm8JSGdhOC4w WNPw== 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:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id e18-20020a056a001a9200b004fa3a8e0087si8914156pfv.318.2022.04.22.10.28.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 10:28:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8AE41BF959; Fri, 22 Apr 2022 10:21:36 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377680AbiDTK1a (ORCPT + 99 others); Wed, 20 Apr 2022 06:27:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359472AbiDTK1R (ORCPT ); Wed, 20 Apr 2022 06:27:17 -0400 Received: from euporie.uberspace.de (euporie.uberspace.de [185.26.156.232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 789753F885 for ; Wed, 20 Apr 2022 03:24:31 -0700 (PDT) Received: (qmail 15788 invoked by uid 989); 20 Apr 2022 10:24:29 -0000 Authentication-Results: euporie.uberspace.de; auth=pass (plain) From: Florian Fischer To: linux-perf-users@vger.kernel.org Cc: Ian Rogers , Xing Zhengjun , linux-kernel@vger.kernel.org, Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Florian Fischer Subject: [PATCH v4 3/3] perf list: print all available tool events Date: Wed, 20 Apr 2022 12:23:54 +0200 Message-Id: <20220420102354.468173-4-florian.fischer@muhq.space> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220420102354.468173-1-florian.fischer@muhq.space> References: <20220420102354.468173-1-florian.fischer@muhq.space> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Bar: ----- X-Rspamd-Report: R_MISSING_CHARSET(0.5) MIME_GOOD(-0.1) REPLY(-4) MID_CONTAINS_FROM(1) BAYES_HAM(-2.968525) X-Rspamd-Score: -5.568525 Received: from unknown (HELO unkown) (::1) by euporie.uberspace.de (Haraka/2.8.28) with ESMTPSA; Wed, 20 Apr 2022 12:24:29 +0200 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER, RDNS_NONE,SPF_HELO_NONE autolearn=no 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 Introduce names for the new tool events 'user_time' and 'system_time'. Signed-off-by: Florian Fischer --- tools/perf/util/evsel.c | 19 ++++++++++------ tools/perf/util/evsel.h | 1 + tools/perf/util/parse-events.c | 40 +++++++++++++++++++++++++++++----- 3 files changed, 47 insertions(+), 13 deletions(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 2a1729e7aee4..d38722560e80 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -597,6 +597,17 @@ static int evsel__sw_name(struct evsel *evsel, char *bf, size_t size) return r + evsel__add_modifiers(evsel, bf + r, size - r); } +const char *evsel__tool_names[PERF_TOOL_MAX] = { + "duration_time", + "user_time", + "system_time", +}; + +static int evsel__tool_name(enum perf_tool_event ev, char *bf, size_t size) +{ + return scnprintf(bf, size, "%s", evsel__tool_names[ev]); +} + static int __evsel__bp_name(char *bf, size_t size, u64 addr, u64 type) { int r; @@ -723,12 +734,6 @@ static int evsel__raw_name(struct evsel *evsel, char *bf, size_t size) return ret + evsel__add_modifiers(evsel, bf + ret, size - ret); } -static int evsel__tool_name(char *bf, size_t size) -{ - int ret = scnprintf(bf, size, "duration_time"); - return ret; -} - const char *evsel__name(struct evsel *evsel) { char bf[128]; @@ -754,7 +759,7 @@ const char *evsel__name(struct evsel *evsel) case PERF_TYPE_SOFTWARE: if (evsel->tool_event) - evsel__tool_name(bf, sizeof(bf)); + evsel__tool_name(evsel->tool_event, bf, sizeof(bf)); else evsel__sw_name(evsel, bf, sizeof(bf)); break; diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 7e2209b47b39..45d674812239 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -262,6 +262,7 @@ extern const char *evsel__hw_cache_op[PERF_COUNT_HW_CACHE_OP_MAX][EVSEL__MAX_ALI extern const char *evsel__hw_cache_result[PERF_COUNT_HW_CACHE_RESULT_MAX][EVSEL__MAX_ALIASES]; extern const char *evsel__hw_names[PERF_COUNT_HW_MAX]; extern const char *evsel__sw_names[PERF_COUNT_SW_MAX]; +extern const char *evsel__tool_names[PERF_TOOL_MAX]; extern char *evsel__bpf_counter_events; bool evsel__match_bpf_counter_events(const char *name); diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 064ec368a90b..c0e88d3b3e3c 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -154,6 +154,21 @@ struct event_symbol event_symbols_sw[PERF_COUNT_SW_MAX] = { }, }; +struct event_symbol event_symbols_tool[PERF_TOOL_MAX] = { + [PERF_TOOL_DURATION_TIME] = { + .symbol = "duration_time", + .alias = "", + }, + [PERF_TOOL_USER_TIME] = { + .symbol = "user_time", + .alias = "", + }, + [PERF_TOOL_SYSTEM_TIME] = { + .symbol = "system_time", + .alias = "", + }, +}; + #define __PERF_EVENT_FIELD(config, name) \ ((config & PERF_EVENT_##name##_MASK) >> PERF_EVENT_##name##_SHIFT) @@ -3058,21 +3073,34 @@ int print_hwcache_events(const char *event_glob, bool name_only) return evt_num; } -static void print_tool_event(const char *name, const char *event_glob, +static void print_tool_event(const struct event_symbol *syms, const char *event_glob, bool name_only) { - if (event_glob && !strglobmatch(name, event_glob)) + if (syms->symbol == NULL) + return; + + if (event_glob && !(strglobmatch(syms->symbol, event_glob) || + (syms->alias && strglobmatch(syms->alias, event_glob)))) return; + if (name_only) - printf("%s ", name); - else + printf("%s ", syms->symbol); + else { + char name[MAX_NAME_LEN]; + if (syms->alias) + snprintf(name, MAX_NAME_LEN, "%s OR %s", syms->symbol, syms->alias); + else + strlcpy(name, syms->symbol, MAX_NAME_LEN); printf(" %-50s [%s]\n", name, "Tool event"); - + } } void print_tool_events(const char *event_glob, bool name_only) { - print_tool_event("duration_time", event_glob, name_only); + // Start at 1 because the first enum entry symbols no tool event + for (int i = 1; i < PERF_TOOL_MAX; ++i) { + print_tool_event(event_symbols_tool + i, event_glob, name_only); + } if (pager_in_use()) printf("\n"); } -- 2.36.0