Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1225546lqt; Fri, 7 Jun 2024 11:27:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVMltAhoiUtijgKjqhjVjAI8KxL4oIfALF4Q3lOafKjTZwJ4i59owpmGWrOEOP5N96IKB5dvtnm5zgCOyqTzBxYqjiQUF6HrkYn3hp6TA== X-Google-Smtp-Source: AGHT+IHfDzlKBOE264donlPhNSFPNysFMUG1+PQOKW3AGN4l9peOI/F17Xr8Hs+6HjwZQ//QqFLp X-Received: by 2002:a17:906:7ac6:b0:a5c:d67a:e8ef with SMTP id a640c23a62f3a-a6cd665b5f2mr206929866b.31.1717784842758; Fri, 07 Jun 2024 11:27:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717784842; cv=pass; d=google.com; s=arc-20160816; b=ZIkFbCuFHhFf+pQ5RfqbNNlc8zhQydbjcvxHuT3SoOSlYGNyIHMSMT7NfR84jPq7iG OHb/0UorEIxRZ/OYAEvYRFkkdAkzo3bj2U9/ZPyrjuLpt+JNFSHhgw1eyaNahMRJxp5/ f60PVa/saVY6Fxxxq5nFpcYDGBS+RoHqQG7XPXvDTJ1rO3XhqmLTCIC7MvCsh/uA4hmf 1XH0xnvZlH8SrVNnYCZxx4ItSB7uT97VrNrurGD2KxAVYQ1mjytz93F+4CmF2O1Pw18R S7rqmSvOkLvaEe0ySJKjuU/l1boH140L664Zv+Evteoldjm8fslQtSbT5oiLSfwBANrp cy9g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=QZcaKlWtYubmW6uw+ITnYPPbj3rW/qCvZ0EXYOlYLks=; fh=buH0fdcXRmRniQH15PdUe28BDRaWkv+bZwUJndpH4Uw=; b=kfW/BSxCnAet2zNgc3DXQuuF+IiQQFH/I8vOpNKTAHE9Q5n1G3bEZ9jH1kyjt8IBQB XdpO6/7jfkm+1Y86LH1xaIljGQD7pSZstsyNcOOVibsjW9w4AQZOkXK5ZzqKzD+hd709 t8793jUjdoH/axUf8L6WcULID+P97yGtXQIhfZcEXbhYtR8zmcc10CXjTQiVzG/O1Dmg bEcyf0TnqdwzZdPIwUb1yBqeDL1IUBjkSdW/vutu7OBMc5QUQ7kjiCbMsmLNhi6BzW+Z NOlOetomLZMlnsfz+2Dt59Fa4eQdEqp+TSAjlKNCfisC7zooXJOelWUndYeZFGCR+med 22rw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sJ+P6kAh; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-206600-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206600-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6efd652b99si1467566b.773.2024.06.07.11.27.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 11:27:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-206600-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sJ+P6kAh; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-206600-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206600-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 26AD11F225F1 for ; Fri, 7 Jun 2024 18:27:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D26BC13E034; Fri, 7 Jun 2024 18:27:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="sJ+P6kAh" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 00825A20; Fri, 7 Jun 2024 18:27:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717784833; cv=none; b=kvTmHPYa2BI7qBPSSYiusoPb/PyXlPK1i2r0SNqsk1T4DYWOMoEkoHGxhSI40KYhoKQjacqJB+rz6lbfNY8fcrnBt0rAAovXvca6PtlG16xwIWSwalwz+kYSdEtTt643MPW+ja0s/cvLv5qqWDOvd12WOdKvQhvA/RrlZRhcZIM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717784833; c=relaxed/simple; bh=+d6eJOSptWCzzm26y7U5MbNGJfLQUzNJXPv4dUZf8Jo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=tmMFJ4xoiYvCpm8eimGrVcLK75m29IjDzu/goOUy+dExUbXfUnl+AkIaoVNZ6wSFJRrKWKwch85eB87Z/4ITokrqGwU0F82KIICDGFuHvtR57ZMwP78naaivo51pwOj1XSk1drnIF//TFm1YtzrGyHJda8uN078QyTm0lpyHGHs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sJ+P6kAh; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3DD17C32786; Fri, 7 Jun 2024 18:27:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717784832; bh=+d6eJOSptWCzzm26y7U5MbNGJfLQUzNJXPv4dUZf8Jo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=sJ+P6kAhbtDhS7jZsR+y53cAyqJidkC3Tdaqg1EQi2Tgk6LdJeXefpIJBnBL+QfGu aiaASN7aB8foNZJ4zRSR9dhcJmC5T7+bCaBCk+JIkr0RmAz+jD9RntfhZHi3C6Cv4K UwZPIWdR137BYrgyQwegkfFQ/r2m1iNoz7Q/snadEWPbtPTvIWgGuJNpwopHG+8MPX z8YmXR0xcFfVHqAAC+QM0wBOLIzJX25nR2yPM4oFCPX3oQimF3iwvUoXHiBMvk/lfZ tTatCZ5mVKq3EZe9nNYQAdzzv67IYhdsL1QKHNeEoaiwrTGjXX3r4oBcfgRPqqHq6G QgTYFcE3wadhQ== Date: Fri, 7 Jun 2024 11:27:10 -0700 From: Namhyung Kim To: kan.liang@linux.intel.com Cc: acme@kernel.org, irogers@google.com, jolsa@kernel.org, adrian.hunter@intel.com, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, "Khalil, Amiri" , stable@vger.kernel.org Subject: Re: [PATCH V2] perf stat: Fix the hard-coded metrics calculation on the hybrid Message-ID: References: <20240606180316.4122904-1-kan.liang@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20240606180316.4122904-1-kan.liang@linux.intel.com> On Thu, Jun 06, 2024 at 11:03:16AM -0700, kan.liang@linux.intel.com 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 cycle > 4,268,965 cpu_core/instructions/ # 0.23 insn per cycle > > The insn per cycle for cpu_core should be 4,268,965 / 9,733,603 = 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. > > In the hard-coded metrics, the events from a different PMU are only > SW_CPU_CLOCK and SW_TASK_CLOCK. They both have the stat type, > STAT_NSECS. Except the SW CLOCK events, check the PMU type as well. > > Fixes: 0a57b910807a ("perf stat: Use counts rather than saved_value") > Reported-by: "Khalil, Amiri" > Reviewed-by: Ian Rogers > Signed-off-by: Kan Liang > Cc: stable@vger.kernel.org Acked-by: Namhyung Kim Thanks, Namhyung > --- > > Changes since V1: > - Don't check the PMU of the SW CLOCK events > > tools/perf/util/stat-shadow.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c > index 3466aa952442..6bb975e46de3 100644 > --- a/tools/perf/util/stat-shadow.c > +++ b/tools/perf/util/stat-shadow.c > @@ -176,6 +176,13 @@ static double find_stat(const struct evsel *evsel, int aggr_idx, enum stat_type > if (type != evsel__stat_type(cur)) > continue; > > + /* > + * Except the SW CLOCK events, > + * ignore if not the PMU we're looking for. > + */ > + if ((type != STAT_NSECS) && (evsel->pmu != cur->pmu)) > + continue; > + > aggr = &cur->stats->aggr[aggr_idx]; > if (type == STAT_NSECS) > return aggr->counts.val; > -- > 2.35.1 >