Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp109238pxb; Mon, 8 Feb 2021 16:57:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJzv1/f9kWo9U5Fnvi6QgGCuPE5EcLTE8bEMvRfRdWmYWKFJYUYhhg0gNw/mM4R5PZmmZDLl X-Received: by 2002:a17:906:25c4:: with SMTP id n4mr19841527ejb.359.1612832222218; Mon, 08 Feb 2021 16:57:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612832222; cv=none; d=google.com; s=arc-20160816; b=c3vH1PS5Vdcbfip+LxndBFrgqeEWw5d/OFQqKjmaft1wS8y15hqPXylWhUlTRWtGvm weIuEwmXn25UhYbkrFt1vGpphIno+2XBk/Y4877LqTMCABLx0xJj3Rifit7n9hv/nmsc Or+wlvzHgQT2gDzB2xc4eVHgcA8SVVcMrK79pgmSdpwH9O+r0vXcTfCjtwXLYkEzAcp2 0H3sVNwNPSJFxXz7vJ8VHM0gzFl4NPEs6EjhAUMlt8aLBWUZtR4bl2aJjxlrCecAP1Qj cuVN1CL5Z7EWh14LJv0/Hds/+JsJu1hqLgYT8DhpM6YV91ncP+hszVKradQxAhxNCUYN b8MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:ironport-sdr:ironport-sdr; bh=yoO9/pEXabAAML65tYAgHpRZs+ZUdcW25Hsgcp2vJh0=; b=tyAmRvkzuNjMlSVP77LWeT2XHEbS+ujzBGIfDPvT+bnfcOGSOnt0K6gOq8vNXimGdf GlNg8q+4iEHB5rCl5CV/S3eqRd3AoH6qYCSe0S19N3N3lEw7nsg68encntgsWuLT9mv5 2OW0hYujIiNIUpw2dYmLtvn02wRCCmLBeDL881qRMYo1T1V8qiuHxmueLorNBaDurILF pEft+LkJCeD9TLXpJ+IoR7G3NZFDDZ2lfclegFAkK7X6qkKWWRqMoDX+Lv+A10SP/7ho Pa2YWzFoh+I7ZetpbDP7XmOruLQTKvWlEIzACbd8kUqTKcDV4oXbiT4JZse0MALXAsM8 IRFQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ko21si12450427ejc.91.2021.02.08.16.56.14; Mon, 08 Feb 2021 16:57:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230140AbhBIAze (ORCPT + 99 others); Mon, 8 Feb 2021 19:55:34 -0500 Received: from mga09.intel.com ([134.134.136.24]:10595 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229729AbhBIAzd (ORCPT ); Mon, 8 Feb 2021 19:55:33 -0500 IronPort-SDR: cnWveyiLb5HRmoOUbEYN7y2xX96vjMnPjHkrpxTYvU4JYuXKrbvzX4z5dddfTmHQD8rxnAmDPy 9kcPP21VqpDw== X-IronPort-AV: E=McAfee;i="6000,8403,9889"; a="181951965" X-IronPort-AV: E=Sophos;i="5.81,163,1610438400"; d="scan'208";a="181951965" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2021 16:53:46 -0800 IronPort-SDR: f4GPOf/tGk4NGtNDq8iV+ngdivpxa0jYrS6gBGdZIjoF5cMPFg2Wgoq18Kb4FF5Le5/g+R7FOR s8VlqY5qYwjg== X-IronPort-AV: E=Sophos;i="5.81,163,1610438400"; d="scan'208";a="395823852" Received: from yjin15-mobl1.ccr.corp.intel.com (HELO [10.238.4.27]) ([10.238.4.27]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2021 16:53:42 -0800 Subject: Re: [PATCH 46/49] perf stat: Filter out unmatched aggregation for hybrid event To: Arnaldo Carvalho de Melo , kan.liang@linux.intel.com Cc: peterz@infradead.org, mingo@kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, bp@alien8.de, namhyung@kernel.org, jolsa@redhat.com, ak@linux.intel.com, alexander.shishkin@linux.intel.com, adrian.hunter@intel.com, "Jin, Yao" References: <1612797946-18784-1-git-send-email-kan.liang@linux.intel.com> <1612797946-18784-47-git-send-email-kan.liang@linux.intel.com> <20210208191645.GQ920417@kernel.org> From: "Jin, Yao" Message-ID: <6f91b752-6e00-b595-62d4-e19b2e724eb3@linux.intel.com> Date: Tue, 9 Feb 2021 08:53:40 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210208191645.GQ920417@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Arnaldo, On 2/9/2021 3:16 AM, Arnaldo Carvalho de Melo wrote: > Em Mon, Feb 08, 2021 at 07:25:43AM -0800, kan.liang@linux.intel.com escreveu: >> From: Jin Yao >> >> perf-stat has supported some aggregation modes, such as --per-core, >> --per-socket and etc. While for hybrid event, it may only available >> on part of cpus. So for --per-core, we need to filter out the >> unavailable cores, for --per-socket, filter out the unavailable >> sockets, and so on. >> >> Before: >> >> root@otcpl-adl-s-2:~# ./perf stat --per-core -e cpu_core/cycles/ -a -- sleep 1 >> >> Performance counter stats for 'system wide': >> >> S0-D0-C0 2 311,114 cycles [cpu_core] > > Why not use the pmu style event name, i.e.: > > S0-D0-C0 2 311,114 cpu_core/cycles/ > > ? > For "cycles [cpu_core]" style, it's very easy. We just need to set 'stat_config.no_merge = true', and no more coding work. Please let me think about a easy way for pmu style event name. Thanks Jin Yao >> S0-D0-C4 2 59,784 cycles [cpu_core] >> S0-D0-C8 2 121,287 cycles [cpu_core] >> S0-D0-C12 2 2,690,245 cycles [cpu_core] >> S0-D0-C16 2 2,060,545 cycles [cpu_core] >> S0-D0-C20 2 3,632,251 cycles [cpu_core] >> S0-D0-C24 2 775,736 cycles [cpu_core] >> S0-D0-C28 2 742,020 cycles [cpu_core] >> S0-D0-C32 0 cycles [cpu_core] >> S0-D0-C33 0 cycles [cpu_core] >> S0-D0-C34 0 cycles [cpu_core] >> S0-D0-C35 0 cycles [cpu_core] >> S0-D0-C36 0 cycles [cpu_core] >> S0-D0-C37 0 cycles [cpu_core] >> S0-D0-C38 0 cycles [cpu_core] >> S0-D0-C39 0 cycles [cpu_core] >> >> 1.001779842 seconds time elapsed >> >> After: >> >> root@otcpl-adl-s-2:~# ./perf stat --per-core -e cpu_core/cycles/ -a -- sleep 1 >> >> Performance counter stats for 'system wide': >> >> S0-D0-C0 2 1,088,230 cycles [cpu_core] >> S0-D0-C4 2 57,228 cycles [cpu_core] >> S0-D0-C8 2 98,327 cycles [cpu_core] >> S0-D0-C12 2 2,741,955 cycles [cpu_core] >> S0-D0-C16 2 2,090,432 cycles [cpu_core] >> S0-D0-C20 2 3,192,108 cycles [cpu_core] >> S0-D0-C24 2 2,910,752 cycles [cpu_core] >> S0-D0-C28 2 388,696 cycles [cpu_core] >> >> Reviewed-by: Andi Kleen >> Signed-off-by: Jin Yao >> --- >> tools/perf/util/stat-display.c | 20 ++++++++++++++++++++ >> 1 file changed, 20 insertions(+) >> >> diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c >> index 21a3f80..fa11572 100644 >> --- a/tools/perf/util/stat-display.c >> +++ b/tools/perf/util/stat-display.c >> @@ -630,6 +630,20 @@ static void aggr_cb(struct perf_stat_config *config, >> } >> } >> >> +static bool aggr_id_hybrid_matched(struct perf_stat_config *config, >> + struct evsel *counter, struct aggr_cpu_id id) >> +{ >> + struct aggr_cpu_id s; >> + >> + for (int i = 0; i < evsel__nr_cpus(counter); i++) { >> + s = config->aggr_get_id(config, evsel__cpus(counter), i); >> + if (cpu_map__compare_aggr_cpu_id(s, id)) >> + return true; >> + } >> + >> + return false; >> +} >> + >> static void print_counter_aggrdata(struct perf_stat_config *config, >> struct evsel *counter, int s, >> char *prefix, bool metric_only, >> @@ -643,6 +657,12 @@ static void print_counter_aggrdata(struct perf_stat_config *config, >> double uval; >> >> ad.id = id = config->aggr_map->map[s]; >> + >> + if (perf_pmu__hybrid_exist() && >> + !aggr_id_hybrid_matched(config, counter, id)) { >> + return; >> + } >> + >> ad.val = ad.ena = ad.run = 0; >> ad.nr = 0; >> if (!collect_data(config, counter, aggr_cb, &ad)) >> -- >> 2.7.4 >> >