From nobody Fri Apr 4 12:26:52 2025 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 740681F03EC for ; Wed, 2 Apr 2025 20:16:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743624978; cv=none; b=JABK65fJxcXN7JrVeWa76Ql3wsPZSlqPogGBRbiK2zsnPAr7xQoJFvPWHNRpvCqRZxoYn09/yyKlyltV5iuf2q1ih/vijftCedWSgcK/sF4MwBlZeYrrlDXyQEmd5Bzbxm06/QsnHNzPlnV/mw1ZIZGg8Mpcc6iYty/5i/TTik8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743624978; c=relaxed/simple; bh=mdSSrhP7G24frprN16593VOBIgMZgeUhPBNK6wrZNsk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=eT9iCLRt/9gA23FtTUvyawvAWslJRsb/YKi4pK58xy3XRbe9ksm3yN5lAhnliLb5HQDcVf42SI3sIjBnbAS+VJsI+3zERgjQn4PlZVrcSuXQeiqDWBZrPRstMkGx3iGBQzbxcMZ7zyyIoZCwL2rqIuxlDAWx1Jf58ke77q08Czs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=yipm/8kr; arc=none smtp.client-ip=209.85.215.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="yipm/8kr" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-af570998077so184576a12.0 for ; Wed, 02 Apr 2025 13:16:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1743624976; x=1744229776; darn=vger.kernel.org; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=32l0Pu2pjVOQ0/rzRKMg0Sp9sEBo5wkzEsYD7DuEcpE=; b=yipm/8krmTWExkLJlePo7dM92sbC8vgIf9wYAbnKVgszX2MF5rE+rPzGlZHvEeYCaL isLFRNZ22EUSaFZ1FyPE5llzowUU3vQkqke+sPJHr99Z03/ZIh88EdQEL0IEG76Z/i5b fYg43pJVOuZ9itpKAcLXO7hZFCPxyiHsH9rf6NxkTYmX117tO3YDTfugjTgH59VbztEs HynIv2mMVSNeH4/KD58y5Lqr0rA7gFqCNvfnQjOUWbTKYOd9ex17RGb1noaBpxMr4reT ty5jmyekQg+SDiL4C93/D5ERD/QkeefvlJ9BCbiInAlZ6C+WyRXziXFQU+fGug4cFMM9 0/oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743624976; x=1744229776; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=32l0Pu2pjVOQ0/rzRKMg0Sp9sEBo5wkzEsYD7DuEcpE=; b=jrBkmKTYNEdY8+whT8WcM4fnOQg8PJiPEwAhLO3sTR3v6QcOIeURY+mnOgFkkTfjo3 dc8+PqhMXewtmDO0ra2ZmeFk0SkCmmugyXbIw0AvE2diVkcbOl4dVg3Snv/eEkFUAhKd 5qKHJcy9SCeuFKaKRHB/hvBU2DASEasyMEQA/jC5qhW4J2vdmEjaChV1Gd5GulUz8bxo jHGwYAb0Q14blLLDE8qDLfw2C+pBJGWAnhA5skzntdTnimMgyp9LfQXvrlhT1SOy/u48 2wQNUKb/F85frC0o+YgrBWqFwnVRFyW/m9Dq7pOHLQlGaQHGiDSlz6jWBv9y56O6Pwtf q+vg== X-Forwarded-Encrypted: i=1; AJvYcCV65FnOawSQkX40/ZfRY0xUidJnJbJVy1TgHcKuQg/bOa+Z9WZrCq3ojb1j1X1srUJUeqQm2CKIu8uNKUE=@vger.kernel.org X-Gm-Message-State: AOJu0YyuFAtUCSvde5aE3PMU3QoYIUnGucEc887QU9TeD+4vDe3LeC0L 3pSTKw8ibNSWto+hdLeq2HRBw25LJAy1JlKuKZrrdCt5cY+5Othz2YEPl3uIiDy9plMEy38b6AT eytGHkQ== X-Google-Smtp-Source: AGHT+IEA5HC2pgKufmc8BlDFZQkWT4SBZPM+GdUwHnsP32QmD9Uj4LuXnzm5s7gHWkyrTRUYBQU+oV3zK5zf X-Received: from plxx10.prod.google.com ([2002:a17:902:e04a:b0:223:5416:c809]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:ea03:b0:220:c813:dfcc with SMTP id d9443c01a7336-2292f9fa333mr300249905ad.40.1743624975684; Wed, 02 Apr 2025 13:16:15 -0700 (PDT) Date: Wed, 2 Apr 2025 13:15:45 -0700 In-Reply-To: <20250402201549.4090305-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250402201549.4090305-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.504.g3bcea36a83-goog Message-ID: <20250402201549.4090305-2-irogers@google.com> Subject: [PATCH v3 1/5] perf stat: Better hybrid support for the NMI watchdog warning From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , Howard Chu , Dominique Martinet , Levi Yun , "Dr. David Alan Gilbert" , Andi Kleen , James Clark , Weilin Wang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Prior to this patch evlist__has_hybrid would return false if the processor wasn't hybrid or the evlist didn't contain any core events. If the only PMU used by events was cpu_core then it would true even though there are no cpu_atom events. For example: ``` $ perf stat --cputype=3Dcpu_core -e '{cycles,cycles,cycles,cycles,cycles,cy= cles,cycles,cycles,cycles}' true Performance counter stats for 'true': cpu_core/cycles/ = (0.00%) cpu_core/cycles/ = (0.00%) cpu_core/cycles/ = (0.00%) cpu_core/cycles/ = (0.00%) cpu_core/cycles/ = (0.00%) cpu_core/cycles/ = (0.00%) cpu_core/cycles/ = (0.00%) cpu_core/cycles/ = (0.00%) cpu_core/cycles/ = (0.00%) 0.001981900 seconds time elapsed 0.002311000 seconds user 0.000000000 seconds sys ``` This patch changes evlist__has_hybrid to return true only if the evlist contains events from >1 core PMU. This means the NMI watchdog warning is shown for the case above. Signed-off-by: Ian Rogers Reviewed-by: Kan Liang --- tools/perf/util/stat-display.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index e852ac0d9847..1115efb380fb 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -822,16 +822,28 @@ static bool is_mixed_hw_group(struct evsel *counter) return false; } =20 -static bool evlist__has_hybrid(struct evlist *evlist) +static bool evlist__has_hybrid_pmus(struct evlist *evlist) { struct evsel *evsel; + struct perf_pmu *last_core_pmu =3D NULL; =20 if (perf_pmus__num_core_pmus() =3D=3D 1) return false; =20 evlist__for_each_entry(evlist, evsel) { - if (evsel->core.is_pmu_core) + if (evsel->core.is_pmu_core) { + struct perf_pmu *pmu =3D evsel__find_pmu(evsel); + + if (pmu =3D=3D last_core_pmu) + continue; + + if (last_core_pmu =3D=3D NULL) { + last_core_pmu =3D pmu; + continue; + } + /* A distinct core PMU. */ return true; + } } =20 return false; @@ -872,7 +884,7 @@ static void printout(struct perf_stat_config *config, s= truct outstate *os, ok =3D false; =20 if (counter->supported) { - if (!evlist__has_hybrid(counter->evlist)) { + if (!evlist__has_hybrid_pmus(counter->evlist)) { config->print_free_counters_hint =3D 1; if (is_mixed_hw_group(counter)) config->print_mixed_hw_group_error =3D 1; --=20 2.49.0.504.g3bcea36a83-goog From nobody Fri Apr 4 12:26:52 2025 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 77B8B1F0E27 for ; Wed, 2 Apr 2025 20:16:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743624979; cv=none; b=jeooc5jc9A5FOaow7Qz5MZGKUNEHEAF8jS8s8ya5rchedeU/zLNhdXCTclq8aNZLOpjGkb+YB1wm8RbcdOMdtJGTllgyHECruTk2owjhdTm+I0UvAbz/U/fD1O+UC1SLp1FWl7i6YEGjMJ5UUVrUmhGPns2YuKhpfkuGz2ktF1E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743624979; c=relaxed/simple; bh=NqnWpcdFkNGPmqWCPNT6GGaIm7Gc0q9VpwYczE12dRI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=YG5iQN68nUQyc7TDQVAHnld6pvW4SJBMSy8mFDRANVGgWodxxS3u3uhx/xj/9CehAdj/Zbz1trPEOa3wMX/zSR/vKlnyhWf4KzpuW811xkCwB9RxU3/Ggh4nyREd7Cl3krrBVtm8HgnS4xxrbjNerRR3QlHFGF9C+Vlx5l1llTI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=oWXp68gG; arc=none smtp.client-ip=209.85.214.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="oWXp68gG" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2242f3fd213so1533165ad.1 for ; Wed, 02 Apr 2025 13:16:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1743624978; x=1744229778; darn=vger.kernel.org; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=GVMZzaRI0SYaZ9HIFXqjbn9kAaASuQl6uCuXVUyZL/Q=; b=oWXp68gGcpbatrX/v+U5Sy6YtXo2PXM3WnBs4mDHIwt8mRrjegp4QVIh8xQ9chB6ZX zgXjXG3whyF7b0TiDPPzdOdZ5Ffe5JcJ6WOJMZnUQOX6r8keR7uFKGtf1r8cPFVgCwD2 xMhvxZbwMOIn4WKY5F/eoLFd1/aXuci4s3qVLiBjD11psFFVOaL5CyI3sJa3eauL/l49 VmBXVn9iXCroJ/O6nCTytYHsw7cCkR15IQDjA2FNkEhsvJjAwxpg1KnkNu54KegJP9q4 T1JKUOIH/DK8RKpBbCZ7F8QaLX8CRUxtPXIQabjLofs8KBDAzXFSXnTaGchouvs5squl /Bzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743624978; x=1744229778; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GVMZzaRI0SYaZ9HIFXqjbn9kAaASuQl6uCuXVUyZL/Q=; b=Fnf+ZVVPfdO8pJFtvgYf+5Ii/JnsZ9e52llXnyCfAaP2vhbuUDEGX+t9ErBhAH0j4J cUtK5XNErJWrD585XP5pbDSbp7QV9zWrsYjzyp54Rwp/+byQY6GVrK+UaQIn9cOD2kDO xAQIqRXdoBQCyDt8ayt6Pq6AyMNbc74BJqjR8TLZX/UDPXt71DOf9Afn2YMNVbTpp+Gu Jy8oInGWR3/JNPoStyE5YrOTTKrmWkRXutPO93bZ5fdVfzmyhb5zkG/RxMyXEbxDaXwR XBkdA9nq8GvWTcqKgjXzjS8/q7yFun0QIzP4zOR5pE5+kS+wZELediqbFyP0QAo7dtrE qAFw== X-Forwarded-Encrypted: i=1; AJvYcCXeZ8Y+maAEg3SiXbpDDK5Qf3G9+QGy8Wm4ubMfLecPBdE/B+t49TBIR4t9y/uAZcJu/zrjcoYi5zD05ss=@vger.kernel.org X-Gm-Message-State: AOJu0YzKneYk/I282UL1Bp6qfLwW6ZFD7mG1sTi8m0/6Qr1KJPhusZ24 OHHhFCB1AUJvn0aLTZPzWiiXgoDkKK9kYBoiusTAbsLyItiqHYrbC5QT53pnRcu6HWi5aES2/tT 76ffVaw== X-Google-Smtp-Source: AGHT+IE9JQSaSNT9+T67Fkw2cDbYozJxAUfJ3kBmZZqgEDU9Xl9sBP5tq+Bq6erIy5pJoy1fkGy1uDx6xAaq X-Received: from plry12.prod.google.com ([2002:a17:902:b48c:b0:223:4788:2e83]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:d586:b0:224:93e:b5d7 with SMTP id d9443c01a7336-22977e0fba2mr1340135ad.34.1743624977770; Wed, 02 Apr 2025 13:16:17 -0700 (PDT) Date: Wed, 2 Apr 2025 13:15:46 -0700 In-Reply-To: <20250402201549.4090305-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250402201549.4090305-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.504.g3bcea36a83-goog Message-ID: <20250402201549.4090305-3-irogers@google.com> Subject: [PATCH v3 2/5] perf stat: Remove print_mixed_hw_group_error From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , Howard Chu , Dominique Martinet , Levi Yun , "Dr. David Alan Gilbert" , Andi Kleen , James Clark , Weilin Wang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" print_mixed_hw_group_error will print a warning when a group of events uses different PMUs. This isn't possible to happen as parse_events__sort_events_and_fix_groups will break groups when this happens, adding the warning at the start of perf of: WARNING: events were regrouped to match PMUs As the previous mixed group warning can never happen, remove the associated code. Signed-off-by: Ian Rogers Reviewed-by: Kan Liang --- tools/perf/util/stat-display.c | 31 ------------------------------- tools/perf/util/stat.h | 1 - 2 files changed, 32 deletions(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index 1115efb380fb..aab3697aed63 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -798,30 +798,6 @@ static void abs_printout(struct perf_stat_config *conf= ig, print_cgroup(config, os, evsel->cgrp); } =20 -static bool is_mixed_hw_group(struct evsel *counter) -{ - struct evlist *evlist =3D counter->evlist; - u32 pmu_type =3D counter->core.attr.type; - struct evsel *pos; - - if (counter->core.nr_members < 2) - return false; - - evlist__for_each_entry(evlist, pos) { - /* software events can be part of any hardware group */ - if (pos->core.attr.type =3D=3D PERF_TYPE_SOFTWARE) - continue; - if (pmu_type =3D=3D PERF_TYPE_SOFTWARE) { - pmu_type =3D pos->core.attr.type; - continue; - } - if (pmu_type !=3D pos->core.attr.type) - return true; - } - - return false; -} - static bool evlist__has_hybrid_pmus(struct evlist *evlist) { struct evsel *evsel; @@ -886,8 +862,6 @@ static void printout(struct perf_stat_config *config, s= truct outstate *os, if (counter->supported) { if (!evlist__has_hybrid_pmus(counter->evlist)) { config->print_free_counters_hint =3D 1; - if (is_mixed_hw_group(counter)) - config->print_mixed_hw_group_error =3D 1; } } } @@ -1587,11 +1561,6 @@ static void print_footer(struct perf_stat_config *co= nfig) " echo 0 > /proc/sys/kernel/nmi_watchdog\n" " perf stat ...\n" " echo 1 > /proc/sys/kernel/nmi_watchdog\n"); - - if (config->print_mixed_hw_group_error) - fprintf(output, - "The events in group usually have to be from " - "the same PMU. Try reorganizing the group.\n"); } =20 static void print_percore(struct perf_stat_config *config, diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h index 2fda9acd7374..1bcd7634bf47 100644 --- a/tools/perf/util/stat.h +++ b/tools/perf/util/stat.h @@ -100,7 +100,6 @@ struct perf_stat_config { int times; int run_count; int print_free_counters_hint; - int print_mixed_hw_group_error; const char *csv_sep; struct stats *walltime_nsecs_stats; struct rusage ru_data; --=20 2.49.0.504.g3bcea36a83-goog From nobody Fri Apr 4 12:26:52 2025 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A61B01F1537 for ; Wed, 2 Apr 2025 20:16:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743624982; cv=none; b=EPE/leRWlfuneuSkLdILGXYDzHsf6DiWwdSiYbbVQ636IgFTPIupgmN7JVM3zndoH3w0OfegdykVNKX+9eLr01BUbO1p6hdgcSAILxClzP0Jg0LiGdrNJ7S8pwU5FaIsdtI1labLdZCof5x2pj4BBoXX1K+UCKGIYKGDY+OA8Ys= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743624982; c=relaxed/simple; bh=ceFQQBDmr9eZ5yU3Gt86zh2f8+RxL6DcgnNhvGpxxF4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=OCPGMAy2Fnlnu6zCHEx0P6tJL8TNuuUUidH7BobCBzgCAKCC4WSYr0jCMdpwxmj8FfQGe4yrouMpAKCdErQlNNBmlNJluvG9vZxeAB10a7/lyYwkzR9OUWAzBrXZ3QkjwPyUC4s/4kEHe/CkSDlIDX0BRmqNFXEQnfz81Hsf+bM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=DZhuGTSV; arc=none smtp.client-ip=209.85.214.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="DZhuGTSV" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-227ea16b03dso3094425ad.3 for ; Wed, 02 Apr 2025 13:16:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1743624980; x=1744229780; darn=vger.kernel.org; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=d/Qfr113zCIU5rUe0KDXRj0KUMUinv6gA3VPY5V4Jtk=; b=DZhuGTSVbrRzQ78VxJpp2S0YKG/IZxKIueRqDM5j/ybLpqR7464l9ZG00hWPgha1ud AsZliy6rlcBYbDhyBYqmojmgxp8j3tzkhK8x2xAguMo93sS5BJNU4ECof3vPOFSAMdWE lsvHavXZhMb7fA9dU6dIIpq5gc0rtCQv1eZWiDjQPAwcKA3eoKEdfl+kR3wCtx+Yqh8h isVnkslUqR42ozLTP5sYc7wYmB241N0yltF0TjP8/gE9AOhhfFSjx1ih/efvdI3Y7qlD LJaAsQ929KugZkuflXloQ0zZMMjF3OaEdTztJmiCADwGbhi2koUkAYqBmOYs+EZLAZNI ckeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743624980; x=1744229780; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=d/Qfr113zCIU5rUe0KDXRj0KUMUinv6gA3VPY5V4Jtk=; b=doGotn7TyB/JNJPQSI+f8GQqrY20tpuHhABMPmpCPfnKmmhc0K1Vy/hUTLeFozRnwm XecQ3wpmj1kf1xpKTT0YVm7/QLkkBkDCaiOF6faTRHfPxcRoEZy04g0l0YeosUrntd41 F1EpxT1Aw4RoNnUr3Tsf/4KvPhluBaCHv+SayfwVuIGPjuv1TcELc+awLkVu/M6eMJcB LNzsONCmb9EiuMZT/0vGg88cvgNxVLbabZTNtMZHtvLNqTTe+RbFJjeteiT5NCMRH/aP UhAnsXa7gDAP2jOihBExVUvmKlSOoWCBGiGVSD2tu2CqrnUgooa8zS6b21vYZGGIdwWE oasw== X-Forwarded-Encrypted: i=1; AJvYcCV/1ggqWRnfshsyRgp09nZ0VfKED4gZ+HL+rm+4HmSfEXMgvq49lUgSi43XFy/Ctw9KqJOTFswo/IAjYtw=@vger.kernel.org X-Gm-Message-State: AOJu0YyeQI88DMgNPTX+VI2pMA8nbLFHgNfa4+egBM9upzNbtvICw+FJ xEaeSIbPDTt6M79Ev3aP5sqZnnLvJk/wdQcCTFnlAZkD+7BnaYUYto3x7T9UqXmczySJhLmEBDL DGJvFGQ== X-Google-Smtp-Source: AGHT+IETEif39DUX+D51g2bBbhpyP0oodQFGAfpXoFFKrQ1cjkkkGk0Knxqrd1W1Zzu+AtS/B6svQpHL6ora X-Received: from ploc6.prod.google.com ([2002:a17:902:8486:b0:220:e952:af68]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:f543:b0:221:7b4a:475a with SMTP id d9443c01a7336-22977e0c7aamr930985ad.52.1743624979911; Wed, 02 Apr 2025 13:16:19 -0700 (PDT) Date: Wed, 2 Apr 2025 13:15:47 -0700 In-Reply-To: <20250402201549.4090305-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250402201549.4090305-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.504.g3bcea36a83-goog Message-ID: <20250402201549.4090305-4-irogers@google.com> Subject: [PATCH v3 3/5] perf evlist: Refactor evlist__scnprintf_evsels From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , Howard Chu , Dominique Martinet , Levi Yun , "Dr. David Alan Gilbert" , Andi Kleen , James Clark , Weilin Wang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Switch output to using a strbuf so the storage can be resized. Add a maximum size argument to avoid too much output that may happen for uncore events. Rename as scnprintf is no longer used. Signed-off-by: Ian Rogers Reviewed-by: Kan Liang --- tools/perf/builtin-record.c | 9 ++++++--- tools/perf/util/evlist.c | 21 ++++++++++++--------- tools/perf/util/evlist.h | 3 ++- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index ba20bf7c011d..9a3f7d9f881d 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -51,6 +51,7 @@ #include "util/clockid.h" #include "util/off_cpu.h" #include "util/bpf-filter.h" +#include "util/strbuf.h" #include "asm/bug.h" #include "perf.h" #include "cputopo.h" @@ -2784,13 +2785,15 @@ static int __cmd_record(struct record *rec, int arg= c, const char **argv) record__auxtrace_snapshot_exit(rec); =20 if (forks && workload_exec_errno) { - char msg[STRERR_BUFSIZE], strevsels[2048]; + char msg[STRERR_BUFSIZE]; const char *emsg =3D str_error_r(workload_exec_errno, msg, sizeof(msg)); + struct strbuf sb =3D STRBUF_INIT; =20 - evlist__scnprintf_evsels(rec->evlist, sizeof(strevsels), strevsels); + evlist__format_evsels(rec->evlist, &sb, 2048); =20 pr_err("Failed to collect '%s' for the '%s' workload: %s\n", - strevsels, argv[0], emsg); + sb.buf, argv[0], emsg); + strbuf_release(&sb); err =3D -1; goto out_child; } diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index c1a04141aed0..ffb5be41a465 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -35,6 +35,7 @@ #include "util/util.h" #include "util/env.h" #include "util/intel-tpebs.h" +#include "util/strbuf.h" #include #include #include @@ -2468,23 +2469,25 @@ struct evsel *evlist__find_evsel(struct evlist *evl= ist, int idx) return NULL; } =20 -int evlist__scnprintf_evsels(struct evlist *evlist, size_t size, char *bf) +void evlist__format_evsels(struct evlist *evlist, struct strbuf *sb, size_= t max_length) { struct evsel *evsel; - int printed =3D 0; + bool first =3D true; =20 evlist__for_each_entry(evlist, evsel) { if (evsel__is_dummy_event(evsel)) continue; - if (size > (strlen(evsel__name(evsel)) + (printed ? 2 : 1))) { - printed +=3D scnprintf(bf + printed, size - printed, "%s%s", printed ? = "," : "", evsel__name(evsel)); - } else { - printed +=3D scnprintf(bf + printed, size - printed, "%s...", printed ?= "," : ""); - break; + + if (!first) + strbuf_addch(sb, ','); + + if (sb->len > max_length) { + strbuf_addstr(sb, "..."); + return; } + strbuf_addstr(sb, evsel__name(evsel)); + first =3D false; } - - return printed; } =20 void evlist__check_mem_load_aux(struct evlist *evlist) diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index edcbf1c10e92..21f6bff319fd 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h @@ -20,6 +20,7 @@ struct pollfd; struct thread_map; struct perf_cpu_map; struct record_opts; +struct strbuf; struct target; =20 /* @@ -430,7 +431,7 @@ int event_enable_timer__process(struct event_enable_tim= er *eet); =20 struct evsel *evlist__find_evsel(struct evlist *evlist, int idx); =20 -int evlist__scnprintf_evsels(struct evlist *evlist, size_t size, char *bf); +void evlist__format_evsels(struct evlist *evlist, struct strbuf *sb, size_= t max_length); void evlist__check_mem_load_aux(struct evlist *evlist); void evlist__warn_user_requested_cpus(struct evlist *evlist, const char *c= pu_list); void evlist__uniquify_name(struct evlist *evlist); --=20 2.49.0.504.g3bcea36a83-goog From nobody Fri Apr 4 12:26:52 2025 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 651E81F37BC for ; Wed, 2 Apr 2025 20:16:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743624983; cv=none; b=O6OqJdCGMo6nsgemsQDaj5VQA/9u/hiacVcfmAOGz5O1n3jhspSKjr33vpmBs+QGQ57KjFw5qFELQFq8d1emSvsLdAq7Bwm3RkaYTBxBjqsj7x+9CU6v1FDvm75hvK7Gm/EB+OOA3NVlugtbrz9awTFLZvmkqFb+PtE8b3acbgs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743624983; c=relaxed/simple; bh=WStuIdPt8lRJg1FWf8KPFEILp1PnsGADoTb7+XPTPCo=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=OIi1C//H4nP4fWX2Qjp5GCuDbvSoM5zkNtm3dqdaAzQv+9QxdKEMcjy7vftF9AlMvumfuoK/CWtgqbDVOmnoWdm7gkR9ksg6qKIhG9wh5u3DEaik7u/k/RMNR2HZvkAS2QIMFceEASulMj6ld2BB72YrQEsHneAefHT3LAT2XU4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ZcX2JdaF; arc=none smtp.client-ip=209.85.214.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ZcX2JdaF" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-229170fbe74so1925055ad.2 for ; Wed, 02 Apr 2025 13:16:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1743624982; x=1744229782; darn=vger.kernel.org; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=3tDmbLrtoU9NWl61/Y1ycLMfPN40NbRlPLTERdTcD4c=; b=ZcX2JdaFK797Fd6wlJs0yu/IEeo4JQOLQzzFfk6L3La+glK+BVZJmPYLQ3bBCseKE1 mqtUrgbxgA0EWcEdYFbUxdzFd7MU5aUL/PTlRFO1Z0Bmj44MBOoIXJtjF4WTzCMW7d9Y jRMPV0idDeTqVtGMSHIxeYzsnetKIw6N1jerS1o1c+xKigQwtdRzkiS2CM3uFOhthdlU IlIL9HhSedN8i5ZWqh9vCn5Qvx0UR8hPgXYb7tRI+EGMMiPg66lNfE8CIouRJZCtHdUK dTiM8JwTScXqfuhiuzsKPjz/p/1+NP6ClW+OKEiAORrH+Go8vO2ReRHwe+0gwrm+8p5e CmBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743624982; x=1744229782; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=3tDmbLrtoU9NWl61/Y1ycLMfPN40NbRlPLTERdTcD4c=; b=qgeDLIH1VK/ddBmucpMv0RRtTgOq8o/opyqZVDSQENE6530xrXJDXKS5X45bpSfIIO YyUB7Undh/v06I4OUwX+uproWJSLOTgOuAad95dm2dZ5+82Vz3kK7YphrDEIkH1N3N37 pP9//Y3yrQiNPkwVK3I3SKjedQO4269lvuZOUBvB/z7q3YckOyRJtSdanHSe3wiIeCPd abgJsFo5PwNbLVtZt0XCkN0h2HX6ArVke1zgO5BDtomAFXiNF57NRPBjVC8Sxt4VonqG yZIk4/mj+wDg1lZC6/mlYosrtCl0uCDXCD2mqU+Cwo0JVvKsz1ZWyFGn+U2li55l7tvZ J91w== X-Forwarded-Encrypted: i=1; AJvYcCX+Jr0I82BonAE6M0yiOkztiddUZZf1GyTIGkExnAKyBJz99wcTenHb3nQ3G3FVNOTOnVV3czt0HEuNB74=@vger.kernel.org X-Gm-Message-State: AOJu0YzSlhqwCZE4segZjCn0R2DEY+zevVnKbt2AKRtAm52RntX3v57U v22Sqx51wntGf6tyO3ATMqY46qTfvWCSshm5pVGgVsyieEkVEzpJruM7FzPnAgDSmrJ4Xj+0BHY X8LHI4g== X-Google-Smtp-Source: AGHT+IFPE0DDi1RjFCqnrb0Hi7HSJbP/alBx968X4Vig8llhyMTnMqG2kWgh2WhFFwFKqa7GG5ipt79Ci8Zq X-Received: from pleu12.prod.google.com ([2002:a17:903:41cc:b0:220:c367:eb6d]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:ebd1:b0:223:3630:cd32 with SMTP id d9443c01a7336-2292fa162abmr287207785ad.53.1743624981872; Wed, 02 Apr 2025 13:16:21 -0700 (PDT) Date: Wed, 2 Apr 2025 13:15:48 -0700 In-Reply-To: <20250402201549.4090305-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250402201549.4090305-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.504.g3bcea36a83-goog Message-ID: <20250402201549.4090305-5-irogers@google.com> Subject: [PATCH v3 4/5] perf evlist: Add groups to evlist__format_evsels From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , Howard Chu , Dominique Martinet , Levi Yun , "Dr. David Alan Gilbert" , Andi Kleen , James Clark , Weilin Wang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Make groups visible in output: Before: {cycles,instructions} -> cpu_atom/cycles/,cpu_atom/instructions/,cpu_core/cycles/,cpu_core/instructi= ons/ After: {cycles,instructions} -> {cpu_atom/cycles/,cpu_atom/instructions/},{cpu_core/cycles/,cpu_core/instru= ctions/} Signed-off-by: Ian Rogers Reviewed-by: Kan Liang --- tools/perf/util/evlist.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index ffb5be41a465..6ebe0795e1c9 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -2471,13 +2471,18 @@ struct evsel *evlist__find_evsel(struct evlist *evl= ist, int idx) =20 void evlist__format_evsels(struct evlist *evlist, struct strbuf *sb, size_= t max_length) { - struct evsel *evsel; + struct evsel *evsel, *leader =3D NULL; bool first =3D true; =20 evlist__for_each_entry(evlist, evsel) { + struct evsel *new_leader =3D evsel__leader(evsel); + if (evsel__is_dummy_event(evsel)) continue; =20 + if (leader !=3D new_leader && leader && leader->core.nr_members > 1) + strbuf_addch(sb, '}'); + if (!first) strbuf_addch(sb, ','); =20 @@ -2485,9 +2490,15 @@ void evlist__format_evsels(struct evlist *evlist, st= ruct strbuf *sb, size_t max_ strbuf_addstr(sb, "..."); return; } + if (leader !=3D new_leader && new_leader->core.nr_members > 1) + strbuf_addch(sb, '{'); + strbuf_addstr(sb, evsel__name(evsel)); first =3D false; + leader =3D new_leader; } + if (leader && leader->core.nr_members > 1) + strbuf_addch(sb, '}'); } =20 void evlist__check_mem_load_aux(struct evlist *evlist) --=20 2.49.0.504.g3bcea36a83-goog From nobody Fri Apr 4 12:26:52 2025 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 165EF1F417E for ; Wed, 2 Apr 2025 20:16:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743624986; cv=none; b=fsWJP0HCfz4xvZmG8Hp0M5vvKDmUZZmp8jnMJNpcSxggG+ljSGpFtGO4ljVQ7Jt+LIbfvABid7MQw5bblUpl9AEctGtLNTo40UnYUCZNd7YbUcUG3RkGKP5uhhKzoQsjL+0QaMe30wp8VeyG3D7W76Y5b4BSet7nGWHMo6A/XGg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743624986; c=relaxed/simple; bh=XJNVlfb9B6e09OVvYHlLgV02vSfa13DfWe+IMu0BsHw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=hXid6aMff4bLu9CPEtozTPLmY7pkjuirq2zXpy/YooN5fWtdnWvmfbNLdmEaMzaV7mBEemGoORFe426ur/CE+1phSMTZ0Ad9m65XmmNW3peFIOITCapANjMtR0lrc7q6dJ20FGXIKip8u9Lod1ipR0bHuCjU5QUPjt7loEaEbhE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=p2EsBXdq; arc=none smtp.client-ip=209.85.216.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="p2EsBXdq" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2ff4b130bb2so172623a91.0 for ; Wed, 02 Apr 2025 13:16:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1743624984; x=1744229784; darn=vger.kernel.org; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=B2hDS3YsXTlEuSmhORL5o7layHPktsvi9Jj/B/AMxqI=; b=p2EsBXdq+WB49CIJz7a4CEZ/iN451SQ15WCnD8Ws39ZCa4ED37hwZtn41CMRTSa50q STB6GmuXsBffgZr0cFyYbUP+Hql/6APVSpdqspqSyp2oOlBWw3OL7YPqATp6th3+6MYG AJE772kpDtSTkosM6Tw4y1hv+BIFKwId18DgA3KkyhHoRhuz+TBmnxDxj5up5+RwjPYR 7+CdWs8i8mWDIjncbHn/OI51owo7QbvGd2/3Tvv3orivDa+L2DMvxntbFPR1vDI1/gQZ 1G7lzM/ErCVt1BaPpegr3Yuz6lHDzSqObpjUnuXcbEtP5x9Z1U1FZXKWVWgWfdOgx4uB OASw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743624984; x=1744229784; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=B2hDS3YsXTlEuSmhORL5o7layHPktsvi9Jj/B/AMxqI=; b=A+FtCYekAvcl91t4O8XP59wxwaOmu/ft+fo7VRNXwQ+7aZM0AEMIhT8CznA8ZwKuPE MECP1/1UxkZQKYmSJhY3A0TqBTFiOMjtZJeXS2ACYbgZY2tybVOTaTGxbnYqecPVxgEj XW4cZR3YxdbbTw1gMVHhq4902iktwLuHidm4d08h9WHWpA5J6JVgBuoaimQV0U5TSoFx Zm88LQi6I06I3/yk/ZfG8l0RjOK65WuTBuQQWMJ36TDtA955S9Ao6CTpXPz0EjbaCoIU Nv7dGNmVNJ/irYMu5jp7oMzCJhpUwg4qMYoo9DlNjJgXFqDMBivBlAVzvWWyqlSYZvuU Jpqw== X-Forwarded-Encrypted: i=1; AJvYcCVXS7lYPthxPdAs1asIg3YZ3VMsf4DfPgybSmWDfBH+09k7/XA0EbLJeuBz+ut3fw3dJbElIhVqBKlxzmg=@vger.kernel.org X-Gm-Message-State: AOJu0Yyik8vfOc4Pzi/a5isikU1SxdoWyAKkSrK9QtPfVaZ3mMGpYYqv I7p/vx/wu6fRhSJj6f4hcOdXayJGtiu3hBD+P/0zArep7RscDA8+fN+ksNks1lEADPEka6sWnBY fFuSAXg== X-Google-Smtp-Source: AGHT+IGWRDhVif65PZjK6L6tokXcwfnxg3KYz2H32NL1j6yAsld5CATaklhVtmImMk0tbsc8phvPpUNyY8GA X-Received: from pjd11.prod.google.com ([2002:a17:90b:54cb:b0:2ff:5752:a78f]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:1f92:b0:2f7:e201:a8cc with SMTP id 98e67ed59e1d1-305320b1002mr31454142a91.18.1743624984352; Wed, 02 Apr 2025 13:16:24 -0700 (PDT) Date: Wed, 2 Apr 2025 13:15:49 -0700 In-Reply-To: <20250402201549.4090305-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250402201549.4090305-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.504.g3bcea36a83-goog Message-ID: <20250402201549.4090305-6-irogers@google.com> Subject: [PATCH v3 5/5] perf parse-events: Add debug dump of evlist if reordered From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , Howard Chu , Dominique Martinet , Levi Yun , "Dr. David Alan Gilbert" , Andi Kleen , James Clark , Weilin Wang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add debug verbose output to show how evsels were reordered by parse_events__sort_events_and_fix_groups. For example: ``` $ perf record -v -e '{instructions,cycles}' true Using CPUID GenuineIntel-6-B7-1 WARNING: events were regrouped to match PMUs evlist after sorting/fixing: '{cpu_atom/instructions/,cpu_atom/cycles/},{cp= u_core/instructions/,cpu_core/cycles/}' ``` Signed-off-by: Ian Rogers Reviewed-by: Kan Liang --- tools/perf/util/parse-events.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 5152fd5a6ead..7952f431f82b 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -28,6 +28,7 @@ #include "util/evsel_config.h" #include "util/event.h" #include "util/bpf-filter.h" +#include "util/stat.h" #include "util/util.h" #include "tracepoint.h" =20 @@ -2196,14 +2197,23 @@ int __parse_events(struct evlist *evlist, const cha= r *str, const char *pmu_filte if (ret2 < 0) return ret; =20 - if (ret2 && warn_if_reordered && !parse_state.wild_card_pmus) - pr_warning("WARNING: events were regrouped to match PMUs\n"); - /* * Add list to the evlist even with errors to allow callers to clean up. */ evlist__splice_list_tail(evlist, &parse_state.list); =20 + if (ret2 && warn_if_reordered && !parse_state.wild_card_pmus) { + pr_warning("WARNING: events were regrouped to match PMUs\n"); + + if (verbose > 0) { + struct strbuf sb =3D STRBUF_INIT; + + evlist__uniquify_name(evlist); + evlist__format_evsels(evlist, &sb, 2048); + pr_debug("evlist after sorting/fixing: '%s'\n", sb.buf); + strbuf_release(&sb); + } + } if (!ret) { struct evsel *last; =20 --=20 2.49.0.504.g3bcea36a83-goog