Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp91693rdf; Mon, 20 Nov 2023 17:39:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IHz1RxdQhb6E/E9zYv08g0BvdvU+7MoHDpygQtLONHa3Ro5rHx7dO2mcu0ahaNSrfVHWP3M X-Received: by 2002:a17:90a:f018:b0:27f:fc2f:4831 with SMTP id bt24-20020a17090af01800b0027ffc2f4831mr8250764pjb.13.1700530751442; Mon, 20 Nov 2023 17:39:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700530751; cv=none; d=google.com; s=arc-20160816; b=sAkJILayhgUlZYjYdChMsIYQzxCuumRQQ3iE0Lc5jS10aopxzwHrH5dDcUyzdWFw6m yrW8zLg3/kE8UegHGbsz4O3h9Z8HMeHaqU8l6FAvwjmFF+fWz9ifkNEfBK8zpVqMDS6E FlClkydWdB0MxBvRe8DfXJVXkpKk8R3hYuqn5I1RZE7KCeKLaDc+u6DwG1lCsmnoDbtb 4XMQMIDFp3U1xp/fgXgVm40xGsrWi4tGpoLCqmYnvM5t1uusDSPNLPA1xaUY0taCtt8m d5ztE18IvCb1z7RqtJkKQeUy5LmaRAxaXZR/vQA9ETYj3ykwFu+HZM2Vpw673xg5vDUc 3YhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=yygaa2E4xjYmCPWa9v9Ch+C0H0sMJgVYjSFKA5Uyvac=; fh=MeKcGCMGfxPWE9ifvEX1ZwMNok/W6u8ks08hiRZ93F4=; b=vXzbWcmrU6g94x2MuW3Pfhfh7T7Y7c5LNJJSJ8jX/NL/o21T00E8JejhLMh/YmNyvH pPlMLma+V1r0vykWj4RqbDvchVVl0vdgu26CYPJs3SDT4WnEgZQFYQhogF84XfGLhV71 3mndyWSeK5+e9olDtCNOkaLTajrk5VUt9ybC1urbU6qX8e5uEegy2UQEM/4XTuwTCJ/4 rvYIq/4DZ2Ad5n0oTNIip6MPjdVdeO5YhxqBnVgw53d2dNnjSBa9epcmbD9kL66yVam4 wyyR0zbwhkB4NyoPzgseUmuG8iDTGjt1PHDSA4AcBU80/sx7NZTZdirAmqWDi0FQaPPl lbEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ByJ82N8k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id d15-20020a63fd0f000000b005be232472easi9275156pgh.78.2023.11.20.17.39.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 17:39:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ByJ82N8k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id BB84B807C643; Mon, 20 Nov 2023 17:39:08 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232815AbjKUBjB (ORCPT + 99 others); Mon, 20 Nov 2023 20:39:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229679AbjKUBjA (ORCPT ); Mon, 20 Nov 2023 20:39:00 -0500 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6D0FA2; Mon, 20 Nov 2023 17:38:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700530736; x=1732066736; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=+7VvbUVCHmTCIcY7kK6/rBlQv5zQw4GkO8xAr+x002c=; b=ByJ82N8k7Bv/lD8U7DTuW/9QMijrijQnTpZamwsel9cuLVaLYXdEHyU5 Y+u1g3zAvhIf+QYaUlyMdutAv4ovqcTK5x1QCLRW/XXVLyOHR2BsZ9h6u Ez8URu/ZwEgGB5hlUVoAyhwsdH0n/Ck1OJnvWZQ0D44mpvipJLCTQXlZ6 JJBaCTomoFEPhkC7aofFBM/zLpUHB/H2nTUro0QqLPTUCAhfkedmzOP/7 vEVLPK2Ub9DsmB9bJs7x3Mwpb6U1TftP1qO3tQFCduO/Sc+EQ5mrSbqnZ oNunWAulJdHAWVBeIgZ9GazSWzPAdxymd1cu+FjThujjrqphwg7KEUb4L g==; X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="458235181" X-IronPort-AV: E=Sophos;i="6.04,215,1695711600"; d="scan'208";a="458235181" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 17:38:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="770087205" X-IronPort-AV: E=Sophos;i="6.04,215,1695711600"; d="scan'208";a="770087205" Received: from dmi-pnp-i7.sh.intel.com ([10.239.159.155]) by fmsmga007.fm.intel.com with ESMTP; 20 Nov 2023 17:38:53 -0800 From: Dapeng Mi To: Peter Zijlstra , Ingo Molnar , Kan Liang Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Zhenyu Wang , Dapeng Mi , Dapeng Mi , stable@vger.kernel.org Subject: [PATCH] perf/x86/intel: Correct wrong 'or' operation for pmu capabilities Date: Tue, 21 Nov 2023 09:46:28 +0800 Message-Id: <20231121014628.729989-1-dapeng1.mi@linux.intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 20 Nov 2023 17:39:08 -0800 (PST) When running perf-stat command on Intel hybrid platform, perf-stat reports the following errors. sudo taskset -c 7 ./perf stat -vvvv -e cpu_atom/instructions/ sleep 1 Opening: cpu/cycles/:HG ------------------------------------------------------------ perf_event_attr: type 0 (PERF_TYPE_HARDWARE) config 0xa00000000 disabled 1 ------------------------------------------------------------ sys_perf_event_open: pid 0 cpu -1 group_fd -1 flags 0x8 sys_perf_event_open failed, error -16 Performance counter stats for 'sleep 1': cpu_atom/instructions/ It looks the cpu_atom/instructions/ event can't be enabled on atom pmu even the process is pinned on atom core. The investigation shows that exclusive_event_init() helper always returns -EBUSY error in the perf event creation. That's strange since the atom pmu should not be a exclusive PMU. Further investigation shows the issue is introduced by commit 97588df87b56 ("perf/x86/intel: Add common intel_pmu_init_hybrid()"). The commit originally intents to clear the bit PERF_PMU_CAP_AUX_OUTPUT from pmu capabilities if intel_cap.pebs_output_pt_available is not set, but it incorrectly uses 'or' operation and leads to all pmu capabilities bits are set to 1 except bit PERF_PMU_CAP_AUX_OUTPUT. Testing this fix on Intel hybrid platforms, the observed issues disappear. Fixes: 97588df87b56 ("perf/x86/intel: Add common intel_pmu_init_hybrid()") Cc: stable@vger.kernel.org Signed-off-by: Dapeng Mi --- arch/x86/events/intel/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c index a08f794a0e79..ce1c777227b4 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -4660,7 +4660,7 @@ static void intel_pmu_check_hybrid_pmus(struct x86_hybrid_pmu *pmu) if (pmu->intel_cap.pebs_output_pt_available) pmu->pmu.capabilities |= PERF_PMU_CAP_AUX_OUTPUT; else - pmu->pmu.capabilities |= ~PERF_PMU_CAP_AUX_OUTPUT; + pmu->pmu.capabilities &= ~PERF_PMU_CAP_AUX_OUTPUT; intel_pmu_check_event_constraints(pmu->event_constraints, pmu->num_counters, base-commit: b85ea95d086471afb4ad062012a4d73cd328fa86 -- 2.34.1