From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mta0.migadu.com (out-228.mta0.migadu.com [91.218.175.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07E67370AE7 for ; Thu, 13 Aug 2026 15:49:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.228 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786636196; cv=none; b=an3A29VZFAeAmDGCf1Wx9WmbpXQ1gjEAkvEGvx07lAWTRbYZFkI+xhHw4oro/qfS9RQQyutU3E67J1RpQTJ4ZavhShz0tzTEQxxdWnOLfYfIYMHoWnqQERQ7RHM6YB/h5iAj5PFrg4cdXiukLTv0K9VMh9BphvOm/r8WVCwGqdw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786636196; c=relaxed/simple; bh=44TR69x5ZAwBqBOOwd22fnYBam5ymuntq7grA3Sn4D0=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=BZB0fca12VlE6qF5kQWrHbN+OB0xARO2VntVI8WkXd7PKv/n0VKHVf558Q858YNm+78s8TgW8IqJtuCF4qjec9snr6cN+Ez70CylC6hNpxnVDJLLXHk1pk/XWnGsiKoIfqoe6CYmABRUcJmfe3pWIwNRW7RXSetE+P7FvunynLE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=xKKbj0tK; arc=none smtp.client-ip=91.218.175.228 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="xKKbj0tK" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=44TR69x5ZAwBqBOOwd22fnYBam5ymuntq7grA3Sn4D0=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1786636182; v=1; x=1787240982; b=xKKbj0tKLi0NSB6TAgaoQicyHfgBNzS3hxfGkPf7DNOsPu/l/MUGY32z8wHoKYkYkhr/iYkk tfKSReXZNkWsSD3Q06H5ImqVk449AEmV2Cmo/B24X5jFaDbgxdzIogkaPL/Xgsh4KC5ND7GILEj t0YzHznab2TmQnH6rrtqEhEg= X-Envelope-To: linux-kernel@vger.kernel.org Received: from localhost (77.97.51.77) by smtp.migadu.com with ESMTPS id 1965510105143205; Thu, 13 Aug 2026 15:49:42 +0000 X-Migadu-Flow: FLOW_OUT Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Thu, 13 Aug 2026 16:49:40 +0100 Message-Id: Cc: "Borislav Petkov" , "Dave Hansen" , "Peter Zijlstra" , "Andrew Morton" , "David Hildenbrand" , "Vlastimil Babka" , "Mike Rapoport" , "Wei Xu" , "Johannes Weiner" , "Zi Yan" , "Lorenzo Stoakes" , , , , "Sumit Garg" , "Will Deacon" , , "Kalyazin, Nikita" , , "Itazuri, Takahiro" , "Andy Lutomirski" , "David Kaplan" , "Thomas Gleixner" , "Patrick Bellasi" , "Reiji Watanabe" , "Sean Christopherson" Subject: Re: [PATCH v3 05/26] x86: move PAE PMD preallocation defines to header From: "Brendan Jackman" To: "Yosry Ahmed" , "Brendan Jackman" X-Mailer: aerc 0.21.0 References: <20260726-page_alloc-unmapped-v3-0-6f5729aa9832@google.com> <20260726-page_alloc-unmapped-v3-5-6f5729aa9832@google.com> In-Reply-To: On Sat Aug 1, 2026 at 12:59 AM BST, Yosry Ahmed wrote: > On Sun, Jul 26, 2026 at 10:22:38PM +0000, Brendan Jackman wrote: >> In a subsequent patch these defines will need to be referenced from a ne= w >> file, move them as a separate patch for easy review. >>=20 >> The comments have style violations (personal pronouns etc), do not fix >> them as this is just code movement. >>=20 >> No functional change intended. >>=20 >> Signed-off-by: Brendan Jackman > > AFAICT, this is only needed to expose PREALLOCATED_PMDS for > mm_local_map_to_user() in patch #7. The only usage is a BUILD_BUG_ON(). > > I wonder if it would be more preferrable to keep the definitions in > pgtable.c and add a runtime check instead in mm_local_map_to_user(), > something like: > > diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mm= u_context.h > index 09b8d8e6a56ea..15055cb80092c 100644 > --- a/arch/x86/include/asm/mmu_context.h > +++ b/arch/x86/include/asm/mmu_context.h > @@ -268,7 +268,6 @@ static inline pmd_t *pgd_to_pmd_walk(pgd_t *pgd, unsi= gned long va) > > static inline int mm_local_map_to_user(struct mm_struct *mm) > { > - BUILD_BUG_ON(!PREALLOCATED_PMDS); > pgd_t *k_pgd =3D pgd_offset(mm, MM_LOCAL_BASE_ADDR); > pgd_t *u_pgd =3D kernel_to_user_pgdp(k_pgd); > pmd_t *k_pmd, *u_pmd; > @@ -277,6 +276,9 @@ static inline int mm_local_map_to_user(struct mm_stru= ct *mm) > k_pmd =3D pgd_to_pmd_walk(k_pgd, MM_LOCAL_BASE_ADDR); > u_pmd =3D pgd_to_pmd_walk(u_pgd, MM_LOCAL_BASE_ADDR); > > + if (WARN_ON_ONCE(!k_pmd || !u_pmd)) > + return -EINVAL; > + > BUILD_BUG_ON(MM_LOCAL_END_ADDR - MM_LOCAL_BASE_ADDR > PMD_SIZE); > > /* Preallocate the PTE table so it can be shared. */ Yeah, I'd say that's fine. Will get back to you if I find another reason why I thought the move was necessary...