Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp880153pxt; Thu, 5 Aug 2021 14:09:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwosfamDLfS6xgd3SFq3qEcfU0md9moznwJYDXrhi9p3370IPDldBWM1F0wh73qKk/dHzm X-Received: by 2002:a92:7b10:: with SMTP id w16mr70981ilc.241.1628197778575; Thu, 05 Aug 2021 14:09:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628197778; cv=none; d=google.com; s=arc-20160816; b=vnRzFp2mMfdpobyoN9iKdMGYGh+yk95wEJ5nVYdhU1OcrEW6H5wsJnvTtvXEWBcLBs uLo4q6tYLa9Rbaa/JIdEjF42L+f0rbr7yaNlaBqYDcK6fQqS09UJUwuDMEM0dODUcrZz LloCLt4njnKE5PvZt10ty686hJ7OPR5EwJlJJfWSN3voDOUnTHjKRWrZbj2YvcUqA8VC qTYef+QKys7sQ432TmqmA38c8e8eBbFKkWT0HJDE5I0iOcxR064x95OuNrp629Ip7Ied c/1yFoRxF2Gwb7nOWaxKZ3hQHznZ0gfucfq+zNLM7ObjCotIK2GIplGW0qJK9osIymZR 4dlg== 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=Wc0GbL6NTbU4PARfHU3RQzdhaDIhKKBfKRDAFccFqtg=; b=nopFh6F4sSrhlS5c/iT9V+4Gx2TnY3XMCZqokxsHoNgFEpilXh/AYwiccTeCiqrzUH cIxknw6054Xl9blLwwdo3BZsHzBV9P2ld4GxSWgGDLHiv4U2fYJ9nQtDn7qXnN7s7+Fw 7VCsnL2xpg7fZGm/fTGdagI5sEnv4+x6WJceJnUCfc2U+a5yRSpMwVLE8qa9v6d3SlZH Ywj2+CxGbXSgQpd+EsDLYkKe2h5t3BXMk8Ip3d1erIIBlKjYQTfUcJRDnkdc6tGm65Bm Pt8i+FWg2yPR24rXnOJ0HentVnOA00RUmwaKnCHqdPItcJ0LIE52EmkzrTjx3ii5e8HW Q0Dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sent.com header.s=fm1 header.b=Ryn5X3bX; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=HjLaHum4; 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 n125si6789967iod.85.2021.08.05.14.09.25; Thu, 05 Aug 2021 14:09:38 -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=Ryn5X3bX; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=HjLaHum4; 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 S242209AbhHETGR (ORCPT + 99 others); Thu, 5 Aug 2021 15:06:17 -0400 Received: from new3-smtp.messagingengine.com ([66.111.4.229]:40991 "EHLO new3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242142AbhHETEM (ORCPT ); Thu, 5 Aug 2021 15:04:12 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id 39C435810C0; Thu, 5 Aug 2021 15:03:57 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 05 Aug 2021 15:03:57 -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=Wc0GbL6NTbU4P ARfHU3RQzdhaDIhKKBfKRDAFccFqtg=; b=Ryn5X3bXridco5AVtFQnjx1sBJgN+ i0WN0ZlrHQY24/6dWbGmZlBP5f+R1hCAooamyTV2td/YJdtB0D48TdX+CrCcrv5J fBqNkSldXCisN2TyzlAn/jd3xfwgS3DvtcCcwTzPdQiK6Pnu5zGPNoll5+WfY1sX cizJiEKtN5BskiTXIINYptCOBvh/B4WhrebIB0wDIBDjdXXWZyaiuyc5DX6GCOq1 tFE4Eio+7r5rPV3O8xb6W5xGhw6qNzF1AFQ4a7qwUg9M5QSRitrJN1Bl1mhrdwHx rUvgf8VJr6qAq5YKfY8A0eE8IWmECcqT84UOalmBbrO4OK6/N/hRe0IiA== 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=Wc0GbL6NTbU4PARfHU3RQzdhaDIhKKBfKRDAFccFqtg=; b=HjLaHum4 z+hmthhaW4rvC0GeGl9U5UYBcmA90+RQv9sCg6rMXHd1ZlYPVuSxt71+e7RNUKD0 qIeGa+HDZkRYHcB/Fhxjh7knYdxN0hJCHRT91drZUP6AAxQscn17ZiVm5Xn/K6E9 aJpA4zMfDIBgormznM23Try4ZqJ5YOTHNR8HHnVlE3pg2Pf2KSY/S2aLjG+xykHb Kou1tXaeQ2ZzrvuQIROGJesn60DmnuEScMZFaQFgP/ySyCowFAexIsgIjT9l+GSg 2URe3BzG1ig9qat9r7NF7QrS3MeLNKUrt4p7bmwtC93DTTlVahtGcN+yKL32RHrD 24g7hHJ33EIP4A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrieelgdduvdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfrhgggfestdhqredtredttdenucfhrhhomhepkghiucgj rghnuceoiihirdihrghnsehsvghnthdrtghomheqnecuggftrfgrthhtvghrnhepieejue dvueduuefhgefhheeiuedvtedvuefgieegveetueeiueehtdegudehfeelnecuvehluhhs thgvrhfuihiivgepvdenucfrrghrrghmpehmrghilhhfrhhomhepiihirdihrghnsehsvg hnthdrtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 5 Aug 2021 15:03:56 -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 , Marc Zyngier , Catalin Marinas , Christoph Lameter , Quentin Perret , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu Subject: [RFC PATCH 14/15] mm: introduce MIN_MAX_ORDER to replace MAX_ORDER as compile time constant. Date: Thu, 5 Aug 2021 15:02:52 -0400 Message-Id: <20210805190253.2795604-15-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 For other MAX_ORDER uses (described below), there is no need or too much hassle to convert certain static array to dynamic ones. Add MIN_MAX_ORDER to serve as compile time constant in place of MAX_ORDER. ARM64 hypervisor maintains its own free page list and does not import any core kernel symbols, so soon-to-be runtime variable MAX_ORDER is not accessible in ARM64 hypervisor code. Also there is no need to allocating very large pages. In SLAB/SLOB/SLUB, 2-D array kmalloc_caches uses MAX_ORDER in its second dimension. It is too much hassle to allocate memory for kmalloc_caches before any proper memory allocator is set up. Signed-off-by: Zi Yan Cc: Marc Zyngier Cc: Catalin Marinas Cc: Christoph Lameter Cc: Vlastimil Babka Cc: Quentin Perret Cc: linux-arm-kernel@lists.infradead.org Cc: kvmarm@lists.cs.columbia.edu Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org --- arch/arm64/kvm/hyp/include/nvhe/gfp.h | 2 +- arch/arm64/kvm/hyp/nvhe/page_alloc.c | 3 ++- include/linux/mmzone.h | 3 +++ include/linux/slab.h | 8 ++++---- mm/slab.c | 2 +- mm/slub.c | 7 ++++--- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/arch/arm64/kvm/hyp/include/nvhe/gfp.h b/arch/arm64/kvm/hyp/inc= lude/nvhe/gfp.h index fb0f523d1492..c774b4a98336 100644 --- a/arch/arm64/kvm/hyp/include/nvhe/gfp.h +++ b/arch/arm64/kvm/hyp/include/nvhe/gfp.h @@ -16,7 +16,7 @@ struct hyp_pool { * API at EL2. */ hyp_spinlock_t lock; - struct list_head free_area[MAX_ORDER]; + struct list_head free_area[MIN_MAX_ORDER]; phys_addr_t range_start; phys_addr_t range_end; unsigned short max_order; diff --git a/arch/arm64/kvm/hyp/nvhe/page_alloc.c b/arch/arm64/kvm/hyp/nvhe= /page_alloc.c index 41fc25bdfb34..a1cc1b648de0 100644 --- a/arch/arm64/kvm/hyp/nvhe/page_alloc.c +++ b/arch/arm64/kvm/hyp/nvhe/page_alloc.c @@ -226,7 +226,8 @@ int hyp_pool_init(struct hyp_pool *pool, u64 pfn, unsig= ned int nr_pages, int i; =20 hyp_spin_lock_init(&pool->lock); - pool->max_order =3D min(MAX_ORDER, get_order(nr_pages << PAGE_SHIFT)); + + pool->max_order =3D min(MIN_MAX_ORDER, get_order(nr_pages << PAGE_SHIFT)); for (i =3D 0; i < pool->max_order; i++) INIT_LIST_HEAD(&pool->free_area[i]); pool->range_start =3D phys; diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 09aafc05aef4..379dada82d4b 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -27,11 +27,14 @@ #ifndef CONFIG_ARCH_FORCE_MAX_ORDER #ifdef CONFIG_SET_MAX_ORDER #define MAX_ORDER CONFIG_SET_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 #define MAX_ORDER CONFIG_ARCH_FORCE_MAX_ORDER +#define MIN_MAX_ORDER CONFIG_ARCH_FORCE_MAX_ORDER #endif /* CONFIG_ARCH_FORCE_MAX_ORDER */ #define MAX_ORDER_NR_PAGES (1 << (MAX_ORDER - 1)) =20 diff --git a/include/linux/slab.h b/include/linux/slab.h index 2c0d80cca6b8..d8747c158db6 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -244,8 +244,8 @@ static inline void __check_heap_object(const void *ptr,= unsigned long n, * to do various tricks to work around compiler limitations in order to * ensure proper constant folding. */ -#define KMALLOC_SHIFT_HIGH ((MAX_ORDER + PAGE_SHIFT - 1) <=3D 25 ? \ - (MAX_ORDER + PAGE_SHIFT - 1) : 25) +#define KMALLOC_SHIFT_HIGH ((MIN_MAX_ORDER + PAGE_SHIFT - 1) <=3D 25 ? \ + (MIN_MAX_ORDER + PAGE_SHIFT - 1) : 25) #define KMALLOC_SHIFT_MAX KMALLOC_SHIFT_HIGH #ifndef KMALLOC_SHIFT_LOW #define KMALLOC_SHIFT_LOW 5 @@ -258,7 +258,7 @@ static inline void __check_heap_object(const void *ptr,= unsigned long n, * (PAGE_SIZE*2). Larger requests are passed to the page allocator. */ #define KMALLOC_SHIFT_HIGH (PAGE_SHIFT + 1) -#define KMALLOC_SHIFT_MAX (MAX_ORDER + PAGE_SHIFT - 1) +#define KMALLOC_SHIFT_MAX (MIN_MAX_ORDER + PAGE_SHIFT - 1) #ifndef KMALLOC_SHIFT_LOW #define KMALLOC_SHIFT_LOW 3 #endif @@ -271,7 +271,7 @@ static inline void __check_heap_object(const void *ptr,= unsigned long n, * be allocated from the same page. */ #define KMALLOC_SHIFT_HIGH PAGE_SHIFT -#define KMALLOC_SHIFT_MAX (MAX_ORDER + PAGE_SHIFT - 1) +#define KMALLOC_SHIFT_MAX (MIN_MAX_ORDER + PAGE_SHIFT - 1) #ifndef KMALLOC_SHIFT_LOW #define KMALLOC_SHIFT_LOW 3 #endif diff --git a/mm/slab.c b/mm/slab.c index d0f725637663..0041de8ec0e9 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -466,7 +466,7 @@ static int __init slab_max_order_setup(char *str) { get_option(&str, &slab_max_order); slab_max_order =3D slab_max_order < 0 ? 0 : - min(slab_max_order, MAX_ORDER - 1); + min(slab_max_order, MIN_MAX_ORDER - 1); slab_max_order_set =3D true; =20 return 1; diff --git a/mm/slub.c b/mm/slub.c index b6c5205252eb..228e4a77c678 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -3564,8 +3564,9 @@ static inline int calculate_order(unsigned int size) /* * Doh this slab cannot be placed using slub_max_order. */ - order =3D slab_order(size, 1, MAX_ORDER, 1); - if (order < MAX_ORDER) + + order =3D slab_order(size, 1, MIN_MAX_ORDER, 1); + if (order < MIN_MAX_ORDER) return order; return -ENOSYS; } @@ -4079,7 +4080,7 @@ __setup("slub_min_order=3D", setup_slub_min_order); static int __init setup_slub_max_order(char *str) { get_option(&str, (int *)&slub_max_order); - slub_max_order =3D min(slub_max_order, (unsigned int)MAX_ORDER - 1); + slub_max_order =3D min(slub_max_order, (unsigned int)MIN_MAX_ORDER - 1); =20 return 1; } --=20 2.30.2