From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 81603C43458 for ; Mon, 13 Jul 2026 16:19:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7AE256B00C5; Mon, 13 Jul 2026 12:19:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 785E86B00C6; Mon, 13 Jul 2026 12:19:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 69BA36B00C7; Mon, 13 Jul 2026 12:19:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 2966F6B00C5 for ; Mon, 13 Jul 2026 12:19:41 -0400 (EDT) Received: from smtpin06.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay08.hostedemail.com (Postfix) with ESMTP id BFF701401F2 for ; Mon, 13 Jul 2026 15:40:17 +0000 (UTC) X-FDA: 84984164874.06.118B609 Received: from out-171.mta0.migadu.com (out-171.mta0.migadu.com [91.218.175.171]) by imf22.hostedemail.com (Postfix) with ESMTP id C826AC0008 for ; Mon, 13 Jul 2026 15:40:13 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=VpL91rYo; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf22.hostedemail.com: domain of brendan.jackman@linux.dev designates 91.218.175.171 as permitted sender) smtp.mailfrom=brendan.jackman@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1783957216; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=zlkLaHtRYAVpE4WxTmCUGpkNu8tzK1MssH3C9d4Lj50=; b=FCI6cLW78PkT+Ut+dvq9tns8t6HJX5gduM8oaSgc1rlPlr8JMwuei7zE1iTXPJnJoQZaXd 19Ad79DM88ZcWrvHcR2HtoIEGcT/tAuV5kMxy2Pl5Sm7NK+acK2vUDqFaAA8C9X/RRQtyw jxYi3ChQNCRRR8hXHSrclQB7qon1B2k= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=VpL91rYo; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf22.hostedemail.com: domain of brendan.jackman@linux.dev designates 91.218.175.171 as permitted sender) smtp.mailfrom=brendan.jackman@linux.dev ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1783957216; b=M9NcXmEALVw5nv7Bf6OnW9Fjqi4OizLvMOUtUjWfkEyuznZgEvsfAO0jyo8Yz/HfCRspbO mZwlHUHQz2BM+y+R4ETfG2O9IMnSWJBh9cjrD6yXYl2rO68cRreDRsHgEYsXSJiHOM7Zd4 8B39epkRcmcMCxPDHNDicK9ZOkoT1lw= Mime-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1783957211; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zlkLaHtRYAVpE4WxTmCUGpkNu8tzK1MssH3C9d4Lj50=; b=VpL91rYo+y2+CR011e23Uc5ksnQ1xmwHVNTLJQsVl2f8ubPHy06muUywGP3MBmv+brEROf 6VBVC24s3DS0AzmDgQXa/wuLOylma8BfZMphJzNJtlzl9RDPya6gy9aJSHUbOGK9y+mMQm 7swMY0r9LyNXKHeqJelB7hXkbqwa0xA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 13 Jul 2026 15:40:04 +0000 Message-Id: Cc: "Harry Yoo (Oracle)" , "Gregory Price" , "Alexei Starovoitov" , "Matthew Wilcox" , "Hao Ge" , , , , , , "Yosry Ahmed" Subject: Re: [PATCH v5 05/18] mm/page_alloc: unify __alloc_frozen_pages[_nolock]_noprof() X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: "Brendan Jackman" To: "Zi Yan" , "Brendan Jackman" , "Andrew Morton" , "Vlastimil Babka" , "Suren Baghdasaryan" , "Michal Hocko" , "Johannes Weiner" , "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" References: <20260703-alloc-trylock-v5-0-c87b714e19d3@google.com> <20260703-alloc-trylock-v5-5-c87b714e19d3@google.com> In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: C826AC0008 X-Stat-Signature: rg1zewc75b8aecoe9puqz8geknarwiqb X-Rspam-User: X-HE-Tag: 1783957213-715995 X-HE-Meta: U2FsdGVkX18qyd9Q80g37U01J+9QLij/v5eY8rGna/7jQe8h7Iy/QOAgeOjBK5yr9805Rt60OeNxsPn/5vDjH1MBvOBw1uECRhckkQkQZNOZ4Uu4TNNvqXviMkIxIMM88Ji9g4jZK5Pe1q/1RTMqjq/iaqyrzKXuWaMwdD5wFi/ZrgzAWseP/yuVwdaBNsJeJwlh7qm83vae1OrEVz47I31v5KDkKNH7MyaEZSIpBGYWFUqVMUnUaDD4JJtKKua6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Ha/BjMeQs5Aw49YAFS+qEopbtu5s2XlKjXSJeOTqhTyve+yPKHLBmiQ== Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Fri Jul 3, 2026 at 2:42 PM UTC, Zi Yan wrote: > On Fri Jul 3, 2026 at 8:31 AM EDT, Brendan Jackman wrote: >> Currently the core allocator code is controlled by ALLOC_NOLOCK, but the >> main entry point function is significantly different from the normal >> __alloc_frozen_pages_nolock(), this is tiring when reading the code. >> >> Plumb the ALLOC_NOLOCK control one layer up in the call stack: create >> an alloc_flags argument to __alloc_frozen_pages_nolock() (which is only >> exposed to mm/) and then turn the nolock variant into a thin wrapper >> that just sets that flag (as well as handling NUMA_NO_NODE, similar to >> how some of the wrappers in gfp.h do). >> >> For consistency, set ALLOC_WMARK_MIN explicitly in fastpath_alloc_flags >> for the new ALLOC_NOLOCK path. This was already "done" silently in >> __alloc_frozen_pages_nolock_noprof(): ALLOC_WMARK_MIN is 0. >> >> Rationale that this doesn't change anything: >> >> 1. Simple bits: A bunch of the nolock-specific handling is just moved to >> the new alloc_order_allowed(), alloc_nolock_allowed() and >> gfp_nolock. >> >> 2. __alloc_frozen_pages_noprof() has some extra logic that wasn't >> previously in the nolock variant: >> >> a. Application of gfp_allowed_mask; this only affects early boot, >> only flags that affect the slowpath get changed here, and the >> nolock allocation path isn't allowed to the GFP_BOOT_MASK flags. >> >> b. Application of current_gfp_context() - also only affects the >> slowpath >> >> 3. The slowpath itself: this is now just explicitly skipped under >> !ALLOC_TRYLOCK. > > s/TRYLOCK/NOLOCK Thanks - Andrew would you mind fixing this up in mm-new? >> >> Ulterior motive: adding an alloc_flags arg to the allocator's >> mm-internal entrypoint can later be used to do more allocation >> customisation without needing to create new GFP flags. >> >> No functional change intended. >> >> Reviewed-by: Vlastimil Babka (SUSE) >> Signed-off-by: Brendan Jackman >> --- >> mm/hugetlb.c | 3 +- >> mm/mempolicy.c | 10 +-- >> mm/page_alloc.c | 192 +++++++++++++++++++++++++++++--------------------= ------- >> mm/page_alloc.h | 6 +- >> mm/slub.c | 6 +- >> 5 files changed, 117 insertions(+), 100 deletions(-) >> > > > >> +/* >> + * This is the 'heart' of the zoned buddy allocator. >> + */ >> +struct page *__alloc_frozen_pages_noprof(gfp_t gfp, unsigned int order, >> + int preferred_nid, nodemask_t *nodemask, unsigned int alloc_flags) >> +{ >> + struct page *page; >> + gfp_t alloc_gfp; /* The gfp_t that was actually used for allocation */ >> + struct alloc_context ac =3D { }; >> + unsigned int fastpath_alloc_flags =3D alloc_flags; >> + >> + /* Other flags could be supported later if needed. */ >> + if (WARN_ON(alloc_flags & ~ALLOC_NOLOCK)) >> return NULL; >> =20 >> + if (!alloc_order_allowed(gfp, order, alloc_flags)) >> + return NULL; >> + >> + if (alloc_flags & ALLOC_NOLOCK) { >> + VM_WARN_ON_ONCE(gfp & ~__GFP_ACCOUNT); >> + if (!alloc_nolock_allowed()) >> + return NULL; > > At first look, I wonder why __alloc_frozen_pages_noprof() needs to care > about alloc_nolock_allowed(). But the patch's idea is to centralize all > allocation policies, so it makes sense. > > Ideally, I would want alloc_frozen_pages_nolock_noprof() to filter as > much as possible, so that __alloc_frozen_pages_noprof() has minimal/no > awareness of ALLOC_NOLOCK. But ALLOC_NOLOCK has different preferences > compared to the default __alloc_frozen_pages_noprof() policy like > ALLOC_WMARK_MIN vs ALLOC_WMARK_LOW, skip slowpath, and more. Maybe we > could do something like: > > __alloc_frozen_pages_noprof() > { > alloc_fastpath(); > alloc_slowpath(); > } > > alloc_frozen_pages_nolock_noprof() > { > alloc_order_allowed(); > alloc_nolock_allow(); > alloc_fastpath(); > } > > But it still cannot remove ALLOC_NOLOCK completely from > __alloc_frozen_pages_noprof(), like the nofragment skip. Anyway, this > patch is a reasonable cleanup. Thanks. Yeah, thanks this does look sensible but I think it's a separate cleanup.