Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp136421lqp; Mon, 10 Jun 2024 22:31:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXzoZ64pbUGGQVM/qUuN9pWzojmt3tPowAhouFL7CV0e1WFsSerj71guHqQrNnPAmGqaH/Gth1RBwlLcGTF0f2mz85IUpvgMKHNJ9IQOw== X-Google-Smtp-Source: AGHT+IEZEIjHhP3aTzuD5G1M+TB9L/Xo5cp5NBjPEbMPUNIhKQcyAfuvcA0i/JnrSUJgoRUhtjBI X-Received: by 2002:a05:620a:248e:b0:795:15ed:1fcb with SMTP id af79cd13be357-7953c6ee86amr1378744085a.59.1718083907098; Mon, 10 Jun 2024 22:31:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718083907; cv=pass; d=google.com; s=arc-20160816; b=HYzkmZFCi0aAnK5lp82EbSHud1eS3HOGjXuTAAygVXXY+Fd37IPJS3ws1UPnpM9l7s 4iwH51zKZruV50X/qKIFfzPrr97RIX9+Cq1S7JAzB3Oy4kqWXh+zIrN2sYX1cfMX3z6B duS4IdRZ0jF6RVz1s8R9Oq8MPUxHCB97uhPKO4PkQp1wD/LBFNiJGfU21TkQroNtApoN eAzdZbSj96PLPwc67/VWlXehhnMvOuxo3Feg9GE/Veu0fO4XmMAExQoP57Hv6xuV5ta7 cO7iwVBM2VXhgaaFC7z0S0SqAOvOBnf4SiLt1U3A2tzOSLn1i45siFuCQTneoMQaioOH YWGw== 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=oLhvGzGA89Gn72ZgnjiFjoZC8A+844mOqlgOheBtYrY=; fh=7D8bWqELNqJM6KF7zbibUOya8038rGAdDMFXsJMRu8c=; b=ezPfUFgVudgTrLvQnMQFUdOkAURQeJHkAyzWM5h2iilwb11Qi9k6lcIYofx2wA6uVt CHIytQCaVf50GeL0QtcHqsuPiNUAs9mq79qdQZ0ZQqVsD6cLhUuRu3yJdNsrvCmxStds gS9aUGiSyfxFpY2UEdYC+pMsck1CYm/8n2uOFOnJANkctEPDG9HGV7CDozx1PKH4WU4G QghCo+NR4rvLWgVV8dw//K3Gfdp601DSzxbfO4d8CI2jRsLN/PMPnr6uqy8VZem0/2ko vnPmm6WdBGQF0LKTJEzqltHKKnrKcgRUu4jHcnKOFQlhT+hbD97s+JBKM1cwnk1HFCgu jzMQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fxdqEzhC; 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-209274-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209274-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-795331d0e0asi1315378685a.295.2024.06.10.22.31.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 22:31:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-209274-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fxdqEzhC; 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-209274-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209274-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id A18F51C23646 for ; Tue, 11 Jun 2024 05:31:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C9CE2173343; Tue, 11 Jun 2024 05:24:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="fxdqEzhC" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 2E48F171090; Tue, 11 Jun 2024 05:24:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718083448; cv=none; b=Up/Cz3jkPRfNHntSX+BhA1zap8rUoSFdbjWYd6LP2FctKkuWQvlEU2U1KR+d+dg10JLx7A6h1DR/9vIhtinVi/Pq8q4UEgS2gG/daEtZX6AnJOutHB20Do0JGGqj8eGGIS/cp4OklF2BM6uekZmKLMTJd+/Zu8vF0ZpajCAZE/4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718083448; c=relaxed/simple; bh=sbxT1spkya1gfXZM1JBab7vAzWLK6tZyzuJqwcb5Uhk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hOq6hxwg6nj1At72+vLq+veYHPHbIwJ+1xlDcQtufEtbe1Le7aXEr+wgy8CePWL9j7dTWZUYk39nbcQCeo6iK849/m9MUJMGwxGnHNnsLqZDJle2V8j2iOWzesmOfU+4wiJA5nt6inDf2dZjX7JjYzNI6x6eU1wwV/rDeDNAHI8= 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=fxdqEzhC; arc=none smtp.client-ip=192.198.163.17 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=1718083447; x=1749619447; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sbxT1spkya1gfXZM1JBab7vAzWLK6tZyzuJqwcb5Uhk=; b=fxdqEzhCbNtqWPy7bVmt1PXIjtHQny7+nqnQFtUsyjKqFTDqANzJVBhy I0T15YwJh3RfntBF/Mo77c2AXENbD6P8QRQGDsv0LLDI6LTt5DVUP0fGS DEx6PlxTcsb20oPXMX2LPAhSWlfuaeOhLuFIBWoSn6VkuDmOBIycSpmbp 4T+QGKzFnx1zpTGgT6MpeecC9zI5neHTv2aUaoiIIqUw2K/jOFSxKXF0F HY7pQDbHwHM6daWaeLLbgA+qsZjBZ8IZ31U8+x6CXiI5ILw9dOVd35ExC l4O1TyDBXqTJPHU2IxNMXgfYsmRqzskybP2PU6DZlzc2tCzAy4dysvFj7 g==; X-CSE-ConnectionGUID: uN72Mn3qQAmltSD/83rccg== X-CSE-MsgGUID: ApuD6bN7TaCm+yQO2VDuaA== X-IronPort-AV: E=McAfee;i="6600,9927,11099"; a="14651138" X-IronPort-AV: E=Sophos;i="6.08,229,1712646000"; d="scan'208";a="14651138" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2024 22:24:03 -0700 X-CSE-ConnectionGUID: JP0nYxn0QR6WIhNynsI+vQ== X-CSE-MsgGUID: OXU+0aLmTJ+tdp5kSd0ThA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,229,1712646000"; d="scan'208";a="44441198" Received: from fl31ca102ks0602.deacluster.intel.com (HELO gnr-bkc.deacluster.intel.com) ([10.75.133.163]) by orviesa004.jf.intel.com with ESMTP; 10 Jun 2024 22:24:04 -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 v12 4/8] perf stat: Plugin retire_lat value from sampled data to evsel Date: Tue, 11 Jun 2024 01:23:23 -0400 Message-ID: <20240611052331.85715-5-weilin.wang@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611052331.85715-1-weilin.wang@intel.com> References: <20240611052331.85715-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. No special metric calculation and event print out code required for retire_latency events. Signed-off-by: Weilin Wang --- tools/perf/arch/x86/util/evlist.c | 6 ++++++ tools/perf/util/evsel.c | 15 +++++++++++++++ tools/perf/util/evsel.h | 5 +++++ 3 files changed, 26 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 905096f16ce8..9f19feb28d21 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,11 @@ 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__read_retire_lat(struct evsel *evsel, int cpu_map_idx, int thread) +{ + return tpebs_set_evsel(evsel, cpu_map_idx, thread); +} + static void evsel__set_count(struct evsel *counter, int cpu_map_idx, int thread, u64 val, u64 ena, u64 run, u64 lost) { @@ -1530,6 +1536,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__read_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; @@ -1832,6 +1844,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__read_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