From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796533976; b=0b91KfErieXodqEIkqUN0Nhu9F7i8P41e2Q+bVhzHcwct5Cl4Lwamg6GfaHC69znqJ+M 9Bs9YRgJZ6SRvVQw8PUCzb0/uok3IpGlKFwe98BG/eYnDu61raOpX7gGcnfOygMsCurxB tEbBxbNJdsLWUSDZw+xZcTrEZ53a+APFBbr3gH9EFexklqa9Xtw9FkeHBlRy2VLj4uHh2 PkFGlO0N67VnEvae7wkNaDLDmrMnmmGL5vlHyPywwtP4azoo+oMbJ1Bv5N+Q/PV+rNtin kQudY0f2a60p8dwfLltrHMd4q+FPPGXm6hEJF8njlkJxHASMLoE+0yxA17SdtWrO28A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796533976; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=EAIIwnpSDoWuzWnJ9pYmmGexVDyjhir1GFM1ODCb6tw=; b=CuhHfwgCJXegFxtqyZywGbme2dBFvhBgaLX4CkOH9mhDGUmf4MqklQD2ZV8dNv400ptP UvqVqdZCEwc3mPonkXQENNy+qdtTJWD/caKsRXevYywVIE2uUh99M92rbOYHE2y3+DiNV HKGQn0hC8WhhLLqBz0s1TSU84qvRX9ou6CsrrmOcUcheBzKLSDlt1WqUZG3qyvd9VcP8k Zfk8+rnBfXb5nQjEU4CMSBPDKn8USGbj2ECpxvcMdm+RBHLOGLiUH2Dof12PAyBwb6bSe wsMl1FZQwjZhibAlzEwT9D6nauLl+bsoHNuLGiikCwjf1iAdJDwKNLua4dDPYqljZ7g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=i0Cpureo; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 57058606A682 for ; Sun, 6 Dec 2026 05:12:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=i0Cpureo Received: by smtp.kernel.org (Postfix) with ESMTPSA id B72BC1F0092B; Sun, 6 Dec 2026 05:12:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796533976; bh=EAIIwnpSDoWuzWnJ9pYmmGexVDyjhir1GFM1ODCb6tw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=i0CpureoTv7d580PBfj42an02IxDbMfN87h+x6KKTKZcCDZFzCyXmpL87CFV5vONm rQQlY8WD7+N8/2mBezHoWDpB3r7iEhS1KFn5S3cD3PfKKsg9iUQSVFS51yS5wvxilL L/vgpeoHbB/ziDJVN1vupKDlqbuMYGKpHvlEOvJz3VjEn1cNHiBnbV0QXdAfbDf6WO uFq6R5G/3XCWUeL/ajzQ1maCUO1xtj9mEmalQEd23VdYoRvH62TRxo4i3OCXVQkgKh 8ZNEqK7WLJDEza0NFgsfinE2kZyTjtLt5HLDAWfUwnmVgG1L8m+XQY6eAYsHLK/XPo WJpbFh6a73DBg== From: Eric Biggers To: x86@kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen Cc: linux-kernel@vger.kernel.org, Christoph Hellwig , Dapeng Mi , Kan Liang , Peter Zijlstra , Jiaming Zhang , Eric Biggers Subject: [PATCH 3/4] perf/x86/intel: Remove redundant cpu_has_xfeatures() checks Date: Sat, 5 Dec 2026 21:12:24 -0800 Message-ID: <20261206051225.298193-4-ebiggers@kernel.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261206051225.298193-1-ebiggers@kernel.org> References: <20261206051225.298193-1-ebiggers@kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Remove the cpu_has_xfeatures() checks from __intel_update_pmu_xregs_caps(), since they are redundant with the corresponding X86_FEATURE_* checks. fpu__init_system_xstate() already disables XSAVE (and therefore XSAVES), AVX, AVX512F, SHSTK (and USER_SHSTK), and APX if their required xstate components are missing. Also simplify the AVX-512 case to OR in XFEATURE_MASK_AVX512 directly. Signed-off-by: Eric Biggers --- arch/x86/events/intel/core.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c index e752111f5ecd7..2f6ad6121a815 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -6255,8 +6255,7 @@ static inline void __intel_update_pmu_xregs_caps(struct pmu *pmu) if (!boot_cpu_has(X86_FEATURE_XSAVES)) return; - if (!boot_cpu_has(X86_FEATURE_XMM) || - !cpu_has_xfeatures(XFEATURE_MASK_SSE, NULL)) + if (!boot_cpu_has(X86_FEATURE_XMM)) return; /* @@ -6266,22 +6265,13 @@ static inline void __intel_update_pmu_xregs_caps(struct pmu *pmu) */ x86_pmu.ext_regs_mask |= XFEATURE_MASK_SSE; - if (boot_cpu_has(X86_FEATURE_AVX) && - cpu_has_xfeatures(XFEATURE_MASK_YMM, NULL)) + if (boot_cpu_has(X86_FEATURE_AVX)) x86_pmu.ext_regs_mask |= XFEATURE_MASK_YMM; - if (boot_cpu_has(X86_FEATURE_APX) && - cpu_has_xfeatures(XFEATURE_MASK_APX, NULL)) + if (boot_cpu_has(X86_FEATURE_APX)) x86_pmu.ext_regs_mask |= XFEATURE_MASK_APX; - if (boot_cpu_has(X86_FEATURE_AVX512F)) { - if (cpu_has_xfeatures(XFEATURE_MASK_OPMASK, NULL)) - x86_pmu.ext_regs_mask |= XFEATURE_MASK_OPMASK; - if (cpu_has_xfeatures(XFEATURE_MASK_ZMM_Hi256, NULL)) - x86_pmu.ext_regs_mask |= XFEATURE_MASK_ZMM_Hi256; - if (cpu_has_xfeatures(XFEATURE_MASK_Hi16_ZMM, NULL)) - x86_pmu.ext_regs_mask |= XFEATURE_MASK_Hi16_ZMM; - } - if (cpu_feature_enabled(X86_FEATURE_USER_SHSTK) && - cpu_has_xfeatures(XFEATURE_MASK_CET_USER, NULL)) + if (boot_cpu_has(X86_FEATURE_AVX512F)) + x86_pmu.ext_regs_mask |= XFEATURE_MASK_AVX512; + if (cpu_feature_enabled(X86_FEATURE_USER_SHSTK)) x86_pmu.ext_regs_mask |= XFEATURE_MASK_CET_USER; dest_pmu->capabilities |= PERF_PMU_CAP_EXTENDED_REGS; -- 2.56.1