From nobody Sat Oct 3 05:31:21 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 804BF3F9A1C; Wed, 5 Aug 2026 12:26:51 +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=1785932812; cv=none; b=YnRYOztLoZqoA2k1ie6LoXM4QCUVFYSYzFpoN+tYR0axIlB2J83S9B4pvNXqBKuii7TdUfC+RoilGtOFJXL9T3mzWEbetn3JgPJaTkukH4eayot3HpAXifV/uvy4fklcSSQyi4WmJHtx2SyhF3XZe/ziAeVSYOibw0vyPLUIH80= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785932812; c=relaxed/simple; bh=IcwH6wVUiOnnlwYG1uooNkJdqbs7tkf95ul3icKaL8I=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=s39jwR8nurE7GZx/gZ04R50bkYQPaYOimC9LV4nxoZdgRFq21KMfCB/eIdHa+fttfr4cpD/ssY5prDeSXLXkt8Nho3jsAp6jCjxsS7nvoj+4LhLD04KEOUmQRNwobr1v12IolpmYx5+snwzZwwIIcbpYCSgpsd9oQ9tK6z8Gdlw= 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=dAPv+uSQ; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=FuS834mY; 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="dAPv+uSQ"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="FuS834mY" Date: Wed, 05 Aug 2026 12:26:48 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1785932809; 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=IwJxLDVM30TFOL5PuI670HRqSLpjMEXp7cIba+KbNmw=; b=dAPv+uSQ6LCGf99nDrjDf+/Hbvo3DhAWaYEELPIkSrH08MVpV69aXZuBSbLkf7Y4s57w+a zu8o/KxTUqPsF8LL+Vaj/I37gEQkCN6cBQbjNlMlBKpBst+4jkNfiw9h2U8UBfT6NQh+eM jTW/1maa+UhUMThr0oHm8jSds+J/vl7iDSvQT2XK0n1wvIRCi9h2Wt+CNNUBrKAgBXSQLo XsM3eKsQtPsKK4chjmfmwAfDJZua2LsbQyBxYKsf/IAzGGDYHgvlhipPSn1z3ixZv+HFzh p5vPQZ/bsbPql39hbnCWTewxlO97ymFWch3PwaCqiNPNPw0NMJD/BSz88WAkvg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1785932809; 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=IwJxLDVM30TFOL5PuI670HRqSLpjMEXp7cIba+KbNmw=; b=FuS834mYoaQLAl2HlRSw16bFsCDKRdjsuZK2rboOZ9UwmvdW4X0UyPMKZLPQ4Y6aooVfgz w07diKMRvtBI2dDw== From: "tip-bot2 for Peter Zijlstra" 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: Use guard() for pgd_lock Cc: "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260729111119.488154104@infradead.org> References: <20260729111119.488154104@infradead.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <178593280829.708.14299422635762572348.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: 7558828805dae97ed82c8662119667189d062415 Gitweb: https://git.kernel.org/tip/7558828805dae97ed82c8662119667189= d062415 Author: Peter Zijlstra AuthorDate: Wed, 29 Jul 2026 13:08:09 +02:00 Committer: Peter Zijlstra CommitterDate: Wed, 05 Aug 2026 14:19:35 +02:00 x86/mm: Use guard() for pgd_lock Signed-off-by: Peter Zijlstra (Intel) Link: https://patch.msgid.link/20260729111119.488154104@infradead.org --- arch/x86/mm/pat/set_memory.c | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c index fc6a1b2..ad52c9d 100644 --- a/arch/x86/mm/pat/set_memory.c +++ b/arch/x86/mm/pat/set_memory.c @@ -85,9 +85,8 @@ static unsigned long direct_pages_count[PG_LEVEL_NUM]; void update_page_count(int level, unsigned long pages) { /* Protect against CPA */ - spin_lock(&pgd_lock); + guard(spinlock)(&pgd_lock); direct_pages_count[level] +=3D pages; - spin_unlock(&pgd_lock); } =20 static void split_page_count(int level) @@ -1075,16 +1074,11 @@ static int __should_split_large_page(pte_t *kpte, u= nsigned long address, static int should_split_large_page(pte_t *kpte, unsigned long address, struct cpa_data *cpa) { - int do_split; - if (cpa->force_split) return 1; =20 - spin_lock(&pgd_lock); - do_split =3D __should_split_large_page(kpte, address, cpa); - spin_unlock(&pgd_lock); - - return do_split; + guard(spinlock)(&pgd_lock); + return __should_split_large_page(kpte, address, cpa); } =20 static void split_set_pte(struct cpa_data *cpa, pte_t *pte, unsigned long = pfn, @@ -1135,16 +1129,14 @@ __split_large_page(struct cpa_data *cpa, pte_t *kpt= e, unsigned long address, bool nx, rw; pte_t *tmp; =20 - spin_lock(&pgd_lock); + guard(spinlock)(&pgd_lock); /* * Check for races, another CPU might have split this page * up for us already: */ tmp =3D _lookup_address_cpa(cpa, address, &level, &nx, &rw); - if (tmp !=3D kpte) { - spin_unlock(&pgd_lock); + if (tmp !=3D kpte) return 1; - } =20 paravirt_alloc_pte(&init_mm, page_to_pfn(base)); =20 @@ -1177,7 +1169,6 @@ __split_large_page(struct cpa_data *cpa, pte_t *kpte,= unsigned long address, break; =20 default: - spin_unlock(&pgd_lock); return 1; } =20 @@ -1225,7 +1216,6 @@ __split_large_page(struct cpa_data *cpa, pte_t *kpte,= unsigned long address, * just split large page entry. */ flush_tlb_all(); - spin_unlock(&pgd_lock); =20 return 0; } @@ -1374,7 +1364,7 @@ static int collapse_pud_page(pud_t *pud, unsigned lon= g addr, */ static int collapse_large_pages(unsigned long addr, struct list_head *pgta= bles) { - int collapsed =3D 0; + int collapsed; pgd_t *pgd; p4d_t *p4d; pud_t *pud; @@ -1382,26 +1372,24 @@ static int collapse_large_pages(unsigned long addr,= struct list_head *pgtables) =20 addr &=3D PMD_MASK; =20 - spin_lock(&pgd_lock); + guard(spinlock)(&pgd_lock); pgd =3D pgd_offset_k(addr); if (pgd_none(*pgd)) - goto out; + return 0; p4d =3D p4d_offset(pgd, addr); if (p4d_none(*p4d)) - goto out; + return 0; pud =3D pud_offset(p4d, addr); if (!pud_present(*pud) || pud_leaf(*pud)) - goto out; + return 0; pmd =3D pmd_offset(pud, addr); if (!pmd_present(*pmd) || pmd_leaf(*pmd)) - goto out; + return 0; =20 collapsed =3D collapse_pmd_page(pmd, addr, pgtables); if (collapsed) collapsed +=3D collapse_pud_page(pud, addr, pgtables); =20 -out: - spin_unlock(&pgd_lock); return collapsed; } =20