From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F26E3921ED for ; Wed, 15 Jul 2026 14:45:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784126728; cv=none; b=qmzykyKzN1u7WUldMMg/JqY79hSrI9Zq2mjIHDU+8kN9BQPpLNADWDOt1WsiEiSrLQYxioX3mfm7fuKk1dIoFtKBCPlZJyUNi+ntG8DTNe/gbWVoHghWN14+VSle6OvqYZuz8zryn0dg3M0VAjHvCaHiAAsI2y7Yq3wFbeC2lPg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784126728; c=relaxed/simple; bh=ZkVm5mREPrQJK9QBde7qM1gWw8oJAlEsGSqPC33PL78=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=rkIQvTZMzzXN/fC2tSQXrmYRRYvXIKvdzqRQjvnHvBwfsbUDhbJzjLxmajejzEr5jbykptZNYOSBOWJr7cb+WLbC1JL/ir5/XfVezzCZKSNnUxF4WR4d1vVJN8vPeqyklmWOkrePuVh+fs4uLU8jKljOAFQG8h8/IAeMpHQwXsM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=g+YERq2p; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="g+YERq2p" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E9E31F000E9; Wed, 15 Jul 2026 14:45:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784126726; bh=oquQTvF/j88a5pNc97m2WIIvPBJ82F3CQXM+/EUr2E4=; h=From:To:Cc:Subject:Date; b=g+YERq2p+7qMAd69uKpbANu2Q3QPLeoPtyeF5FLeVdby+MpKc5WHjzBjr0dv1ELhb LevXfesI4VCDPMLGQLtL3EvVy6z+bUDWGzhCO7jpoCa9zKjxSuL/sVr9VdReNF9FtT 5UsZe/dsrWXPa8jA+0GaBCcjQ8LaBIbm0FcNsDup1eVWKgPeDRhkDOGokbuMGIi2IW LBsdNHt8fpO8kCck2d07U1bI0DCB4Duobs1rKMnAmqGSiGw9EqKldSmm2gw3VAifhV 3MvGooMPVWwB15OkSTuiFnH8+IKCTyqSvtgO0gpcdtphr6N4xOC1k12cwBVSVJXaOi Zig9+hTnNaHfw== From: Mike Rapoport To: Dave Hansen Cc: Andy Lutomirski , Borislav Petkov , "Denis V . Lunev" , Ingo Molnar , Juergen Gross , Kiryl Shutsemau , Mike Rapoport , "H. Peter Anvin" , Peter Zijlstra , Thomas Gleixner , linux-kernel@vger.kernel.org, x86@kernel.org, Dave Hansen Subject: [PATCH] x86/mm/pat: don't gate cpa_lock on debug_pagealloc_enabled() Date: Wed, 15 Jul 2026 17:45:19 +0300 Message-ID: <20260715144519.934289-1-rppt@kernel.org> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: "Mike Rapoport (Microsoft)" Dave Hansen says: My only question is *why*!?!? Why add extra locking complexity and rules to optimize debug_pagealloc, which is already horrendously slow. Stop gating cpa_lock on debug_pagealloc_enabled() to simplify the code. Suggested-by: Dave Hansen Signed-off-by: Mike Rapoport (Microsoft) --- arch/x86/mm/pat/set_memory.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c index d023a40a1e03..e8316f5ffa8a 100644 --- a/arch/x86/mm/pat/set_memory.c +++ b/arch/x86/mm/pat/set_memory.c @@ -62,10 +62,9 @@ enum cpa_warn { static const int cpa_warn_level = CPA_PROTECT; /* - * Serialize cpa() (for !DEBUG_PAGEALLOC which uses large identity mappings) - * using cpa_lock. So that we don't allow any other cpu, with stale large tlb - * entries change the page attribute in parallel to some other cpu - * splitting a large page entry along with changing the attribute. + * Serialize cpa() using cpa_lock so that we don't allow any other cpu, with + * stale large tlb entries, to change the page attribute in parallel to some + * other cpu splitting a large page entry along with changing the attribute. */ static DEFINE_SPINLOCK(cpa_lock); @@ -1235,11 +1234,9 @@ static int split_large_page(struct cpa_data *cpa, pte_t *kpte, { struct ptdesc *ptdesc; - if (!debug_pagealloc_enabled()) - spin_unlock(&cpa_lock); + spin_unlock(&cpa_lock); ptdesc = pagetable_alloc(GFP_KERNEL, 0); - if (!debug_pagealloc_enabled()) - spin_lock(&cpa_lock); + spin_lock(&cpa_lock); if (!ptdesc) return -ENOMEM; @@ -2023,11 +2020,9 @@ static int __change_page_attr_set_clr(struct cpa_data *cpa, int primary) if (cpa->flags & (CPA_ARRAY | CPA_PAGES_ARRAY)) cpa->numpages = 1; - if (!debug_pagealloc_enabled()) - spin_lock(&cpa_lock); + spin_lock(&cpa_lock); ret = __change_page_attr(cpa, primary); - if (!debug_pagealloc_enabled()) - spin_unlock(&cpa_lock); + spin_unlock(&cpa_lock); if (ret) goto out; base-commit: a13c140cc289c0b7b3770bce5b3ad42ab35074aa -- 2.53.0