From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 39B2831A577 for ; Wed, 17 Dec 2025 08:27:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765960027; cv=none; b=qNa62+xqBUa5GTCSbyZalF6LB+wCrEEnOoEQa2bm9Ym2XHLiBSzwkG3h/hZiH3Z4GV+w6mozj9a42ZEUmjXdfPRlSqc0F/6LCbfCJpyiXiLO4tt3qfczFe2KLEQppA1P34by/tXLMa2idx7uCECtHSiHuPa/QrQ99SzEcmsRviA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765960027; c=relaxed/simple; bh=VIBKsTGQfe4738oad1WpCRHH7bxJeDELTsha/WTN6hk=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=JWeC4nEtwx/wsCwsp2jZt26JDLVjm03E28TE1DVS5AChZZbPayauDqpDq0BugPp89OOkfCuHWkWXmO7ikT/leLJesONlEsVwYZzmq6D3On1jbwn7GNBSknzjohpGJIA9XysIfqEWV4biQCbrLtVovOqf6NhZl7QssnnOJosGFz4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5760314BF; Wed, 17 Dec 2025 00:26:57 -0800 (PST) Received: from [10.57.91.77] (unknown [10.57.91.77]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3337D3F73F; Wed, 17 Dec 2025 00:27:03 -0800 (PST) Message-ID: <6ca6e796-cded-4221-b1f8-92176a80513e@arm.com> Date: Wed, 17 Dec 2025 08:27:01 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/2] mm/vmalloc: Add attempt_larger_order_alloc parameter Content-Language: en-GB To: "Uladzislau Rezki (Sony)" , linux-mm@kvack.org, Andrew Morton Cc: Vishal Moola , Dev Jain , Baoquan He , LKML References: <20251216211921.1401147-1-urezki@gmail.com> <20251216211921.1401147-2-urezki@gmail.com> From: Ryan Roberts In-Reply-To: <20251216211921.1401147-2-urezki@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 16/12/2025 21:19, Uladzislau Rezki (Sony) wrote: > Introduce a module parameter to enable or disable the large-order > allocation path in vmalloc. High-order allocations are disabled by > default so far, but users may explicitly enable them at runtime if > desired. > > High-order pages allocated for vmalloc are immediately split into > order-0 pages and later freed as order-0, which means they do not > feed the per-CPU page caches. As a result, high-order attempts tend > to bypass the PCP fastpath and fall back to the buddy allocator that > can affect performance. > > However, when the PCP caches are empty, high-order allocations may > show better performance characteristics especially for larger > allocation requests. I wonder if a better solution would be "allocate order-0 if available in pcp, else try large order, else fallback to order-0" Could that provide the best of all worlds without needing a configuration knob? > > Since the best strategy is workload-dependent, this patch adds a > parameter letting users to choose whether vmalloc should try > high-order allocations or stay strictly on the order-0 fastpath. > > Signed-off-by: Uladzislau Rezki (Sony) > --- > mm/vmalloc.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > index d3a4725e15ca..f66543896b16 100644 > --- a/mm/vmalloc.c > +++ b/mm/vmalloc.c > @@ -43,6 +43,7 @@ > #include > #include > #include > +#include > > #define CREATE_TRACE_POINTS > #include > @@ -3671,6 +3672,9 @@ vm_area_alloc_pages_large_order(gfp_t gfp, int nid, unsigned int order, > return nr_allocated; > } > > +static int attempt_larger_order_alloc; > +module_param(attempt_larger_order_alloc, int, 0644); Would this be better as a bool? Docs say that you can then specify 0/1, y/n or Y/N as the value; that's probably more intuitive? nit: I'd favour a shorter name. Perhaps large_order_alloc? Thanks, Ryan > + > static inline unsigned int > vm_area_alloc_pages(gfp_t gfp, int nid, > unsigned int order, unsigned int nr_pages, struct page **pages) > @@ -3679,8 +3683,9 @@ vm_area_alloc_pages(gfp_t gfp, int nid, > struct page *page; > int i; > > - nr_allocated = vm_area_alloc_pages_large_order(gfp, nid, > - order, nr_pages, pages); > + if (attempt_larger_order_alloc) > + nr_allocated = vm_area_alloc_pages_large_order(gfp, nid, > + order, nr_pages, pages); > > /* > * For order-0 pages we make use of bulk allocator, if