Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp1456966rdg; Sat, 12 Aug 2023 01:53:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHgCd1OAYB6L83LJDvjii/rhI5NzxbLkCYFUTYUgEdF9uYT4HhN9ML6/RZnQ6Hw678eBq/X X-Received: by 2002:a05:6a20:9383:b0:13d:860e:e346 with SMTP id x3-20020a056a20938300b0013d860ee346mr6423645pzh.5.1691830431490; Sat, 12 Aug 2023 01:53:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691830431; cv=none; d=google.com; s=arc-20160816; b=zVTMFy/6tmPy2HXyeT9uQsbj6bBys73ag7apk2/zMzv8lqTlDMnWqcGBmZDCW0P46g 59IdDlTNoqeehbvUOU2bG3T3uTnaa7etfszck4c2vqlS6SYXYCgFyahQndoxc2rDnE1w gB+ap/V7QEjPBioDHx+AwqwY7P64X0iAqPMUSohGM8RZylHnly0OKYzzsfCMWDbTALQ8 6Q7Yvcq4gKzl6i2QQZ8zll+IGdZpdkO/2UMZNpqGezd8iSqk9WR/XgqLDrUWfaJ6RtaT /z+c9ZlZDsFN1zWPosKxEgiRYQYAP1FBLchuLTHZupSmPWiGJNlOsRts5OyCjKo50JQu gLRg== 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=n3trUYTXeFu9bmfyvPQ2JgzFRprOpkd/dOancYRRLvQ=; fh=yJzUIAXk3G9GFZhd7AEi53Yh6JaeRXiXWLsFmPRnLKo=; b=ebmwMjE7jNCgDisuvlsHZ/Nq9nBbmrQGUHZrPCSKGiaQmHLjeLLAoILq0vpKz6UjUU hquESzRaCOyflfYCAKe77g7A/uCYphFgS4xyO6zKOSy9oE+kfWE9Fr7I6aG9csS+ceYy h3cGl9Qd4nxQjgE2Lx/K7aVj507dyVtvvlC75j5cpOwVRu+uWst/KSGoUO/LKOHwefsX WoucfEa+yKhSoeNcMidU+JgUCzlUrva2ceIpTMAcPaaMqBDDsrCtYLh7QurU1ofH/g5H tR0s+q1arRgvve0kkITUF+L1JVEY4xpb3hhFPkgbS8X9JrZmToMKnMtf6Nj4qnz4rpWG gVDw== 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:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n1-20020a632701000000b00565327794dfsi4901774pgn.60.2023.08.12.01.53.34; Sat, 12 Aug 2023 01:53:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236686AbjHLIwY (ORCPT + 99 others); Sat, 12 Aug 2023 04:52:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236285AbjHLIwG (ORCPT ); Sat, 12 Aug 2023 04:52:06 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C6C12684; Sat, 12 Aug 2023 01:52:09 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RNDs73NHFzrS89; Sat, 12 Aug 2023 16:50:51 +0800 (CST) Received: from localhost.localdomain (10.67.174.95) by kwepemm600003.china.huawei.com (7.193.23.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Sat, 12 Aug 2023 16:52:06 +0800 From: Yang Jihong To: , , , , , , , , , , , , , CC: Subject: [RFC v1 10/16] perf evsel: Add evsel__intval_common() helper Date: Sat, 12 Aug 2023 08:49:11 +0000 Message-ID: <20230812084917.169338-11-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT In-Reply-To: <20230812084917.169338-1-yangjihong1@huawei.com> References: <20230812084917.169338-1-yangjihong1@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.174.95] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600003.china.huawei.com (7.193.23.202) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 Add evsel__intval_common() helper to search for common_field in tracepoint format. Signed-off-by: Yang Jihong --- tools/perf/util/evsel.c | 13 +++++++++++++ tools/perf/util/evsel.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index e41bc4d9925f..f3ad2fa862bf 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -2764,6 +2764,11 @@ struct tep_format_field *evsel__field(struct evsel *evsel, const char *name) return tep_find_field(evsel->tp_format, name); } +struct tep_format_field *evsel__common_field(struct evsel *evsel, const char *name) +{ + return tep_find_common_field(evsel->tp_format, name); +} + void *evsel__rawptr(struct evsel *evsel, struct perf_sample *sample, const char *name) { struct tep_format_field *field = evsel__field(evsel, name); @@ -2832,6 +2837,14 @@ u64 evsel__intval(struct evsel *evsel, struct perf_sample *sample, const char *n return field ? format_field__intval(field, sample, evsel->needs_swap) : 0; } + +u64 evsel__intval_common(struct evsel *evsel, struct perf_sample *sample, const char *name) +{ + struct tep_format_field *field = evsel__common_field(evsel, name); + + return field ? format_field__intval(field, sample, evsel->needs_swap) : 0; +} + #endif bool evsel__fallback(struct evsel *evsel, int err, char *msg, size_t msgsize) diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 848534ec74fa..815be2491938 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -340,6 +340,7 @@ struct perf_sample; #ifdef HAVE_LIBTRACEEVENT void *evsel__rawptr(struct evsel *evsel, struct perf_sample *sample, const char *name); u64 evsel__intval(struct evsel *evsel, struct perf_sample *sample, const char *name); +u64 evsel__intval_common(struct evsel *evsel, struct perf_sample *sample, const char *name); static inline char *evsel__strval(struct evsel *evsel, struct perf_sample *sample, const char *name) { @@ -352,6 +353,7 @@ struct tep_format_field; u64 format_field__intval(struct tep_format_field *field, struct perf_sample *sample, bool needs_swap); struct tep_format_field *evsel__field(struct evsel *evsel, const char *name); +struct tep_format_field *evsel__common_field(struct evsel *evsel, const char *name); static inline bool __evsel__match(const struct evsel *evsel, u32 type, u64 config) { -- 2.30.GIT