Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp445536lqr; Wed, 5 Jun 2024 10:21:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUEd0JgXGwCtnfAaZaFATCMVk5dLGn8no5zfopQc6Fr7fNXM8n7ygegJDdzRuO8Kbwunc+rM4oCdtzYUG57jZ5vgl1IZdrp+4Wui0FSGA== X-Google-Smtp-Source: AGHT+IEz6th8oj++r6cUUKc5ukcV+KoTkKZ3grE2bWMLZmOE3BlDXTppMdh3zjkX3NlweHdd0VKH X-Received: by 2002:a0d:ec42:0:b0:61b:2b7:27d8 with SMTP id 00721157ae682-62cbb4ff8cfmr27951277b3.23.1717608097431; Wed, 05 Jun 2024 10:21:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717608097; cv=pass; d=google.com; s=arc-20160816; b=LtJ6c+irfNDumPG1zwJObeCo4lkrHXXnJWftlDic3/U4w0EVLtOT6WHyvRyhsm/XmM 2sWp4+dQoznGv5hiZx/42NKiElRaev9++ea+LCkVEAWamtKY1zPpKQyY3Fkom7LIMfKR fKEzjrw1r6FvkQ6zX0UTtDRKoKBQ1/NuaVP/2VVXNcNJpTEM2p3/93dJB5btqinQQxbW MLi7vwpfTpbS1LfT/spxwGIPVEmFkq806gyZU1PaFQQJ6ypddHfEUjAJVs885jUu5323 chv6G74NfsJLFuI1icfvVN5CQaQGioEpUEI6nGSVAADAP2/tkS8vM6CNMOcpfd+5Si/c EXJg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=kYCo0S4v9XF6m0fRGRV3IsBGozW86ded8JzpR7EngjU=; fh=hixmnK5b8oVrxAatrNbAfdKx8GaH+9L4CfHL4r/G5Vo=; b=x8tzsFdPoZv4FrrMIkhTLICBzT7f25WIAmjaDo459kBZ+jrCh24RLKjMlmnf4PCN5q jnrnBLjE5n2F3Po+/fw835pxFxbk8QvwoAxtL7LxvtSEttSLZQF67h8Xe8jhlLMjDZcM rC6ZN+4oMXpxRDgCBHb3ErunpQywVA7fiqmAOG+rE2KzoK6p+FPBcnjvDb/K9DLJcDuS /TJ2wTNNkeIcWV1APqPpkbVL8dFL+wFnIYbDqAF1ZDcjVFEHxtl2J+bMM5kCNGXSkSNf 6IcVG71MUdN96TXNO8mF+veROMreRDLpjwZmJ2oDrPg5Q+oQa2Vsb6AYEoOa8KyKCs1P Rlaw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=nBhdOLxt; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-202969-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202969-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6ae4b4018aasi144474036d6.273.2024.06.05.10.21.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 10:21:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202969-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=nBhdOLxt; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-202969-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202969-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 290E61C24868 for ; Wed, 5 Jun 2024 17:21:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B3DC913A24D; Wed, 5 Jun 2024 17:21:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="nBhdOLxt" Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (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 456BF2770E for ; Wed, 5 Jun 2024 17:21:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717608086; cv=none; b=Tu3+CB+gltaLrdcF8XnA3pO2YQtvZLs3RgsQ9c1wMwUOh9sDpOK9fPtVhGmpppjH+n8CA5urEqyJDadYZpmuM18pjh9o3NJ2nxTJ+mf0HwwAP9/9ebt0n8hS+hZnIwujhKoMBCCX1I/8EufJuSwAJj6VXGbbFmR8zTrk3/3/kHs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717608086; c=relaxed/simple; bh=Tcwq5dn9T53VXyu2UVdw5TjGv2V1CJsT9RFq6hlk9QE=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Boi8sj6sMgzZfhBJb3UQW7vEm5X1oJs/4FZkHPZDFd+kn/9YZCRNqTaVtHHMisr6HwNt+0NpID6o0dX9Edui4pvG+OodwtmK1DA3QRB0RVT8XrmJH3FCYeI8U5Fr54gzVPynUjG6PlumBZiNBfCQzCU+aj5b5UglZ3PVsguuNuI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=nBhdOLxt; arc=none smtp.client-ip=209.85.214.171 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=google.com Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1ee5f3123d8so5965ad.1 for ; Wed, 05 Jun 2024 10:21:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1717608083; x=1718212883; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=kYCo0S4v9XF6m0fRGRV3IsBGozW86ded8JzpR7EngjU=; b=nBhdOLxtqLb/6IDbSQ7cbc5oFvALnCWkUFIjJpsMkQMjQOE7dXBUGCuCe0F70vOJTp zhzuMjL9el0GaUd0i1WJEHri3+EanWtrRKxyHidjzQ/6xr2O0L2TViyOyN0qBsugfwTj s7BOzVznQsc5gt6LIzggVG1PffrMGNOJQJA7unbUKbvQDovJqfLwcqst9FQsGz+3PSfe TLQYIoltUHGQjUYDr/ayFtWklpnSuTK6pSXJNMna13LdoLTI7TJ2Yw72OMKZym5NiaFL lh0TjaY3qEEj8VMMdZZwvnfvJTPGh3hKLdiDydhLBno8R8tW+5J4LyVpNlx4xBPGKOOW /YPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717608083; x=1718212883; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kYCo0S4v9XF6m0fRGRV3IsBGozW86ded8JzpR7EngjU=; b=TsXglhq5nCB/JFI9WLAClvBaUAAAegfhxCq/vN9AMOMyji4Crxb9Ll0cyhITfkH4Zt 2dXZTV045S9VsnG+XfJYQ9HpujOkHVk5oxRwXc4Llbaus9LtkXSMWKDQtCz9IuJGf3TH 5ujdBDh4y6WzzVF1Q9VI9438oZz5m6h49MRI3WFgiL/l6QrQd91nny7ur8efSp6kCrqO ZM4LLAg33ByVhGQe9pCP9I1pcS4fl4+ojUC4m2hvmSiFVE/bGH3rIlSYra6+sjVP3WG4 DSCSgQqlORBI8fCvRA+cOoiWbE3+VpWmJqxjlVWikeEcDwCziW3dRWBVeYEOkzIR+7xP Rhcg== X-Forwarded-Encrypted: i=1; AJvYcCVenVpZkHA9HKZ9RUs/mL+qBCTMbjyKcZv/Y8JQ4yZ5usRj26efpItcs2ABEPWEajHdwC1wVr6jZQ+FV+buGUgvVkl7xU1J+wmAHBKj X-Gm-Message-State: AOJu0YxZcmQE5O63GX0uIqoytEqG0nP961KHkRw6S932kdFE90PjCx3Y 7k1M2+YnsTvGBDFARXIiVLgCK5GkIfxPOf0YSnJDjnAl2kRyuTFxKODXI9NT1+A0YvNOfn7cBk6 YxVhiTXWiVwwY7r1hzxE3LZjvAq86oTBy/qBz X-Received: by 2002:a17:902:ee8a:b0:1f6:5bba:8ea3 with SMTP id d9443c01a7336-1f6a7b01893mr3570835ad.25.1717608083107; Wed, 05 Jun 2024 10:21:23 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240605160848.4116061-1-kan.liang@linux.intel.com> In-Reply-To: <20240605160848.4116061-1-kan.liang@linux.intel.com> From: Ian Rogers Date: Wed, 5 Jun 2024 10:21:10 -0700 Message-ID: Subject: Re: [PATCH] perf stat: Fix the hard-coded metrics calculation on the hybrid To: kan.liang@linux.intel.com Cc: acme@kernel.org, namhyung@kernel.org, jolsa@kernel.org, adrian.hunter@intel.com, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, "Khalil, Amiri" , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jun 5, 2024 at 9:10=E2=80=AFAM wrote: > > From: Kan Liang > > The hard-coded metrics is wrongly calculated on the hybrid machine. > > $ perf stat -e cycles,instructions -a sleep 1 > > Performance counter stats for 'system wide': > > 18,205,487 cpu_atom/cycles/ > 9,733,603 cpu_core/cycles/ > 9,423,111 cpu_atom/instructions/ # 0.52 insn per cycl= e > 4,268,965 cpu_core/instructions/ # 0.23 insn per cycl= e > > The insn per cycle for cpu_core should be 4,268,965 / 9,733,603 =3D 0.44. > > When finding the metric events, the find_stat() doesn't take the PMU > type into account. The cpu_atom/cycles/ is wrongly used to calculate > the IPC of the cpu_core. > > Fixes: 0a57b910807a ("perf stat: Use counts rather than saved_value") > Reported-by: "Khalil, Amiri" > Signed-off-by: Kan Liang Reviewed-by: Ian Rogers Thanks, Ian > Cc: stable@vger.kernel.org > --- > tools/perf/util/stat-shadow.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.= c > index 3466aa952442..4d0edc061f1a 100644 > --- a/tools/perf/util/stat-shadow.c > +++ b/tools/perf/util/stat-shadow.c > @@ -176,6 +176,10 @@ static double find_stat(const struct evsel *evsel, i= nt aggr_idx, enum stat_type > if (type !=3D evsel__stat_type(cur)) > continue; > > + /* Ignore if not the PMU we're looking for. */ > + if (evsel->pmu !=3D cur->pmu) > + continue; > + > aggr =3D &cur->stats->aggr[aggr_idx]; > if (type =3D=3D STAT_NSECS) > return aggr->counts.val; > -- > 2.35.1 >