mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] x86/mm/pat: don't gate cpa_lock on debug_pagealloc_enabled()
@ 2026-07-15 14:45 Mike Rapoport
  2026-07-15 15:08 ` Dave Hansen
  2026-07-15 15:10 ` [tip: x86/mm] x86/mm/pat: Don't " tip-bot2 for Mike Rapoport (Microsoft)
  0 siblings, 2 replies; 3+ messages in thread
From: Mike Rapoport @ 2026-07-15 14:45 UTC (permalink / raw)
  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, x86, Dave Hansen

From: "Mike Rapoport (Microsoft)" <rppt@kernel.org>

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 <dave.hansen@intel.com>
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
---
 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-07-15 15:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-15 14:45 [PATCH] x86/mm/pat: don't gate cpa_lock on debug_pagealloc_enabled() Mike Rapoport
2026-07-15 15:08 ` Dave Hansen
2026-07-15 15:10 ` [tip: x86/mm] x86/mm/pat: Don't " tip-bot2 for Mike Rapoport (Microsoft)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox