From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.73]) (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 E3A053932DF for ; Mon, 23 Mar 2026 11:01:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774263702; cv=none; b=mONV3pm1qnUA2XN881KcCGslY16HHEr1P0/CjPpIRaeg1kaHltOVttMOMvCNCpQ5lQroefiKmu9MATPNMbodUtkqhd4kYqywTrVzfpQ+mwpzwLwaclGSR82+q9JoohvAQJQpJFA4f2x3bjqe9fvC6VlGdR59UTBFGG21ziEVHjg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774263702; c=relaxed/simple; bh=Z7tZ89MsFIkm5xgrtsEQGBF4C6An7+1ziWWRZ1Ldbrk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=ER49drQ9sWqOB4PSH/rm4tEBZP8FRlXxeqKqpj2Iu93NTFsYLdIgj6zBbLFiTgqIbL77soCDnbfOy2MWWMRQrkKs5ilU4N35vK/pbZX3XxlOAmtGDoOUXsaRE8T2Pem3d7mvAY3fvBhVNQSQH+VnwsBN8I11+HkIFBgtof1t8Fo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Zw+ozVnp; arc=none smtp.client-ip=209.85.221.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Zw+ozVnp" Received: by mail-wr1-f73.google.com with SMTP id ffacd0b85a97d-43b40c22eaeso4342791f8f.2 for ; Mon, 23 Mar 2026 04:01:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1774263699; x=1774868499; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=fw594RC7Otx4FzA9sHEiwCzrolkTaDAMaFwy+wBrh1g=; b=Zw+ozVnpXM9t5XCKRUdkobA7bp829aGUGWaWKK/KUp00LJKdWHpjf1AztMcf9zUgsy iYL/xB1ncgJwp2UjCq3KdwV14qvpwTdVVeI5u6BrlgDTeNSXTrvsG0xqL3lnGHSAk7RN qV8F4rD4ehMHUL2b+uzoa7SFn4mJ1TtWi4bOigOfPASI0fDqEcbE0LJP/ofYloy26SLC 5Dv1KktoGlVWYmyWbkgzn3mRr9y1HSwb0e1RNP2iSgiafmMjWfs0yaKXo5iLUh2Fdu9O aL979oxMYdSd7kKGzuO1f/CQH1+0ZOgiq3St3zYZpPnaiAL0LVXtMgpyL69tu3ySkKW6 3D/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774263699; x=1774868499; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fw594RC7Otx4FzA9sHEiwCzrolkTaDAMaFwy+wBrh1g=; b=P7HoFN3tk9SjghGPe52RUOCnybgsPOyxwORUExPLG/0IYnKfc1lTl3SNAtc+3TotF2 BqYioHPAZCIpCVJeiCo1QBQeTxfibVlyvweZGFjlZGwxkzNdbw8ev2KtHl+4r/BndVwy LCRCUwuT6V8Yps8aBedNbeY2K4PoA/7IGVO8yhtN72YF5BvA146zHya65TP2do2IjlZB x3W3+plYaPX53IOhD6yeZ8jQLCKIUPZt7FgmnyPFYuo8r3wXzuycD7WyEJRFGDW595U2 MYPU+8IYqHhxn8srT7ojjL6UtKIN4E6hKfpqSatnDUXwu4kW6SuRNdlHA3oJPLH35BG2 Hpdw== X-Forwarded-Encrypted: i=1; AJvYcCVU0ntxNWBl4wgJLiMvWEbiNStmm8R/Ucsdll4SdWddunKYQfxtkOiDdL8BMVNLYh0nyuMhroYVlC9JZ2c=@vger.kernel.org X-Gm-Message-State: AOJu0Yymbi291PmUNedqq9dY8u5uR3I1uWDssP3b57/gJhJg+SiYdUv6 HegdNzlQtOp+RQ6/UKFjvgPT2awbVgg3v5w/iWJo7AWSwlLQ3yghGUEYOFGzeXFBhW93NRHv83S y0Rki7tXiRDRbJg== X-Received: from wrrj9.prod.google.com ([2002:adf:ff89:0:b0:43b:63b2:2d6d]) (user=jackmanb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:348c:b0:485:39b2:a47c with SMTP id 5b1f17b1804b1-486fee1af1cmr140778235e9.25.1774263699152; Mon, 23 Mar 2026 04:01:39 -0700 (PDT) Date: Mon, 23 Mar 2026 11:01:38 +0000 In-Reply-To: <554c886f-6678-4208-8566-15aa140f6c4b@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260320-page_alloc-unmapped-v2-0-28bf1bd54f41@google.com> <20260320-page_alloc-unmapped-v2-1-28bf1bd54f41@google.com> <554c886f-6678-4208-8566-15aa140f6c4b@intel.com> X-Mailer: aerc 0.21.0 Message-ID: Subject: Re: [PATCH v2 01/22] x86/mm: split out preallocate_sub_pgd() From: Brendan Jackman To: Dave Hansen , Brendan Jackman , Borislav Petkov , Dave Hansen , Peter Zijlstra , Andrew Morton , David Hildenbrand , Vlastimil Babka , Wei Xu , Johannes Weiner , Zi Yan , Lorenzo Stoakes Cc: , , , , Sumit Garg , , , Will Deacon , , "Kalyazin, Nikita" , , "Itazuri, Takahiro" , Andy Lutomirski , David Kaplan , Thomas Gleixner , Yosry Ahmed Content-Type: text/plain; charset="UTF-8" On Fri Mar 20, 2026 at 7:42 PM UTC, Dave Hansen wrote: > On 3/20/26 11:23, Brendan Jackman wrote: >> - /* >> - * The goal here is to allocate all possibly required >> - * hardware page tables pointed to by the top hardware >> - * level. > > This comment is pretty important, IMNHO, and you zapped it. > > The problem here is that the per-MM carved out space is PGD-sized. You > want to make sure there are page tables allocated for that space. But, > if you say "go allocate a p4d" then that will collapse down to doing > nothing on a 4-level system. > > So, this is effectively: > > Go allocate a p4d or pud, depending on if it's 4 or 5 level. > Basically, always allocate the level that the hardware PGD > points to. > > Could we put a comment to that effect around somewhere, please? Hm I kinda thought the comments I left in there captured all this stuff, but yeah I can see this is a bit of a weird function so more commentary makes sense. How about I just put a few more words into the top comment: /* * Allocate all possibly requried hardware page tables pointed to ths * top hardware level. In other words, allocate a p4d on 5-level or a * pud on 4-level. */ And then just leave the internal one as it is: /* * On 4-level systems, the P4D layer is folded away and * the above code does no preallocation. Below, go down * to the pud _software_ level to ensure the second * hardware level is allocated on 4-level systems too. */