Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp129074pxf; Wed, 10 Mar 2021 23:13:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJwpF3gR84oGRhYEKvCE4l2fPw1a/7kaWWjFu7nRG9yJkjO0LnsiEnFXF2Vy+LACIJ0vgipT X-Received: by 2002:a17:906:26c9:: with SMTP id u9mr1793444ejc.166.1615446830533; Wed, 10 Mar 2021 23:13:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615446830; cv=none; d=google.com; s=arc-20160816; b=DiqoEsCMF8VlTmxfADTxKjL5NyOZ4H2bvCfmazvntoBSqhCVYjvW5VXIlaXxZ5AYrW 06I6qXQQ5bEWwsM9gLy5OH9AqvMBWvVbP27FodKWv10hDW4V74qb7CX/bS8pPm9F2lgc oex54kUopopHtBou2+TTTCa8oCbKZBFKy08MjJQ70iWPi2CN2iSnb/JFk2hCzFHdeejh rBL7KXue7yvdBygNay8WRH7W2hZxDnqBHPDUbeF+OM/fouxGa8yiO4uJSXoEQ5tS/+YI mxxu/4kL13nBcRdMMdZETIyI4nb9AqIfOh3hiJyFXiqKZb/QWZo/0ja4t4NlPuxgTW6C 09hQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:ironport-sdr:ironport-sdr; bh=edCIErfZ99rgJsTwdpsz7WE3fwcutkddlsknrPnIQxM=; b=z4kExO2C44uDypA2WrYB8RiU76JQgQ1AYdAD6fn6VKHoDbsYw6sqOFnWJbbRK4lGee UfhbKtAVqujldGvIuvPKmr9HneJrTYK3jVjviAhLh8TgEzpExCJuG0+ALTkCYV1rgLZU Cgqojzo1vCxWp/sPRr/mENXaK9q4k8jGHKTUUvHYbfbQJZDFcn20Qm/JJOoft0ed63MY WmP3IwvC3kOaZZCCPQ8EJ249yQPTxBx629vtfbxiQzBXnhroOtxx/RhbNQ5Km416Msol ysSKJVcEAKnnwRiuVsTEwq2e4kVND6pHrjJqs2VId/izHxTH3PethBJ92C/+Q02P1fQX Zc3g== 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 o16si1178857ejb.259.2021.03.10.23.13.28; Wed, 10 Mar 2021 23:13:50 -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 S231890AbhCKHJa (ORCPT + 99 others); Thu, 11 Mar 2021 02:09:30 -0500 Received: from mga04.intel.com ([192.55.52.120]:22599 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231697AbhCKHI6 (ORCPT ); Thu, 11 Mar 2021 02:08:58 -0500 IronPort-SDR: 29cWf3EqmVDepDQrc+dChe7EhNj46ti02CY1ZkdUmSoxWsnlMqJFJopB1eWoiWrwVAj1kGh/u4 stYWsbn+hOpA== X-IronPort-AV: E=McAfee;i="6000,8403,9919"; a="186246083" X-IronPort-AV: E=Sophos;i="5.81,239,1610438400"; d="scan'208";a="186246083" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2021 23:08:58 -0800 IronPort-SDR: w0LDzSuoOXFLP0++21EGcSUZy64hYPdpD7GsHBR+NA8O2+PPs+Imgi0pthfskHEzeb/YyjyVzT MXtM3tQ1JiBA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,239,1610438400"; d="scan'208";a="509937953" Received: from kbl-ppc.sh.intel.com ([10.239.159.163]) by fmsmga001.fm.intel.com with ESMTP; 10 Mar 2021 23:08:56 -0800 From: Jin Yao To: acme@kernel.org, jolsa@kernel.org, peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com Cc: Linux-kernel@vger.kernel.org, ak@linux.intel.com, kan.liang@intel.com, yao.jin@intel.com, Jin Yao Subject: [PATCH v2 16/27] perf evlist: Warn as events from different hybrid PMUs in a group Date: Thu, 11 Mar 2021 15:07:31 +0800 Message-Id: <20210311070742.9318-17-yao.jin@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210311070742.9318-1-yao.jin@linux.intel.com> References: <20210311070742.9318-1-yao.jin@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If a group has events which are from different hybrid PMUs, shows a warning. This is to remind the user not to put the core event and atom event into one group. root@ssp-pwrt-002:~# ./perf stat -e "{cpu_core/cycles/,cpu_atom/cycles/}" -- sleep 1 WARNING: Group has events from different hybrid PMUs Performance counter stats for 'sleep 1': cpu_core/cycles/ cpu_atom/cycles/ 1.002585908 seconds time elapsed Signed-off-by: Jin Yao --- tools/perf/builtin-record.c | 3 +++ tools/perf/builtin-stat.c | 7 ++++++ tools/perf/util/evlist.c | 44 +++++++++++++++++++++++++++++++++++++ tools/perf/util/evlist.h | 2 ++ 4 files changed, 56 insertions(+) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 363ea1047148..188a1198cd4b 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -929,6 +929,9 @@ static int record__open(struct record *rec) pos = evlist__reset_weak_group(evlist, pos, true); goto try_again; } + + if (errno == EINVAL && perf_pmu__hybrid_exist()) + evlist__warn_hybrid_group(evlist); rc = -errno; evsel__open_strerror(pos, &opts->target, errno, msg, sizeof(msg)); ui__error("%s\n", msg); diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 7a732508b2b4..6f780a039db0 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -239,6 +239,9 @@ static void evlist__check_cpu_maps(struct evlist *evlist) struct evsel *evsel, *pos, *leader; char buf[1024]; + if (evlist__hybrid_exist(evlist)) + return; + evlist__for_each_entry(evlist, evsel) { leader = evsel->leader; @@ -726,6 +729,10 @@ enum counter_recovery { static enum counter_recovery stat_handle_error(struct evsel *counter) { char msg[BUFSIZ]; + + if (perf_pmu__hybrid_exist() && errno == EINVAL) + evlist__warn_hybrid_group(evsel_list); + /* * PPC returns ENXIO for HW counters until 2.6.37 * (behavior changed with commit b0a873e). diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index f139151b9433..5ec891418cdd 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -2224,3 +2224,47 @@ void evlist__invalidate_all_cpus(struct evlist *evlist) perf_cpu_map__put(evlist->core.all_cpus); evlist->core.all_cpus = perf_cpu_map__empty_new(1); } + +static bool group_hybrid_conflict(struct evsel *leader) +{ + struct evsel *pos, *prev = NULL; + + for_each_group_evsel(pos, leader) { + if (!pos->pmu_name || !perf_pmu__is_hybrid(pos->pmu_name)) + continue; + + if (prev && strcmp(prev->pmu_name, pos->pmu_name)) + return true; + + prev = pos; + } + + return false; +} + +void evlist__warn_hybrid_group(struct evlist *evlist) +{ + struct evsel *evsel; + + evlist__for_each_entry(evlist, evsel) { + if (evsel__is_group_leader(evsel) && + evsel->core.nr_members > 1 && + group_hybrid_conflict(evsel)) { + WARN_ONCE(1, "WARNING: Group has events from " + "different hybrid PMUs\n"); + return; + } + } +} + +bool evlist__hybrid_exist(struct evlist *evlist) +{ + struct evsel *evsel; + + evlist__for_each_entry(evlist, evsel) { + if (evsel__is_hybrid_event(evsel)) + return true; + } + + return false; +} diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index 0da683511d98..33dec3bb5739 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h @@ -369,4 +369,6 @@ struct evsel *evlist__find_evsel(struct evlist *evlist, int idx); void evlist__invalidate_all_cpus(struct evlist *evlist); bool evlist__has_hybrid_events(struct evlist *evlist); +void evlist__warn_hybrid_group(struct evlist *evlist); +bool evlist__hybrid_exist(struct evlist *evlist); #endif /* __PERF_EVLIST_H */ -- 2.17.1