From nobody Mon Dec 15 23:28:19 2025 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 025C3227599 for ; Mon, 15 Dec 2025 10:40:28 +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=1765795230; cv=none; b=aSsounZtBcawpd/qA0ffV9ZzXk93lNEvNrKFGNIrwsXbP/y6T/nN7Inn5AnSk4+rjteAQvABUMjHzP0fw5KNZI7x6sWPeyX/aCqr6urzAdJIhDw7+7JLSxdmLtZXnk4SkPmPDMEtGfj1h9oKE19Pz5j+AjIztpbFh0dbgleA9yI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765795230; c=relaxed/simple; bh=Vx4a7fl+ydFKDtKAIN7RqVMdYeB5XYAGZxfSyv7mL7Y=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=NrUclHQEutAKUcVTd0mZZmfewncu5wbSjxoKg9IEWxcLl9pSVO4KUUt3lzV7Xi0u5AfMCiU+uFFcQ6RGawme5z8/wCxZkU6bg/tuEGuggMM0RJuwQsshquW0PNcITqlRXxYIulfQr0DE52vSiTp9agNHKYV0xYz9yZ3mWkO1fC8= 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=tQ0oQ3Ju; 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="tQ0oQ3Ju" Received: by mail-wr1-f73.google.com with SMTP id ffacd0b85a97d-43009df5ab3so656742f8f.1 for ; Mon, 15 Dec 2025 02:40:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1765795227; x=1766400027; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=sTvGtLS7N+gCGHNScVBwulc7S+0JY+4KtDSa6CxwkxY=; b=tQ0oQ3JuXrVBHFUtyCjU0yWVwXPVekdrobzAz/s1CUeN2fTCbzl2JpKRUY5zn558T/ Jvr9eQUsWmTgav+yIS03yNlW8tTe2Uin/Y9TDWKPGWx1watjKnB9in0q9JP0scfs7WM6 u2U2H7riNTuy+8WUH8htVKqPEXCO7e5K1CbeeYddI9MGJx/g77dJ0bUvuLcg4kMv0WgN 4Lv7q25bOcHEv4/0cZ8OlIaFcx3nPJyjZMMfYvFF6UMa22FnEh3lYCEvPvEISDYgRPEE OyniEzsJKs5GFGkyubIC5PocylV1uOLcPr3c+JhkjsdR5uadGp9ddpTu5GMG3TnQ2SXT +/YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765795227; x=1766400027; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=sTvGtLS7N+gCGHNScVBwulc7S+0JY+4KtDSa6CxwkxY=; b=jjvQ49i8jrJHZzkcscVDyQuvlzM0SAqq+dUGdTfEs6Py78Kh/zBsmvAenhew/jEcSk p7qMfyPneC9Iy9v2/nZcEG+5oZSCXvlMMX/plyBtK3O50yxe1P/3HoSwkult8vOxjOaL +eBEZOfqrShgHwBeep3QNA8OscsgBKRsK4aHzfNW+KY7TISuOSC48+csltn181gsZ/Mx MzPrPFsyGWyZPYHmiRt0VUJgr0ifhcEvGmNYzYg9JMJ0jYrQkmwgja6BDAaBXsPGlpK4 FZHmdP9RaV3ocArS5RJgwP4H0sZ5aDHnWl4oJNCU8gJwgZKOOk9eM4fjI6GjROycqu2E MXEg== X-Forwarded-Encrypted: i=1; AJvYcCUM/o0qkRg9DcPr6Fa1Fjt1XS2beie54AkIOh9RBdXYsuv7lXnJStpvNUSw/NoI5g/WZXMhmASkecCNQNI=@vger.kernel.org X-Gm-Message-State: AOJu0YxyJq8qR3C+iWjDo1Wx2TeGJW7ePt98J5KAlUd5zQfR6cmK3mdf gOVEv7Agbb/uYNhQ36BzsclK4r2L/vpV89CnYFl5/arEVNaMv9LTiMfxp1cOlp1JwIjTrcYDY0l YCcHXXCQdUSvUpA== X-Google-Smtp-Source: AGHT+IG5GkEWqIH4ybkcTK4ISjnWq/y+Aat4wfFxlH3Xj3He5aRLXuRIJMIOLYrtbwFX8VEwBSblMj4mh/OfzA== X-Received: from wmpg4.prod.google.com ([2002:a05:600c:4c84:b0:477:55d3:90d1]) (user=jackmanb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:1c81:b0:477:a02d:397a with SMTP id 5b1f17b1804b1-47a8f89c91cmr101729205e9.2.1765795227251; Mon, 15 Dec 2025 02:40:27 -0800 (PST) Date: Mon, 15 Dec 2025 10:40:25 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAJjlP2kC/4XNSw7CIBCA4as0rMXASB+48h7GGKAjJWmLgYZom t5dWje6MO7mn2S+mUnE4DCSYzGTgMlF58cch11BTKdGi9S1uQkwKDmwhmpB06D63hs6ONtN1/d cl0LVkqNAzkg+vge8uccGny+5OxcnH57bn8TX7V8yccqpFEpq3aDRrDlZ722Pe+MHspoJPh350 4HsgKhAK6hQtfzLWZblBfCIOa8FAQAA X-Change-Id: 20251208-b4-vmalloc-might_alloc-754a791e4e10 X-Mailer: b4 0.14.2 Message-ID: <20251215-b4-vmalloc-might_alloc-v3-1-92dd8e406868@google.com> Subject: [PATCH v3] mm/vmalloc: clarify why vmap_range_noflush() might sleep From: Brendan Jackman To: Andrew Morton , Uladzislau Rezki Cc: Anshuman Khandual , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Brendan Jackman Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The only reason vmap_range_noflush() can sleep is because of pagetable allocations. The actual allocation mechanism is arch-specific so might_alloc() doesn't work here (what GFP flags would be used?). Hence, just add a comment. Also note that this might do a TLB shootdown. This is not actually sleeping but it requires IRQs on for x86, and might_sleep() incidentally serves to detect violations of that too. Signed-off-by: Brendan Jackman Reviewed-by: Uladzislau Rezki (Sony) --- Applies to mm-new. Changes in v3: - Added note about TLB shootdowns and x86. - Since the comment no longer fit on one line anyway, also be a bit more verbose in general. - Link to v2: https://lore.kernel.org/r/20251209-b4-vmalloc-might_alloc-v2-= 1-2462ba26ead1@google.com Changes in v2: - Switched from might_alloc() to keeping might_sleep() + comment - Link to v1: https://lore.kernel.org/r/20251208-b4-vmalloc-might_alloc-v1-= 1-94a9bb8ecb08@google.com --- mm/vmalloc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 41dd01e8430c548167d6123f6ec66bf798f20eec..be4e5f2566a4490d45de29568df= 538b7c8515b01 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -305,6 +305,11 @@ static int vmap_range_noflush(unsigned long addr, unsi= gned long end, int err; pgtbl_mod_mask mask =3D 0; =20 + /* + * Might allocate pagetables (for most archs a more precise annotation + * would be might_alloc(GFP_PGTABLE_KERNEL)). Also might shootdown TLB + * (requires IRQs enabled on x86). + */ might_sleep(); BUG_ON(addr >=3D end); =20 --- base-commit: d0a24447990a9d8212bfb3a692d59efa74ce9f86 change-id: 20251208-b4-vmalloc-might_alloc-754a791e4e10 Best regards, --=20 Brendan Jackman