Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp574280rdb; Thu, 1 Feb 2024 18:27:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IGEJbs8sralwGFAl8zMfiFpHVahkuGo32Ft26J1EG8HkPJGLvcupTJuEs71jmyHcyYbRfla X-Received: by 2002:a17:902:b212:b0:1d8:fe1e:7cb2 with SMTP id t18-20020a170902b21200b001d8fe1e7cb2mr5301902plr.45.1706840869450; Thu, 01 Feb 2024 18:27:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706840869; cv=pass; d=google.com; s=arc-20160816; b=k4WKCj6D6p1EP7TTWosAzsb8bdr95NGIln4XhRCQwbSweWzbsJ+n/CtsR07/O6MTS6 vbXs/eAljPjSJXANV6b3PeLCrxZducI2Vwu9Ksc9Bhx0FCgufAB6EYx32YaGFjK1jdYW SvoTRv5L9laTAuSN9Tv9ucZXwDcNWcUmf1qSZF/hIfldGi0GpAYEkzCaizMcTYXeZSTL dJWLbnqZEQlcuTq3F2V0nP3boPCmWb7js0WsXLQEnQWdy9a+W5AFb0Ukx8xPeVZXjZzK +K1op7r7Gdbrbwj3sbhdQaKmd40FXEUV+bNX98oeErt2LW8gxpc+QqkSHDJsED+LeWd5 Sduw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:references:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:in-reply-to:date :dkim-signature; bh=eE8QPd1iYx3LHUzisH1HrCND1yAXDK1EtvXVhual9UM=; fh=67BiszUVFrgwoFuiPMZTohNv/dAr92Yw0cXMC3M0rkA=; b=kqLl2hZITAOGgHn6y1cRtlXoTS1Isn71EGIp+OGahyY2HvgymQ0MXGEON1/8xmetM9 W21ISLY621l77O4vXl4BFIuTRybPAVG/7MNM6WFMBhFKVdLIoPk0e+M9Kt0w/OTsV0vI EZJegonJUBH4dzYJjQ0sLNx9iPQZhwBbL6VcCnWHMdM/j9CN7kS4RLjmNemLAjzjDuEc FxhL+S8+GVeDSsPxxDpvycKNOjK0Hzdh81Npk3YnUXR71gzvDlQmhjahTzWXylN3RrrJ tAS3G9/5VmNdf1dQDdZxqEq5lUJvj1CX5lU8wRK8De78pMlp8O68sE/0YhnaPBFXwRHa YvIQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ezlwYCE9; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-49090-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49090-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=1; AJvYcCXf1ldKqR/256N3eGux0mY9+tiAM1fQsWx4Yg3zt7s9flDQ7/nV4uGda8f3njo44pCVF+kGc588luiCRnVegjPKHDVQnWDZA4x2PFYRwQ== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id b5-20020a170902d50500b001d8f08c25b5si852463plg.309.2024.02.01.18.27.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 18:27:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49090-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ezlwYCE9; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-49090-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49090-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 53058B2373F for ; Fri, 2 Feb 2024 02:26:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D81C7DDD6; Fri, 2 Feb 2024 02:25:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ezlwYCE9" Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.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 68155C2D9 for ; Fri, 2 Feb 2024 02:25:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706840731; cv=none; b=R7OiwtAEY8+IeE07aOZM3FhEnUhqW7oN5K2SBCvLooSbBLWi4iHO9eaBTT7sTE66fo6dcohbFghnC/c2rY1c11jkEjdch8alpL+VJ+1ZxVuzp9AcqEQZoUlkw1Eo3pc91huIumdg8t8Qm3Jnxj86Vz4wHi1sQPg2hKAHdjMYmb0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706840731; c=relaxed/simple; bh=+dGqQcOQIiIKm4nZa/D+qKz6TWrGgBGYDyGjniDUOCI=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=X1c4W2FxnNSeGM84e5lg4LezbVeQOdO/xLdagakfKV0n+Bv+5zMmf85Z4BTXfNwKyns42fx0Ld8QfRbJG1pW2irKxUhhS/9tMgVVYOH1v1oYvrH9TK/xHVRmzDp8n9XzzCGQyHdvPZ4/hPt0MNYfMuoHgofSrUqRtvzgrdlIBtY= 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=ezlwYCE9; arc=none smtp.client-ip=209.85.128.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 Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-60424617790so14621387b3.0 for ; Thu, 01 Feb 2024 18:25:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706840728; x=1707445528; darn=vger.kernel.org; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=eE8QPd1iYx3LHUzisH1HrCND1yAXDK1EtvXVhual9UM=; b=ezlwYCE9t6t1TrxsZ0UaWrChQKObdDSkzmUaS4H1JVsE2pBMW/diNYMo9xkG1/SMDS Fe4QUBKxQDLN6AMgR5q1NjsaNJ91zJjhZbK6uLHKkDc8ObUp7ozBKbvd/msiHW0Euyxw frf8woe9Q5Vz1CDla1eZK32VOfIa/06lxgDuFLmAFwG7FJ8eCZtuAysR+Vxwygvo1V2f MmbjndJ9uFLxF+TiXr+vpEv7u0L0rdl+CinBKmMMJnErfvHPaOAOE7LYi30a6qVGpu/r cSJrFiYtowgimvReBmTHPz9HwPahUhPjTvAyoODHJJ60vfKdQN0Sq9dBJPe7iIihieAG 5Xtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706840728; x=1707445528; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=eE8QPd1iYx3LHUzisH1HrCND1yAXDK1EtvXVhual9UM=; b=sWMRF0TYvatnluJ5axFwnYl5BK73JxiXhz1qdMPT53gxAOzbWpCip4fanwexkRUlT7 IqXYZAuLR3rQNnQA8z1q62VFhesZCqCUk3huWMD5o1yoQxcCSpoIeN5xuvNBqpquQd1B xJRGmGIFaPq/nQ3cOTrrv/RX3rE1Y0W+WWZaJx126SzXKnWN98Zf1WtWtyPF9xdN23uc 6fkDVbwaET/XkYY5FVZP8GQ0/nSSeo9kEzm8nZ7Sx29wCnJ6pnRhDsTBivCEaY7T0ovY snfGM+4h0vmYq8JFtDSOGWHRTXAuyMq89K3w6PSYhFpGXMJDIoK69oyUuXL5x8c9OEGu 3j1A== X-Gm-Message-State: AOJu0YzMXJtRvGMn1MFPux5PE4lEXONQ/RGAwEa8goTn1aO3s0NR854j VYILyFw03XuGL8jNTseJaeIfV/rITt2BfqCI/NfluGLRjmCall5guuSRh/767O3bAIzJOsavz+2 kMa4KhA== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:a85f:db1d:a66b:7f53]) (user=irogers job=sendgmr) by 2002:a05:690c:f8d:b0:604:1eea:a39e with SMTP id df13-20020a05690c0f8d00b006041eeaa39emr554346ywb.3.1706840728429; Thu, 01 Feb 2024 18:25:28 -0800 (PST) Date: Thu, 1 Feb 2024 18:25:12 -0800 In-Reply-To: <20240202022512.467636-1-irogers@google.com> Message-Id: <20240202022512.467636-3-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240202022512.467636-1-irogers@google.com> X-Mailer: git-send-email 2.43.0.594.gd9cf4e227d-goog Subject: [PATCH v1 3/3] perf stat: Fix metric-only aggregation index 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 , Kajol Jain , John Garry , Kaige Ye , K Prateek Nayak , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Stephane Eranian Content-Type: text/plain; charset="UTF-8" Aggregation index was being computed using the evsel's cpumap which may have a different (typically the same or fewer) entries. Before: ``` $ perf stat --metric-only -A -M memory_bandwidth_total -a sleep 1 Performance counter stats for 'system wide': MB/s memory_bandwidth_total MB/s memory_bandwidth_total MB/s memory_bandwidth_total MB/s memory_bandwidth_total MB/s memory_bandwidth_total MB/s memory_bandwidth_total CPU0 12.8 0.0 12.9 12.7 0.0 12.6 CPU1 1.007806367 seconds time elapsed ``` After: ``` $ perf stat --metric-only -A -M memory_bandwidth_total -a sleep 1 Performance counter stats for 'system wide': MB/s memory_bandwidth_total MB/s memory_bandwidth_total MB/s memory_bandwidth_total MB/s memory_bandwidth_total MB/s memory_bandwidth_total MB/s memory_bandwidth_total CPU0 15.4 0.0 15.3 15.0 0.0 14.9 CPU18 0.0 0.0 13.5 5.2 0.0 11.9 1.007858736 seconds time elapsed ``` Signed-off-by: Ian Rogers --- tools/perf/util/stat-display.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index 8c61f8627ebc..ce830c6afdf2 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -1126,11 +1126,16 @@ static void print_no_aggr_metric(struct perf_stat_config *config, u64 ena, run, val; double uval; struct perf_stat_evsel *ps = counter->stats; - int aggr_idx = perf_cpu_map__idx(evsel__cpus(counter), cpu); + int aggr_idx = 0; - if (aggr_idx < 0) + if (!perf_cpu_map__has(evsel__cpus(counter), cpu)) continue; + cpu_aggr_map__for_each_idx(aggr_idx, config->aggr_map) { + if (config->aggr_map->map[aggr_idx].cpu.cpu == cpu.cpu) + break; + } + os->evsel = counter; os->id = aggr_cpu_id__cpu(cpu, /*data=*/NULL); if (first) { -- 2.43.0.594.gd9cf4e227d-goog