From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (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 D902E43AC3; Sat, 6 Jul 2024 23:30:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720308607; cv=none; b=kfVYKuKb7wIjW0mmnXFN5FP8ana4jVxW1Dvlc2ZV/O6UZgNXWMNge6UAcqnwI5os24za0McUdrqRyFT0bgTki8y81OjyqTRZh4gHv/WZstm3EPeiILc6akU9wscL5bJu4V0YLUiX4n9w1QtcGecFdIO49GK6pUuK8PhfY/2kxPk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720308607; c=relaxed/simple; bh=UYxp0J5BBqmL4B6bO1B1wJ23uuONJPHgBsA/OrY61bc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bXPOMGwefFJ1TLkg9IxzrJohctPwyjTNx1iAPzRxxLVX4EpX0vYwdoY/sVNXa1v8TRaacHRdFCPQlluRX0jnify/tNmpjyrh66adGXvwOhQglLJI1FMV2uM549nMvsfXYNW3M6TTYxNwR2pCxfg6bB57c5MCMf2y7wy3QZNlXqk= 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=RjSNK/YC; arc=none smtp.client-ip=192.198.163.7 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="RjSNK/YC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1720308606; x=1751844606; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UYxp0J5BBqmL4B6bO1B1wJ23uuONJPHgBsA/OrY61bc=; b=RjSNK/YCTy9j0tybhSBsvC30agH0NmCKu+1qkiQtdkfOy2aByu+EPVg3 H3PRJo93hEXUDSpJG71yjlF/ab5HL4o71Fm+70p1rjDOCEY/R/y25UcOD GtlxXWs3MyMBAoRiMpjjjTyjf3JmDlwKSlIIRd5lvjkDeMt6JQDhNXuBh XtSJXFTQB/B0JFeh2Dkpk7UoiwEByMhsIidohNRnx447XSgfg08QtDUDC Bmn3VU1vwAyAMWOUaWNb8jYO48Bfqun65mG3fppWGLPj/qT2knxO9F5Tf y2oYDO3b59BXV+BbUECQNqqvsl1ONdziZT2PVjIOt6OzxCvwdFx3oeQ1U A==; X-CSE-ConnectionGUID: h/Ss//uDTri9Tiw4fq6Lfw== X-CSE-MsgGUID: /U6PaXWuQEa+HiBKGWK/gQ== X-IronPort-AV: E=McAfee;i="6700,10204,11125"; a="42971650" X-IronPort-AV: E=Sophos;i="6.09,188,1716274800"; d="scan'208";a="42971650" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2024 16:30:05 -0700 X-CSE-ConnectionGUID: /+wV3jSHSae4YGsGV2MTVQ== X-CSE-MsgGUID: MYMkh2jQSVGgoP3zfPUZ0g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,188,1716274800"; d="scan'208";a="78294841" Received: from fl31ca102ks0602.deacluster.intel.com (HELO gnr-bkc.deacluster.intel.com) ([10.75.133.163]) by fmviesa001.fm.intel.com with ESMTP; 06 Jul 2024 16:30: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 v16 4/8] perf stat: Plugin retire_lat value from sampled data to evsel Date: Sat, 6 Jul 2024 19:29:51 -0400 Message-ID: <20240706232956.304944-5-weilin.wang@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240706232956.304944-1-weilin.wang@intel.com> References: <20240706232956.304944-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 1d000fa2c6cf..d607056b73c9 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -59,6 +59,7 @@ #include #include #include +#include "util/intel-tpebs.h" #include @@ -1539,6 +1540,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) { @@ -1546,6 +1552,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; @@ -1838,6 +1850,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 14f777b9e03e..a5da4b03bb1c 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -311,6 +311,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