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 F2134481AB0 for ; Wed, 22 Jul 2026 08:52:07 +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=1784710329; cv=none; b=loHwTOfxSr2JVD4tV/OVFB4ID/q36DC6PrIl8hCSOpLjPW+HeO4Pig9NbpZpBpn323I16c9Vnb/BW5iZjq1yUkbqiFR6x5TxzDY8cD7532K6c6myrs2LcJgHksI8NQ40iUanZRgPBC3ZddprtqZBr7QLcjgf7umfX1pwP9e9ZIM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784710329; c=relaxed/simple; bh=fmFf/Us3qkDanfTla0jqV1FNr5CqnHvt4dZiGgzDIxg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=eFXFnSyeb0u1hRWuxSvMzz9kjPfbhXep82wCFNnbzVhow6ESiz0dMMQD4gpxc8Q4cP6I89Aw6LnTEpW1EAXHSuPI2/tglv1bf+sujHHNTa7jhorpmH3w3nwqD7W9qqN6E924cjX/LYEP+FIxUCRHGCoIVk3Pi7uUhpOMaIS5uTA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RFTzVBh1; 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="RFTzVBh1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 865A31F00A3E; Wed, 22 Jul 2026 08:52:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784710327; bh=aWMdQMYbcGyFmRXb6tIVGfuUD1Bw86GI9RSrhCOsFus=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=RFTzVBh11T5LftOdh58l80hgtnWKkxvHLgUIySQF56SLqDYlCMjFxo85cSz/209f+ rRkIR1F7yzBx9kMT64zfooHrCCh6kT0R2PYqjgkxCi0cuN0mluqA4vX7zhpdr8Sf4U IP+yJ2DgmvcWA1MUh9poeLTvpA4WqweaAfRJ70zfA/caNYjaOGlgO3vJ/2SMNbKhSC 9KZBBtrww78qU09x0o1dCQ8QMqVqBgnTaLjIWQH57W/utY+WaBRUf8Wt68ClNlwYhU lF0rs56wfyT9r1G6LaLxIhNXJZVEW5cmSyGX6sBrOGAuMyGfj6zp1aWUPpZk24TOpS AHSt+Lw/ShV4w== Date: Wed, 22 Jul 2026 11:51:56 +0300 From: Mike Rapoport To: "Lorenzo Stoakes (ARM)" Cc: Dave Hansen , Andy Lutomirski , Borislav Petkov , "Denis V . Lunev" , Ingo Molnar , Juergen Gross , Kiryl Shutsemau , "H. Peter Anvin" , Peter Zijlstra , Thomas Gleixner , linux-kernel@vger.kernel.org, x86@kernel.org, Dave Hansen Subject: Re: [PATCH] x86/mm/pat: don't gate cpa_lock on debug_pagealloc_enabled() Message-ID: 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 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Tue, Jul 21, 2026 at 04:49:13PM +0100, Lorenzo Stoakes (ARM) wrote: > On Wed, Jul 15, 2026 at 05:45:19PM +0300, Mike Rapoport wrote: > > 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); > > -> _irqsave() is needed I think :) see below I'm rather thinking that it will be simpler overall to restore the if, but wrap it in cpa_lock()/cpa_unlock() helpers with a better comment than what we have now above DEFINE_SPINLOCK(cpa_lock). > > ptdesc = pagetable_alloc(GFP_KERNEL, 0); > > - if (!debug_pagealloc_enabled()) > > - spin_lock(&cpa_lock); > > + spin_lock(&cpa_lock); > > -> _irqrestore() as below -- Sincerely yours, Mike.