From nobody Sat Feb 7 15:22:00 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 37E1082890; Fri, 16 Aug 2024 06:45:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723790744; cv=none; b=E4PIoOx+LuNyF2N9HL1GI27xDO/359/HoD9brSK7pxFBVyUfRqnuiDaIhx9Q6IfIcKOvFCA9qvzaugu/N289pJLxVrkQNftjx+Ltw3IsayLGdMzOG2ceghrufJJc4iMV1gmXwCjYaal9JhstGeWUyLZdZhJeZK7VDwh2cjv2Qes= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723790744; c=relaxed/simple; bh=RzanKec69OjpYow528ddx8RJu3FhJQBfxfE59UoUTMc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WzbbMAflpurpvCKbBwlaK5kp/hJJ1ZfwboyPbfvDcdfRQ0RtEccPsoWH+0adFiTkpToT2kb7tUNp1zthzWzdX0gktgEgYLU/lFj1RBw+v3mGWIxQcrRMML+CH6IvNsv7i6jzmBHs2T322SM9uzCPthXf9/ZROncZgxrtMPvyg3Y= 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=dDkNyW2w; arc=none smtp.client-ip=198.175.65.10 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="dDkNyW2w" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1723790742; x=1755326742; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RzanKec69OjpYow528ddx8RJu3FhJQBfxfE59UoUTMc=; b=dDkNyW2wUZeDnYVhf8H6vXY8I+ITDWdCLq9+vLCrfCEj780KrHOyl35R MQCwJlXo6Qj0k1n5IIABd8i3WxFEVNr85lx8HBj8hePqG8nJ1TlFIwmFq 2sdpZNxyXw00ZlljEcxpN0yYTLrZfuQTL7b4Szaapm50ZS78ihVtLeO/Q EyNxZk/Co9qgJIK21donRt8ngQLRDM2dU0jY6IW88mNuyS9KHjxJaQKyi d11RDYv1bZzJ5uqqLP5j5+AJy5tkWzjKpEDSno2F3WgYwQMF+azJyQk3d eXEW5FHXko/9cqwJu9pjv15dX40xc5SzMxXp7DrRM0SdqqOHUdBOUEYGo A==; X-CSE-ConnectionGUID: cmBwPandTMGLPI7a9sK/RQ== X-CSE-MsgGUID: JFHTefURTg2oO/UPnU/hLg== X-IronPort-AV: E=McAfee;i="6700,10204,11165"; a="39530744" X-IronPort-AV: E=Sophos;i="6.10,150,1719903600"; d="scan'208";a="39530744" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Aug 2024 23:45:42 -0700 X-CSE-ConnectionGUID: GfUBMuzHQZq+WIGu4OqQ/A== X-CSE-MsgGUID: iUHa/864T5663tEUJS0gTQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,150,1719903600"; d="scan'208";a="60150008" Received: from emr.sh.intel.com ([10.112.229.56]) by orviesa007.jf.intel.com with ESMTP; 15 Aug 2024 23:45:39 -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 v4 1/6] perf x86/topdown: Complete topdown slots/metrics events check Date: Fri, 16 Aug 2024 12:29:33 +0000 Message-Id: <20240816122938.32228-2-dapeng1.mi@linux.intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240816122938.32228-1-dapeng1.mi@linux.intel.com> References: <20240816122938.32228-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. Signed-off-by: Dapeng Mi Reviewed-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 b1ce0c52d88d..332e8907f43e 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 Sat Feb 7 15:22:01 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 F3AEC82890; Fri, 16 Aug 2024 06:45:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723790749; cv=none; b=JGHGJ0NTK8JHxbHJlZf0usb088SuiMfUuTZUepBnsd4OghVf6FaNbSeFikrmJwrM/RONhKlhamWJrJrq6yaC8mkVfMPIW0Q/oEzNeePkdqA195ByN/oLDdSmaO2y4pXul3/+rdhYHhiqYwTh3fJno7ScQd3MIiCwBZpF5pMBOfY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723790749; c=relaxed/simple; bh=n1IW3cJiQOA07ZWVTOc4/XAvaItKxA0tfFMoaRScEHg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OFGvr3ZCr1owdWex4wrXOsdoeN4Q93Lkz23U3U4SGTlbxQ24aM7qjVM6o7z4IGuPxxjIwr2VJ7keQUtw6AtA53tSpUT45uCSqA50qpwA+KMMn7L7H4qcAujruF3MVhjDnLvnyZ0aREEHpQ7ex51C7fVcn+7EtNHyPYbzpzRP8Ro= 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=hdUVUk1p; arc=none smtp.client-ip=198.175.65.10 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="hdUVUk1p" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1723790748; x=1755326748; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=n1IW3cJiQOA07ZWVTOc4/XAvaItKxA0tfFMoaRScEHg=; b=hdUVUk1p6nyZ7vE6OL0jaLeANGpMK9lbiIXBrDcRZnHVe9Zq/ajR6YAT eQ8jf8fZfkNg1/CZBOPkGhENVMXnwG0yJGXuTzAa2q14L7fCv5OcK5NH1 devEEFaii9gQ3fewd4o2KJPpxXSDPq68jsijTFisys2bfWENSWxkju/c6 GbnebJtYBjrS+NwXJ20ptXEPWmEk83/SW5daW75cktAysCWDpYm8fUPVY 1gU1AifDYhFXVvDai0k6Rvrk2/vFIZ+64bnU2PUYL4ZeF9N/oFkXwc4qn +I+Dcu4/b+H57RdnCQqS2Lwo+BjDW2Bz2LxEy3FfdZHJpB4om1odNKE+Q g==; X-CSE-ConnectionGUID: qf/8q4WhRqK1HyuAvsmXZw== X-CSE-MsgGUID: Z7eLSL2oQCigxBuUH7OJKw== X-IronPort-AV: E=McAfee;i="6700,10204,11165"; a="39530751" X-IronPort-AV: E=Sophos;i="6.10,150,1719903600"; d="scan'208";a="39530751" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Aug 2024 23:45:47 -0700 X-CSE-ConnectionGUID: eDbwGywRQTKdtsdoLIze7w== X-CSE-MsgGUID: drOt/agRRMi3kMekqACZbw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,150,1719903600"; d="scan'208";a="60150019" Received: from emr.sh.intel.com ([10.112.229.56]) by orviesa007.jf.intel.com with ESMTP; 15 Aug 2024 23:45:43 -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 v4 2/6] perf x86/topdown: Correct leader selection with sample_read enabled Date: Fri, 16 Aug 2024 12:29:34 +0000 Message-Id: <20240816122938.32228-3-dapeng1.mi@linux.intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240816122938.32228-1-dapeng1.mi@linux.intel.com> References: <20240816122938.32228-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 ------------------------------------------------------------ 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. 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 Sat Feb 7 15:22:01 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 095618289E; Fri, 16 Aug 2024 06:45:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723790751; cv=none; b=aseNt/bOXrs4xgqPPmWhyEBSnCAu8jvv8B+eU4agh8FHTZ5+uMRNd7BgBEdOgj4GpgdL02EdVM0xM+8sgzIvkIXd6RaWubxpbwUXpq2jPJz2GzppwVT+YE0HhkcjOa/uOx3QGpjuMSqAbxVVI7UJsOTU6rEqivf4hcIj9IATyY4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723790751; c=relaxed/simple; bh=co+r/S4tHY9XhzKEcE2Gsywi4LBChhsgb5rJOjHPSe8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gTH6luNyH0Piqsjly5cMneUqHhEkxQJvLon7fZ5R1FliW4FczH2+pwN8NjW0S9bx64c+dWwOrEfo+HQZo7QEwb9bhhrrPtDGqmAa32Z1Q8GllUvXKPMT6ujvVROduFxWPjceExnZ0mVA67a7s81if3tTFkZbY+Ps4oeJ7tPhfBc= 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=NEhXG8/K; arc=none smtp.client-ip=198.175.65.10 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="NEhXG8/K" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1723790750; x=1755326750; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=co+r/S4tHY9XhzKEcE2Gsywi4LBChhsgb5rJOjHPSe8=; b=NEhXG8/KUPihy3XbwROa2h2HKRiK4PQaqJLQF0NV/nxtczzFWzWKOtky AyF6Tj5T84ZTPF5MHP1hWV9ca0t9ulLakLPaZt0HchrsBqhWpREMPbkiU Si+V+stniRh04f3RleUQ7U5SLOVGDUN+BVKnVsIwKCy1cY/+YlhfLTrzx 2HHUePqWT91laQ9cL/OC7G+3HdY/tyFit4n86nQ0K1UXqi7XtiR1AKInJ K/oVj9sTxCHrBA8Fm7Xt6bdvMDeYCYivDhvPxeOs38BekrZ81wlfB8gTN UIQnMbaiP7WESIcsvBSdpLnuHCKv0TzxOFf4ci8ZU9YSxGpZLirgZfzJd A==; X-CSE-ConnectionGUID: XM9wUaAWSgSEijPTZjTX/g== X-CSE-MsgGUID: INwE2Ee3RIiN5Lqz8yZ/aA== X-IronPort-AV: E=McAfee;i="6700,10204,11165"; a="39530757" X-IronPort-AV: E=Sophos;i="6.10,150,1719903600"; d="scan'208";a="39530757" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Aug 2024 23:45:49 -0700 X-CSE-ConnectionGUID: GxxgxZB7QVm8s8WQ4+/zzQ== X-CSE-MsgGUID: OaI3UZdqQZ6TnF8YlvoOjQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,150,1719903600"; d="scan'208";a="60150026" Received: from emr.sh.intel.com ([10.112.229.56]) by orviesa007.jf.intel.com with ESMTP; 15 Aug 2024 23:45:46 -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 v4 3/6] perf x86/topdown: Don't move topdown metric events in group Date: Fri, 16 Aug 2024 12:29:35 +0000 Message-Id: <20240816122938.32228-4-dapeng1.mi@linux.intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240816122938.32228-1-dapeng1.mi@linux.intel.com> References: <20240816122938.32228-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 ------------------------------------------------------------ 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. 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 332e8907f43e..b8a38c0ca36d 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 Sat Feb 7 15:22:01 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 3503712C7F9; Fri, 16 Aug 2024 06:45:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723790753; cv=none; b=TOm3f+rG1aiv+4QQ1yLkNcZmQDOy+AZZ+/EtGKtUxHK9R40/Ca8GCaMbgzz1xaIhmgkV8N8vY2mPRLEB2kQmHJznIxrNeRZFwdtnYBTPMogu7XjMrY4jmxMrYni/MMtEgDCxaX7ZjkVvGB24T5AUquZ17uGhPhDIVPE607MRwFc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723790753; c=relaxed/simple; bh=7NPeKnDoJ/P82slpVaSMciOgj75XI6ViCTDAXn0KGrA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=eBTYfnHVzKkzDkC4nJ5eN7tMsck6kQoBUwjDM4gJVINH/DrjLjOAHR8+qP1A26vZbFIwVDlRywil64hkZFXHaIEqTTRoSirJ+BIM44KhgHpWAbORbwtaK/vm06fOUb2Agg80tFidkDx1cVwtgTKSz3EFj54puLdvaoAmYSmJCek= 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=Cs5Uu5Yk; arc=none smtp.client-ip=198.175.65.10 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="Cs5Uu5Yk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1723790752; x=1755326752; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7NPeKnDoJ/P82slpVaSMciOgj75XI6ViCTDAXn0KGrA=; b=Cs5Uu5YkG79FfNvQNpez62mSYDXhNAEiYWuuwjlIcoroBOlr6wxoX+O2 wx1Larf3J6RQtkQaK3j7FdeaG4ONAM0Ptdjov59aUAI13ov4mkFOG/rMb Q48O/Q0cYhvcdPvRmTiiAm+QpK2wYa+qXGf55Kcz9T27SKrw6rtJjwv36 K3imNdCDBWMx5cx5vDl27bXtIoi7MyJDivBJIZQnzHggDfEgH5WuSX3rt HUIsjNbPhselFNWz1B4WWD1TvD5Ya10C0M5W6w7uz3r/dmMp/3FYLVGfj bKtvhqzBk3K9K2JAkv2DpIhjwyM6EX120yiT5mbXguf08oEa2LLlKyXx5 A==; X-CSE-ConnectionGUID: m65m93loSaaPHJRaW/pJ1A== X-CSE-MsgGUID: bRXpYF13RPWqlJYaq+/4iQ== X-IronPort-AV: E=McAfee;i="6700,10204,11165"; a="39530770" X-IronPort-AV: E=Sophos;i="6.10,150,1719903600"; d="scan'208";a="39530770" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Aug 2024 23:45:52 -0700 X-CSE-ConnectionGUID: FOaWWgknTkO2Syj3YrtOZQ== X-CSE-MsgGUID: cMxC8OtmTK601jyX7ia21Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,150,1719903600"; d="scan'208";a="60150033" Received: from emr.sh.intel.com ([10.112.229.56]) by orviesa007.jf.intel.com with ESMTP; 15 Aug 2024 23:45:49 -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 v4 4/6] perf tests: Add leader sampling test in record tests Date: Fri, 16 Aug 2024 12:29:36 +0000 Message-Id: <20240816122938.32228-5-dapeng1.mi@linux.intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240816122938.32228-1-dapeng1.mi@linux.intel.com> References: <20240816122938.32228-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 Signed-off-by: Dapeng Mi Reviewed-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 3d1a7759a7b2..8e3e66780fed 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" @@ -190,11 +191,38 @@ test_branch_counter() { echo "Basic branch counter 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]" +} + test_per_thread test_register_capture test_system_wide test_workload test_branch_counter +test_leader_sampling =20 cleanup exit $err --=20 2.40.1 From nobody Sat Feb 7 15:22:01 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 6E6831369BB; Fri, 16 Aug 2024 06:45:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723790756; cv=none; b=MPThxM1lnpAqDCnrdoNMa6a0+Q5wyEHLsRUJGviC8zmf92k+toWk9XM3984eo77TtlOdt3fxUNsnwW38su1bMUve4CR9YGw+W908SHsTPuKy3IRtT1+f4ESQlyWjRfaeGOB9H5gl6DRNcIwQZPy/uLjLr4svpByefH5jbXbIgrU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723790756; c=relaxed/simple; bh=mYzLvmSJZKTBkmZhbdKH2s+bnRSxYws90RWrHKTt1cU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pzy1nfzqILA71UwNTHLULglboe9ATIMQo3H0Ob/K27fCBZKFEKhrrVERlgUryUiFYsQEIa9HGmpSZeiQTgUSlgB+x0a06r3YQfjhdqdzjnjnVge9cFT0MPCz2js0uldhbLHpXLPlKaBpk2rFRB6S02unZMV2nrlM3K3tNBpPoes= 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=A27plleB; arc=none smtp.client-ip=198.175.65.10 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="A27plleB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1723790755; x=1755326755; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mYzLvmSJZKTBkmZhbdKH2s+bnRSxYws90RWrHKTt1cU=; b=A27plleBJYE7lO63sU5ympjAEizH+KSlKSfJ2EIRLjllfgO/iSQwsbMc thRVFbyNFjGOu2ewH3H9BMJGkn1PEKCYJ0hkESTyCdzW/Jpr8PPfgvW/D TMA4I1ae6ccao3QyFIf7SkT8aT9i9bwAlQKzF3BH+4/OkrA+pmvqZkuKw sTZwvy8AYTuvrQ3y5NK6JEJq7jnqlvGnymTesYEsG0JtB6ZuZcaI3YVmQ 75EbCnf7wPywTe7myBuzjsozjz216qrKZSc3bXNvTic9Rx5yVHqDEtrYY dkSkXMChJasL1qsDi8nzbiXFGoxAnDLnSbIyCWhM4SwRIS488eH8SaCz/ g==; X-CSE-ConnectionGUID: jeoZ05HcTGORIo3q1Ogz4g== X-CSE-MsgGUID: MWuz6JE9TB2mLxRdH/uDAg== X-IronPort-AV: E=McAfee;i="6700,10204,11165"; a="39530790" X-IronPort-AV: E=Sophos;i="6.10,150,1719903600"; d="scan'208";a="39530790" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Aug 2024 23:45:55 -0700 X-CSE-ConnectionGUID: 4LN1bvIrRcyFYrjq6LuVaA== X-CSE-MsgGUID: o2Yzk5sMSBm9JX8ARarJYg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,150,1719903600"; d="scan'208";a="60150058" Received: from emr.sh.intel.com ([10.112.229.56]) by orviesa007.jf.intel.com with ESMTP; 15 Aug 2024 23:45:53 -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 v4 5/6] perf tests: Add topdown events counting and sampling tests Date: Fri, 16 Aug 2024 12:29:37 +0000 Message-Id: <20240816122938.32228-6-dapeng1.mi@linux.intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240816122938.32228-1-dapeng1.mi@linux.intel.com> References: <20240816122938.32228-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. Signed-off-by: Dapeng Mi Reviewed-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 8e3e66780fed..9d0c43427811 100755 --- a/tools/perf/tests/shell/record.sh +++ b/tools/perf/tests/shell/record.sh @@ -217,12 +217,29 @@ 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]" +} + test_per_thread test_register_capture test_system_wide test_workload test_branch_counter test_leader_sampling +test_topdown_leader_sampling =20 cleanup exit $err 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 Sat Feb 7 15:22:01 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 9CD8A13A26B; Fri, 16 Aug 2024 06:45:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723790759; cv=none; b=a94rnjvsI6IPlPjCyWGbP1BcpbAqI+L1P7OXuOfF1EmrUQWx2kR3a/Q4MBuOvMENtevRzXD11nG60czcU0Qgzy24PvN8vm5Mf6fhRMTDsmFpB1S1Vvqh+92uNiUmXV8FkCKE3HbtM/e5II3Ob5mHDSjOP/j+BE+DcPTYnb0RQUc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723790759; c=relaxed/simple; bh=PyZgNILmP4YBkkVr6sygCkBQ67L4OAU6Lr5J99p0djE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GYZUUz98shy6MfUoPrPVh5UejCTUKo0Pl4PRODF+E5VFGj/UDhWIWqcy5a9HsQanAhI0+3Bz8f46q6ppl/iT6OSeSyMF/9FT1dCBoNYSkUhqSfdsj7vz4l1EnmavPdM17tgYjmMw22MgSQkuteQffFn96WFdRd5mCfzaQoYNbjU= 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=H/3Oa+e6; arc=none smtp.client-ip=198.175.65.10 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="H/3Oa+e6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1723790758; x=1755326758; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PyZgNILmP4YBkkVr6sygCkBQ67L4OAU6Lr5J99p0djE=; b=H/3Oa+e6EgBfyRmvr+hSqIw5BxQcCtZJZs+1LJdpOFvb0tBzq5fpqLyM OloZ7RgWiq+4+BAJVC/ZBIhHNLK/8UZgNRbcSNGuSyIjFsyIyl9RuAuMc /HNPMay2QasRb2ockbTT7fsfJPvqQ+eL0mTxPKwuik0wiMeiq+cuCHDaE pKMaUReMFSiSPWEaeIernZRaqttYCyhasxNqtnk9w5f5/KaV2DuQp2tM5 Bboxjk08gJxFX07zqzEYZGeLHZ5Dpv0hwUc8/Uj6gpJy7eU4f/L2m/uEE YhGx9Eug70OE/QqQFtxZwk8qCG4jT7wqLULSYl7gCKCf1tYlEgCUS9hMP A==; X-CSE-ConnectionGUID: wG+GA3uAR/O/nP+GlHEifA== X-CSE-MsgGUID: G251xN08Sy6WZVRfMiFQDA== X-IronPort-AV: E=McAfee;i="6700,10204,11165"; a="39530797" X-IronPort-AV: E=Sophos;i="6.10,150,1719903600"; d="scan'208";a="39530797" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Aug 2024 23:45:58 -0700 X-CSE-ConnectionGUID: DuWe3jLgQguiDKseF7Cg1A== X-CSE-MsgGUID: 3djLFv0xTo60dRSDhdlzYg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,150,1719903600"; d="scan'208";a="60150062" Received: from emr.sh.intel.com ([10.112.229.56]) by orviesa007.jf.intel.com with ESMTP; 15 Aug 2024 23:45:56 -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 v4 6/6] perf tests: Add more topdown events regroup tests Date: Fri, 16 Aug 2024 12:29:38 +0000 Message-Id: <20240816122938.32228-7-dapeng1.mi@linux.intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240816122938.32228-1-dapeng1.mi@linux.intel.com> References: <20240816122938.32228-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. Signed-off-by: Dapeng Mi Reviewed-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