Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp872718pxt; Thu, 5 Aug 2021 13:57:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYaJ0I7+cesZhGz0llRyDfLq1LSngnSuuOe8p9VCGFvWAi6p6ESRyEJjGojMtUuidkVo1I X-Received: by 2002:a92:1944:: with SMTP id e4mr559812ilm.186.1628197066112; Thu, 05 Aug 2021 13:57:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628197066; cv=none; d=google.com; s=arc-20160816; b=eDBpdAEataFEO34D/TEdnAwE1TXlm5go1UgcIiXjU2HaT5HUQAlm3su80vBWqhva56 +VftBX9i8eHW/C1E0cBmf1HKtnp9mMWB55VtvgPdTAqpOZ/CRd1aHQb0IXah7q2P4OAT IyOJSF4+MgaIUEciB83rfjEnaXvyyh9BR8ZXrbyU9H2lfoE8xz1CE042saJVUt1OL2+p PJ8wFFbjx28ekvBavUn3jnC7pJAfAjL8RCJmtGSj2c7cO5c2emJ3Gx02LQh2oA+EdeUR AqorikAQwdv9nVeSzabH5S2KuIR8ny14OUUHrqWAGc1vJN2icT1MKbr/AQkMtdBy0lXg fb2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version:reply-to :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=RA0AsrTogxcWFpocSItHzob/KJFuxJUXcWJazBJO2Zo=; b=BuGDSFpbfrAwbyPSEaaNIxgjHhNfUghsQpDpnGtpSwoBLoW0S+nt9fSK3l8ebWDOSr YBwoGIkj5ytZEcOD3k+rBl+AgffY1sXPnZ8eiDYpYEzCmpZjhitnuTftQTZ4uKpWCCR4 fU2oMnEiNZybzw94i1gnyjq3DyQlgp9g7sAOmSHfLRJiS14AjNuSKGaVdag9OzGS/foQ WDImRCaAR30PRoatAkWPYTLnQuWyV+MtdcxswtBxq98R272bP0h4Gmiy0gaW6WbnehCx sdyhc0HkrmBfzzVg395P/ae9fDNs4PCAbU8nQduBckz5yWJPeftoWy14hmGPrkaSNKvz aSoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sent.com header.s=fm1 header.b=JyLRlPZX; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=B5FDGE67; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sent.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z21si6574075jao.126.2021.08.05.13.57.34; Thu, 05 Aug 2021 13:57:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@sent.com header.s=fm1 header.b=JyLRlPZX; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=B5FDGE67; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sent.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242704AbhHETE2 (ORCPT + 99 others); Thu, 5 Aug 2021 15:04:28 -0400 Received: from new3-smtp.messagingengine.com ([66.111.4.229]:41351 "EHLO new3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241964AbhHETEN (ORCPT ); Thu, 5 Aug 2021 15:04:13 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.nyi.internal (Postfix) with ESMTP id 13EB55810C2; Thu, 5 Aug 2021 15:03:58 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 05 Aug 2021 15:03:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sent.com; h=from :to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; s=fm1; bh=RA0AsrTogxcWF pocSItHzob/KJFuxJUXcWJazBJO2Zo=; b=JyLRlPZXhY/YsYb3uK/2AGnlh+FwS Y1jht/x4sJjVPeILSUeUeMTghzUcayGRaVZDgpnxsOvRpmAiSuh3hqO8rhJNGCXw XnpfLgRSo6UFfeycRGYXWRZy13eZIcp8dJybYtR0iNuDORKLebq8bRn38Sh23LGM 9TwR0bd5rzaKbcLN4pP/acBA7CG6bqvpMqFUDZaRJo6Xrg9R/dWHNT1sa0y4vbEQ 3/4Zjb6ZIKiU3xOzNM83mwHjGalGkm5ddo+Pvk2NDovx7NjuJuuYw3f5S8ZhqB27 iNEwOY5U5LtM4uWjDLJW7OHtfUDtsKQJsUWBI9rUkfboAfYXrEAB/HADQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:reply-to:subject :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=RA0AsrTogxcWFpocSItHzob/KJFuxJUXcWJazBJO2Zo=; b=B5FDGE67 RnzMlNvwvWbIZsWz0Btgst5jK279cYY4OL2hhNQZwrTnFWtR5/vIpHlSR0rysul5 yRSOrqad7K1OmCGgnW32K8uy9JeZ5Gw7P4j0I/kqsaAv5Moah3NqkC1Kmyuh/KLT C8pSGOv5+aexvq5jIsSMwrINoDQY0K03XvHNNG3lyt3np+20i1m52n0WM1fYv0Q+ BW/c4MSNPHs7jk/PLEz0UbcZ10a9uUgXBuncMSEaOW9dwjsIhFBYcjOcyQ9yv9Lm HQcnL3pNDdTZh4LSgC6sPeYU12SiZa4ZkyTkafWTNyh/JJt2hzsohF8wGWYp5axp GvdFUIpaS39cvA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrieelgddufedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfrhgggfestdhqredtredttdenucfhrhhomhepkghiucgj rghnuceoiihirdihrghnsehsvghnthdrtghomheqnecuggftrfgrthhtvghrnhepieejue dvueduuefhgefhheeiuedvtedvuefgieegveetueeiueehtdegudehfeelnecuvehluhhs thgvrhfuihiivgepvdenucfrrghrrghmpehmrghilhhfrhhomhepiihirdihrghnsehsvg hnthdrtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 5 Aug 2021 15:03:57 -0400 (EDT) From: Zi Yan To: David Hildenbrand , linux-mm@kvack.org Cc: Matthew Wilcox , Vlastimil Babka , "Kirill A . Shutemov" , Mike Kravetz , Michal Hocko , John Hubbard , linux-kernel@vger.kernel.org, Zi Yan , Jonathan Corbet , "Paul E. McKenney" , Randy Dunlap , Thomas Gleixner , linux-doc@vger.kernel.org Subject: [RFC PATCH 15/15] mm: make MAX_ORDER a kernel boot time parameter. Date: Thu, 5 Aug 2021 15:02:53 -0400 Message-Id: <20210805190253.2795604-16-zi.yan@sent.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210805190253.2795604-1-zi.yan@sent.com> References: <20210805190253.2795604-1-zi.yan@sent.com> Reply-To: Zi Yan MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zi Yan With the new buddy_alloc_max_order, users can specify larger MAX_ORDER than set in CONFIG_ARCH_MAX_ORDER or CONFIG_SET_MAX_ORDER. It can be set any value >=3D CONFIG_ARCH_MAX_ORDER or CONFIG_SET_MAX_ORDER, but < 256 (limited by vmscan scan_control and per-cpu free page list). Signed-off-by: Zi Yan Cc: Jonathan Corbet Cc: "Paul E. McKenney" Cc: Randy Dunlap Cc: Thomas Gleixner Cc: Vlastimil Babka Cc: linux-doc@vger.kernel.org Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org --- .../admin-guide/kernel-parameters.txt | 5 +++ include/linux/mmzone.h | 23 +++++++++++-- mm/page_alloc.c | 34 ++++++++++++++++++- mm/vmscan.c | 1 - 4 files changed, 58 insertions(+), 5 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentatio= n/admin-guide/kernel-parameters.txt index 5c59a5fb17c3..a37141aa28ae 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -465,6 +465,11 @@ bttv.pll=3D See Documentation/admin-guide/media/bttv.rst bttv.tuner=3D =20 + buddy_alloc_max_order=3D [KNL] This parameter adjusts the size of largest + pages that can be allocated from kernel buddy allocator. The largest + page size is 2^buddy_alloc_max_order * PAGE_SIZE. + Format: integer + bulk_remove=3Doff [PPC] This parameter disables the use of the pSeries firmware feature for flushing multiple hpte entries at a time. diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 379dada82d4b..9ca4d59722a1 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -26,14 +26,25 @@ /* Free memory management - zoned buddy allocator. */ #ifndef CONFIG_ARCH_FORCE_MAX_ORDER #ifdef CONFIG_SET_MAX_ORDER -#define MAX_ORDER CONFIG_SET_MAX_ORDER +/* Defined in mm/page_alloc.c */ +extern int buddy_alloc_max_order; + +#define MAX_ORDER buddy_alloc_max_order #define MIN_MAX_ORDER CONFIG_SET_MAX_ORDER #else #define MAX_ORDER 11 #define MIN_MAX_ORDER MAX_ORDER #endif /* CONFIG_SET_MAX_ORDER */ #else + +#ifdef CONFIG_SPARSEMEM_VMEMMAP +/* Defined in mm/page_alloc.c */ +extern int buddy_alloc_max_order; + +#define MAX_ORDER buddy_alloc_max_order +#else #define MAX_ORDER CONFIG_ARCH_FORCE_MAX_ORDER +#endif /* CONFIG_SPARSEMEM_VMEMMAP */ #define MIN_MAX_ORDER CONFIG_ARCH_FORCE_MAX_ORDER #endif /* CONFIG_ARCH_FORCE_MAX_ORDER */ #define MAX_ORDER_NR_PAGES (1 << (MAX_ORDER - 1)) @@ -1557,8 +1568,14 @@ void sparse_init(void); * pfn_valid_within() should be used in this case; we optimise this away * when we have no holes within a MAX_ORDER_NR_PAGES block. */ -#if ((MAX_ORDER - 1 + PAGE_SHIFT) > SECTION_SIZE_BITS) -#define pfn_valid_within(pfn) pfn_valid(pfn) +#if defined(CONFIG_ARCH_FORCE_MAX_ORDER) || defined(CONFIG_SET_MAX_ORDER) +static inline bool pfn_valid_within(unsigned long pfn) +{ + if ((MAX_ORDER - 1 + PAGE_SHIFT) > SECTION_SIZE_BITS) + return pfn_valid(pfn); + + return 1; +} #else #define pfn_valid_within(pfn) (1) #endif diff --git a/mm/page_alloc.c b/mm/page_alloc.c index bfa6962f7615..ea6f8d85a4cf 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1487,7 +1487,6 @@ static void free_pcppages_bulk(struct zone *zone, int= count, batch_free =3D count; =20 order =3D pindex_to_order(pindex); - BUILD_BUG_ON(MAX_ORDER >=3D (1< MIN_MAX_ORDER && max_order < S8_MAX && + max_order < (1< S8_MAX); BUILD_BUG_ON(DEF_PRIORITY > S8_MAX); BUILD_BUG_ON(MAX_NR_ZONES > S8_MAX); =20 --=20 2.30.2