Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp3242549lqo; Tue, 21 May 2024 10:40:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWGT0wPqbZWA9bMX7dzNXsiQOzOaVot2Kf+2Mx5/mAyuIP48zCTPxr2MAt0HpGbh+W5olmD+YIOm82+IJitkO4w99MT5EaytdKwgFSBxQ== X-Google-Smtp-Source: AGHT+IGWR9weXjeI1RjB4+pzaskAbw1RI3nq9UDNAg1dxMvVceHz+Dp123z+5RH/DrciGKLR1QCb X-Received: by 2002:a50:9ec5:0:b0:568:8e22:4eff with SMTP id 4fb4d7f45d1cf-5734d6df0d5mr20687386a12.37.1716313238700; Tue, 21 May 2024 10:40:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716313238; cv=pass; d=google.com; s=arc-20160816; b=mj/PrcIjo6L4WSsNbQ3L0QLL5LvrIsAoeoQK31UxXLuRfCSLTuR5Cjgkxs/VQc3S9u l95W9WlH5pWrMY4XVhWt45SGt02oLTjt7EhQKfbuqV/Al9PR+qIC93gX5ZQ/7ayY8Kzg xMGYenoMc8E8GZKnDq7RecKyQ9iq61/I/Lz8f4h+wrn2i7Ehkj0CA5VVBRarZMbJW8gb q335sFSgTdgrvqpQoG4zF8OabFMmEMrTu13k/nAENSf9JhTbczTunoUtkA25d3MiTHQT X18sgb7h7op3dJYGUZ2B9WgplmQSF0N+wIyMn45V07KgCXVeTFzNEW3bwHhdSCJqkdFe FCkg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ogxtAowpGsS4O55bwZjoZ6g4ZpBOdXRrStqz4Djnfsg=; fh=7D8bWqELNqJM6KF7zbibUOya8038rGAdDMFXsJMRu8c=; b=q4XQQaUcnUI6Q4M8EDNOJwFzE0u833iGhtLrY0CycgGgy91cv7ykF7482UAOQVUyGt vMuG5N7rB1b7ka+25vEFxZMXe+RLl8pXqfyMzoW284LPe1mnDDc9INblOGlsnfK7hUJs bq4JXBWyWSUq8ZdUSv2BNhKQroHPYANdo593C32M3WKvZTDOIenQGvbCoYefwGMQxGmW 5LFLzv1a+WDTUgSWc40z6gY7tpRXPvGis7+H8JXPDm1rJBEGdhZF6aVMDunFt/rRAJjD emo769hxq4A8C1jjOXYfY2mPA1HZp79PwXKM7Y9eBmOzeHsaXfIpwCdFRQpfx4c8aeUK VYYg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=aXjcyD7e; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-185282-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-185282-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5733c3272b7si14979833a12.398.2024.05.21.10.40.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 10:40:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-185282-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=aXjcyD7e; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-185282-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-185282-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 3FD381F222D2 for ; Tue, 21 May 2024 17:40:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D433B14901C; Tue, 21 May 2024 17:40:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="aXjcyD7e" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F93E148820; Tue, 21 May 2024 17:40:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716313201; cv=none; b=TFzGpxQMkyphwg4bmUYHU+2NVjhcUySELkdClBiKyexMedSS5UPCouG43o0/K4YnGw4m1fPkUMt2vnGJp5azVoO/QHOqS1QAGl/Copk8buTt2ant/fOZAFKYxeQVPYLT/g/0THaGnc9Q2E8DWzLvjAixwgMWVuxpIYJSClJrqu8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716313201; c=relaxed/simple; bh=WsqpE6hySICZuLE1ggqpieCn1M2X1N9qSkG2FYXQ0/I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MQB67q4V11xwYntm/ggBsZW1MxwLASXhypULmcRAypR6s4EqCM23062WF9tSmNWUh/R5q3WAmCG1I7k4+R9PxNnn5mYMkAtr4zM49S+jUPPcV0zpglL9oFsYBumTuxcuvrsE1+sbdnAozjILv4hIPV1ZZpzoXdm3IFOU/1exDaQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=aXjcyD7e; arc=none smtp.client-ip=192.198.163.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716313200; x=1747849200; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WsqpE6hySICZuLE1ggqpieCn1M2X1N9qSkG2FYXQ0/I=; b=aXjcyD7eJV/qRnfp3MV//ynR59LdufC1OSSteVoLxamcE9B8fDWoJQ1f khNZmzKqTBw1qoEhodv8O2x+yn1cpxwjo+B63HLrPZE84ZafvNfjL285D 2dU6pO/qPgew6E4MKZLy7Xdx+4dC2MJDWqoh8kYQl17pJQWDQs5gpp5Wo ++IWIt9uNbgCCdZnLv7/mnOfamsll5NMmXAofoytQLhpKJ6OTs6TX1Hs5 rotw+AQWamSa86u4AiXVUmd7KyKUKIJOpCIMIhtmpO9xtfP74Fwf+rOHz 8vvR167k/MG9SVyvewxroDDmhMsJWTCR9kl+rkkwh3mfLAwzrdJgs/470 g==; X-CSE-ConnectionGUID: RjPIwDfsR/eKtxidrRiZbA== X-CSE-MsgGUID: 0dfNoopgQIuseXAdcceW4A== X-IronPort-AV: E=McAfee;i="6600,9927,11079"; a="12317667" X-IronPort-AV: E=Sophos;i="6.08,178,1712646000"; d="scan'208";a="12317667" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 10:39:58 -0700 X-CSE-ConnectionGUID: U/ZnUg6bQiOM5wyGuvkKWQ== X-CSE-MsgGUID: Or9MlpM2RoWwnsIdX/NUXQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,178,1712646000"; d="scan'208";a="32924964" Received: from fl31ca102ks0602.deacluster.intel.com (HELO gnr-bkc.deacluster.intel.com) ([10.75.133.163]) by fmviesa007.fm.intel.com with ESMTP; 21 May 2024 10:39:58 -0700 From: weilin.wang@intel.com To: weilin.wang@intel.com, Namhyung Kim , Ian Rogers , Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Perry Taylor , Samantha Alt , Caleb Biggers Subject: [RFC PATCH v9 4/7] perf stat: Plugin retire_lat value from sampled data to evsel Date: Tue, 21 May 2024 13:39:32 -0400 Message-ID: <20240521173952.3397644-5-weilin.wang@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240521173952.3397644-1-weilin.wang@intel.com> References: <20240521173952.3397644-1-weilin.wang@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Weilin Wang In current :R parsing implementation, the parser would recognize events with retire_latency modifier and insert them into the evlist like a normal event. Ideally, we need to avoid counting these events. In this commit, at the time when a retire_latency evsel is read, set the retire latency value processed from the sampled data to count value. This sampled retire latency value will be used for metric calculation and final event count print out. Signed-off-by: Weilin Wang --- tools/perf/arch/x86/util/evlist.c | 6 +++++ tools/perf/util/evsel.c | 44 +++++++++++++++++++++++++++++++ tools/perf/util/evsel.h | 5 ++++ 3 files changed, 55 insertions(+) diff --git a/tools/perf/arch/x86/util/evlist.c b/tools/perf/arch/x86/util/evlist.c index b1ce0c52d88d..cebdd483149e 100644 --- a/tools/perf/arch/x86/util/evlist.c +++ b/tools/perf/arch/x86/util/evlist.c @@ -89,6 +89,12 @@ int arch_evlist__cmp(const struct evsel *lhs, const struct evsel *rhs) return 1; } + /* Retire latency event should not be group leader*/ + if (lhs->retire_lat && !rhs->retire_lat) + return 1; + if (!lhs->retire_lat && rhs->retire_lat) + return -1; + /* Default ordering by insertion index. */ return lhs->core.idx - rhs->core.idx; } diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index a0a8aee7d6b9..4d700338fc99 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -58,6 +58,7 @@ #include #include #include +#include "util/intel-tpebs.h" #include @@ -1523,6 +1524,40 @@ static int evsel__read_one(struct evsel *evsel, int cpu_map_idx, int thread) return perf_evsel__read(&evsel->core, cpu_map_idx, thread, count); } +static int evsel__set_retire_lat(struct evsel *evsel, int cpu_map_idx, int thread) +{ + struct perf_counts_values *count; + struct tpebs_retire_lat *t; + bool found = false; + __u64 val; + + count = perf_counts(evsel->counts, cpu_map_idx, thread); + + list_for_each_entry(t, &tpebs_results, nd) { + if (!strcmp(t->tpebs_name, evsel->name)) { + found = true; + break; + } + } + + if (!found) + return -1; + + /* + * Only set retire_latency value to the first CPU and thread. + */ + if (cpu_map_idx == 0 && thread == 0) + val = t->val; + else + val = 0; + + count->val = val; + /* Set ena and run to non-zero */ + count->ena = count->run = 1; + count->lost = 0; + return 0; +} + static void evsel__set_count(struct evsel *counter, int cpu_map_idx, int thread, u64 val, u64 ena, u64 run, u64 lost) { @@ -1530,6 +1565,12 @@ static void evsel__set_count(struct evsel *counter, int cpu_map_idx, int thread, count = perf_counts(counter->counts, cpu_map_idx, thread); + if (counter->retire_lat) { + evsel__set_retire_lat(counter, cpu_map_idx, thread); + perf_counts__set_loaded(counter->counts, cpu_map_idx, thread, true); + return; + } + count->val = val; count->ena = ena; count->run = run; @@ -1778,6 +1819,9 @@ int evsel__read_counter(struct evsel *evsel, int cpu_map_idx, int thread) if (evsel__is_tool(evsel)) return evsel__read_tool(evsel, cpu_map_idx, thread); + if (evsel__is_retire_lat(evsel)) + return evsel__set_retire_lat(evsel, cpu_map_idx, thread); + if (evsel->core.attr.read_format & PERF_FORMAT_GROUP) return evsel__read_group(evsel, cpu_map_idx, thread); diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index bd8e84954e34..aaf572317e92 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -303,6 +303,11 @@ static inline bool evsel__is_tool(const struct evsel *evsel) return evsel->tool_event != PERF_TOOL_NONE; } +static inline bool evsel__is_retire_lat(const struct evsel *evsel) +{ + return evsel->retire_lat; +} + const char *evsel__group_name(struct evsel *evsel); int evsel__group_desc(struct evsel *evsel, char *buf, size_t size); -- 2.43.0