From nobody Fri Nov 29 23:49:15 2024 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 2155E1448DC; Fri, 13 Sep 2024 05:21:13 +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=1726204875; cv=none; b=UaELfohJLJaTLjRwJcu5DFXlYqgMZWJsDesYjPVtMJxHorI2OTMCoxshJiu4lGxXjZX/CySNa8KYV64QK9aXwsgQoNPpvcfJFk1M6pRm0/BBn+ugJBS9/lKgwAnv7eL5YAM+kJGzF0V/z97GW5fqfuoBpibu8ZmmAXC+eC9c4MI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726204875; c=relaxed/simple; bh=OPRO3Ck5Mv9JVxsIkE9GdKaKnw+uc3sa72LXbE7ZSHc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JoFhtYQcn6DrVsUA2pEwoMbBiWIHaFG5OAaDHX5O80NBt24uVf0LhTh8dvs4MpMxSp9ze9OJC+SR4tsh+zHUGAxQWVyKZObw71iMuag7WeH59P46Dg7DK5VxnjmV7jis+5Bf5K5F1YWB5M0CuYUT4iiG28dWGxYqowpi6tdwukw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=lGp6q++U; arc=none smtp.client-ip=192.198.163.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="lGp6q++U" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1726204874; x=1757740874; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OPRO3Ck5Mv9JVxsIkE9GdKaKnw+uc3sa72LXbE7ZSHc=; b=lGp6q++UYWB4BHdSReBQ4MtAhXgJETNujjuXt42Z56Wd1GIgyvKQ7vmF rReV3nhflvga0mglBxHHVJgXUJV/1DiT3LShZGksloALEnae2WaffmRvz vHPUvnxpg3wCXBkhAnXBQKlMDymRD7XaX+Og3lTISpXoO5xfZ7WXZPseE nWVjDoYoLJzByj3G6Z/HXHOLaVOaYPQKo06DUGJ2wh9KPfy53FNWeed9+ 2iCgKGr/4L+o92u6J70gPL5XdLu0/JECqGK5Z0+IZLC6j3d7IM2bsV7po WIsRFA6f53ldHqzik5jQ8E3kPRgEQNJrGh6pWtphOI+ZfZWZBnyYHpR7U w==; X-CSE-ConnectionGUID: KIEEb37YT+a+itoRdfI8hw== X-CSE-MsgGUID: GyadPeUzQW60y/jqnu2KlA== X-IronPort-AV: E=McAfee;i="6700,10204,11193"; a="24967762" X-IronPort-AV: E=Sophos;i="6.10,225,1719903600"; d="scan'208";a="24967762" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2024 22:21:13 -0700 X-CSE-ConnectionGUID: WVUgNk4fQoinykkXgtan6Q== X-CSE-MsgGUID: ZNgjLrlNTCqqhhw3flA/0A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,225,1719903600"; d="scan'208";a="67900597" Received: from emr.sh.intel.com ([10.112.229.56]) by fmviesa009.fm.intel.com with ESMTP; 12 Sep 2024 22:21:10 -0700 From: Dapeng Mi To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , Adrian Hunter , Alexander Shishkin , Kan Liang Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Yongwei Ma , Dapeng Mi , Dapeng Mi Subject: [Patch v5 1/6] perf x86/topdown: Complete topdown slots/metrics events check Date: Fri, 13 Sep 2024 08:47:07 +0000 Message-Id: <20240913084712.13861-2-dapeng1.mi@linux.intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240913084712.13861-1-dapeng1.mi@linux.intel.com> References: <20240913084712.13861-1-dapeng1.mi@linux.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: quoted-printable Content-Type: text/plain; charset="utf-8" It's not complete to check whether an event is a topdown slots or topdown metrics event by only comparing the event name since user may assign the event by RAW format, e.g. perf stat -e '{instructions,cpu/r400/,cpu/r8300/}' sleep 1 Performance counter stats for 'sleep 1': instructions cpu/r400/ cpu/r8300/ 1.002917796 seconds time elapsed 0.002955000 seconds user 0.000000000 seconds sys The RAW format slots and topdown-be-bound events are not recognized and not regroup the events, and eventually cause error. Thus add two helpers arch_is_topdown_slots()/arch_is_topdown_metrics() to detect whether an event is topdown slots/metrics event by comparing the event config directly, and use these two helpers to replace the original event name comparisons. Reviewed-by: Kan Liang Signed-off-by: Dapeng Mi Tested-by: Kan Liang --- tools/perf/arch/x86/util/evlist.c | 8 ++--- tools/perf/arch/x86/util/evsel.c | 3 +- tools/perf/arch/x86/util/topdown.c | 48 +++++++++++++++++++++++++++++- tools/perf/arch/x86/util/topdown.h | 2 ++ 4 files changed, 55 insertions(+), 6 deletions(-) diff --git a/tools/perf/arch/x86/util/evlist.c b/tools/perf/arch/x86/util/e= vlist.c index cebdd483149e..79799865a62a 100644 --- a/tools/perf/arch/x86/util/evlist.c +++ b/tools/perf/arch/x86/util/evlist.c @@ -78,14 +78,14 @@ int arch_evlist__cmp(const struct evsel *lhs, const str= uct evsel *rhs) if (topdown_sys_has_perf_metrics() && (arch_evsel__must_be_in_group(lhs) || arch_evsel__must_be_in_group(rh= s))) { /* Ensure the topdown slots comes first. */ - if (strcasestr(lhs->name, "slots") && !strcasestr(lhs->name, "uops_retir= ed.slots")) + if (arch_is_topdown_slots(lhs)) return -1; - if (strcasestr(rhs->name, "slots") && !strcasestr(rhs->name, "uops_retir= ed.slots")) + if (arch_is_topdown_slots(rhs)) return 1; /* Followed by topdown events. */ - if (strcasestr(lhs->name, "topdown") && !strcasestr(rhs->name, "topdown"= )) + if (arch_is_topdown_metrics(lhs) && !arch_is_topdown_metrics(rhs)) return -1; - if (!strcasestr(lhs->name, "topdown") && strcasestr(rhs->name, "topdown"= )) + if (!arch_is_topdown_metrics(lhs) && arch_is_topdown_metrics(rhs)) return 1; } =20 diff --git a/tools/perf/arch/x86/util/evsel.c b/tools/perf/arch/x86/util/ev= sel.c index 090d0f371891..181f2ba0bb2a 100644 --- a/tools/perf/arch/x86/util/evsel.c +++ b/tools/perf/arch/x86/util/evsel.c @@ -6,6 +6,7 @@ #include "util/pmu.h" #include "util/pmus.h" #include "linux/string.h" +#include "topdown.h" #include "evsel.h" #include "util/debug.h" #include "env.h" @@ -44,7 +45,7 @@ bool arch_evsel__must_be_in_group(const struct evsel *evs= el) strcasestr(evsel->name, "uops_retired.slots")) return false; =20 - return strcasestr(evsel->name, "topdown") || strcasestr(evsel->name, "slo= ts"); + return arch_is_topdown_metrics(evsel) || arch_is_topdown_slots(evsel); } =20 int arch_evsel__hw_name(struct evsel *evsel, char *bf, size_t size) diff --git a/tools/perf/arch/x86/util/topdown.c b/tools/perf/arch/x86/util/= topdown.c index 3f9a267d4501..49f25d67ed77 100644 --- a/tools/perf/arch/x86/util/topdown.c +++ b/tools/perf/arch/x86/util/topdown.c @@ -32,6 +32,52 @@ bool topdown_sys_has_perf_metrics(void) } =20 #define TOPDOWN_SLOTS 0x0400 +bool arch_is_topdown_slots(const struct evsel *evsel) +{ + if (evsel->core.attr.config =3D=3D TOPDOWN_SLOTS) + return true; + + return false; +} + +static int compare_topdown_event(void *vstate, struct pmu_event_info *info) +{ + int *config =3D vstate; + int event =3D 0; + int umask =3D 0; + char *str; + + if (!strcasestr(info->name, "topdown")) + return 0; + + str =3D strcasestr(info->str, "event=3D"); + if (str) + sscanf(str, "event=3D%x", &event); + + str =3D strcasestr(info->str, "umask=3D"); + if (str) + sscanf(str, "umask=3D%x", &umask); + + if (event =3D=3D 0 && *config =3D=3D (event | umask << 8)) + return 1; + + return 0; +} + +bool arch_is_topdown_metrics(const struct evsel *evsel) +{ + struct perf_pmu *pmu =3D evsel__find_pmu(evsel); + int config =3D evsel->core.attr.config; + + if (!pmu || !pmu->is_core) + return false; + + if (perf_pmu__for_each_event(pmu, false, &config, + compare_topdown_event)) + return true; + + return false; +} =20 /* * Check whether a topdown group supports sample-read. @@ -44,7 +90,7 @@ bool arch_topdown_sample_read(struct evsel *leader) if (!evsel__sys_has_perf_metrics(leader)) return false; =20 - if (leader->core.attr.config =3D=3D TOPDOWN_SLOTS) + if (arch_is_topdown_slots(leader)) return true; =20 return false; diff --git a/tools/perf/arch/x86/util/topdown.h b/tools/perf/arch/x86/util/= topdown.h index 46bf9273e572..1bae9b1822d7 100644 --- a/tools/perf/arch/x86/util/topdown.h +++ b/tools/perf/arch/x86/util/topdown.h @@ -3,5 +3,7 @@ #define _TOPDOWN_H 1 =20 bool topdown_sys_has_perf_metrics(void); +bool arch_is_topdown_slots(const struct evsel *evsel); +bool arch_is_topdown_metrics(const struct evsel *evsel); =20 #endif --=20 2.40.1 From nobody Fri Nov 29 23:49:15 2024 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 E6838184554; Fri, 13 Sep 2024 05:21:17 +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=1726204879; cv=none; b=FFg33ihEKV6iW1wOKaWhBsle4DoQLqGK39LO/kKdwG5SR2kw0RlcXmTwVZd2c67dne6jJ4X/7QPaDyN1T+L/vlvIRiePQgElcVqUS9yeam7Yp1ELosRMQPAFdQ/PpJh+vGZ91uY0UIOUg+cpedX6VCBq4unCD1zt192SgUcGue0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726204879; c=relaxed/simple; bh=tRBWtr+Ykv1pX7SwVvMQenMWtsUgyxfpeNeMo8gPmPA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=J/pVVe+AYU8pLpcbILu5/O/FbNwlWFxJqB5fPTmm8S3N7HZBtFtIgD80qM3D8J2ytqbv4CuDdfWIOH5gnx+cwUpOtPJJVcIqXc1AmwQOhp5kdNU70hvTzPkwq8/jtJnsNDCZ9C30cXl34duXA4OiFEKNL/2mQdYlmuJJyiplh20= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=GrJJJyeM; arc=none smtp.client-ip=192.198.163.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="GrJJJyeM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1726204878; x=1757740878; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tRBWtr+Ykv1pX7SwVvMQenMWtsUgyxfpeNeMo8gPmPA=; b=GrJJJyeMVeBoJnz1vAeKKZ+9ZEzxGIrp7A5TllfYUR9NSLZFR4ZQ/sUm 53fBllXezgE0D3n1G7CKUh5cShKkBBQngE0QaiOIWTlRGQOQbM+b0N/zo v3ArJKtTZqtbCFQKqWeR6pusAgq3Oru2Gz3KpuRWB1jcRG/zQTMoGWejM cwnJ+8eBdFwVUmTj66bxFa7r60iAYr2g0o5W+frf7e79R2/XkiBHk3Aje uqN/JimRvyp0Tr+JW8H9ANW8vTu38FuDXEBkVnGlJWuUegOngEEzjoZdT pmrt37ORHg9JfdbOngqssIMwtxUMkV+qKzWUBMfwQ9twKPFtvkBPmJ4a5 Q==; X-CSE-ConnectionGUID: 7Ti/b/7oQ3GTRRS2asJJWw== X-CSE-MsgGUID: 5OXTcTWETw+dLqgMVkFGFA== X-IronPort-AV: E=McAfee;i="6700,10204,11193"; a="24967768" X-IronPort-AV: E=Sophos;i="6.10,225,1719903600"; d="scan'208";a="24967768" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2024 22:21:16 -0700 X-CSE-ConnectionGUID: LNljV9ZKQkyH1lGI5wtrXQ== X-CSE-MsgGUID: wB6f+7XjSxKFSkn+QIzOFA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,225,1719903600"; d="scan'208";a="67900608" Received: from emr.sh.intel.com ([10.112.229.56]) by fmviesa009.fm.intel.com with ESMTP; 12 Sep 2024 22:21:13 -0700 From: Dapeng Mi To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , Adrian Hunter , Alexander Shishkin , Kan Liang Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Yongwei Ma , Dapeng Mi , Dapeng Mi Subject: [Patch v5 2/6] perf x86/topdown: Correct leader selection with sample_read enabled Date: Fri, 13 Sep 2024 08:47:08 +0000 Message-Id: <20240913084712.13861-3-dapeng1.mi@linux.intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240913084712.13861-1-dapeng1.mi@linux.intel.com> References: <20240913084712.13861-1-dapeng1.mi@linux.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: quoted-printable Content-Type: text/plain; charset="utf-8" Addresses an issue where, in the absence of a topdown metrics event within a sampling group, the slots event was incorrectly bypassed as the sampling leader when sample_read was enabled. perf record -e '{slots,branches}:S' -c 10000 -vv sleep 1 In this case, the slots event should be sampled as leader but the branches event is sampled in fact like the verbose output shows. perf_event_attr: type 4 (cpu) size 168 config 0x400 (slots) sample_type IP|TID|TIME|READ|CPU|IDENTIFIER read_format ID|GROUP|LOST disabled 1 sample_id_all 1 exclude_guest 1 Reviewed-by: Kan Liang Tested-by: Kan Liang ------------------------------------------------------------ sys_perf_event_open: pid -1 cpu 0 group_fd -1 flags 0x8 =3D 5 ------------------------------------------------------------ perf_event_attr: type 0 (PERF_TYPE_HARDWARE) size 168 config 0x4 (PERF_COUNT_HW_BRANCH_INSTRUCTIONS) { sample_period, sample_freq } 10000 sample_type IP|TID|TIME|READ|CPU|IDENTIFIER read_format ID|GROUP|LOST sample_id_all 1 exclude_guest 1 The sample period of slots event instead of branches event is reset to 0. This fix ensures the slots event remains the leader under these conditions. Reviewed-by: Kan Liang Signed-off-by: Dapeng Mi --- tools/perf/arch/x86/util/topdown.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tools/perf/arch/x86/util/topdown.c b/tools/perf/arch/x86/util/= topdown.c index 49f25d67ed77..cb2c64928bc4 100644 --- a/tools/perf/arch/x86/util/topdown.c +++ b/tools/perf/arch/x86/util/topdown.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include "api/fs/fs.h" #include "util/evsel.h" +#include "util/evlist.h" #include "util/pmu.h" #include "util/pmus.h" #include "util/topdown.h" @@ -87,11 +88,24 @@ bool arch_is_topdown_metrics(const struct evsel *evsel) */ bool arch_topdown_sample_read(struct evsel *leader) { + struct evsel *evsel; + if (!evsel__sys_has_perf_metrics(leader)) return false; =20 - if (arch_is_topdown_slots(leader)) - return true; + if (!arch_is_topdown_slots(leader)) + return false; + + /* + * If slots event as leader event but no topdown metric events + * in group, slots event should still sample as leader. + */ + evlist__for_each_entry(leader->evlist, evsel) { + if (evsel->core.leader !=3D leader->core.leader) + return false; + if (evsel !=3D leader && arch_is_topdown_metrics(evsel)) + return true; + } =20 return false; } --=20 2.40.1 From nobody Fri Nov 29 23:49:15 2024 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 D6C30185B63; Fri, 13 Sep 2024 05:21:19 +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=1726204881; cv=none; b=UM/sre4FpN5R0/polzfPO/q+qGcEUJz0TkTzoUF5tK9fuKNEVqTECsbvOH+pUsIzGMvVFwJJw2dwMdbOedePW58PqH3Efzn8/ssJ582Wb/B/9OLQFhsa9zY08CNupTEruCgBHTj3a/OJMLjVeJX+QH4bkul/i/4JsM1SUIAK5Jg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726204881; c=relaxed/simple; bh=2572e8cA8yYZXkLcO7kKy729URDqdzFhdFRm2F+ltfg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WIPqZtYfm/W7fb27ZnL93iZS+80Akgnr9qfEkaO+Z9I21cC9k1jBsRXZ6EUL7cULNhtyXJjGXZC9rSYuD81DtBV4uIKhTBIz5s92ueILm+0HnjqT+La2wLBGuz+h4OIvoZOeiO+HerKzs4LoJc68lSG9l7BM8yGdKB2b5qY3o/c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=F+iaMqtd; arc=none smtp.client-ip=192.198.163.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="F+iaMqtd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1726204880; x=1757740880; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2572e8cA8yYZXkLcO7kKy729URDqdzFhdFRm2F+ltfg=; b=F+iaMqtd2VoTRvXtMppVDibnMlzr4psQI4mldGKOjuTGsdDD3TxvaNFI 6lGb5ivwpZTewFKhGLAvacwCKwaBBLSPiegpVRiPrFeksXN+zqv+E7kRz IX3xlPxI/w1+W2EyPbXdNb0hdwgeuCUkRNE4zjkvVVjEOHMCQllBodOLx o5OQi/zF6tn78zY4qAH0jSvjTAqtuEkfkT+c6Ns6fmMJNeH1uqUw94vIg Gbem74LFRpPvRCmfkTHRFyzYn+tJIEqEXGIFicBSrOwUnyBIWvV+xJ4w0 TCs6N7ZpZrspvy4ZfzLVwtI3hfk3AiNUPHyPC3kGF3YflRXe94tZv8FCZ w==; X-CSE-ConnectionGUID: rUkF32NhSiaFN6rNqHB94w== X-CSE-MsgGUID: x6zZv63tR4OE0UTf0213IQ== X-IronPort-AV: E=McAfee;i="6700,10204,11193"; a="24967779" X-IronPort-AV: E=Sophos;i="6.10,225,1719903600"; d="scan'208";a="24967779" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2024 22:21:19 -0700 X-CSE-ConnectionGUID: GtlSinzGR/CPGB4YAOHiXg== X-CSE-MsgGUID: wyy9aAO9TGydqgoCjIZ4Sw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,225,1719903600"; d="scan'208";a="67900617" Received: from emr.sh.intel.com ([10.112.229.56]) by fmviesa009.fm.intel.com with ESMTP; 12 Sep 2024 22:21:16 -0700 From: Dapeng Mi To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , Adrian Hunter , Alexander Shishkin , Kan Liang Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Yongwei Ma , Dapeng Mi , Dapeng Mi Subject: [Patch v5 3/6] perf x86/topdown: Don't move topdown metric events in group Date: Fri, 13 Sep 2024 08:47:09 +0000 Message-Id: <20240913084712.13861-4-dapeng1.mi@linux.intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240913084712.13861-1-dapeng1.mi@linux.intel.com> References: <20240913084712.13861-1-dapeng1.mi@linux.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: quoted-printable Content-Type: text/plain; charset="utf-8" when running below perf command, we say error is reported. perf record -e "{slots,instructions,topdown-retiring}:S" -vv -C0 sleep 1 Reviewed-by: Kan Liang Tested-by: Kan Liang ------------------------------------------------------------ perf_event_attr: type 4 (cpu) size 168 config 0x400 (slots) sample_type IP|TID|TIME|READ|CPU|PERIOD|IDENTIFIER read_format ID|GROUP|LOST disabled 1 sample_id_all 1 exclude_guest 1 ------------------------------------------------------------ sys_perf_event_open: pid -1 cpu 0 group_fd -1 flags 0x8 =3D 5 ------------------------------------------------------------ perf_event_attr: type 4 (cpu) size 168 config 0x8000 (topdown-retiring) { sample_period, sample_freq } 4000 sample_type IP|TID|TIME|READ|CPU|PERIOD|IDENTIFIER read_format ID|GROUP|LOST freq 1 sample_id_all 1 exclude_guest 1 ------------------------------------------------------------ sys_perf_event_open: pid -1 cpu 0 group_fd 5 flags 0x8 sys_perf_event_open failed, error -22 Error: The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (topdown-retiring). The reason of error is that the events are regrouped and topdown-retiring event is moved to closely after the slots event and topdown-retiring event needs to do the sampling, but Intel PMU driver doesn't support to sample topdown metrics events. For topdown metrics events, it just requires to be in a group which has slots event as leader. It doesn't require topdown metrics event must be closely after slots event. Thus it's a overkill to move topdown metrics event closely after slots event in events regrouping and furtherly cause the above issue. Thus don't move topdown metrics events forward if they are already in a group. Reviewed-by: Kan Liang Signed-off-by: Dapeng Mi --- tools/perf/arch/x86/util/evlist.c | 62 ++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/tools/perf/arch/x86/util/evlist.c b/tools/perf/arch/x86/util/e= vlist.c index 79799865a62a..20b4f3c2afa3 100644 --- a/tools/perf/arch/x86/util/evlist.c +++ b/tools/perf/arch/x86/util/evlist.c @@ -75,6 +75,61 @@ int arch_evlist__add_default_attrs(struct evlist *evlist, =20 int arch_evlist__cmp(const struct evsel *lhs, const struct evsel *rhs) { + /* + * Currently the following topdown events sequence are supported to + * move and regroup correctly. + * + * a. all events in a group + * perf stat -e "{instructions,topdown-retiring,slots}" -C0 sleep 1 + * WARNING: events were regrouped to match PMUs + * Performance counter stats for 'CPU(s) 0': + * 15,066,240 slots + * 1,899,760 instructions + * 2,126,998 topdown-retiring + * b. all events not in a group + * perf stat -e "instructions,topdown-retiring,slots" -C0 sleep 1 + * WARNING: events were regrouped to match PMUs + * Performance counter stats for 'CPU(s) 0': + * 2,045,561 instructions + * 17,108,370 slots + * 2,281,116 topdown-retiring + * c. slots event in a group but topdown metrics events outside the group + * perf stat -e "{instructions,slots},topdown-retiring" -C0 sleep 1 + * WARNING: events were regrouped to match PMUs + * Performance counter stats for 'CPU(s) 0': + * 20,323,878 slots + * 2,634,884 instructions + * 3,028,656 topdown-retiring + * d. slots event and topdown metrics events in two groups + * perf stat -e "{instructions,slots},{topdown-retiring}" -C0 sleep 1 + * WARNING: events were regrouped to match PMUs + * Performance counter stats for 'CPU(s) 0': + * 26,319,024 slots + * 2,427,791 instructions + * 2,683,508 topdown-retiring + * + * If slots event and topdown metrics events are not in same group, the + * topdown metrics events must be first event after the slots event group, + * otherwise topdown metrics events can't be regrouped correctly, e.g. + * + * a. perf stat -e "{instructions,slots},cycles,topdown-retiring" -C0 sle= ep 1 + * WARNING: events were regrouped to match PMUs + * Performance counter stats for 'CPU(s) 0': + * 17,923,134 slots + * 2,154,855 instructions + * 3,015,058 cycles + * topdown-retiring + * + * if slots event and topdown metrics events are in two groups, the group= which + * has topdown metrics events must contain only the topdown metrics event, + * otherwise topdown metrics event can't be regrouped correctly as well, = e.g. + * + * a. perf stat -e "{instructions,slots},{topdown-retiring,cycles}" -C0 s= leep 1 + * WARNING: events were regrouped to match PMUs + * Error: + * The sys_perf_event_open() syscall returned with 22 (Invalid argumen= t) for + * event (topdown-retiring) + */ if (topdown_sys_has_perf_metrics() && (arch_evsel__must_be_in_group(lhs) || arch_evsel__must_be_in_group(rh= s))) { /* Ensure the topdown slots comes first. */ @@ -85,7 +140,12 @@ int arch_evlist__cmp(const struct evsel *lhs, const str= uct evsel *rhs) /* Followed by topdown events. */ if (arch_is_topdown_metrics(lhs) && !arch_is_topdown_metrics(rhs)) return -1; - if (!arch_is_topdown_metrics(lhs) && arch_is_topdown_metrics(rhs)) + /* + * Move topdown events forward only when topdown events + * are not in same group with previous event. + */ + if (!arch_is_topdown_metrics(lhs) && arch_is_topdown_metrics(rhs) && + lhs->core.leader !=3D rhs->core.leader) return 1; } =20 --=20 2.40.1 From nobody Fri Nov 29 23:49:15 2024 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 A1B4818BC20; Fri, 13 Sep 2024 05:21:23 +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=1726204885; cv=none; b=oDknOgUDQgi1UZhmJkYNoZfQ1H0mLEssgO6fDOWp1kdYZmhoQupvS9wOk1HorOH8eLFsck+2dGbxYeG+/7vf1RuEb8+kr5uiGuqRkLeGflWNVk9WRAQsckZ0KrbbJlfZnuMQAyOhZNjbOzvGM1DKRDmCeBebkN6YAx2YKOyMIGM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726204885; c=relaxed/simple; bh=M4wZMTQkeHr562pePJNnwyLBEOJd2PtzhwbjMGz+bu8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nzpw09JnlooPz6rw4fdjt6idtrSmf3Voc7RqGXRWsDhrLy7/cQtzpuk3QVbwpu0V/tNn1qxGcGHR4W8xz6k8P+7ExFo3/spg/HkFhiJMoA3c/x9wx4CAShKQhGoFch83e36Lo8XRwWI39DkvQyEcQpmJbB7on8pDFI/Z/n0viCE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=CreoeVY+; arc=none smtp.client-ip=192.198.163.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="CreoeVY+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1726204883; x=1757740883; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=M4wZMTQkeHr562pePJNnwyLBEOJd2PtzhwbjMGz+bu8=; b=CreoeVY+lJAUkPIfiP70WjMx7GZJyQ5Qrv7gr+iffRTIEqetsEyn4dLT Ab/4os0TjJhC2Mht6eSg4NARgwtNh2LLbT/S40TiU1AmpDl5I+4jYH7tN RMQDs1ri5GN6AMM5ZmTj++sGLeDgpne03D2PcAtY2ImHHmeokc/h1jSAv VBJP1Tkc5gNrMD8BrHnJQAJOmYL8ySfaYfo70GNwyVkgAgiRv3figN0EG orA/c3PoUftTxBMpOXSDrF5w37pwvkHG0u4bstoL1BopcCOlh59skedbc D1M/+sDRzK3juYDldgjquk+46dn+FS0gRMo+riKlL2ejI9/+maC242HTa A==; X-CSE-ConnectionGUID: bPo4HzKGSuKf1u5ICC1VIA== X-CSE-MsgGUID: 3ap0+d6ORue9IrQJ7zzjEQ== X-IronPort-AV: E=McAfee;i="6700,10204,11193"; a="24967786" X-IronPort-AV: E=Sophos;i="6.10,225,1719903600"; d="scan'208";a="24967786" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2024 22:21:22 -0700 X-CSE-ConnectionGUID: 9pLGOrNBSjGOuNPYuXBzbg== X-CSE-MsgGUID: XlJYMd44SkWVrvmdSdbebg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,225,1719903600"; d="scan'208";a="67900627" Received: from emr.sh.intel.com ([10.112.229.56]) by fmviesa009.fm.intel.com with ESMTP; 12 Sep 2024 22:21:19 -0700 From: Dapeng Mi To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , Adrian Hunter , Alexander Shishkin , Kan Liang Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Yongwei Ma , Dapeng Mi , Dapeng Mi Subject: [Patch v5 4/6] perf tests: Add leader sampling test in record tests Date: Fri, 13 Sep 2024 08:47:10 +0000 Message-Id: <20240913084712.13861-5-dapeng1.mi@linux.intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240913084712.13861-1-dapeng1.mi@linux.intel.com> References: <20240913084712.13861-1-dapeng1.mi@linux.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: quoted-printable Content-Type: text/plain; charset="utf-8" Add leader sampling test to validate event counts are captured into record and the count value is consistent. Suggested-by: Kan Liang Reviewed-by: Kan Liang Signed-off-by: Dapeng Mi Tested-by: Kan Liang --- tools/perf/tests/shell/record.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/reco= rd.sh index 048078ee2eca..45baf7910640 100755 --- a/tools/perf/tests/shell/record.sh +++ b/tools/perf/tests/shell/record.sh @@ -17,6 +17,7 @@ skip_test_missing_symbol ${testsym} =20 err=3D0 perfdata=3D$(mktemp /tmp/__perf_test.perf.data.XXXXX) +script_output=3D$(mktemp /tmp/__perf_test.perf.data.XXXXX.script) testprog=3D"perf test -w thloop" cpu_pmu_dir=3D"/sys/bus/event_source/devices/cpu*" br_cntr_file=3D"/caps/branch_counter_nr" @@ -228,6 +229,32 @@ test_cgroup() { echo "Cgroup sampling test [Success]" } =20 +test_leader_sampling() { + echo "Basic leader sampling test" + if ! perf record -o "${perfdata}" -e "{branches,branches}:Su" perf test = -w brstack 2> /dev/null + then + echo "Leader sampling [Failed record]" + err=3D1 + return + fi + index=3D0 + perf script -i "${perfdata}" > $script_output + while IFS=3D read -r line + do + # Check if the two branches counts are equal in each record + branches=3D$(echo $line | awk '{for(i=3D1;i<=3DNF;i++) if($i=3D=3D"bra= nches:") print $(i-1)}') + if [ $(($index%2)) -ne 0 ] && [ ${branches}x !=3D ${prev_branches}x ] + then + echo "Leader sampling [Failed inconsistent branches count]" + err=3D1 + return + fi + index=3D$(($index+1)) + prev_branches=3D$branches + done < $script_output + echo "Basic leader sampling test [Success]" +} + # raise the limit of file descriptors to minimum if [[ $default_fd_limit -lt $min_fd_limit ]]; then ulimit -Sn $min_fd_limit @@ -239,6 +266,7 @@ test_system_wide test_workload test_branch_counter test_cgroup +test_leader_sampling =20 # restore the default value ulimit -Sn $default_fd_limit --=20 2.40.1 From nobody Fri Nov 29 23:49:15 2024 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 B220C1AB6CB; Fri, 13 Sep 2024 05:21:25 +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=1726204887; cv=none; b=EcrB6my/8l6JGtt7xjrPuA8N6Bo3nQUO3O+XFLvV9W8k3C4uzIHCm7LjiYG6RX1uBYQf6Bn1uQ6G/H31FEg8c1S+P1NjlRCiznlkOpC2IPjKRjwrvxCvnt246I85a65feyKVvobWv3duFsop2VNNwKmQWN6AFr4qDxVRTAQVasU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726204887; c=relaxed/simple; bh=C2ZvJpwCXSNILnFYconCFl+Fj+d2lFtFpfu8vJOxExY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ImoT4LwU7bnoXtHNx90poynvKEybJkHK6u3On+wqyCquEjYZAHqs6qinAWtCMFrRrwG91Ej7lgwR0waaU4mOMH3EUxZVt92HAG1f/bunyX/9XPEvRpI/0AxlkDk7MzMt1PWyKZ017TSZRXm3MVNLTpGrntuL9Vd+wIc/EuhfKaU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=IjM7k1kR; arc=none smtp.client-ip=192.198.163.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="IjM7k1kR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1726204885; x=1757740885; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=C2ZvJpwCXSNILnFYconCFl+Fj+d2lFtFpfu8vJOxExY=; b=IjM7k1kRc+IhwfA0q1h5H9YGiSGKzQ6k9iQMZQZMKPwNTa+VtN/qoORY YOxhAQXEB6Mqj//F8XCb8BsxuJfvXAlH1JtkmK8eV+mESV919McLREDiQ kCen6WdOvC5CcOABXli4xivFSpvFLnY2gKI6k8QQB+gayhF+J4wIN2LIg hj4kGFA2zW+WHoRmHZNpd4yXmV89W+viuz8Afba77/LKz9iqDiT8tQmi2 UIa7Mi+ksj5JGwaM/z1IdSONQA5KQOJPw4PYiw81Cz8feKRCBh6ymFjFT spVyu8i5KUGV1lbwQtejBIqYamxSUbmMjrHnkZkR6Xyl2P/uyKJ7cqE2M w==; X-CSE-ConnectionGUID: A6LOyVA+Q02dOs6f595iaw== X-CSE-MsgGUID: 4dh02ZziR1qFIPlZJbYpcQ== X-IronPort-AV: E=McAfee;i="6700,10204,11193"; a="24967794" X-IronPort-AV: E=Sophos;i="6.10,225,1719903600"; d="scan'208";a="24967794" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2024 22:21:25 -0700 X-CSE-ConnectionGUID: ujdnykkeQeOSnSe+OkYNUw== X-CSE-MsgGUID: 4Pm5oCasQX2V/OJvsSyXkw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,225,1719903600"; d="scan'208";a="67900636" Received: from emr.sh.intel.com ([10.112.229.56]) by fmviesa009.fm.intel.com with ESMTP; 12 Sep 2024 22:21:22 -0700 From: Dapeng Mi To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , Adrian Hunter , Alexander Shishkin , Kan Liang Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Yongwei Ma , Dapeng Mi , Dapeng Mi Subject: [Patch v5 5/6] perf tests: Add topdown events counting and sampling tests Date: Fri, 13 Sep 2024 08:47:11 +0000 Message-Id: <20240913084712.13861-6-dapeng1.mi@linux.intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240913084712.13861-1-dapeng1.mi@linux.intel.com> References: <20240913084712.13861-1-dapeng1.mi@linux.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: quoted-printable Content-Type: text/plain; charset="utf-8" Add counting and leader sampling tests to verify topdown events including raw format can be reordered correctly. Reviewed-by: Kan Liang Signed-off-by: Dapeng Mi Tested-by: Kan Liang --- tools/perf/tests/shell/record.sh | 17 +++++++++++++++++ tools/perf/tests/shell/stat.sh | 6 ++++++ 2 files changed, 23 insertions(+) diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/reco= rd.sh index 45baf7910640..8d6366d96883 100755 --- a/tools/perf/tests/shell/record.sh +++ b/tools/perf/tests/shell/record.sh @@ -255,6 +255,22 @@ test_leader_sampling() { echo "Basic leader sampling test [Success]" } =20 +test_topdown_leader_sampling() { + echo "Topdown leader sampling test" + if ! perf stat -e "{slots,topdown-retiring}" true 2> /dev/null + then + echo "Topdown leader sampling [Skipped event parsing failed]" + return + fi + if ! perf record -o "${perfdata}" -e "{instructions,slots,topdown-retiri= ng}:S" true 2> /dev/null + then + echo "Topdown leader sampling [Failed topdown events not reordered cor= rectly]" + err=3D1 + return + fi + echo "Topdown leader sampling test [Success]" +} + # raise the limit of file descriptors to minimum if [[ $default_fd_limit -lt $min_fd_limit ]]; then ulimit -Sn $min_fd_limit @@ -267,6 +283,7 @@ test_workload test_branch_counter test_cgroup test_leader_sampling +test_topdown_leader_sampling =20 # restore the default value ulimit -Sn $default_fd_limit diff --git a/tools/perf/tests/shell/stat.sh b/tools/perf/tests/shell/stat.sh index 3f1e67795490..092a7a2abcf8 100755 --- a/tools/perf/tests/shell/stat.sh +++ b/tools/perf/tests/shell/stat.sh @@ -79,6 +79,12 @@ test_topdown_groups() { err=3D1 return fi + if perf stat -e '{instructions,r400,r8000}' true 2>&1 | grep -E -q "" + then + echo "Topdown event group test [Failed raw format slots not reordered = first]" + err=3D1 + return + fi echo "Topdown event group test [Success]" } =20 --=20 2.40.1 From nobody Fri Nov 29 23:49:15 2024 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 AC0851BA292; Fri, 13 Sep 2024 05:21:28 +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=1726204891; cv=none; b=dJXH/czE4qRL1IwAtQoc5DrAP+Ve0nNfoJG3z0QD8AcZqcvgjiJ5JUOXs16d7sqM/V7FCwuYW4ScJGB9HFFgRujgj/V0XT9bHuZgFLee83w+NJqaYN+ZI5sPKnd5io+1WBut/IrHeKrIX4xnIwdjnPofwb1MakA0uOKUzWjvtw0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726204891; c=relaxed/simple; bh=ny5tsc2816HdyNr0QPIRAAn/tx+IdHcJgx2i9LCmDBI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OB7dWWj0WadsQrnoYAFmNXmERQXIh9MOX+YX3ceb6MqrpgnJUlN41a9AcXmnTj1+31f9RYEccPnBVh6OobzUDEe/qEmqGHEpedZMeU8KTOspMG+1jPH6ZdLZQr9Wm0f9CpHOUlUYajL5MCDnhYlSBtvgBud/MB/qj3wBvjwfi78= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=RnFMqbIg; arc=none smtp.client-ip=192.198.163.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="RnFMqbIg" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1726204889; x=1757740889; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ny5tsc2816HdyNr0QPIRAAn/tx+IdHcJgx2i9LCmDBI=; b=RnFMqbIgqLrAaYyvB2wts0xbn4u62/z5edeYJ7pEgkgJFRKJjIlWUTHQ nD8gK6uNyJ/phe0uwSPkM3gBvGndC5oLzbxBQyuycM11A0h61hbJWimIT vlxHpm50EWt62QlvtE+YwxAE+uCScQBP+hqVIg69E3b4WgQeou3nWrbd8 hG8yNWdbbFTOchW0kwYpEGAUR6RqHJwqe3pOmVAXpToe2SiOdFQ95vTr1 QUp9SltzS7K1vRZ5BHm1P22zPhLLbcPo4CnfL2qXhDNHr1pF/b6fsWhhy baIMS+BnNCkwZgASyFy7KVW5a38y/nsyNQKVT4U4L2NGrWQt2s9YPf0Q8 A==; X-CSE-ConnectionGUID: 0VhMEptZQwyPoirmIPhYRg== X-CSE-MsgGUID: NbRCJxekR6uZcqkQj8KJhQ== X-IronPort-AV: E=McAfee;i="6700,10204,11193"; a="24967804" X-IronPort-AV: E=Sophos;i="6.10,225,1719903600"; d="scan'208";a="24967804" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2024 22:21:28 -0700 X-CSE-ConnectionGUID: QGYorN4IRdGBxti6yYYZJQ== X-CSE-MsgGUID: imzeAYHDTHODh8WURfGkHQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,225,1719903600"; d="scan'208";a="67900648" Received: from emr.sh.intel.com ([10.112.229.56]) by fmviesa009.fm.intel.com with ESMTP; 12 Sep 2024 22:21:25 -0700 From: Dapeng Mi To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , Adrian Hunter , Alexander Shishkin , Kan Liang Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Yongwei Ma , Dapeng Mi , Dapeng Mi Subject: [Patch v5 6/6] perf tests: Add more topdown events regroup tests Date: Fri, 13 Sep 2024 08:47:12 +0000 Message-Id: <20240913084712.13861-7-dapeng1.mi@linux.intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240913084712.13861-1-dapeng1.mi@linux.intel.com> References: <20240913084712.13861-1-dapeng1.mi@linux.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: quoted-printable Content-Type: text/plain; charset="utf-8" Add more test cases to cover all supported topdown events regroup cases. Reviewed-by: Kan Liang Signed-off-by: Dapeng Mi Tested-by: Kan Liang --- tools/perf/tests/shell/stat.sh | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/tools/perf/tests/shell/stat.sh b/tools/perf/tests/shell/stat.sh index 092a7a2abcf8..85897898a1f4 100755 --- a/tools/perf/tests/shell/stat.sh +++ b/tools/perf/tests/shell/stat.sh @@ -73,9 +73,27 @@ test_topdown_groups() { err=3D1 return fi - if perf stat -e '{topdown-retiring,slots}' true 2>&1 | grep -E -q "" + if perf stat -e 'instructions,topdown-retiring,slots' true 2>&1 | grep -= E -q "" then - echo "Topdown event group test [Failed slots not reordered first]" + echo "Topdown event group test [Failed slots not reordered first in no= -group case]" + err=3D1 + return + fi + if perf stat -e '{instructions,topdown-retiring,slots}' true 2>&1 | grep= -E -q "" + then + echo "Topdown event group test [Failed slots not reordered first in si= ngle group case]" + err=3D1 + return + fi + if perf stat -e '{instructions,slots},topdown-retiring' true 2>&1 | grep= -E -q "" + then + echo "Topdown event group test [Failed topdown metrics event not move = into slots group]" + err=3D1 + return + fi + if perf stat -e '{instructions,slots},{topdown-retiring}' true 2>&1 | gr= ep -E -q "" + then + echo "Topdown event group test [Failed topdown metrics group not merge= into slots group]" err=3D1 return fi --=20 2.40.1