Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp5230pxv; Wed, 7 Jul 2021 18:44:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwErZcg2Pd1Hfw8FDCExjuXF6K0R/QQTe97HTyySSEdE903Rfa6pjSJh/3JIBx+2SdPQ8F7 X-Received: by 2002:a05:6402:135a:: with SMTP id y26mr33120570edw.256.1625708658161; Wed, 07 Jul 2021 18:44:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625708658; cv=none; d=google.com; s=arc-20160816; b=wxZEXK9WpqEy4Qm78gvz/omYjcaoYJRAqyp8dqdF9t+NSuhQszaHkxYAjOibI9Ant8 mn2c3Deii6l4olSxDFO46Vtl5L8M3DnMAE4AN9sGZ30G89rNHbdwf+hqXlyPdsaFd5eX gWl0PrsO7DI+FvYxPT2WmcY1r+voMCL9cILIKPUxlT1HbG06IJMWvri/3AbIlUGuTwx8 g3nsZj+ODsXtPUipykD49gZJgxHfIePiK206NNHWH8wvd1aRRlOa+c4ScrT3pwy/+hfV wu+4+ATiRe/lNfN9omjjXo/A8r2o3BwN/K3cOdYf6umBVcWz/T1QHSTGZ7CxGQ4Ri9YD Qurw== 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; bh=YbGKbdsAwyEX7W+ks2WKX8DZ1NqFaDUmHeLuFcBqMI4=; b=iOKF85lK/IecEPKicMfvirCDSdlb9Y/9RMGI6L97tpXvmcCdTJiKs0VRqnfXuYVEZO vgRKq/M3y/5fJXOIN2H5zuDks0XoOaNMMGlS9b4j4EiebGFft7b2Ah/DqnEARtwqdJYp N9dfdrETu15fBF0bQvPgho5ZNknvg8x0rzxBHhLYV94O1JgcU20LJO057wiDfy/J4Vbq KrBoFqbCnXrhlG/Zzm/gVosXswx4xjTcAf9KmNv4eA5wx7m5wF0DfqVzdzohZ/ua4EdD GgShJkx75o0H//9x5QN4ODLLjBQq64MeMXGKy5Wbt6VA/XQlTId4tzdlfzFeoo6KS7+a EHQQ== 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 b15si938940edy.228.2021.07.07.18.43.51; Wed, 07 Jul 2021 18:44:18 -0700 (PDT) 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 S230208AbhGHBlN (ORCPT + 99 others); Wed, 7 Jul 2021 21:41:13 -0400 Received: from mga06.intel.com ([134.134.136.31]:38895 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230106AbhGHBlJ (ORCPT ); Wed, 7 Jul 2021 21:41:09 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10038"; a="270538740" X-IronPort-AV: E=Sophos;i="5.84,222,1620716400"; d="scan'208";a="270538740" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jul 2021 18:38:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,222,1620716400"; d="scan'208";a="457708830" Received: from kbl-ppc.sh.intel.com ([10.239.159.163]) by orsmga008.jf.intel.com with ESMTP; 07 Jul 2021 18:38:23 -0700 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 1/4] perf pmu: Skip invalid hybrid pmu Date: Thu, 8 Jul 2021 09:36:58 +0800 Message-Id: <20210708013701.20347-2-yao.jin@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210708013701.20347-1-yao.jin@linux.intel.com> References: <20210708013701.20347-1-yao.jin@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On hybrid platform, such as Alderlake, if atom CPUs are offlined, the kernel still exports the sysfs path '/sys/devices/cpu_atom/' for 'cpu_atom' pmu but the file '/sys/devices/cpu_atom/cpus' is empty, which indicates this is an invalid pmu. Need to check and skip the invalid hybrid pmu. Before: # perf list ... branch-instructions OR cpu_atom/branch-instructions/ [Kernel PMU event] branch-instructions OR cpu_core/branch-instructions/ [Kernel PMU event] branch-misses OR cpu_atom/branch-misses/ [Kernel PMU event] branch-misses OR cpu_core/branch-misses/ [Kernel PMU event] bus-cycles OR cpu_atom/bus-cycles/ [Kernel PMU event] bus-cycles OR cpu_core/bus-cycles/ [Kernel PMU event] ... The cpu_atom events are still displayed even if atom CPUs are offlined. After: # perf list ... branch-instructions OR cpu_core/branch-instructions/ [Kernel PMU event] branch-misses OR cpu_core/branch-misses/ [Kernel PMU event] bus-cycles OR cpu_core/bus-cycles/ [Kernel PMU event] ... Now only cpu_core events are displayed. Signed-off-by: Jin Yao --- tools/perf/util/pmu.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 88c8ecdc60b0..cb20a9f69a04 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -927,6 +927,13 @@ static struct perf_pmu *pmu_lookup(const char *name) LIST_HEAD(format); LIST_HEAD(aliases); __u32 type; + bool is_hybrid = perf_pmu__hybrid_mounted(name); + + /* + * Check pmu name for hybrid and the pmu may be invalid in sysfs + */ + if (!strncmp(name, "cpu_", 4) && !is_hybrid) + return NULL; /* * The pmu data we store & need consists of the pmu @@ -955,7 +962,7 @@ static struct perf_pmu *pmu_lookup(const char *name) pmu->is_uncore = pmu_is_uncore(name); if (pmu->is_uncore) pmu->id = pmu_id(name); - pmu->is_hybrid = perf_pmu__hybrid_mounted(name); + pmu->is_hybrid = is_hybrid; pmu->max_precise = pmu_max_precise(name); pmu_add_cpu_aliases(&aliases, pmu); pmu_add_sys_aliases(&aliases, pmu); -- 2.17.1