From nobody Sat Jul 25 16:48:48 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 B78CF1E5B68; Wed, 15 Jul 2026 15:11:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784128263; cv=none; b=ICRjouxIcGQi2HGzX+AS1K5oGbL5D4dbkIHAft5Cgyk32UPVHKpI8HIfK6dmlQLlnBWYsK2wZR6DcQXkoZgAcoTWSQ1JiLXWWqOQVnkUhSfd7MhBZnz4fUXNj5Int5hcvEaibdbmM6hXScxQuyiZzKhXz/h8l4DjI2LWKrP8mtI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784128263; c=relaxed/simple; bh=biAtc4H/0DFLeDBTPglRSQsdhQMsaltkzMJHJ4J9DLI=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=Zf8T5yfkW4tdfrnXsEX7xra0WZgGl6mSdtE9REEk2IruGZzbfZnWVBLb4rl3nWJvvcbIkCPzxA++QYol0D1rVQWoxQxBfHmiKFgQIkCCitT3ZJ2H1VWbcrmLUSNT+Csi4eqml37ExdF2kHfXsKGWtw7Bf7dP3dkqxjeaVkbBpIs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=GWVfGBdh; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=q/bco1gc; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="GWVfGBdh"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="q/bco1gc" Date: Wed, 15 Jul 2026 15:10:58 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1784128260; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zX1oZlAcNlU5jcHj2E/EbSFbJHkUlTF58ND/mOa9vCM=; b=GWVfGBdhpBbR2RDMWTx03fHEAh7/0uEVFf6sE+9Pj4WGMF1DLdEYTu20Y7E0TO1m/DVIF4 aMcBYN2E6DfuGX41pjBeBV046GBdpYnJ1ITQ++Xp0Tg4hElycmVWytFLhXMCTlXNDYghmC 6YSYAONI+ZfW7/pJ+aEQnzxUm2G1S9vob4twmpxAKNAdTBsZts2n1aOwuNa9V8k8v8qyt/ ooHj1f1OXZ835t0LMkUuUB8JuLBoFCmLlhfYqHgo89Wn/8iJhYar+y6cOqL4ULJGRKBW+z THGZxnYpCnYiWVeTseJPsxpwwG7+QFys7pJU+oZ3ts3brThhTCddhPULrl/vFg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1784128260; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zX1oZlAcNlU5jcHj2E/EbSFbJHkUlTF58ND/mOa9vCM=; b=q/bco1gcaLd0S98VPBYC0NqcY/8BAJaPQjUq7cYYSkt4NKdtX80eDAPZddN068rU3na7qg E6RzqFfjqWX2KGDQ== From: "tip-bot2 for Mike Rapoport (Microsoft)" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/mm] x86/mm/pat: Don't gate cpa_lock on debug_pagealloc_enabled() Cc: Dave Hansen , "Mike Rapoport (Microsoft)" , Dave Hansen , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260715144519.934289-1-rppt@kernel.org> References: <20260715144519.934289-1-rppt@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <178412825847.1844600.13225828544752951237.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the x86/mm branch of tip: Commit-ID: 5fce67641a3ed9a0782eaa228ddece526461a367 Gitweb: https://git.kernel.org/tip/5fce67641a3ed9a0782eaa228ddece526= 461a367 Author: Mike Rapoport (Microsoft) AuthorDate: Wed, 15 Jul 2026 17:45:19 +03:00 Committer: Dave Hansen CommitterDate: Wed, 15 Jul 2026 08:00:49 -07:00 x86/mm/pat: Don't gate cpa_lock on debug_pagealloc_enabled() The splitting and merging of kernel page table mappings between small and large is protected by cpa_lock. The merging is relatively new but the splitting is ancient. The splitting has a locking optimization: since DEBUG_PAGEALLOC forces all mappings to 4k, there are no large pages to split. So the code that *might* cause a split can just skip the locking (and a few other things). This is entertaining, but it adds complexity and makes for weird locking rules. Plus it's all for a debugging feature which makes the kernel super slow in the first place. Optimizing something which is already super slow and not used in production is not the best way to spend our complexity budget. Stop gating cpa_lock on debug_pagealloc_enabled() to simplify the code and the locking rules. [ dhansen: flesh out changelog ] Suggested-by: Dave Hansen Signed-off-by: Mike Rapoport (Microsoft) Signed-off-by: Dave Hansen Link: https://patch.msgid.link/20260715144519.934289-1-rppt@kernel.org Link: https://lore.kernel.org/all/aab44f08-89f8-47fe-bee4-0ab6b25968c6@inte= l.com/ --- 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 45623d4..e9b4083 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 =3D CPA_PROTECT; =20 /* - * Serialize cpa() (for !DEBUG_PAGEALLOC which uses large identity mapping= s) - * 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, wi= th + * stale large tlb entries, to change the page attribute in parallel to so= me + * other cpu splitting a large page entry along with changing the attribut= e. */ static DEFINE_SPINLOCK(cpa_lock); =20 @@ -1234,11 +1233,9 @@ static int split_large_page(struct cpa_data *cpa, pt= e_t *kpte, { struct ptdesc *ptdesc; =20 - if (!debug_pagealloc_enabled()) - spin_unlock(&cpa_lock); + spin_unlock(&cpa_lock); ptdesc =3D pagetable_alloc(GFP_KERNEL, 0); - if (!debug_pagealloc_enabled()) - spin_lock(&cpa_lock); + spin_lock(&cpa_lock); if (!ptdesc) return -ENOMEM; =20 @@ -2022,11 +2019,9 @@ static int __change_page_attr_set_clr(struct cpa_dat= a *cpa, int primary) if (cpa->flags & (CPA_ARRAY | CPA_PAGES_ARRAY)) cpa->numpages =3D 1; =20 - if (!debug_pagealloc_enabled()) - spin_lock(&cpa_lock); + spin_lock(&cpa_lock); ret =3D __change_page_attr(cpa, primary); - if (!debug_pagealloc_enabled()) - spin_unlock(&cpa_lock); + spin_unlock(&cpa_lock); if (ret) goto out; =20