Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp71836pxh; Thu, 7 Apr 2022 14:19:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGZZ650vGL4xYYHUeU51gxU5IZm5/uFkm1IwUB+8z2EyEXU9RlBuwHnx0Lnk+mNcDIo0x0 X-Received: by 2002:a17:90b:3017:b0:1cb:10d1:93d with SMTP id hg23-20020a17090b301700b001cb10d1093dmr6011106pjb.217.1649366377694; Thu, 07 Apr 2022 14:19:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649366377; cv=none; d=google.com; s=arc-20160816; b=xJp8w43v/x7O4SG3B4nOZ/pn4H30XfbM+A1+xxVnVTfWCl6wXYoX95vYfnv4vKYpdL xYEICd+5r++8xNiM+AebpaFqqPCRx8Fxzk/GDRex1oD4e5TNrTbzsXEMdeZjY6UBaTO6 ymobZINQhI+i6cFFS8QDx10xGKHARySdSf+yKv2iJE99ognqE5IifXrK5EmiBHhM8s7N cZiRuWbZFORIlYwCI7eUqePdFkUfxFBQf5ZucwjwD7tDKc0ZE2lJeQuwh9jdwgFxDqMt BRplqtIO41pEnM0O6BqzYtQuI+WTIoi0ieJ+WzCH2bMUbAIWcJCu/Jaf5juaDhRtw/B2 RXmA== 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=H4vejzs7NSRLKArbVw1xVIdYyIT9rBkWxd4xQzAZbZM=; b=s44/NLFIYwOZRl2upagfvDszUY7yinZ/c3jwVBYczV7E0UG6SP+hZzNbmefYaKm9hv 5em16gB68rf+pn36+dncjo7MalyLFRDJD4nhVKSyj3UImt4UPKjpEaHtFpScSFzCMuxZ NLCdBPLNJZT96h4/LrGz/8OrinJmwEsA6kF0dGX6P7ThqP/3LWlvwpIIl1XVEiaNnsFn 1Ghtbr+HPbkk1GcW31/L4A3VESADcHGVnb5WUPan3kne0SYGdb3DWOkhE3FeiYzmcA66 iu6TumyejSsMJaNPTV1vuvzLUBPAOhfE72fBHUNsMVTDsc/OMcyattNIernTiqYPseqv wUCQ== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id h128-20020a625386000000b004fa8a73c6ecsi1507535pfb.180.2022.04.07.14.19.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 14:19:37 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9525B4793A3; Thu, 7 Apr 2022 13:11:09 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243472AbiDGJAf (ORCPT + 99 others); Thu, 7 Apr 2022 05:00:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243372AbiDGJA0 (ORCPT ); Thu, 7 Apr 2022 05:00:26 -0400 Received: from euporie.uberspace.de (euporie.uberspace.de [185.26.156.232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F151C90E2 for ; Thu, 7 Apr 2022 01:58:24 -0700 (PDT) Received: (qmail 18008 invoked by uid 989); 7 Apr 2022 08:58:21 -0000 Authentication-Results: euporie.uberspace.de; auth=pass (plain) From: Florian Fischer To: Xing Zhengjun Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Florian Schmaus , Florian Fischer Subject: [PATCH v3 3/3] perf list: print all available tool events Date: Thu, 7 Apr 2022 10:57:21 +0200 Message-Id: <20220407085721.3289414-4-florian.fischer@muhq.space> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220407085721.3289414-1-florian.fischer@muhq.space> References: <69656438-8b9a-000b-0702-02dc480639f9@linux.intel.com> <20220407085721.3289414-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.852212) X-Rspamd-Score: -5.452212 Received: from unknown (HELO unkown) (::1) by euporie.uberspace.de (Haraka/2.8.28) with ESMTPSA; Thu, 07 Apr 2022 10:58:21 +0200 X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,FROM_SUSPICIOUS_NTLD, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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 and aliases for the new tool events 'rusage_user_time' and 'rusage_system_time'. --- 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..26cf7e76698b 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_LAST] = { + "duration_time", + "rusage_user_time", + "rusage_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 e89b1224ae61..2adb97383952 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -261,6 +261,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_LAST]; 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 e9d3d4404ea6..c232ab79d434 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_LAST] = { + [PERF_TOOL_DURATION_TIME] = { + .symbol = "duration_time", + .alias = "", + }, + [PERF_TOOL_RU_UTIME] = { + .symbol = "rusage_user_time", + .alias = "ru_utime", + }, + [PERF_TOOL_RU_STIME] = { + .symbol = "rusage_system_time", + .alias = "ru_stime", + }, +}; + #define __PERF_EVENT_FIELD(config, name) \ ((config & PERF_EVENT_##name##_MASK) >> PERF_EVENT_##name##_SHIFT) @@ -3057,21 +3072,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 = 0; i < PERF_TOOL_LAST; ++i) { + print_tool_event(event_symbols_tool + i, event_glob, name_only); + } if (pager_in_use()) printf("\n"); } -- 2.35.1