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 0D2624DC531 for ; Wed, 22 Jul 2026 08:55:16 +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=1784710518; cv=none; b=kcRei6WmeWUHU/kS67+0wCdUF7XDGMHtwcwCijgKtsZlYN/I+uMJzKdNmulCsZY+/hvTMVbAVg8bcRSJ+JlKE2Pd3oCS6s4kMkIgBnwwfUEFwQ2gk6WHtlpjvchWp36DeOitrE0q95XXYj7Bb9ooMGEUmovsRysCm7syaQVxZRY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784710518; c=relaxed/simple; bh=t+NpM0B4OB99AndXrA6LXqiHZzkJFd2nmZco5A8v39c=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SWoKQC91A/+CK5WYJu4YOEX3UxioQjjEKq+oiGcIxbH+X8vfPeq40ZmplW28my341hWYkK88hKouxTnGRwF93EqCJzcHlFCiw05eEJiOWDcCw/yXMRwLHaipSkD7G9dWmFyjexDiMmw4hbA/Vbk3SqPN8v6uSElvWYnBkqpVnOU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=W9HsA838; 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="W9HsA838" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4DE81F000E9; Wed, 22 Jul 2026 08:55:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784710516; bh=3rDhCcqEBIg8lLMyTQxquQKDhGFtD+UY5rSv9uSeM/0=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=W9HsA838J+rmu7YQsTb/rZDLmeAJIJhlMrcHf5ddXE+FGc3T439V/CvmamzeF+1fW ITpySlShcPPgsU88tCfzzEsns8VRJCL4fPyAWVmhg0aqL0GPPmx935GK24m3uWM64e aWdRa8ynvbBd9Nh6yXkQKKGbX/xh2xHlYLv1Xk+T58if2mEyJy5mjvoRyCUFISoKIa bGsK9MWbGUnmXiuV089WQFuESDoKHM3pSbPrd6nrJBNK5Fon4lZzWBlpAa5UvvXJ1M haXVtOdTD1GoGhhFXMzn+TzYdXt+tlSq+GV8KMITU5zSo9i7gQgzk/leuLADUpMJUk 86zbRvO2lNn5w== Date: Wed, 22 Jul 2026 09:54:59 +0100 From: "Lorenzo Stoakes (ARM)" To: Mike Rapoport 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 Wed, Jul 22, 2026 at 11:51:56AM +0300, Mike Rapoport wrote: > 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). Right yeah, like cpa_[un]lock() that has the conditional in it and explains why. But that does leave us with unfortunate races too if you allow collapse I think :) So if reinstated and we retain Denis's patch, his should gate the collapse on debug pagealloc again. Oh what a web we have spun... > > > > ptdesc = pagetable_alloc(GFP_KERNEL, 0); > > > - if (!debug_pagealloc_enabled()) > > > - spin_lock(&cpa_lock); > > > + spin_lock(&cpa_lock); > > > > -> _irqrestore() as below > > -- > Sincerely yours, > Mike. Cheers, Lorenzo