From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lj1-f202.google.com (mail-lj1-f202.google.com [209.85.208.202]) (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 4E2984D90DF for ; Thu, 2 Jul 2026 09:50:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782985807; cv=none; b=IY+VsXXG6JpWBjQo6MQPdeseaC9vUKkSIdKR6G/NEXnwQgA2d/CtCKECg89QkwHdlazjxw5xU09jGicOodL5640Pi1eETMcdhFlH8cD+8+sF38FUHvqR2ynRgBJ5AN2pJnXLpYwVmlL3zGe5RIAlLs39SGJymIokVKyM69Fejco= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782985807; c=relaxed/simple; bh=etU0KmQ93MVQ8p8e74J7jmNSb0FdCttGT65sD7BwF2Y=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Sc1rDB4B+Zh9VPR2XOYuf+Vw78fgOHJeRoalqTUgA9neMjCf1W1Q3GoQ0kzRWIuxn1NdNOnLgKdKrSeN5BMxWR1k6dooEiW+qpA/QcFTwb6DxdV2Ag/ihcT+pyzD+iDL6d28vRUWaWe0emHOmt2WR0sWHHhpGI31ug5GNrXb2fA= 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=pFRl9GIF; arc=none smtp.client-ip=209.85.208.202 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="pFRl9GIF" Received: by mail-lj1-f202.google.com with SMTP id 38308e7fff4ca-39ad42eaf7cso8303321fa.2 for ; Thu, 02 Jul 2026 02:50:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1782985803; x=1783590603; 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=BxUSvpYnRk7TPJu9DIAcrJg+2SEdx9XX7++N/RbsLUU=; b=pFRl9GIF8PNs6khrE1DceKWjRGwMpNpdoTSd1YfOybtRQVZo6rJG+5r7kV+W4d7Vv2 aQ0BEW7j0b/07MbzYAoGCarWpoHHaYQ431+t9HhO/3iZa59b/MkMiOKJRx0jLjhCcs38 TLUXOe8/dlTs0GC/qcDLJ8QW4GgdFV4QkXR6wSiJE9E3hR7tx1t0D2mlBJtkHzY859BY u7oSsBpIOqoHGlQGecLt5E51hyJ+NftF+pl531X+DbKpBdmY2CPLqd1UKfpGL7VOxkeq vzIdwI/wcXl+Qrg5bknvtBwoqBMMZGS8Gc35iBwVJZD9H2Yv56MvABXZj1h5Bx1NKq5v DKsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782985803; x=1783590603; 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=BxUSvpYnRk7TPJu9DIAcrJg+2SEdx9XX7++N/RbsLUU=; b=rewo3FPT/7WywfrhsKBV/iGLnp8gEseWQHbxdtdf63jMG9geBrBzDY3x0KINdSBgs0 5VuSCmuPG9Fr1jD6Xtlw8C8buxTZ/RNWviDZV12Qpu8qA4FlSKlSaHRWuFqj8gHo6f38 IPR8pDrbpNjnL6hp8apH0y3+wleP4etALWxLXnWhlu5Hdq3N2Et/xWFa7GHuo4AXmtXI xGOyB9Bl+kwxEaoXUYYajgaEKQ56MpMp/oUFTaIq5Pa/OVbF4r3aHPpsoWUDNGG3veRb sYK7Xj9H4tY3SlrRqcEDAztwmB/XNhUZzcFVgX9eFKdJP9QBcQTaA+IQgYa/sxz0A+wI VhNA== X-Forwarded-Encrypted: i=1; AHgh+RozreJs66pOoJ8SYjo5NLdV88Xi5zenewCpZL+121SUjGnJPe6NZEnIU5tD0o7bQUgTA5C5yt3/nlhNYro=@vger.kernel.org X-Gm-Message-State: AOJu0YwC5L2A23c+Rzl5Q+lSppAXkn9ed1sr9WEhdbvQshiJiVGu92S7 ezBBRL5emuvko+UxQlSj184LXf1gQEoe5r4/rgy81Pxp4Y+fqfPMeXeqVTJjut/T7TamTAPRNQf S3w+x2Qz3BfF0Dg== X-Received: from ljic12-n2.prod.google.com ([2002:a05:651c:234c:20b0:39a:f395:e002]) (user=jackmanb job=prod-delivery.src-stubby-dispatcher) by 2002:a2e:9b12:0:b0:39a:cfe8:dcde with SMTP id 38308e7fff4ca-39b37005de1mr6442781fa.30.1782985803272; Thu, 02 Jul 2026 02:50:03 -0700 (PDT) Date: Thu, 02 Jul 2026 09:49:44 +0000 In-Reply-To: <20260702-alloc-trylock-v4-0-0af8ff387e80@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260702-alloc-trylock-v4-0-0af8ff387e80@google.com> X-Mailer: b4 0.15.2 Message-ID: <20260702-alloc-trylock-v4-13-0af8ff387e80@google.com> Subject: [PATCH v4 13/18] mm: Remove __alloc_pages_node() From: Brendan Jackman To: Andrew Morton , Vlastimil Babka , Suren Baghdasaryan , Michal Hocko , Johannes Weiner , Zi Yan , Muchun Song , Oscar Salvador , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Mike Rapoport , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Ying Huang , Alistair Popple , Hao Li , Christoph Lameter , David Rientjes , Roman Gushchin , Sebastian Andrzej Siewior , Clark Williams , Steven Rostedt Cc: "Harry Yoo (Oracle)" , Gregory Price , Johannes Weiner , Alexei Starovoitov , Matthew Wilcox , Hao Ge , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev, derkling@google.com, reijiw@google.com, Brendan Jackman , Yosry Ahmed Content-Type: text/plain; charset="utf-8" There were only a few users, which have been removed. The only advantage of this API over alloc_pages_node() is avoiding a single conditional branch. The disadvantages are: 1. More API surface, more sources of confusion, more maintenance. 2. Worse impact of CPU hotplug bugs: most users of __alloc_pages_node() were using the result of cpu_to_node(); if the CPU gets hotplugged out this will return NUMA_NO_NODE. If one of these paths fails to protect against a concurrent hotplug then page_alloc.c will use NUMA_NO_NODE as an index into NODE_DATA() and cause some horrible memory corruption or other. With alloc_pages_node(), the code might just work fine. Ulterior motive: this frees up the __* variants of the allocator APIs to serve specifically for use as mm-internal API. Reviewed-by: Suren Baghdasaryan Reviewed-by: Vlastimil Babka (SUSE) Signed-off-by: Brendan Jackman --- include/linux/gfp.h | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/include/linux/gfp.h b/include/linux/gfp.h index 01d6d2591f49e..3bf55a5f9143e 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h @@ -256,21 +256,6 @@ static inline void warn_if_node_offline(int this_node, gfp_t gfp_mask) dump_stack(); } -/* - * Allocate pages, preferring the node given as nid. The node must be valid and - * online. For more general interface, see alloc_pages_node(). - */ -static inline struct page * -__alloc_pages_node_noprof(int nid, gfp_t gfp_mask, unsigned int order) -{ - VM_BUG_ON(nid < 0 || nid >= MAX_NUMNODES); - warn_if_node_offline(nid, gfp_mask); - - return __alloc_pages_noprof(gfp_mask, order, nid, NULL); -} - -#define __alloc_pages_node(...) alloc_hooks(__alloc_pages_node_noprof(__VA_ARGS__)) - static inline struct folio *__folio_alloc_node_noprof(gfp_t gfp, unsigned int order, int nid) { @@ -293,7 +278,10 @@ static inline struct page *alloc_pages_node_noprof(int nid, gfp_t gfp_mask, if (nid == NUMA_NO_NODE) nid = numa_mem_id(); - return __alloc_pages_node_noprof(nid, gfp_mask, order); + VM_BUG_ON(nid < 0 || nid >= MAX_NUMNODES); + warn_if_node_offline(nid, gfp_mask); + + return __alloc_pages_noprof(gfp_mask, order, nid, NULL); } #define alloc_pages_node(...) alloc_hooks(alloc_pages_node_noprof(__VA_ARGS__)) -- 2.54.0