From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.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 708D137C90E for ; Mon, 23 Mar 2026 12:01:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774267304; cv=none; b=oU3LSIk5/aCXsZFoJZ+qMMgJ2WJMcgG/xRAGg39gApqW2pwpla5UFcKRb5bf5LBBnJO799gvqewWNXXPGE4kUk3xq83gGyxLagJ/16XkX9igD5VXnVphUVjpTBw3vn0JguvjEt3lZuO6C+R2VBRzyoPha7gxHMpglsjd8MjWkx8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774267304; c=relaxed/simple; bh=ofo12L+oT1RR3VqhdHHP10Bc5d/V+LT9mky6S1pwXBc=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Yew5VKgnNZl8VNtEJwnWihk3uOpZjf5rClW5rfLt7dW8lsiiGlJmp89jyGn4y6n1IJJ1MzuMnI9vbHHsdEkw5gmWX5wCiCZAN3MAN8ceZeqMCKzV26KQbc+Tk9A6z0UG4yRiGK8DW9FRKRx3K4FCGMLReZoCVr7kigxcXiLpuF0= 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=B1SigVUD; arc=none smtp.client-ip=209.85.128.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="B1SigVUD" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-487018c8244so14169815e9.3 for ; Mon, 23 Mar 2026 05:01:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1774267302; x=1774872102; 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=9PU7c6Ak+cD1xqE0Ag3FZYs88dCaVaPlNoPrIQ+v6QI=; b=B1SigVUDb8RjC1fGczIJbzlcrQpXM8tQZUrqKrfqqfh4RsK/UHzOWfBbnxhfRAJYLr lLqwonNNu77JRAzkGLDsRceLrwwoVPLQ6CZPrmzOJzzeLuY963lfpp8Q5RSJj7FtAgYH Uok+0JZynw4dtq7rBh01RiAen+mCA02CQjeWo0C6gbcHm7euLEbTKmlrqttL+nmgRpiw Sb0MSmtAxXt+cVYaN+VrsBuymQMJh6pflnCUq0ij3XChR906L/Ek45AXf1fPs3yL6Uie +h2HkpUaleGd+0N2F0FR9N12yfJNKUt6GEwIeDxbKv5Mel5jLyyR6afhWpi5r80WgcgC sKRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774267302; x=1774872102; 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=9PU7c6Ak+cD1xqE0Ag3FZYs88dCaVaPlNoPrIQ+v6QI=; b=LGu9RcXPWyU5hnnz+urK0+mOgz79Zm2d/3rQ2Qg7k3tXYoFJtAlxXcLqeU+Y4uPmbD jaFyHwcgVfNJcAcHPCAj50yLNvbuM9xsrgHofYAcfBkoJyQcYon1IEVgOBsTr7R9AE4V g3ltXKeKqNbqaqQ880uoYHqtjjlibPKxhda+6USmgzkBsGqgO40VZ701I1+j5eQd9zU+ ezL4sgWrlYfmTZZKcQJs3+88JRauWYN9mf0BBE81kkCRWlRmbT+6RTjUVfdIgq5SzOvU u7f3nEjRUEi6P1nx6GnxgZgpkt3hEDPILsSSvb5M99ks3DN276d6FTy1jPzpVHp9fl9L xgiQ== X-Forwarded-Encrypted: i=1; AJvYcCWDUs67xWiMaakrDdalsWQ2sZxohXORJdyVjovGWxRdu75f8cRGtnF0PnR2mwX68Bl6oS6Ga3C1wv7+Jak=@vger.kernel.org X-Gm-Message-State: AOJu0YyeNxMQlY/mAD3QwUGGwCQRRsgvv9NbFgsCJT9O9tOMvHzjeWs9 q5FItWwGtgSl+n0x+3Bv3ehGWoFGxNZwEd3Vy15FhHHeeP8GfIgxi7d8r4ukSQeC5wNcQ4fWly5 urmDuG2+KzBvaaA== X-Received: from wmbha26.prod.google.com ([2002:a05:600c:861a:b0:486:fbd8:2af6]) (user=jackmanb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:468b:b0:485:5812:bb9e with SMTP id 5b1f17b1804b1-486feb5a4d0mr174722475e9.0.1774267301692; Mon, 23 Mar 2026 05:01:41 -0700 (PDT) Date: Mon, 23 Mar 2026 12:01:40 +0000 In-Reply-To: <17e58542-1221-48dd-88b9-236128515ed2@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-2-28bf1bd54f41@google.com> <17e58542-1221-48dd-88b9-236128515ed2@intel.com> X-Mailer: aerc 0.21.0 Message-ID: Subject: Re: [PATCH v2 02/22] x86/mm: Generalize LDT remap into "mm-local region" 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:47 PM UTC, Dave Hansen wrote: > On 3/20/26 11:23, Brendan Jackman wrote: >> >> +#ifdef CONFIG_MM_LOCAL_REGION >> +static inline void mm_local_region_free(struct mm_struct *mm) >> +{ >> + if (mm_local_region_used(mm)) { >> + struct mmu_gather tlb; >> + unsigned long start = MM_LOCAL_BASE_ADDR; >> + unsigned long end = MM_LOCAL_END_ADDR; >> + >> + /* >> + * Although free_pgd_range() is intended for freeing user >> + * page-tables, it also works out for kernel mappings on x86. >> + * We use tlb_gather_mmu_fullmm() to avoid confusing the >> + * range-tracking logic in __tlb_adjust_range(). >> + */ >> + tlb_gather_mmu_fullmm(&tlb, mm); > > These are superficial nits and I need to go through this series in > actual detail, Thanks, this series is pretty brutal so I'm very happy to receive incremental reviews! > but here are the nits: > > Indentation is bad. What you have here double-indents the whole function. > > Do this: > > struct mmu_gather tlb; > unsigned long start = MM_LOCAL_BASE_ADDR; > unsigned long end = MM_LOCAL_END_ADDR; > > if (!mm_local_region_used(mm)) > return; > > ... rest of code here Ack > >> + * We use tlb_gather_mmu_fullmm() to avoid confusing the >> + * range-tracking logic in __tlb_adjust_range(). >> + */ > > Imperative voice, please. Yeah I don't think I'm ever gonna stop making this mistake. Any LLM should be able to catch this for me, I think it's time to find a way to get that into my pre-mail workflow. > And a meta-comment: > >> Documentation/arch/x86/x86_64/mm.rst | 4 +- >> arch/x86/Kconfig | 2 + >> arch/x86/include/asm/mmu_context.h | 119 ++++++++++++++++++++++++++++- >> arch/x86/include/asm/page.h | 32 ++++++++ >> arch/x86/include/asm/pgtable_32_areas.h | 9 ++- >> arch/x86/include/asm/pgtable_64_types.h | 12 ++- >> arch/x86/kernel/ldt.c | 130 +++++--------------------------- > > This is too big and there's too much going on here. This is doing a few > logical things like both introducing mm-local regions *and* making the > LDT remap one of them. IIRC I tried this but having both an mm-local region and a separate LDT remap at the same time is annoying, it would mean reviewing temporary code to deal with both existing at the same time. However I just had an idea: I will try creating the mm-local region but with size 0. Then in a separate patch I'll expand it and simultaneously move the LDT remap into it.