From patchwork Thu Aug 5 19:02:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 12421857 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7DFAC432BE for ; Thu, 5 Aug 2021 19:03:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7F6D461168 for ; Thu, 5 Aug 2021 19:03:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7F6D461168 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=sent.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 997A96B0071; Thu, 5 Aug 2021 15:03:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 948EC6B0072; Thu, 5 Aug 2021 15:03:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 725D28D0001; Thu, 5 Aug 2021 15:03:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0251.hostedemail.com [216.40.44.251]) by kanga.kvack.org (Postfix) with ESMTP id 582746B0071 for ; Thu, 5 Aug 2021 15:03:44 -0400 (EDT) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 14698269B2 for ; Thu, 5 Aug 2021 19:03:44 +0000 (UTC) X-FDA: 78441951168.31.FE3843F Received: from new3-smtp.messagingengine.com (new3-smtp.messagingengine.com [66.111.4.229]) by imf18.hostedemail.com (Postfix) with ESMTP id ADDDF40018AC for ; Thu, 5 Aug 2021 19:03:43 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.nyi.internal (Postfix) with ESMTP id 462405810AD; Thu, 5 Aug 2021 15:03:43 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 05 Aug 2021 15:03:43 -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=wTdo21iBPQX8U kFAjwkvjQ0EK84I1J4pRSwJ7mQOzr8=; b=YuF+9bhrhzirasmvngw+F+N/MPIwF u3mw+9QZ1B4MiFo3OT8wBrKfvWpiqjOKrDLnYLRxy+bHMBEZ+pA2ALHoWrhprqZX yhk/PPeXrUOjEwEmNIhtSPu+R1D3PDsnStNBKdpmJSdod2eiiFg+NnBoGD2NRTG5 wGJl1PhZaiju7Kcao4yHJqxarP/HSuoRNFvSJuQlJ8zR3AmtiQ+fmCbYF8VMEy3C kHE5Twb3irrjoPgjKH71t0Q8lDNdyaDcEUiJq+q4seGpEexo85vFsXIrFpcIttoK Jv+BaqPNRylSofoIUJhOPlxaabVUNbg/af6v7hC3LGdPecjuVU04QMalQ== 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=wTdo21iBPQX8UkFAjwkvjQ0EK84I1J4pRSwJ7mQOzr8=; b=KLYqgml+ nv0rwA7/vkJ0ZDg8612bfnM3HTTAHpyqw+RwC+eT+LioA3XmQ7ELdy4tCxBUY64g yxqCmMwNIpOl/Wu1LOGUD1b/fqPpaD941aXu8oliOX1pk3swfd9M0xgelr6jg9x0 vCHag1XB3FygIwVXU4YDlgQOVPDFrIF3Pw2fTFqCEnCTTIBsw26wwK/GlstkkiFB fmcREPjqjdlRO0a9RfiClljJcLB6dh5+uloW6HfZztn/Gjtsh7ddtScZj1NLXZzm OzAn9E0Km8k1az9oXj8UBpbaxoa3KPNn5COz4VfeUQm8nDG7JopsK126y+NcehBK xj7+ZjE21KVjNA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrieelgdduvdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfrhgggfestdhqredtredttdenucfhrhhomhepkghiucgj rghnuceoiihirdihrghnsehsvghnthdrtghomheqnecuggftrfgrthhtvghrnhepieejue dvueduuefhgefhheeiuedvtedvuefgieegveetueeiueehtdegudehfeelnecuvehluhhs thgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepiihirdihrghnsehsvg hnthdrtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 5 Aug 2021 15:03:42 -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 , Andy Lutomirski , x86@kernel.org Subject: [RFC PATCH 01/15] arch: x86: remove MAX_ORDER exceeding SECTION_SIZE check for 32bit vdso. Date: Thu, 5 Aug 2021 15:02:39 -0400 Message-Id: <20210805190253.2795604-2-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 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: ADDDF40018AC Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=YuF+9bhr; dkim=pass header.d=messagingengine.com header.s=fm3 header.b=KLYqgml+; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf18.hostedemail.com: domain of zi.yan@sent.com designates 66.111.4.229 as permitted sender) smtp.mailfrom=zi.yan@sent.com X-Stat-Signature: jbzt41xx1jy5jhwpomr6x7kkiftuzdw4 X-HE-Tag: 1628190223-167333 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Zi Yan For x86_64, 32bit vdso is compiled for compatibility reason and 32bit SECTION_SIZE_BITS value is used during compilation. It causes compilation time error when MAX_ORDER is increased in the 64bit environment even if it is OK for 64bit SECTION_SIZE_BITS. Remove the check during 32bit vdso compilation. The check still exists during the compilation of other kernel components. Signed-off-by: Zi Yan Cc: Andy Lutomirski Cc: x86@kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org --- arch/x86/entry/vdso/Makefile | 1 + include/linux/mmzone.h | 3 +++ 2 files changed, 4 insertions(+) diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile index 05c4abc2fdfd..cad339136ed1 100644 --- a/arch/x86/entry/vdso/Makefile +++ b/arch/x86/entry/vdso/Makefile @@ -156,6 +156,7 @@ KBUILD_CFLAGS_32 += -fno-stack-protector KBUILD_CFLAGS_32 += $(call cc-option, -foptimize-sibling-calls) KBUILD_CFLAGS_32 += -fno-omit-frame-pointer KBUILD_CFLAGS_32 += -DDISABLE_BRANCH_PROFILING +KBUILD_CFLAGS_32 += -DNO_MAX_ORDER_CHECK ifdef CONFIG_RETPOLINE ifneq ($(RETPOLINE_VDSO_CFLAGS),) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 6a1d79d84675..c1d914a72489 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -1245,9 +1245,12 @@ static inline struct zoneref *first_zones_zonelist(struct zonelist *zonelist, #define SECTION_BLOCKFLAGS_BITS \ ((1UL << (PFN_SECTION_SHIFT - pageblock_order)) * NR_PAGEBLOCK_BITS) +/* NO_MAX_ORDER_CHECK when compiling x64 32bit VDSO for 64bit system */ +#ifndef NO_MAX_ORDER_CHECK #if (MAX_ORDER - 1 + PAGE_SHIFT) > SECTION_SIZE_BITS #error Allocator MAX_ORDER exceeds SECTION_SIZE #endif +#endif /* NO_MAX_ORDER_CHECK */ static inline unsigned long pfn_to_section_nr(unsigned long pfn) { From patchwork Thu Aug 5 19:02:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 12421859 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12D6EC432BE for ; Thu, 5 Aug 2021 19:03:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 97FE361040 for ; Thu, 5 Aug 2021 19:03:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 97FE361040 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=sent.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 3CE056B0072; Thu, 5 Aug 2021 15:03:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 308296B0073; Thu, 5 Aug 2021 15:03:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1806B8D0001; Thu, 5 Aug 2021 15:03:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0049.hostedemail.com [216.40.44.49]) by kanga.kvack.org (Postfix) with ESMTP id 000286B0072 for ; Thu, 5 Aug 2021 15:03:47 -0400 (EDT) Received: from smtpin38.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 9F4591802EFFD for ; Thu, 5 Aug 2021 19:03:47 +0000 (UTC) X-FDA: 78441951294.38.1338DD7 Received: from new3-smtp.messagingengine.com (new3-smtp.messagingengine.com [66.111.4.229]) by imf03.hostedemail.com (Postfix) with ESMTP id 35B8E30002D0 for ; Thu, 5 Aug 2021 19:03:47 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.nyi.internal (Postfix) with ESMTP id D3BAC5810B2; Thu, 5 Aug 2021 15:03:46 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 05 Aug 2021 15:03:46 -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=zNZUoCQxGeezK ynu9SXf7RK1yXXzs9UrsyBqx4F2Edk=; b=GtL12AmdeZNPHF6SApyO9wGXfEnlg wNhltluDSQzlmgtvgRRPULzc7FzojizjIvGqjq9l0WTHC8gjjwH0OPxXbGnrnUPm hDSMlGCd6ITo+xRpprv6J4fpF05Dz4iPpq0Q6YTMZ43f9noXHFhoA2ryB+1rwXso 0xje1RyI2eOjiHlPqHk7sE8QpdSibrVzoNaw67a4doWQGdf2ABU4s86r8dg5LwQ8 me86nda6dU5U9VRMEKgR+dFIaxddHn/vkrx5nqQt5s5YvdWVYAaeSBtnQyqaokgp 5PjIXA1zjsCvdR3wQlwKJSjLLc4/gwwwSlV50rFq1ZqkR4cvvw3fC8rqQ== 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=zNZUoCQxGeezKynu9SXf7RK1yXXzs9UrsyBqx4F2Edk=; b=lkUCbjUl PEdQRBtf816Ypmmn3nhNv7Sizw4AzYBiGnl0V9d227YL3157XWzt7AL5QCqGN7cL yqPnZEkLdbcz85N8RdldMN71v2KmRxsPUl7vsMVtamEYXDOPG3U6BvE+pr7+Yru4 /FVQdwNbo4Ycp97k//hOBnZ2yca1DgKkAyOxemQjJQPVSeOqcrlkx7j0BGJaFUyS CWPBdaRML51ZDoxDH0rHuU7w62PfIe1ROCUo1cvMbBryWkG7nPr36V8nKMhl2XkD x4NfRrv0ZBtrGiGrKGOyx1ZKcrBy0Yhjm8JPiSOmYop6IZ1wOMqP+pqW7m9ryknq SMva7CVAvywnQA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrieelgdduvdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfrhgggfestdhqredtredttdenucfhrhhomhepkghiucgj rghnuceoiihirdihrghnsehsvghnthdrtghomheqnecuggftrfgrthhtvghrnhepieejue dvueduuefhgefhheeiuedvtedvuefgieegveetueeiueehtdegudehfeelnecuvehluhhs thgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepiihirdihrghnsehsvg hnthdrtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 5 Aug 2021 15:03:43 -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 , Vineet Gupta , Shawn Guo , Catalin Marinas , Guo Ren , Geert Uytterhoeven , Thomas Bogendoerfer , Ley Foon Tan , Michael Ellerman , Yoshinori Sato , "David S. Miller" , Chris Zankel , linux-snps-arc@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-oxnas@groups.io, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-xtensa@linux-xtensa.org Subject: [RFC PATCH 02/15] arch: mm: rename FORCE_MAX_ZONEORDER to ARCH_FORCE_MAX_ORDER Date: Thu, 5 Aug 2021 15:02:40 -0400 Message-Id: <20210805190253.2795604-3-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 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 35B8E30002D0 Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=GtL12Amd; dkim=pass header.d=messagingengine.com header.s=fm3 header.b=lkUCbjUl; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf03.hostedemail.com: domain of zi.yan@sent.com designates 66.111.4.229 as permitted sender) smtp.mailfrom=zi.yan@sent.com X-Stat-Signature: o3d6so8rp71azqfib6wm55tr7z77tsiu X-HE-Tag: 1628190227-225417 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Zi Yan This Kconfig option is used by individual arch to set its desired MAX_ORDER. Rename it to reflect its actual use. Signed-off-by: Zi Yan Cc: Vineet Gupta Cc: Shawn Guo Cc: Catalin Marinas Cc: Guo Ren Cc: Geert Uytterhoeven Cc: Thomas Bogendoerfer Cc: Ley Foon Tan Cc: Michael Ellerman Cc: Yoshinori Sato Cc: "David S. Miller" Cc: Chris Zankel Cc: linux-snps-arc@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-oxnas@groups.io Cc: linux-csky@vger.kernel.org Cc: linux-ia64@vger.kernel.org Cc: linux-m68k@lists.linux-m68k.org Cc: linux-mips@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org Cc: linux-sh@vger.kernel.org Cc: sparclinux@vger.kernel.org Cc: linux-xtensa@linux-xtensa.org Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org --- arch/arc/Kconfig | 2 +- arch/arm/Kconfig | 2 +- arch/arm/configs/imx_v6_v7_defconfig | 2 +- arch/arm/configs/milbeaut_m10v_defconfig | 2 +- arch/arm/configs/oxnas_v6_defconfig | 2 +- arch/arm/configs/sama7_defconfig | 2 +- arch/arm64/Kconfig | 2 +- arch/csky/Kconfig | 2 +- arch/ia64/Kconfig | 2 +- arch/ia64/include/asm/sparsemem.h | 6 +++--- arch/m68k/Kconfig.cpu | 2 +- arch/mips/Kconfig | 2 +- arch/nios2/Kconfig | 2 +- arch/powerpc/Kconfig | 2 +- arch/powerpc/configs/85xx/ge_imp3a_defconfig | 2 +- arch/powerpc/configs/fsl-emb-nonhw.config | 2 +- arch/sh/configs/ecovec24_defconfig | 2 +- arch/sh/mm/Kconfig | 2 +- arch/sparc/Kconfig | 2 +- arch/xtensa/Kconfig | 2 +- include/linux/mmzone.h | 4 ++-- 21 files changed, 24 insertions(+), 24 deletions(-) diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index b5bf68e74732..923ea4c31e59 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -583,7 +583,7 @@ config ARC_BUILTIN_DTB_NAME endmenu # "ARC Architecture Configuration" -config FORCE_MAX_ZONEORDER +config ARCH_FORCE_MAX_ORDER int "Maximum zone order" default "12" if ARC_HUGEPAGE_16M default "11" diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 2fb7012c3246..286854318fe5 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1523,7 +1523,7 @@ config ARM_MODULE_PLTS Disabling this is usually safe for small single-platform configurations. If unsure, say y. -config FORCE_MAX_ZONEORDER +config ARCH_FORCE_MAX_ORDER int "Maximum zone order" default "12" if SOC_AM33XX default "9" if SA1111 diff --git a/arch/arm/configs/imx_v6_v7_defconfig b/arch/arm/configs/imx_v6_v7_defconfig index 079fcd8d1d11..802310d3ebf5 100644 --- a/arch/arm/configs/imx_v6_v7_defconfig +++ b/arch/arm/configs/imx_v6_v7_defconfig @@ -34,7 +34,7 @@ CONFIG_PCI_IMX6=y CONFIG_SMP=y CONFIG_ARM_PSCI=y CONFIG_HIGHMEM=y -CONFIG_FORCE_MAX_ZONEORDER=14 +CONFIG_ARCH_FORCE_MAX_ORDER=14 CONFIG_CMDLINE="noinitrd console=ttymxc0,115200" CONFIG_KEXEC=y CONFIG_CPU_FREQ=y diff --git a/arch/arm/configs/milbeaut_m10v_defconfig b/arch/arm/configs/milbeaut_m10v_defconfig index 7c07f9893a0f..06967243f74d 100644 --- a/arch/arm/configs/milbeaut_m10v_defconfig +++ b/arch/arm/configs/milbeaut_m10v_defconfig @@ -26,7 +26,7 @@ CONFIG_THUMB2_KERNEL=y # CONFIG_THUMB2_AVOID_R_ARM_THM_JUMP11 is not set # CONFIG_ARM_PATCH_IDIV is not set CONFIG_HIGHMEM=y -CONFIG_FORCE_MAX_ZONEORDER=12 +CONFIG_ARCH_FORCE_MAX_ORDER=12 CONFIG_SECCOMP=y CONFIG_KEXEC=y CONFIG_EFI=y diff --git a/arch/arm/configs/oxnas_v6_defconfig b/arch/arm/configs/oxnas_v6_defconfig index cae0db6b4eaf..df8462272446 100644 --- a/arch/arm/configs/oxnas_v6_defconfig +++ b/arch/arm/configs/oxnas_v6_defconfig @@ -17,7 +17,7 @@ CONFIG_MACH_OX820=y CONFIG_SMP=y CONFIG_NR_CPUS=16 CONFIG_CMA=y -CONFIG_FORCE_MAX_ZONEORDER=12 +CONFIG_ARCH_FORCE_MAX_ORDER=12 CONFIG_SECCOMP=y CONFIG_ARM_APPENDED_DTB=y CONFIG_ARM_ATAG_DTB_COMPAT=y diff --git a/arch/arm/configs/sama7_defconfig b/arch/arm/configs/sama7_defconfig index 938aae4bd80b..f8683b87cb27 100644 --- a/arch/arm/configs/sama7_defconfig +++ b/arch/arm/configs/sama7_defconfig @@ -22,7 +22,7 @@ CONFIG_ATMEL_CLOCKSOURCE_TCB=y # CONFIG_CACHE_L2X0 is not set # CONFIG_ARM_PATCH_IDIV is not set # CONFIG_CPU_SW_DOMAIN_PAN is not set -CONFIG_FORCE_MAX_ZONEORDER=15 +CONFIG_ARCH_FORCE_MAX_ORDER=15 CONFIG_UACCESS_WITH_MEMCPY=y # CONFIG_ATAGS is not set CONFIG_CMDLINE="console=ttyS0,115200 earlyprintk ignore_loglevel" diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index b5b13a932561..972d81f6bb2c 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -1152,7 +1152,7 @@ config XEN help Say Y if you want to run Linux in a Virtual Machine on Xen on ARM64. -config FORCE_MAX_ZONEORDER +config ARCH_FORCE_MAX_ORDER int default "14" if ARM64_64K_PAGES default "12" if ARM64_16K_PAGES diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig index 2716f6395ba7..0fd2333226b7 100644 --- a/arch/csky/Kconfig +++ b/arch/csky/Kconfig @@ -307,7 +307,7 @@ config HIGHMEM select KMAP_LOCAL default y -config FORCE_MAX_ZONEORDER +config ARCH_FORCE_MAX_ORDER int "Maximum zone order" default "11" diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index 4993c7ac7ff6..d1bd010ee7a5 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig @@ -200,7 +200,7 @@ config IA64_CYCLONE Say Y here to enable support for IBM EXA Cyclone time source. If you're unsure, answer N. -config FORCE_MAX_ZONEORDER +config ARCH_FORCE_MAX_ORDER int "MAX_ORDER (11 - 17)" if !HUGETLB_PAGE range 11 17 if !HUGETLB_PAGE default "17" if HUGETLB_PAGE diff --git a/arch/ia64/include/asm/sparsemem.h b/arch/ia64/include/asm/sparsemem.h index 42ed5248fae9..84e8ce387b69 100644 --- a/arch/ia64/include/asm/sparsemem.h +++ b/arch/ia64/include/asm/sparsemem.h @@ -11,10 +11,10 @@ #define SECTION_SIZE_BITS (30) #define MAX_PHYSMEM_BITS (50) -#ifdef CONFIG_FORCE_MAX_ZONEORDER -#if ((CONFIG_FORCE_MAX_ZONEORDER - 1 + PAGE_SHIFT) > SECTION_SIZE_BITS) +#ifdef CONFIG_ARCH_FORCE_MAX_ORDER +#if ((CONFIG_ARCH_FORCE_MAX_ORDER - 1 + PAGE_SHIFT) > SECTION_SIZE_BITS) #undef SECTION_SIZE_BITS -#define SECTION_SIZE_BITS (CONFIG_FORCE_MAX_ZONEORDER - 1 + PAGE_SHIFT) +#define SECTION_SIZE_BITS (CONFIG_ARCH_FORCE_MAX_ORDER - 1 + PAGE_SHIFT) #endif #endif diff --git a/arch/m68k/Kconfig.cpu b/arch/m68k/Kconfig.cpu index 29e946394fdb..c39157f3dd87 100644 --- a/arch/m68k/Kconfig.cpu +++ b/arch/m68k/Kconfig.cpu @@ -408,7 +408,7 @@ config SINGLE_MEMORY_CHUNK order" to save memory that could be wasted for unused memory map. Say N if not sure. -config FORCE_MAX_ZONEORDER +config ARCH_FORCE_MAX_ORDER int "Maximum zone order" if ADVANCED depends on !SINGLE_MEMORY_CHUNK default "11" diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 6dfb27d531dd..0998f671ed7e 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -2284,7 +2284,7 @@ config PAGE_SIZE_64KB endchoice -config FORCE_MAX_ZONEORDER +config ARCH_FORCE_MAX_ORDER int "Maximum zone order" range 14 64 if MIPS_HUGE_TLB_SUPPORT && PAGE_SIZE_64KB default "14" if MIPS_HUGE_TLB_SUPPORT && PAGE_SIZE_64KB diff --git a/arch/nios2/Kconfig b/arch/nios2/Kconfig index c24955c81c92..e5c300198e1f 100644 --- a/arch/nios2/Kconfig +++ b/arch/nios2/Kconfig @@ -50,7 +50,7 @@ menu "Kernel features" source "kernel/Kconfig.hz" -config FORCE_MAX_ZONEORDER +config ARCH_FORCE_MAX_ORDER int "Maximum zone order" range 9 20 default "11" diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 2e213ec6ec05..5edb48b363c4 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -810,7 +810,7 @@ config DATA_SHIFT in that case. If PIN_TLB is selected, it must be aligned to 8M as 8M pages will be pinned. -config FORCE_MAX_ZONEORDER +config ARCH_FORCE_MAX_ORDER int "Maximum zone order" range 8 9 if PPC64 && PPC_64K_PAGES default "9" if PPC64 && PPC_64K_PAGES diff --git a/arch/powerpc/configs/85xx/ge_imp3a_defconfig b/arch/powerpc/configs/85xx/ge_imp3a_defconfig index f29c166998af..e7672c186325 100644 --- a/arch/powerpc/configs/85xx/ge_imp3a_defconfig +++ b/arch/powerpc/configs/85xx/ge_imp3a_defconfig @@ -30,7 +30,7 @@ CONFIG_PREEMPT=y # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set CONFIG_BINFMT_MISC=m CONFIG_MATH_EMULATION=y -CONFIG_FORCE_MAX_ZONEORDER=17 +CONFIG_ARCH_FORCE_MAX_ORDER=17 CONFIG_PCI=y CONFIG_PCIEPORTBUS=y CONFIG_PCI_MSI=y diff --git a/arch/powerpc/configs/fsl-emb-nonhw.config b/arch/powerpc/configs/fsl-emb-nonhw.config index df37efed0aec..521e7a530888 100644 --- a/arch/powerpc/configs/fsl-emb-nonhw.config +++ b/arch/powerpc/configs/fsl-emb-nonhw.config @@ -41,7 +41,7 @@ CONFIG_FIXED_PHY=y CONFIG_FONT_8x16=y CONFIG_FONT_8x8=y CONFIG_FONTS=y -CONFIG_FORCE_MAX_ZONEORDER=13 +CONFIG_ARCH_FORCE_MAX_ORDER=13 CONFIG_FRAMEBUFFER_CONSOLE=y CONFIG_FRAME_WARN=1024 CONFIG_FTL=y diff --git a/arch/sh/configs/ecovec24_defconfig b/arch/sh/configs/ecovec24_defconfig index 03cb916819fa..4c09ca308d43 100644 --- a/arch/sh/configs/ecovec24_defconfig +++ b/arch/sh/configs/ecovec24_defconfig @@ -8,7 +8,7 @@ CONFIG_MODULES=y CONFIG_MODULE_UNLOAD=y # CONFIG_BLK_DEV_BSG is not set CONFIG_CPU_SUBTYPE_SH7724=y -CONFIG_FORCE_MAX_ZONEORDER=12 +CONFIG_ARCH_FORCE_MAX_ORDER=12 CONFIG_MEMORY_SIZE=0x10000000 CONFIG_FLATMEM_MANUAL=y CONFIG_SH_ECOVEC=y diff --git a/arch/sh/mm/Kconfig b/arch/sh/mm/Kconfig index ba569cfb4368..411fdc0901f7 100644 --- a/arch/sh/mm/Kconfig +++ b/arch/sh/mm/Kconfig @@ -18,7 +18,7 @@ config PAGE_OFFSET default "0x80000000" if MMU default "0x00000000" -config FORCE_MAX_ZONEORDER +config ARCH_FORCE_MAX_ORDER int "Maximum zone order" range 9 64 if PAGE_SIZE_16KB default "9" if PAGE_SIZE_16KB diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index f0c0f955e169..2206c99612ed 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig @@ -273,7 +273,7 @@ config ARCH_SPARSEMEM_ENABLE config ARCH_SPARSEMEM_DEFAULT def_bool y if SPARC64 -config FORCE_MAX_ZONEORDER +config ARCH_FORCE_MAX_ORDER int "Maximum zone order" default "13" help diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig index b843902ad9fd..90784aa68cf8 100644 --- a/arch/xtensa/Kconfig +++ b/arch/xtensa/Kconfig @@ -709,7 +709,7 @@ config HIGHMEM If unsure, say Y. -config FORCE_MAX_ZONEORDER +config ARCH_FORCE_MAX_ORDER int "Maximum zone order" default "11" help diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index c1d914a72489..98e3297b9e09 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -24,10 +24,10 @@ #include /* Free memory management - zoned buddy allocator. */ -#ifndef CONFIG_FORCE_MAX_ZONEORDER +#ifndef CONFIG_ARCH_FORCE_MAX_ORDER #define MAX_ORDER 11 #else -#define MAX_ORDER CONFIG_FORCE_MAX_ZONEORDER +#define MAX_ORDER CONFIG_ARCH_FORCE_MAX_ORDER #endif #define MAX_ORDER_NR_PAGES (1 << (MAX_ORDER - 1)) From patchwork Thu Aug 5 19:02:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 12421861 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5564CC19F34 for ; Thu, 5 Aug 2021 19:03:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E0A0460F42 for ; Thu, 5 Aug 2021 19:03:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E0A0460F42 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=sent.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 7284D6B0073; Thu, 5 Aug 2021 15:03:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6D6C66B0075; Thu, 5 Aug 2021 15:03:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 578418D0001; Thu, 5 Aug 2021 15:03:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0233.hostedemail.com [216.40.44.233]) by kanga.kvack.org (Postfix) with ESMTP id 3A0BC6B0073 for ; Thu, 5 Aug 2021 15:03:49 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id D3C031801AB4B for ; Thu, 5 Aug 2021 19:03:48 +0000 (UTC) X-FDA: 78441951336.06.9D1172E Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by imf01.hostedemail.com (Postfix) with ESMTP id 874A45039993 for ; Thu, 5 Aug 2021 19:03:48 +0000 (UTC) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 251CE5C012C; Thu, 5 Aug 2021 15:03:48 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 05 Aug 2021 15:03:48 -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=v5NnXPi+8SUnu /jjhBdJO56OpiXwS+o/8RFQPthUdEk=; b=dqZLVVgc/tDrYGtB4C5omQ7wBpsS1 MnMFDV2tagbRW7NA4p2dSfm3tIx+ggRIjXvWYNvw1udop9lR444i6ePE8POJeS6r hE5A15LzsO7KEbefolvXSLeqo3cAcKasgXjRQvr5e4evCbIg+iH7xgTblIZKLZFF Ox6B9FWTbLpOfvuig1I+lDE4kXgpYG/fjveQ5C0MHXM1zyqrRpHT9ux25Pq8QUj7 FyiWmUCc+XhpJdkFVKMDJS5W/2VYF2OHUsrkPXsBXg1YCHLohN+KDxsO5LDZBeak xuMePxhOy2YgpDw+/cStHNtpJvnyG3IpSAHtesisym7qNSAeQ2KEwLb2g== 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=v5NnXPi+8SUnu/jjhBdJO56OpiXwS+o/8RFQPthUdEk=; b=AuYeRFBk Fto0001rxUnyMnRKNl116YMle+RkuezGiD/vi0HS/1ASrOr7n8tmaRwS6rdZME06 MPDnoXdFxi4PrJ5p6oKzFZoavo8NqhkTPtkUE/0gXozzw6yMZT9452j+6cft04M7 RsHuCuGH/DApDj0tUcJ4iG3ikVvz89SQquFZTr/v9SEM91xMxvrStDAgnyZhr9AD FXVNeTr5jVorCNhaEHAwWcKo2YNmCmzCly0gerT9c6ME2KWgNLpxKaaJsalWv2W/ iPZC5RwhRVQJBwP40oB8889yfy67E+5FAbkzmdxAngWVxL1lomVP6xuSKTPe5mPm OhAsCfNEqBJzCQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrieelgdduvdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfrhgggfestdhqredtredttdenucfhrhhomhepkghiucgj rghnuceoiihirdihrghnsehsvghnthdrtghomheqnecuggftrfgrthhtvghrnhepieejue dvueduuefhgefhheeiuedvtedvuefgieegveetueeiueehtdegudehfeelnecuvehluhhs thgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepiihirdihrghnsehsvg hnthdrtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 5 Aug 2021 15:03:46 -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 Subject: [RFC PATCH 03/15] mm: check pfn validity when buddy allocator can merge pages across mem sections. Date: Thu, 5 Aug 2021 15:02:41 -0400 Message-Id: <20210805190253.2795604-4-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 Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=dqZLVVgc; dkim=pass header.d=messagingengine.com header.s=fm3 header.b=AuYeRFBk; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf01.hostedemail.com: domain of zi.yan@sent.com designates 66.111.4.26 as permitted sender) smtp.mailfrom=zi.yan@sent.com X-Stat-Signature: 59qefi3gyhr5jd7j43h4m71wapqokrx9 X-Rspamd-Queue-Id: 874A45039993 X-Rspamd-Server: rspam01 X-HE-Tag: 1628190228-939687 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Zi Yan When MAX_ORDER - 1 + PAGE_SHIFT > SECTION_SIZE_BITS, it is possible to have holes in memory zones. Use pfn_valid to check holes during buddy page merging and physical frame scanning. Signed-off-by: Zi Yan Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org --- include/linux/mmzone.h | 13 +++++++++++++ mm/compaction.c | 20 +++++++++++++------- mm/memory_hotplug.c | 7 +++++++ mm/page_alloc.c | 26 ++++++++++++++++++++++++-- mm/page_isolation.c | 7 ++++++- mm/page_owner.c | 14 +++++++++++++- 6 files changed, 76 insertions(+), 11 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 98e3297b9e09..04f790ed81b7 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -1535,6 +1535,19 @@ void sparse_init(void); #define subsection_map_init(_pfn, _nr_pages) do {} while (0) #endif /* CONFIG_SPARSEMEM */ +/* + * If it is possible to have holes within a MAX_ORDER_NR_PAGES when + * MAX_ORDER_NR_PAGES crosses multiple memory sections, then we + * need to check pfn validity within each MAX_ORDER_NR_PAGES block. + * 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) +#else +#define pfn_valid_within(pfn) (1) +#endif + #endif /* !__GENERATING_BOUNDS.H */ #endif /* !__ASSEMBLY__ */ #endif /* _LINUX_MMZONE_H */ diff --git a/mm/compaction.c b/mm/compaction.c index fbc60f964c38..dda640d51b70 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -306,14 +306,16 @@ __reset_isolation_pfn(struct zone *zone, unsigned long pfn, bool check_source, * is necessary for the block to be a migration source/target. */ do { - if (check_source && PageLRU(page)) { - clear_pageblock_skip(page); - return true; - } + if (pfn_valid_within(pfn)) { + if (check_source && PageLRU(page)) { + clear_pageblock_skip(page); + return true; + } - if (check_target && PageBuddy(page)) { - clear_pageblock_skip(page); - return true; + if (check_target && PageBuddy(page)) { + clear_pageblock_skip(page); + return true; + } } page += (1 << PAGE_ALLOC_COSTLY_ORDER); @@ -583,6 +585,8 @@ static unsigned long isolate_freepages_block(struct compact_control *cc, break; nr_scanned++; + if (!pfn_valid_within(blockpfn)) + goto isolate_fail; /* * For compound pages such as THP and hugetlbfs, we can save @@ -881,6 +885,8 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, cond_resched(); } + if (!pfn_valid_within(low_pfn)) + goto isolate_fail; nr_scanned++; page = pfn_to_page(low_pfn); diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 632cd832aef6..85029994a494 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1617,6 +1617,13 @@ struct zone *test_pages_in_a_zone(unsigned long start_pfn, continue; for (; pfn < sec_end_pfn && pfn < end_pfn; pfn += MAX_ORDER_NR_PAGES) { + int i = 0; + + while ((i < MAX_ORDER_NR_PAGES) && + !pfn_valid_within(pfn + i)) + i++; + if (i == MAX_ORDER_NR_PAGES || pfn + i >= end_pfn) + continue; /* Check if we got outside of the zone */ if (zone && !zone_spans_pfn(zone, pfn)) return NULL; diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 416859e94f86..e4657009fd4f 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -594,6 +594,8 @@ static int page_outside_zone_boundaries(struct zone *zone, struct page *page) static int page_is_consistent(struct zone *zone, struct page *page) { + if (!pfn_valid_within(page_to_pfn(page))) + return 0; if (zone != page_zone(page)) return 0; @@ -1023,12 +1025,16 @@ buddy_merge_likely(unsigned long pfn, unsigned long buddy_pfn, if (order >= MAX_ORDER - 2) return false; + if (!pfn_valid_within(buddy_pfn)) + return false; + combined_pfn = buddy_pfn & pfn; higher_page = page + (combined_pfn - pfn); buddy_pfn = __find_buddy_pfn(combined_pfn, order + 1); higher_buddy = higher_page + (buddy_pfn - combined_pfn); - return page_is_buddy(higher_page, higher_buddy, order + 1); + return pfn_valid_within(buddy_pfn) && + page_is_buddy(higher_page, higher_buddy, order + 1); } /* @@ -1089,6 +1095,8 @@ static inline void __free_one_page(struct page *page, buddy_pfn = __find_buddy_pfn(pfn, order); buddy = page + (buddy_pfn - pfn); + if (!pfn_valid_within(buddy_pfn)) + goto done_merging; if (!page_is_buddy(page, buddy, order)) goto done_merging; /* @@ -1118,6 +1126,9 @@ static inline void __free_one_page(struct page *page, buddy_pfn = __find_buddy_pfn(pfn, order); buddy = page + (buddy_pfn - pfn); + + if (!pfn_valid_within(buddy_pfn)) + goto done_merging; buddy_mt = get_pageblock_migratetype(buddy); if (migratetype != buddy_mt @@ -1746,7 +1757,8 @@ void __init memblock_free_pages(struct page *page, unsigned long pfn, /* * Check that the whole (or subset of) a pageblock given by the interval of * [start_pfn, end_pfn) is valid and within the same zone, before scanning it - * with the migration of free compaction scanner. + * with the migration of free compaction scanner. The scanners then need to use + * only pfn_valid_within() check for holes within pageblocks. * * Return struct page pointer of start_pfn, or NULL if checks were not passed. * @@ -1862,6 +1874,8 @@ static inline void __init pgdat_init_report_one_done(void) */ static inline bool __init deferred_pfn_valid(unsigned long pfn) { + if (!pfn_valid_within(pfn)) + return false; if (!(pfn & (pageblock_nr_pages - 1)) && !pfn_valid(pfn)) return false; return true; @@ -2508,6 +2522,11 @@ static int move_freepages(struct zone *zone, int pages_moved = 0; for (pfn = start_pfn; pfn <= end_pfn;) { + if (!pfn_valid_within(pfn)) { + pfn++; + continue; + } + page = pfn_to_page(pfn); if (!PageBuddy(page)) { /* @@ -8825,6 +8844,9 @@ struct page *has_unmovable_pages(struct zone *zone, struct page *page, } for (; iter < pageblock_nr_pages - offset; iter++) { + if (!pfn_valid_within(pfn + iter)) + continue; + page = pfn_to_page(pfn + iter); /* diff --git a/mm/page_isolation.c b/mm/page_isolation.c index 471e3a13b541..bddf788f45bf 100644 --- a/mm/page_isolation.c +++ b/mm/page_isolation.c @@ -93,7 +93,8 @@ static void unset_migratetype_isolate(struct page *page, unsigned migratetype) buddy_pfn = __find_buddy_pfn(pfn, order); buddy = page + (buddy_pfn - pfn); - if (!is_migrate_isolate_page(buddy)) { + if (pfn_valid_within(buddy_pfn) && + !is_migrate_isolate_page(buddy)) { __isolate_free_page(page, order); isolated_page = true; } @@ -249,6 +250,10 @@ __test_page_isolated_in_pageblock(unsigned long pfn, unsigned long end_pfn, struct page *page; while (pfn < end_pfn) { + if (!pfn_valid_within(pfn)) { + pfn++; + continue; + } page = pfn_to_page(pfn); if (PageBuddy(page)) /* diff --git a/mm/page_owner.c b/mm/page_owner.c index d24ed221357c..23bfb074ca3f 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -276,6 +276,9 @@ void pagetypeinfo_showmixedcount_print(struct seq_file *m, pageblock_mt = get_pageblock_migratetype(page); for (; pfn < block_end_pfn; pfn++) { + if (!pfn_valid_within(pfn)) + continue; + /* The pageblock is online, no need to recheck. */ page = pfn_to_page(pfn); @@ -476,6 +479,10 @@ read_page_owner(struct file *file, char __user *buf, size_t count, loff_t *ppos) continue; } + /* Check for holes within a MAX_ORDER area */ + if (!pfn_valid_within(pfn)) + continue; + page = pfn_to_page(pfn); if (PageBuddy(page)) { unsigned long freepage_order = buddy_order_unsafe(page); @@ -553,9 +560,14 @@ static void init_pages_in_zone(pg_data_t *pgdat, struct zone *zone) block_end_pfn = min(block_end_pfn, end_pfn); for (; pfn < block_end_pfn; pfn++) { - struct page *page = pfn_to_page(pfn); + struct page *page; struct page_ext *page_ext; + if (!pfn_valid_within(pfn)) + continue; + + page = pfn_to_page(pfn); + if (page_zone(page) != zone) continue; From patchwork Thu Aug 5 19:02:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 12421863 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC190C43214 for ; Thu, 5 Aug 2021 19:03:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 66BD760F01 for ; Thu, 5 Aug 2021 19:03:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 66BD760F01 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=sent.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 552BD6B0075; Thu, 5 Aug 2021 15:03:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 48D3C8D0001; Thu, 5 Aug 2021 15:03:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 354F26B007B; Thu, 5 Aug 2021 15:03:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0150.hostedemail.com [216.40.44.150]) by kanga.kvack.org (Postfix) with ESMTP id 197B76B0075 for ; Thu, 5 Aug 2021 15:03:50 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id BFF981802EFFD for ; Thu, 5 Aug 2021 19:03:49 +0000 (UTC) X-FDA: 78441951378.29.353ABF9 Received: from new3-smtp.messagingengine.com (new3-smtp.messagingengine.com [66.111.4.229]) by imf13.hostedemail.com (Postfix) with ESMTP id 5CD2E10187C4 for ; Thu, 5 Aug 2021 19:03:49 +0000 (UTC) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id 05DDA5810B5; Thu, 5 Aug 2021 15:03:49 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 05 Aug 2021 15:03:49 -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=ppy32GVmy6OZk OOejSng3cThhTAJUY99OP+ee8s2A8E=; b=S/XJQV6eETWl+Cvdsgb1bFI94cbuu y/h6D8K4a90v2BwHExBPeOeC/LyOjL0a5z1tFhq4nQzAgli9WrQULDIy0DolhiVD cbMGHXcvzKugFEZfWnLTGdWPJCGKLNMfRq8mphzsV4+xT7+G9Ij7lD8fbJaWDD2k YNBaicI7S5yFQhsY5fiF7wZKpU8F1eVT4LUJx8sR0JXkx/348nSSifHKZz4hYBUt n41iqv+5lrmr8C1gGfSlSj0pJEZfR6MAFiHV3mfIkK/vX/nt3IoTQcXR0xiiTjfE 7gaAdcGehqF/DSunoObtIL92uu1Xcls32HmNC5UNv5Qe0ash2eIM0Vjrw== 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=ppy32GVmy6OZkOOejSng3cThhTAJUY99OP+ee8s2A8E=; b=KJDFjjZV yIOQrCPlG/TJKc5wOfEVskvE0+O33WC52LwAV+KJLw6KATiAK4kCJESSY+wYZx0y Ll5GolCNLMUB///tI6PDTMPOiNXSgkybq+s9pV1snev+0jgNVoALD/LlQugZCYJA wwIgsHmY3DFM6FCMJqzV3U3RBxOiD+YUDJI619NLJGMV4IOGwHeD515XCkD3YbFj LBhX0TitF9X+oU0zlcWSnLcjH6AigIKjV2j8aF3YWmOskD6E7w+pCY+aB6+of+hc HzD5hGti7vYcAjJu3BHUnMEmB5xyZ9WTY2hX+ZAm2EEY1brRjTLGeRP3K73X++Ze 6GQN61lJFdxqaQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrieelgdduvdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfrhgggfestdhqredtredttdenucfhrhhomhepkghiucgj rghnuceoiihirdihrghnsehsvghnthdrtghomheqnecuggftrfgrthhtvghrnhepieejue dvueduuefhgefhheeiuedvtedvuefgieegveetueeiueehtdegudehfeelnecuvehluhhs thgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepiihirdihrghnsehsvg hnthdrtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 5 Aug 2021 15:03:48 -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 , Wei Yang Subject: [RFC PATCH 04/15] mm: prevent pageblock size being larger than section size. Date: Thu, 5 Aug 2021 15:02:42 -0400 Message-Id: <20210805190253.2795604-5-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 Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b="S/XJQV6e"; dkim=pass header.d=messagingengine.com header.s=fm3 header.b=KJDFjjZV; spf=pass (imf13.hostedemail.com: domain of zi.yan@sent.com designates 66.111.4.229 as permitted sender) smtp.mailfrom=zi.yan@sent.com; dmarc=pass (policy=none) header.from=sent.com X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 5CD2E10187C4 X-Stat-Signature: d5d3bwn9sw9i8xxnifrjtzaagzn83mgs X-HE-Tag: 1628190229-223905 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Zi Yan Only physical pages from a section can be guaranteed to be contiguous and so far a pageblock can only group contiguous physical pages by design. Set pageblock_order properly to prevent pageblock going beyond section size. Signed-off-by: Zi Yan Cc: Wei Yang Cc: Vlastimil Babka Cc: "Matthew Wilcox (Oracle)" Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org --- include/linux/pageblock-flags.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/linux/pageblock-flags.h b/include/linux/pageblock-flags.h index 973fd731a520..4277b4267767 100644 --- a/include/linux/pageblock-flags.h +++ b/include/linux/pageblock-flags.h @@ -44,8 +44,11 @@ extern unsigned int pageblock_order; #else /* CONFIG_HUGETLB_PAGE */ -/* If huge pages are not used, group by MAX_ORDER_NR_PAGES */ -#define pageblock_order (MAX_ORDER-1) +/* + * If huge pages are not used, group by MAX_ORDER_NR_PAGES or + * PAGES_PER_SECTION when MAX_ORDER_NR_PAGES is larger. + */ +#define pageblock_order (min(PFN_SECTION_SHIFT, MAX_ORDER-1)) #endif /* CONFIG_HUGETLB_PAGE */ From patchwork Thu Aug 5 19:02:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 12421865 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13DE0C4338F for ; Thu, 5 Aug 2021 19:03:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BD84860F01 for ; Thu, 5 Aug 2021 19:03:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BD84860F01 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=sent.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id C7EB06B007B; Thu, 5 Aug 2021 15:03:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BB8826B007D; Thu, 5 Aug 2021 15:03:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A58E86B007E; Thu, 5 Aug 2021 15:03:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0118.hostedemail.com [216.40.44.118]) by kanga.kvack.org (Postfix) with ESMTP id 838226B007B for ; Thu, 5 Aug 2021 15:03:50 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 2E09818016129 for ; Thu, 5 Aug 2021 19:03:50 +0000 (UTC) X-FDA: 78441951420.13.5CB12C1 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by imf27.hostedemail.com (Postfix) with ESMTP id D39357001F78 for ; Thu, 5 Aug 2021 19:03:49 +0000 (UTC) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 7774A5C0160; Thu, 5 Aug 2021 15:03:49 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 05 Aug 2021 15:03:49 -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=WkfkSBDKtT+JV svcnvI+ensvQFYsr8arKk51nWla/ns=; b=Eig43P7o6pypWoyU3Hgwo3CSypMVP ukIGgpHhdvWi079VQpHg45cL6bV27wy668fQ77gO7jaLVuUa6yrgVDNE31izvaGD Qq4PHwqogRrBecw7ulqS9gS36MAKu0ceQhm4tY0fezKT7Ral+2B9qzpb/IQezyGN o3drdYRotmiJStMDWBCD3ptzV954eIPG8LPXu2DvNWNqDGXFOnZwBRe/G+1aNSze KiYp6za1VQb4iz8hyARC1qCKNH/JXWJOJO5dYrlBwkm6rL86GC4Ua3D2K9dVT3RE VMvJpeKGHJPJE4v4ajSKrbAo/Ei3bjy8BRUrZJWtJ95CmhGRnDzJh7Mtw== 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=WkfkSBDKtT+JVsvcnvI+ensvQFYsr8arKk51nWla/ns=; b=rprndRDD 7vPzUXWe215Wt32209lM4uzb3aVuktPzk8wLAdRoVDG5zPo3syWwO05AmQd+1Ooj d0ZsRdEEsZFgUSit6tF6bp8OozeIEz4LZD6cUQf9VWbjQDxisfnuOu8/wghjlEgz l2FlVeuC0ts3Zm6Oz7Se6kFD8e81U46aRIl7zJPve1FkmmOSCamVil6A29t80cKx 64fFn/UKHI9LAE49zNqeXGVegPWgcl9WLlkTMlXVVca8hwGELSjIibZ9uCRp9I1V DrOZrNjJ4ZHrvpG0oDqcUWdaJf9r5D1WADoVc3+IuZCwwkKIRUo31DQdRWefH4YM aHLFjXncJqQOuA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrieelgdduvdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfrhgggfestdhqredtredttdenucfhrhhomhepkghiucgj rghnuceoiihirdihrghnsehsvghnthdrtghomheqnecuggftrfgrthhtvghrnhepieejue dvueduuefhgefhheeiuedvtedvuefgieegveetueeiueehtdegudehfeelnecuvehluhhs thgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepiihirdihrghnsehsvg hnthdrtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 5 Aug 2021 15:03:49 -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 Subject: [RFC PATCH 05/15] mm/memory_hotplug: online pages at section size. Date: Thu, 5 Aug 2021 15:02:43 -0400 Message-Id: <20210805190253.2795604-6-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 Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=Eig43P7o; dkim=pass header.d=messagingengine.com header.s=fm3 header.b=rprndRDD; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf27.hostedemail.com: domain of zi.yan@sent.com designates 66.111.4.26 as permitted sender) smtp.mailfrom=zi.yan@sent.com X-Stat-Signature: 1naw3m3k66ert5cecyaqmt3hfn41sreg X-Rspamd-Queue-Id: D39357001F78 X-Rspamd-Server: rspam01 X-HE-Tag: 1628190229-419032 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Zi Yan When CONFIG_SET_MAX_ORDER is used, MAX_ORDER can be larger than section size. Holes can appear in hotplug memory chunks with size of 2^MAX_ORDER. Use PFN_SECTION_SHIFT (the order of section size) to limit hotplug memory size. Signed-off-by: Zi Yan Cc: David Hildenbrand Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org --- mm/memory_hotplug.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 85029994a494..91ca751ac20c 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -601,16 +601,16 @@ static void online_pages_range(unsigned long start_pfn, unsigned long nr_pages) unsigned long pfn; /* - * Online the pages in MAX_ORDER - 1 aligned chunks. The callback might - * decide to not expose all pages to the buddy (e.g., expose them + * Online the pages in PFN_SECTION_SHIFT aligned chunks. The callback + * might decide to not expose all pages to the buddy (e.g., expose them * later). We account all pages as being online and belonging to this * zone ("present"). * When using memmap_on_memory, the range might not be aligned to - * MAX_ORDER_NR_PAGES - 1, but pageblock aligned. __ffs() will detect - * this and the first chunk to online will be pageblock_nr_pages. + * PAGES_PER_SECTION - 1, but section size aligned. __ffs() will detect + * this and the first chunk to online will be PAGES_PER_SECTION. */ for (pfn = start_pfn; pfn < end_pfn;) { - int order = min(MAX_ORDER - 1UL, __ffs(pfn)); + int order = min_t(unsigned long, PFN_SECTION_SHIFT, __ffs(pfn)); (*online_page_callback)(pfn_to_page(pfn), order); pfn += (1UL << order); From patchwork Thu Aug 5 19:02:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 12421867 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7BC9C4338F for ; Thu, 5 Aug 2021 19:03:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6CDF660EEA for ; Thu, 5 Aug 2021 19:03:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6CDF660EEA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=sent.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 26C826B007D; Thu, 5 Aug 2021 15:03:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 21D696B007E; Thu, 5 Aug 2021 15:03:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0BC4F6B0080; Thu, 5 Aug 2021 15:03:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0027.hostedemail.com [216.40.44.27]) by kanga.kvack.org (Postfix) with ESMTP id D61F36B007E for ; Thu, 5 Aug 2021 15:03:50 -0400 (EDT) Received: from smtpin40.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 8938A24397 for ; Thu, 5 Aug 2021 19:03:50 +0000 (UTC) X-FDA: 78441951420.40.D5BA46C Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by imf04.hostedemail.com (Postfix) with ESMTP id 472D2500032D for ; Thu, 5 Aug 2021 19:03:50 +0000 (UTC) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id DA32D5C0164; Thu, 5 Aug 2021 15:03:49 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 05 Aug 2021 15:03:49 -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=9b9lnDrs9VQeu LXncQCMIbv4vy0L5khM/fC6d/oCDXA=; b=OU4cZ8TjVlVmleX2bWKetvc5gwm7e jNkfnKbXADKL0QRCPeRLPUYmqPzTKQo8Ahc4VKw6mzAgL3RYFC8kT6o0M71/03G3 dNWLljRBSfrzRzdr+wXOlCQvWuo1CBUn0Aidpzrc9nwwqWHTkR2rhKzvGgqHnpt0 xq3S/JeOJ8/Xfc8HffM2q7IIecv7zOT9T+XhiT+0gysc4Th9IQd+p4cYWVLLqR2u oGQN/VXw1hOirdA59cfd6qTrm9aci5QwnaR6ZDfvpcPYAQkhaaYI02eOiCEn/cTC BDvUB28BUGnrCRTcvcojUZxP9SkoCciZBEneTq4H2RKbsjlpPTjPQA50w== 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=9b9lnDrs9VQeuLXncQCMIbv4vy0L5khM/fC6d/oCDXA=; b=dFXQ9IEJ kYsiA0Yev3dse3G5yyI07udU8K/EmFWe9HfhOVwymJigLFi5ru9alNfRIAIzgbU4 6L26WRHprShkvLASjc2/5Rh1PyTwQWDiOLJbGAspghSOmXseuY4g5QE72SF8Jhhr 6jEG8Qkvz70sMciuY1SkVND29uXciqrNXJBBmp39gqjKKHu79Mi/2iWIyo2JGLrb wTqDwSK7I5dOS+V1+/lIKC66qZHkzzbDgN5WQNlWDxzZHcHCZXztN9PXGbIYNo5y Uh6pQy1/7Gl+RZfb812ehwc22PlFwfUZAHPa0115lifI2Ft2UBHDmazpDZWgh/ls oXUQo5jhcb4QFA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrieelgdduvdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfrhgggfestdhqredtredttdenucfhrhhomhepkghiucgj rghnuceoiihirdihrghnsehsvghnthdrtghomheqnecuggftrfgrthhtvghrnhepieejue dvueduuefhgefhheeiuedvtedvuefgieegveetueeiueehtdegudehfeelnecuvehluhhs thgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepiihirdihrghnsehsvg hnthdrtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 5 Aug 2021 15:03:49 -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 Subject: [RFC PATCH 06/15] mm: use PAGES_PER_SECTION instead for mem_map_offset/next(). Date: Thu, 5 Aug 2021 15:02:44 -0400 Message-Id: <20210805190253.2795604-7-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 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 472D2500032D Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=OU4cZ8Tj; dkim=pass header.d=messagingengine.com header.s=fm3 header.b=dFXQ9IEJ; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf04.hostedemail.com: domain of zi.yan@sent.com designates 66.111.4.26 as permitted sender) smtp.mailfrom=zi.yan@sent.com X-Stat-Signature: 3cfxi7tjt1g4ac4q4zqhiwy5dr4n54uk X-HE-Tag: 1628190230-647594 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Zi Yan mem_map is only guaranteed to be virtually contiguous within a section, so mem_map_offset/next() uses pfn to handle mem_map discontiguity. Use PAGES_PER_SECTION instead of MAX_ORDER_NR_PAGES to describe this condition more precisely. Signed-off-by: Zi Yan Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org --- mm/internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index b1001ebeb286..4ca52c696902 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -485,7 +485,7 @@ static inline void vunmap_range_noflush(unsigned long start, unsigned long end) */ static inline struct page *mem_map_offset(struct page *base, int offset) { - if (unlikely(offset >= MAX_ORDER_NR_PAGES)) + if (unlikely(offset >= PAGES_PER_SECTION)) return nth_page(base, offset); return base + offset; } @@ -497,7 +497,7 @@ static inline struct page *mem_map_offset(struct page *base, int offset) static inline struct page *mem_map_next(struct page *iter, struct page *base, int offset) { - if (unlikely((offset & (MAX_ORDER_NR_PAGES - 1)) == 0)) { + if (unlikely((offset & (PAGES_PER_SECTION - 1)) == 0)) { unsigned long pfn = page_to_pfn(base) + offset; if (!pfn_valid(pfn)) return NULL; From patchwork Thu Aug 5 19:02:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 12421869 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61889C4338F for ; Thu, 5 Aug 2021 19:04:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 128B060F01 for ; Thu, 5 Aug 2021 19:04:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 128B060F01 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=sent.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id EC7E86B007E; Thu, 5 Aug 2021 15:03:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E77A26B0080; Thu, 5 Aug 2021 15:03:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D190B6B0081; Thu, 5 Aug 2021 15:03:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0177.hostedemail.com [216.40.44.177]) by kanga.kvack.org (Postfix) with ESMTP id B0F376B007E for ; Thu, 5 Aug 2021 15:03:51 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 6D3DF248AE for ; Thu, 5 Aug 2021 19:03:51 +0000 (UTC) X-FDA: 78441951462.07.59BBE26 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by imf28.hostedemail.com (Postfix) with ESMTP id C150F9001876 for ; Thu, 5 Aug 2021 19:03:50 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 5E30B5C0163; Thu, 5 Aug 2021 15:03:50 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 05 Aug 2021 15:03:50 -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=Lf+Lo5XZBjeZj 26CYxZH/xK3V5qmXEQIAGQy9/M8Fos=; b=BU7jEjGIWBuA7nBnSpdOo189jkLI5 NwRqb67cGvmHezcEdmUpqZKPS3139uAuuaE3a/BBl+dukvx51LWU4ohrNfGAqfuX ylUL80D/dHflw7e+u+bJJUkDYqlBvvT0N5DHnVq1B+adObgI+yCtI5OTI2aNvTj5 uJE1yMuyJSl63XF7j+hNDPP9pns04qrqXZvE9MGcwIe8qvV9STIYiYnuFQ/06ux5 6kp8Dgv/Hxlw77Fq0m+2q1GTiUK3bPzuqsfiR0oya9dKhUixJB9Dg158nERscoLF 3/VzMXrmYw74Aak9nOcxFRU66AJobAPCLnWM5zLw8xrNXLm2jFkLUgjuQ== 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=Lf+Lo5XZBjeZj26CYxZH/xK3V5qmXEQIAGQy9/M8Fos=; b=B1r8L+Yo PD3pvwzCaLIj12NCvVTj3l6HRer7jSt3363+mRBlrkicVMcqmsmWA/zRfWKJjgKU Ku3V9kJAn+ei1wTRrKpgK52IKHzV9+e3GSfK6NwUrD2j49U3uribv/2sQxgw4LyH 9olPYqQOzd2nlVPRP+WB5UrGREV8c2sb6uCWi0kEGK7mGwHwYqLXV8xKAFcSg6rb VQMuanJUr8g94pni2ctv1BfiwaqXYwfgGvPdetXBQeaWIO8ek+HC8OqZXa2UKySD pv9/OwADCaeePO6T1P4KCWW0u76cDg0xaHRxg4dMChvq2cJtWBQTSHvgwWRxSJLA FsTUFmX9h1fz7A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrieelgddufedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfrhgggfestdhqredtredttdenucfhrhhomhepkghiucgj rghnuceoiihirdihrghnsehsvghnthdrtghomheqnecuggftrfgrthhtvghrnhepieejue dvueduuefhgefhheeiuedvtedvuefgieegveetueeiueehtdegudehfeelnecuvehluhhs thgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepiihirdihrghnsehsvg hnthdrtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 5 Aug 2021 15:03:49 -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 Subject: [RFC PATCH 07/15] mm: hugetlb: use PAGES_PER_SECTION to check mem_map discontiguity Date: Thu, 5 Aug 2021 15:02:45 -0400 Message-Id: <20210805190253.2795604-8-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 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: C150F9001876 Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=BU7jEjGI; dkim=pass header.d=messagingengine.com header.s=fm3 header.b=B1r8L+Yo; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf28.hostedemail.com: domain of zi.yan@sent.com designates 66.111.4.26 as permitted sender) smtp.mailfrom=zi.yan@sent.com X-Stat-Signature: rodqz8xjoz1gmutf693dw9ki7b5s5jpg X-HE-Tag: 1628190230-183472 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Zi Yan mem_map is only guaranteed to be virtually contiguous within a section. Use PAGES_PER_SECTION to check the condition properly. Signed-off-by: Zi Yan Cc: Mike Kravetz Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org --- mm/hugetlb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index ce79d76c42ce..7f78203d6feb 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1784,7 +1784,7 @@ pgoff_t hugetlb_basepage_index(struct page *page) pgoff_t index = page_index(page_head); unsigned long compound_idx; - if (compound_order(page_head) >= MAX_ORDER) + if (compound_order(page_head) >= PAGES_PER_SECTION) compound_idx = page_to_pfn(page) - page_to_pfn(page_head); else compound_idx = page - page_head; From patchwork Thu Aug 5 19:02:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 12421871 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EF36C43216 for ; Thu, 5 Aug 2021 19:04:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B61C961186 for ; Thu, 5 Aug 2021 19:04:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B61C961186 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=sent.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id BE1E66B0080; Thu, 5 Aug 2021 15:03:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B93036B0081; Thu, 5 Aug 2021 15:03:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A32CC8D0001; Thu, 5 Aug 2021 15:03:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0228.hostedemail.com [216.40.44.228]) by kanga.kvack.org (Postfix) with ESMTP id 82DF46B0080 for ; Thu, 5 Aug 2021 15:03:52 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 3066F269CA for ; Thu, 5 Aug 2021 19:03:52 +0000 (UTC) X-FDA: 78441951504.09.10F18C6 Received: from new3-smtp.messagingengine.com (new3-smtp.messagingengine.com [66.111.4.229]) by imf30.hostedemail.com (Postfix) with ESMTP id D5B1AE003077 for ; Thu, 5 Aug 2021 19:03:51 +0000 (UTC) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.nyi.internal (Postfix) with ESMTP id 83F4A5810B7; Thu, 5 Aug 2021 15:03:51 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 05 Aug 2021 15:03:51 -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=zNBa+DPw6skCL 5zqb415g/XSwtRXkYRjfljqWc0rqOw=; b=DyQb67WDvRtWM6HaUooUM/LJ7FBVe RHKFGNkJpgMc/hVEhEU3bBY0j9e1ACpLPdzYhMBgcjDe25DJVAzXtC8OyYQaCVVT DVkY8uIRXHprEmZd7qBlwTwWuaxBZ9hOYHN4GMeCh1CiCofOD28h/6oouXhqIR0t oKln8pn7sD+jD8rKJ0OfZcRP17juq9szZlAFNHgLyTc/QAno4D+VnlxhSsuynNfP 61sbW9SZYU5psQ4GG81DYucrG+Xv1iJYadVgCmDdHfkO6F3fiRucb/vyijDk16O9 /Tu4nUObFASN79yNgjfLeDeMHRAtJC2KV1GiUeMazMZWkFNAisJysmBTw== 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=zNBa+DPw6skCL5zqb415g/XSwtRXkYRjfljqWc0rqOw=; b=gWQXO1i0 jN0W7VaDRO9ZJs7svTKOs6Zt3cVW8ykYAN5L20lmCsOwVLSyKKEZwcwAy8VLeDO+ +cKpfta9nOpdlS3fPnazuUW3DIx4T86hKG9WnNFqjnCwKTmzfFsvE9oh/Mdk21IY ZVbWKhhb5FA53N0Ec0CWeZHZKCmTAAiFT07RnyvlxwVi6mE/6AZGO8VqkOWJuOan ijipS8ZISTZ+UgBOT8KfSFZxVWMUbObBRGAXGyM93Vp8IG6cNc/lcud6npqT4vDF sQHBgCvQgM9uEJk8sIkfHmI/yaEFNhrihPBkIuGmwTxRC6bG58BsFou2qiW9cT3Z UG97Hfi+X2S+MA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrieelgdduvdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfrhgggfestdhqredtredttdenucfhrhhomhepkghiucgj rghnuceoiihirdihrghnsehsvghnthdrtghomheqnecuggftrfgrthhtvghrnhepieejue dvueduuefhgefhheeiuedvtedvuefgieegveetueeiueehtdegudehfeelnecuvehluhhs thgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepiihirdihrghnsehsvg hnthdrtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 5 Aug 2021 15:03:50 -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 , Mike Rapoport , Oscar Salvador , Ying Chen , Feng Zhou , linux-fsdevel@vger.kernel.org Subject: [RFC PATCH 08/15] fs: proc: use PAGES_PER_SECTION for page offline checking period. Date: Thu, 5 Aug 2021 15:02:46 -0400 Message-Id: <20210805190253.2795604-9-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 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: D5B1AE003077 Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=DyQb67WD; dkim=pass header.d=messagingengine.com header.s=fm3 header.b=gWQXO1i0; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf30.hostedemail.com: domain of zi.yan@sent.com designates 66.111.4.229 as permitted sender) smtp.mailfrom=zi.yan@sent.com X-Stat-Signature: tgwzzzzgtcskigiasgmadzybctgucjz3 X-HE-Tag: 1628190231-782663 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Zi Yan It keeps the existing behavior after MAX_ORDER is increased beyond a section size. Signed-off-by: Zi Yan Cc: Mike Rapoport Cc: David Hildenbrand Cc: Oscar Salvador Cc: Ying Chen Cc: Feng Zhou Cc: linux-fsdevel@vger.kernel.org Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org --- fs/proc/kcore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c index 3f148759a5fd..77b7ba48fb44 100644 --- a/fs/proc/kcore.c +++ b/fs/proc/kcore.c @@ -486,7 +486,7 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos) } } - if (page_offline_frozen++ % MAX_ORDER_NR_PAGES == 0) { + if (page_offline_frozen++ % PAGES_PER_SECTION == 0) { page_offline_thaw(); cond_resched(); page_offline_freeze(); From patchwork Thu Aug 5 19:02:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 12421873 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D05B1C4338F for ; Thu, 5 Aug 2021 19:04:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7E04260EEA for ; Thu, 5 Aug 2021 19:04:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7E04260EEA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=sent.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 52CA06B0082; Thu, 5 Aug 2021 15:03:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 501BA6B0083; Thu, 5 Aug 2021 15:03:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 354918D0001; Thu, 5 Aug 2021 15:03:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0213.hostedemail.com [216.40.44.213]) by kanga.kvack.org (Postfix) with ESMTP id 13BB26B0082 for ; Thu, 5 Aug 2021 15:03:54 -0400 (EDT) Received: from smtpin35.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id C41898249980 for ; Thu, 5 Aug 2021 19:03:53 +0000 (UTC) X-FDA: 78441951546.35.4CE5779 Received: from new3-smtp.messagingengine.com (new3-smtp.messagingengine.com [66.111.4.229]) by imf21.hostedemail.com (Postfix) with ESMTP id 774D5D013475 for ; Thu, 5 Aug 2021 19:03:53 +0000 (UTC) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailnew.nyi.internal (Postfix) with ESMTP id 23F145810B9; Thu, 5 Aug 2021 15:03:53 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 05 Aug 2021 15:03:53 -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=bav9UkYGZvp/S Y4+sEgDfc5Rj+WNvVLnm5fMaKPJQdk=; b=AoYLNFC8R8d82d/WRFYvXz1pQUcLY ZRdB+YJbC1BZ2LsdT8uiKSRXrKQOVFtQeszFb7gfKMFVkoXcKPlIjnJi6m15HUBJ v27YQLZxVgSFkWugx1CKQmkSWO0dzqkNnmLbNwsrnKH1epPoJunr+Wl1yZjyiuxR K08mh6TSDgVYc7yo9bQJlmV+WCj09RPZkyMdgpYgJ7a8aHhtbNahW9+6ydqynB3t Yhhg2VHHAmI+XOyJ8kDCRX4LtHjmd/58YE1pzjFpi7aq2xQzdZ7972LCCMCyV0Do GO0T9OEz1KP3fneJ4L2HZNsRfmdwIETiQmt/pQ7nvxY6jvOXCm0B4k8cA== 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=bav9UkYGZvp/SY4+sEgDfc5Rj+WNvVLnm5fMaKPJQdk=; b=FPhvCv8S EUsyNoH9KkfmXugX8+QcCXRQR00+NKVzQNjb59jnObV52uBKmPjj3MLPkZRQZqTp PXeAmHquCG3u/dTBtgygKNhxTPP/iKhnl78Bq9taENJgahMr/ABc9FDaNRIzcefv 3bdObHO6RklONprTBrHerpD2Uq44qKeeYqFZfEZWeiYIpFitAvlFJxwCfMJstJyJ dTMtKv1Yw+FK7qmmGMeTe+yu6UqHXvixNyI/1HWpDrbI9shzGMq703Xi5FqWeBYT E0xbjKLb/yUFgM3/hnDwvGt4s86ZGrNcbOpDdOfQDLKnc5U8/Fs0xCCzha6Jye3F nXlMcTGsol4ULg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrieelgdduvdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfrhgggfestdhqredtredttdenucfhrhhomhepkghiucgj rghnuceoiihirdihrghnsehsvghnthdrtghomheqnecuggftrfgrthhtvghrnhepieejue dvueduuefhgefhheeiuedvtedvuefgieegveetueeiueehtdegudehfeelnecuvehluhhs thgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepiihirdihrghnsehsvg hnthdrtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 5 Aug 2021 15:03:51 -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 , "Michael S. Tsirkin" , Jason Wang , virtualization@lists.linux-foundation.org Subject: [RFC PATCH 09/15] virtio: virtio_mem: use PAGES_PER_SECTION instead of MAX_ORDER_NR_PAGES Date: Thu, 5 Aug 2021 15:02:47 -0400 Message-Id: <20210805190253.2795604-10-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 Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=AoYLNFC8; dkim=pass header.d=messagingengine.com header.s=fm3 header.b=FPhvCv8S; spf=pass (imf21.hostedemail.com: domain of zi.yan@sent.com designates 66.111.4.229 as permitted sender) smtp.mailfrom=zi.yan@sent.com; dmarc=pass (policy=none) header.from=sent.com X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 774D5D013475 X-Stat-Signature: rm9ewwszwzakx5byjufxpw44fnusak35 X-HE-Tag: 1628190233-970532 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Zi Yan It keeps the existing behavior when MAX_ORDER grows beyond a section size. Signed-off-by: Zi Yan Cc: David Hildenbrand Cc: "Michael S. Tsirkin" Cc: Jason Wang Cc: virtualization@lists.linux-foundation.org Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org --- drivers/virtio/virtio_mem.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c index 19036922f7ef..bab5a81fa796 100644 --- a/drivers/virtio/virtio_mem.c +++ b/drivers/virtio/virtio_mem.c @@ -1105,11 +1105,11 @@ static void virtio_mem_clear_fake_offline(unsigned long pfn, */ static void virtio_mem_fake_online(unsigned long pfn, unsigned long nr_pages) { - const unsigned long max_nr_pages = MAX_ORDER_NR_PAGES; + const unsigned long max_nr_pages = PAGES_PER_SECTION; unsigned long i; /* - * We are always called at least with MAX_ORDER_NR_PAGES + * We are always called at least with PAGES_PER_SECTION * granularity/alignment (e.g., the way subblocks work). All pages * inside such a block are alike. */ @@ -1125,7 +1125,7 @@ static void virtio_mem_fake_online(unsigned long pfn, unsigned long nr_pages) if (PageDirty(page)) { virtio_mem_clear_fake_offline(pfn + i, max_nr_pages, false); - generic_online_page(page, MAX_ORDER - 1); + generic_online_page(page, PAGES_PER_SECTION - 1); } else { virtio_mem_clear_fake_offline(pfn + i, max_nr_pages, true); @@ -1228,7 +1228,7 @@ static void virtio_mem_online_page_cb(struct page *page, unsigned int order) if (vm->in_sbm) { /* * We exploit here that subblocks have at least - * MAX_ORDER_NR_PAGES size/alignment - so we cannot + * PAGES_PER_SECTION size/alignment - so we cannot * cross subblocks within one call. */ id = virtio_mem_phys_to_mb_id(addr); @@ -2438,14 +2438,14 @@ static int virtio_mem_init(struct virtio_mem *vm) VIRTIO_MEM_DEFAULT_OFFLINE_THRESHOLD); /* - * We want subblocks to span at least MAX_ORDER_NR_PAGES and + * We want subblocks to span at least PAGES_PER_SECTION and * pageblock_nr_pages pages. This: * - Simplifies our page onlining code (virtio_mem_online_page_cb) * and fake page onlining code (virtio_mem_fake_online). * - Is required for now for alloc_contig_range() to work reliably - * it doesn't properly handle smaller granularity on ZONE_NORMAL. */ - sb_size = max_t(uint64_t, MAX_ORDER_NR_PAGES, + sb_size = max_t(uint64_t, PAGES_PER_SECTION, pageblock_nr_pages) * PAGE_SIZE; sb_size = max_t(uint64_t, vm->device_block_size, sb_size); From patchwork Thu Aug 5 19:02:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 12421875 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1741C4320A for ; Thu, 5 Aug 2021 19:04:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 60A2760EEA for ; Thu, 5 Aug 2021 19:04:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 60A2760EEA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=sent.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 0708B6B0083; Thu, 5 Aug 2021 15:03:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EECEB8D0001; Thu, 5 Aug 2021 15:03:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D8D2F6B0087; Thu, 5 Aug 2021 15:03:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0044.hostedemail.com [216.40.44.44]) by kanga.kvack.org (Postfix) with ESMTP id B2B6F6B0083 for ; Thu, 5 Aug 2021 15:03:54 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 6346322867 for ; Thu, 5 Aug 2021 19:03:54 +0000 (UTC) X-FDA: 78441951588.08.D46267D Received: from new3-smtp.messagingengine.com (new3-smtp.messagingengine.com [66.111.4.229]) by imf19.hostedemail.com (Postfix) with ESMTP id 205A1B000C0C for ; Thu, 5 Aug 2021 19:03:53 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.nyi.internal (Postfix) with ESMTP id B4D585810BA; Thu, 5 Aug 2021 15:03:53 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 05 Aug 2021 15:03:53 -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=km9HG7d0aLbun QBTsj+FmyouAn5cvVzLddI+NBf1S5I=; b=Ca99plPmsBIKRdYO73L+eS0IcmVTU rQSzJdkmcEqNR+acpa6Ghbl6oZt0oiu25ZQXDo/sSV2PLXp/yIIMVcOlU1ylgFt9 c1YnNjK+GpDhW6pyK+lhlbNCxL7T6gdSvktHSfpfWtD0QhtPvdvjhKyVIhLvEinQ kykZMM3z7wSpTyOG7jdOdd3hUStmHdcdlPSag+1k8M+PL3HwtEO7e4YSaPmmM4yQ SJ+8Jk6nXsko2p98OHkZQxJJlRElU2hQuB7exc6I+oce3blx11SjUHbMMQTnayYh r9drJ3osSoKD2iDArGm22yqpzLb9yuYAwbPqcaGGRwPN7skJXVJp4k9pA== 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=km9HG7d0aLbunQBTsj+FmyouAn5cvVzLddI+NBf1S5I=; b=AuCaNREa il44gT/59h7oet5zTmexPudy5yoEZgJCPZQWT7Q0sj457+hvSUKjw8WYNRNeoFU+ 7AtmUotFAQvTWp6TIJU2XU72XE4rp8CtLlJWimlnYkacVl+0asDOKEVAsupxLJpn aMzazxF3PLktYouWanmoFUvzdaK2NtMaq4z4N5WkzG+ebCelp0jX+/bx+uJL76Ym pSsHMf+UCjzguTxJWmpDNAkmVRA9x67tWA0rZJF1rEpRXgl5hCPjc699yzI/lesD lrNYXf+930L/MK+heiyUvifpguRsDKx1s+vSWGVZh844Bb3aXkJk+SbK7fHV/bG6 /Y8xv55+X2nSew== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrieelgddufedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfrhgggfestdhqredtredttdenucfhrhhomhepkghiucgj rghnuceoiihirdihrghnsehsvghnthdrtghomheqnecuggftrfgrthhtvghrnhepieejue dvueduuefhgefhheeiuedvtedvuefgieegveetueeiueehtdegudehfeelnecuvehluhhs thgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepiihirdihrghnsehsvg hnthdrtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 5 Aug 2021 15:03:53 -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 , "Michael S. Tsirkin" , Jason Wang , virtualization@lists.linux-foundation.org Subject: [RFC PATCH 10/15] virtio: virtio_balloon: use PAGES_PER_SECTION instead of MAX_ORDER_NR_PAGES. Date: Thu, 5 Aug 2021 15:02:48 -0400 Message-Id: <20210805190253.2795604-11-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 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 205A1B000C0C Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=Ca99plPm; dkim=pass header.d=messagingengine.com header.s=fm3 header.b=AuCaNREa; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf19.hostedemail.com: domain of zi.yan@sent.com designates 66.111.4.229 as permitted sender) smtp.mailfrom=zi.yan@sent.com X-Stat-Signature: 8obzd8z46yk5mwb8kadz7ag317eaw55e X-HE-Tag: 1628190233-115508 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Zi Yan It keeps the existing behavior when MAX_ORDER grows beyond a section. Signed-off-by: Zi Yan Cc: "Michael S. Tsirkin" Cc: David Hildenbrand Cc: Jason Wang Cc: virtualization@lists.linux-foundation.org Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org --- drivers/virtio/virtio_balloon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index 47dce91f788c..de8d0355d827 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -36,7 +36,7 @@ #define VIRTIO_BALLOON_FREE_PAGE_ALLOC_FLAG (__GFP_NORETRY | __GFP_NOWARN | \ __GFP_NOMEMALLOC) /* The order of free page blocks to report to host */ -#define VIRTIO_BALLOON_HINT_BLOCK_ORDER (MAX_ORDER - 1) +#define VIRTIO_BALLOON_HINT_BLOCK_ORDER (PFN_SECTION_SHIFT - 1) /* The size of a free page block in bytes */ #define VIRTIO_BALLOON_HINT_BLOCK_BYTES \ (1 << (VIRTIO_BALLOON_HINT_BLOCK_ORDER + PAGE_SHIFT)) From patchwork Thu Aug 5 19:02:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 12421877 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4D40C43214 for ; Thu, 5 Aug 2021 19:04:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 574CA61040 for ; Thu, 5 Aug 2021 19:04:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 574CA61040 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=sent.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 5C8D26B0087; Thu, 5 Aug 2021 15:03:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5039C6B0089; Thu, 5 Aug 2021 15:03:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3A2DA6B0088; Thu, 5 Aug 2021 15:03:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0157.hostedemail.com [216.40.44.157]) by kanga.kvack.org (Postfix) with ESMTP id 115156B0085 for ; Thu, 5 Aug 2021 15:03:55 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id BEB76181AF5D7 for ; Thu, 5 Aug 2021 19:03:54 +0000 (UTC) X-FDA: 78441951588.26.6851290 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by imf03.hostedemail.com (Postfix) with ESMTP id 7C7C830025E3 for ; Thu, 5 Aug 2021 19:03:54 +0000 (UTC) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 3C87F5C0165; Thu, 5 Aug 2021 15:03:54 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 05 Aug 2021 15:03:54 -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=pTLuD9o+Rmmgy 0pSJ8qC8qZ3Ebj/NqVHsmXPx9g5Fxc=; b=Kp0Np0Hf0NGj5MD7k1hOtXahgTB13 XkazXI1X7daDaaQnyFKuYl2p4JTQsccsGu0BF42Nl0GFFccmD3nUkiSxYDa4ehD7 V9Fu2U/3KrbMx3oJDSBOZYKyogvAUZs1h2c+/KMelXJlnZiwMzrvSS8XieZOz2AV 29ylT0zTceUen8nFsV9HJwcwFaNTOBS5V6YUOJ+Su3dJUPfn+LojBBeG3VUHHyrB OtWaPS9djWWtKZGQc4kpHtq2OVi/mIQ6VJb81fq5aTjNKatRstc0t92zpKJabC+6 F0Fry3laq170IcGcO5wkkva9qJfGSFruj5TWWf615DTUjrIADTWfMlyiQ== 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=pTLuD9o+Rmmgy0pSJ8qC8qZ3Ebj/NqVHsmXPx9g5Fxc=; b=cn0whdGO Exf5LNe8JX9l3+KjfyixQahsDwaAeSwhUpwYKaKjoGWKm9OAflpKpOgF1/yvtKUv m+l5/51VPD9Te0/h6kIlC3Pm03XIwJV28R9rV4bSkFoYCTvHqqrRDVhvhLK85IK7 5i+1/Z+tUCG8ItxBlOtyyYFkU6FoRiK+S2Jk4qJgJmRkBh5gWEKZjODD658AhZo1 DyelFHJs5BGheZGhVxF4Lm2ZtDOebrEp3MGtvKoGW+6LmkZEC9RA9bRN8qbR1zFc d3mP+D48U6OtAA8RbvJqDYw53CfhGPoTTC39g0anAAU1a+gnbtxjAiox7ZWUx/u2 C1+4OSIoPuMGoA== 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:53 -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 Subject: [RFC PATCH 11/15] mm/page_reporting: report pages at section size instead of MAX_ORDER. Date: Thu, 5 Aug 2021 15:02:49 -0400 Message-Id: <20210805190253.2795604-12-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 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 7C7C830025E3 Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=Kp0Np0Hf; dkim=pass header.d=messagingengine.com header.s=fm3 header.b=cn0whdGO; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf03.hostedemail.com: domain of zi.yan@sent.com designates 66.111.4.26 as permitted sender) smtp.mailfrom=zi.yan@sent.com X-Stat-Signature: edxffd3npz7rhneprh7juneow7b51qtg X-HE-Tag: 1628190234-507474 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Zi Yan page_reporting_order was set to MAX_ORDER, which is always smaller than a memory section size. An upcoming change will make MAX_ORDER larger than a memory section size. Set page_reporting_order to PFN_SECTION_SHIFT to match existing size assumption. Signed-off-by: Zi Yan Cc: David Hildenbrand Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org --- mm/page_reporting.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/page_reporting.c b/mm/page_reporting.c index 382958eef8a9..dc4a2d699862 100644 --- a/mm/page_reporting.c +++ b/mm/page_reporting.c @@ -11,7 +11,8 @@ #include "page_reporting.h" #include "internal.h" -unsigned int page_reporting_order = MAX_ORDER; +/* Set page_reporting_order at section size */ +unsigned int page_reporting_order = PFN_SECTION_SHIFT; module_param(page_reporting_order, uint, 0644); MODULE_PARM_DESC(page_reporting_order, "Set page reporting order"); From patchwork Thu Aug 5 19:02:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 12421879 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D455C432BE for ; Thu, 5 Aug 2021 19:04:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3C9C560EEA for ; Thu, 5 Aug 2021 19:04:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3C9C560EEA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=sent.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 504706B0088; Thu, 5 Aug 2021 15:03:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 466686B0089; Thu, 5 Aug 2021 15:03:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 29CDA6B008A; Thu, 5 Aug 2021 15:03:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0101.hostedemail.com [216.40.44.101]) by kanga.kvack.org (Postfix) with ESMTP id 046AA6B0088 for ; Thu, 5 Aug 2021 15:03:55 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id ADF9D1801C656 for ; Thu, 5 Aug 2021 19:03:55 +0000 (UTC) X-FDA: 78441951630.27.1FBFFCF Received: from new3-smtp.messagingengine.com (new3-smtp.messagingengine.com [66.111.4.229]) by imf12.hostedemail.com (Postfix) with ESMTP id 68AB01000890 for ; Thu, 5 Aug 2021 19:03:55 +0000 (UTC) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.nyi.internal (Postfix) with ESMTP id 17EEE5810BB; Thu, 5 Aug 2021 15:03:55 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 05 Aug 2021 15:03:55 -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=orYSo+lwOeqVc rCXP6bMLdXhBxG79CHa8pLqvu93F90=; b=JLiPNY0alezfanhcEGypspe2ruEbc +S3RVW03KEkS07YejHfFIg6iCZiCQsu9h5DwzMb0jG/b0FrkS4c9Y/NdKeacdvTK 5IEMf1NOtxdyT73Rrqkne+wzqMExrCYGUhVRLM03HCgH5m3P+z644LCalPwbCIVm pRvg3/y4tHPT7QOKLXK7FYSnNes3rxiWEY2Fen+iycw4IPFF11hOpw2BCMjH5s6z h5CWBKWlUi+I5CIkqwWeoiOd5Brg/GLBCxFsUeeC1gqF3j1D29yY23T4ZAfbI2fn 9TUNpofZvkpjxrWCLsbmytqsxyFTB838/bJYc4+xyvgFCm88NUZWSPgqw== 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=orYSo+lwOeqVcrCXP6bMLdXhBxG79CHa8pLqvu93F90=; b=tvn74sNC FppmdcuF0YkjcIsFmOlGO1oUWpkEbiGuwrgia1EXDOKlIC/zLyaHOHfhbYtbhkWN 7g8yMwgdPehka5KZaWsaChTzPoZKaUEQj1pJxR/gAF+2F20xDi5lM8YPawRtracc QWoEsFmHsl199Ji6XBbG7EfaBsygOXf8YUMjjuymzwm1BOUVI1kFPP+vjzdxsBVL yqzrJZtkow5KsmlTgNLtGxS7UPkMG8UZhiFB+QFdtaZ6hceTPyMdsIRgdk94f6lc tuA3WgTCU4tme0WjeqbcAd9Nj178lT6Q7iAFqheIt/2/RpgDVTGcRrKUOq03SUNa Ib0cAzncyRmNKQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrieelgdduvdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfrhgggfestdhqredtredttdenucfhrhhomhepkghiucgj rghnuceoiihirdihrghnsehsvghnthdrtghomheqnecuggftrfgrthhtvghrnhepieejue dvueduuefhgefhheeiuedvtedvuefgieegveetueeiueehtdegudehfeelnecuvehluhhs thgvrhfuihiivgepfeenucfrrghrrghmpehmrghilhhfrhhomhepiihirdihrghnsehsvg hnthdrtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 5 Aug 2021 15:03:54 -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 , Kees Cook , Peter Zijlstra , Nicholas Piggin , Thomas Gleixner Subject: [RFC PATCH 12/15] mm: Make MAX_ORDER of buddy allocator configurable via Kconfig SET_MAX_ORDER. Date: Thu, 5 Aug 2021 15:02:50 -0400 Message-Id: <20210805190253.2795604-13-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 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 68AB01000890 Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=JLiPNY0a; dkim=pass header.d=messagingengine.com header.s=fm3 header.b=tvn74sNC; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf12.hostedemail.com: domain of zi.yan@sent.com designates 66.111.4.229 as permitted sender) smtp.mailfrom=zi.yan@sent.com X-Stat-Signature: zs9ghxry1cg5cmcb9eeqhfens9zk63s4 X-HE-Tag: 1628190235-668324 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Zi Yan With SPARSEMEM_VMEMMAP, all struct page are virtually contigous, thus kernel can manipulate arbitrarily large pages. By checking PFN validity during buddy page merging process, all free pages in buddy allocator's free area have their PFNs contiguous even if the system has several not physically contiguous memory sections. With these two conditions, it is OK to remove the restriction of MAX_ORDER - 1 + PAGE_SHIFT < SECTION_SIZE_BITS and change MAX_ORDER freely. Add SET_MAX_ORDER to allow MAX_ORDER adjustment when arch does not set its own MAX_ORDER via ARCH_FORCE_MAX_ORDER. Make it depend on SPARSEMEM_VMEMMAP, when MAX_ORDER is not limited by SECTION_SIZE_BITS. Signed-off-by: Zi Yan Cc: Kees Cook Cc: Peter Zijlstra Cc: Nicholas Piggin Cc: Thomas Gleixner Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org --- arch/Kconfig | 4 ++++ include/linux/mmzone.h | 14 +++++++++++++- mm/Kconfig | 16 ++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/arch/Kconfig b/arch/Kconfig index 01a3f8048cb7..40bd222adeb8 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -11,6 +11,10 @@ source "arch/$(SRCARCH)/Kconfig" menu "General architecture-dependent options" +config ARCH_FORCE_MAX_ORDER + int + default "0" + config CRASH_CORE bool diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 04f790ed81b7..322b995942e5 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -25,10 +25,14 @@ /* Free memory management - zoned buddy allocator. */ #ifndef CONFIG_ARCH_FORCE_MAX_ORDER +#ifdef CONFIG_SET_MAX_ORDER +#define MAX_ORDER CONFIG_SET_MAX_ORDER +#else #define MAX_ORDER 11 +#endif /* CONFIG_SET_MAX_ORDER */ #else #define MAX_ORDER CONFIG_ARCH_FORCE_MAX_ORDER -#endif +#endif /* CONFIG_ARCH_FORCE_MAX_ORDER */ #define MAX_ORDER_NR_PAGES (1 << (MAX_ORDER - 1)) /* @@ -1245,12 +1249,20 @@ static inline struct zoneref *first_zones_zonelist(struct zonelist *zonelist, #define SECTION_BLOCKFLAGS_BITS \ ((1UL << (PFN_SECTION_SHIFT - pageblock_order)) * NR_PAGEBLOCK_BITS) +/* + * The MAX_ORDER check is not necessary when CONFIG_SET_MAX_ORDER is set, since + * it depends on CONFIG_SPARSEMEM_VMEMMAP, where all struct page are virtually + * contiguous, thus > section size pages can be allocated and manipulated + * without worrying about non-contiguous struct page. + */ +#ifndef CONFIG_SET_MAX_ORDER /* NO_MAX_ORDER_CHECK when compiling x64 32bit VDSO for 64bit system */ #ifndef NO_MAX_ORDER_CHECK #if (MAX_ORDER - 1 + PAGE_SHIFT) > SECTION_SIZE_BITS #error Allocator MAX_ORDER exceeds SECTION_SIZE #endif #endif /* NO_MAX_ORDER_CHECK */ +#endif /* CONFIG_SET_MAX_ORDER*/ static inline unsigned long pfn_to_section_nr(unsigned long pfn) { diff --git a/mm/Kconfig b/mm/Kconfig index 1f9bd3371765..3a030b439501 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -89,6 +89,22 @@ config SPARSEMEM_VMEMMAP pfn_to_page and page_to_pfn operations. This is the most efficient option when sufficient kernel resources are available. +config SET_MAX_ORDER + int "Set maximum order of buddy allocator" + depends on SPARSEMEM_VMEMMAP && (ARCH_FORCE_MAX_ORDER = 0) + range 11 255 + default "11" + help + The kernel memory allocator divides physically contiguous memory + blocks into "zones", where each zone is a power of two number of + pages. This option selects the largest power of two that the kernel + keeps in the memory allocator. If you need to allocate very large + blocks of physically contiguous memory, then you may need to + increase this value. + + This config option is actually maximum order plus one. For example, + a value of 11 means that the largest free memory block is 2^10 pages. + config HAVE_MEMBLOCK_PHYS_MAP bool From patchwork Thu Aug 5 19:02:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 12421881 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8D96C4320E for ; Thu, 5 Aug 2021 19:04:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 46FC560EEA for ; Thu, 5 Aug 2021 19:04:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 46FC560EEA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=sent.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id AF7016B0089; Thu, 5 Aug 2021 15:03:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AA8446B008A; Thu, 5 Aug 2021 15:03:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 96FAE6B008C; Thu, 5 Aug 2021 15:03:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0254.hostedemail.com [216.40.44.254]) by kanga.kvack.org (Postfix) with ESMTP id 719A86B0089 for ; Thu, 5 Aug 2021 15:03:57 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 2306B184A1 for ; Thu, 5 Aug 2021 19:03:57 +0000 (UTC) X-FDA: 78441951714.05.324381A Received: from new3-smtp.messagingengine.com (new3-smtp.messagingengine.com [66.111.4.229]) by imf29.hostedemail.com (Postfix) with ESMTP id AE77F90025A9 for ; Thu, 5 Aug 2021 19:03:56 +0000 (UTC) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.nyi.internal (Postfix) with ESMTP id 5C6245810BE; Thu, 5 Aug 2021 15:03:56 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Thu, 05 Aug 2021 15:03:56 -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=qqGgbHXRUcfRW toLBCPkMjVwN6eMCgkKPzC+WcvJLH8=; b=kPK/AchY6vVGSniKXux/L1ociY3SK 3VayNDyUcM+qyWTmi1Sg14Kfs1DKeOVq/1mcLL7BONOp08v5uN4q3BHu6xllRR7Y eD7W37sOp9jNxVyqg+ljDyp69PUSHDgjW5NCjL2YDhUmK5LAEnY37ewZA534KusC tY1zFGE9dy0I0WNzaXOeqxwkDPyOnRMSyw+hDjsA88QtGleZVGzQSDnOFmovSuwt BwgM+Y9VfdlEUdzF3B9qyhUN1he9INkxT+ji6ULbYKxHLtKNRcFxZIY11i9QmjHX tUD0LGJJnNx8RcnEIlmccmxKdzlnlVxvaSVhqNFM0IMIeKZQLJtrzA4BQ== 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=qqGgbHXRUcfRWtoLBCPkMjVwN6eMCgkKPzC+WcvJLH8=; b=e1E8k7gD BBRbHXhlSwCKwUdYdF4wpV0rsNYSdkfjYnzK3V2FngJkorubBvbj3tEMHnwDjeDB xakzpLZDkQ9kuIgH3kfUPUKs6EUhNkHRDedkmIWJOj5GMrXysyOwTE0QZisKTujY Y4M0fTMIQZdpRFvLxbuRFgOVgjawHiKFWynTKGbhfv1hk55+VQilvIR1KqaSLpWK IdJ1BvbmfayKCug7Octg7s05cOLS40jwH8VzyhgAAwZ4irBQqDkw3ju+Pkb6DNKn IHxkZBdKkaufB9zV3vWbMhp1j67NsWuDZfJq4vwtULMa1JXBK8Ry4Fs8UP4M+ri0 67EYzF+MI1/syQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrieelgdduvdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfrhgggfestdhqredtredttdenucfhrhhomhepkghiucgj rghnuceoiihirdihrghnsehsvghnthdrtghomheqnecuggftrfgrthhtvghrnhepieejue dvueduuefhgefhheeiuedvtedvuefgieegveetueeiueehtdegudehfeelnecuvehluhhs thgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepiihirdihrghnsehsvg hnthdrtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 5 Aug 2021 15:03:55 -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 , Dave Young , Jonathan Corbet , Christian Koenig , David Airlie , kexec@lists.infradead.org, linux-doc@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [RFC PATCH 13/15] mm: convert MAX_ORDER sized static arrays to dynamic ones. Date: Thu, 5 Aug 2021 15:02:51 -0400 Message-Id: <20210805190253.2795604-14-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 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: AE77F90025A9 Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b="kPK/AchY"; dkim=pass header.d=messagingengine.com header.s=fm3 header.b=e1E8k7gD; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf29.hostedemail.com: domain of zi.yan@sent.com designates 66.111.4.229 as permitted sender) smtp.mailfrom=zi.yan@sent.com X-Stat-Signature: tdkqsfherb13j7biuh8drtmyzow7ixaf X-HE-Tag: 1628190236-778032 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Zi Yan This prepares for the upcoming changes to make MAX_ORDER a boot time parameter instead of compilation time constant. All static arrays with MAX_ORDER size are converted to pointers and their memory is allocated at runtime. free_area array in struct zone is allocated using memblock_alloc_node() at boot time and using kzalloc() when memory is hot-added. MAX_ORDER in arm64 nVHE code is independent of kernel buddy allocator, so use CONFIG_FORCE_MAX_ZONEORDER instead. Signed-off-by: Zi Yan Cc: Dave Young Cc: Jonathan Corbet Cc: Christian Koenig Cc: David Airlie Cc: kexec@lists.infradead.org Cc: linux-doc@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org --- .../admin-guide/kdump/vmcoreinfo.rst | 2 +- drivers/gpu/drm/ttm/ttm_device.c | 7 ++- drivers/gpu/drm/ttm/ttm_pool.c | 58 +++++++++++++++++-- include/drm/ttm/ttm_pool.h | 4 +- include/linux/memory_hotplug.h | 1 + include/linux/mmzone.h | 2 +- mm/memory_hotplug.c | 1 + mm/page_alloc.c | 48 ++++++++++++--- 8 files changed, 104 insertions(+), 19 deletions(-) diff --git a/Documentation/admin-guide/kdump/vmcoreinfo.rst b/Documentation/admin-guide/kdump/vmcoreinfo.rst index 3861a25faae1..1c9449b9458f 100644 --- a/Documentation/admin-guide/kdump/vmcoreinfo.rst +++ b/Documentation/admin-guide/kdump/vmcoreinfo.rst @@ -172,7 +172,7 @@ variables. Offset of the free_list's member. This value is used to compute the number of free pages. -Each zone has a free_area structure array called free_area[MAX_ORDER]. +Each zone has a free_area structure array called free_area with length of MAX_ORDER. The free_list represents a linked list of free page blocks. (list_head, next|prev) diff --git a/drivers/gpu/drm/ttm/ttm_device.c b/drivers/gpu/drm/ttm/ttm_device.c index 74e3b460132b..7d994c03fbd0 100644 --- a/drivers/gpu/drm/ttm/ttm_device.c +++ b/drivers/gpu/drm/ttm/ttm_device.c @@ -94,7 +94,9 @@ static int ttm_global_init(void) >> PAGE_SHIFT; num_dma32 = min(num_dma32, 2UL << (30 - PAGE_SHIFT)); - ttm_pool_mgr_init(num_pages); + ret = ttm_pool_mgr_init(num_pages); + if (ret) + goto out; ttm_tt_mgr_init(num_pages, num_dma32); glob->dummy_read_page = alloc_page(__GFP_ZERO | GFP_DMA32); @@ -216,7 +218,8 @@ int ttm_device_init(struct ttm_device *bdev, struct ttm_device_funcs *funcs, bdev->funcs = funcs; ttm_sys_man_init(bdev); - ttm_pool_init(&bdev->pool, dev, use_dma_alloc, use_dma32); + if (ttm_pool_init(&bdev->pool, dev, use_dma_alloc, use_dma32)) + return -ENOMEM; bdev->vma_manager = vma_manager; INIT_DELAYED_WORK(&bdev->wq, ttm_device_delayed_workqueue); diff --git a/drivers/gpu/drm/ttm/ttm_pool.c b/drivers/gpu/drm/ttm/ttm_pool.c index cb38b1a17b09..ae20c80f14a4 100644 --- a/drivers/gpu/drm/ttm/ttm_pool.c +++ b/drivers/gpu/drm/ttm/ttm_pool.c @@ -64,11 +64,11 @@ module_param(page_pool_size, ulong, 0644); static atomic_long_t allocated_pages; -static struct ttm_pool_type global_write_combined[MAX_ORDER]; -static struct ttm_pool_type global_uncached[MAX_ORDER]; +static struct ttm_pool_type *global_write_combined; +static struct ttm_pool_type *global_uncached; -static struct ttm_pool_type global_dma32_write_combined[MAX_ORDER]; -static struct ttm_pool_type global_dma32_uncached[MAX_ORDER]; +static struct ttm_pool_type *global_dma32_write_combined; +static struct ttm_pool_type *global_dma32_uncached; static struct mutex shrinker_lock; static struct list_head shrinker_list; @@ -493,8 +493,10 @@ EXPORT_SYMBOL(ttm_pool_free); * @use_dma32: true if GFP_DMA32 should be used * * Initialize the pool and its pool types. + * + * Returns: 0 on successe, negative error code otherwise */ -void ttm_pool_init(struct ttm_pool *pool, struct device *dev, +int ttm_pool_init(struct ttm_pool *pool, struct device *dev, bool use_dma_alloc, bool use_dma32) { unsigned int i, j; @@ -506,11 +508,30 @@ void ttm_pool_init(struct ttm_pool *pool, struct device *dev, pool->use_dma32 = use_dma32; if (use_dma_alloc) { - for (i = 0; i < TTM_NUM_CACHING_TYPES; ++i) + for (i = 0; i < TTM_NUM_CACHING_TYPES; ++i) { + pool->caching[i].orders = + kzalloc(sizeof(struct ttm_pool_type) * MAX_ORDER, + GFP_KERNEL); + if (!pool->caching[i].orders) { + i--; + goto failed; + } for (j = 0; j < MAX_ORDER; ++j) ttm_pool_type_init(&pool->caching[i].orders[j], pool, i, j); + + } + return 0; + +failed: + for (; i >= 0; i--) { + for (j = 0; j < MAX_ORDER; ++j) + ttm_pool_type_fini(&pool->caching[i].orders[j]); + kfree(pool->caching[i].orders); + } + return -ENOMEM; } + return 0; } /** @@ -696,6 +717,31 @@ int ttm_pool_mgr_init(unsigned long num_pages) mutex_init(&shrinker_lock); INIT_LIST_HEAD(&shrinker_list); + if (!global_write_combined) { + global_write_combined = kzalloc(sizeof(struct ttm_pool_type) * MAX_ORDER, + GFP_KERNEL); + if (!global_write_combined) + return -ENOMEM; + } + if (!global_uncached) { + global_uncached = kzalloc(sizeof(struct ttm_pool_type) * MAX_ORDER, + GFP_KERNEL); + if (!global_uncached) + return -ENOMEM; + } + if (!global_dma32_write_combined) { + global_dma32_write_combined = kzalloc(sizeof(struct ttm_pool_type) * MAX_ORDER, + GFP_KERNEL); + if (!global_dma32_write_combined) + return -ENOMEM; + } + if (!global_dma32_uncached) { + global_dma32_uncached = kzalloc(sizeof(struct ttm_pool_type) * MAX_ORDER, + GFP_KERNEL); + if (!global_dma32_uncached) + return -ENOMEM; + } + for (i = 0; i < MAX_ORDER; ++i) { ttm_pool_type_init(&global_write_combined[i], NULL, ttm_write_combined, i); diff --git a/include/drm/ttm/ttm_pool.h b/include/drm/ttm/ttm_pool.h index 4321728bdd11..5c09e3cf63ce 100644 --- a/include/drm/ttm/ttm_pool.h +++ b/include/drm/ttm/ttm_pool.h @@ -71,7 +71,7 @@ struct ttm_pool { bool use_dma32; struct { - struct ttm_pool_type orders[MAX_ORDER]; + struct ttm_pool_type *orders; } caching[TTM_NUM_CACHING_TYPES]; }; @@ -79,7 +79,7 @@ int ttm_pool_alloc(struct ttm_pool *pool, struct ttm_tt *tt, struct ttm_operation_ctx *ctx); void ttm_pool_free(struct ttm_pool *pool, struct ttm_tt *tt); -void ttm_pool_init(struct ttm_pool *pool, struct device *dev, +int ttm_pool_init(struct ttm_pool *pool, struct device *dev, bool use_dma_alloc, bool use_dma32); void ttm_pool_fini(struct ttm_pool *pool); diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index 97f874a60607..c16aa66db61e 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -326,6 +326,7 @@ extern void clear_zone_contiguous(struct zone *zone); #ifdef CONFIG_MEMORY_HOTPLUG extern void __ref free_area_init_core_hotplug(int nid); +extern void __ref free_area_deinit_core_hotplug(int nid); extern int __add_memory(int nid, u64 start, u64 size, mhp_t mhp_flags); extern int add_memory(int nid, u64 start, u64 size, mhp_t mhp_flags); extern int add_memory_resource(int nid, struct resource *resource, diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 322b995942e5..09aafc05aef4 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -609,7 +609,7 @@ struct zone { ZONE_PADDING(_pad1_) /* free areas of different sizes */ - struct free_area free_area[MAX_ORDER]; + struct free_area *free_area; /* zone flags, see below */ unsigned long flags; diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 91ca751ac20c..4ce20b6482aa 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1239,6 +1239,7 @@ static void rollback_node_hotadd(int nid) arch_refresh_nodedata(nid, NULL); free_percpu(pgdat->per_cpu_nodestats); + free_area_deinit_core_hotplug(nid); arch_free_nodedata(pgdat); } diff --git a/mm/page_alloc.c b/mm/page_alloc.c index e4657009fd4f..bfa6962f7615 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6053,11 +6053,21 @@ void show_free_areas(unsigned int filter, nodemask_t *nodemask) for_each_populated_zone(zone) { unsigned int order; - unsigned long nr[MAX_ORDER], flags, total = 0; - unsigned char types[MAX_ORDER]; + unsigned long *nr, flags, total = 0; + unsigned char *types; if (show_mem_node_skip(filter, zone_to_nid(zone), nodemask)) continue; + + nr = kmalloc(sizeof(unsigned long) * MAX_ORDER, GFP_KERNEL); + if (!nr) + goto skip_zone; + types = kmalloc(sizeof(unsigned char) * MAX_ORDER, GFP_KERNEL); + if (!types) { + kfree(nr); + goto skip_zone; + } + show_node(zone); printk(KERN_CONT "%s: ", zone->name); @@ -6083,8 +6093,11 @@ void show_free_areas(unsigned int filter, nodemask_t *nodemask) show_migration_types(types[order]); } printk(KERN_CONT "= %lukB\n", K(total)); - } + kfree(nr); + kfree(types); + } +skip_zone: hugetlb_show_meminfo(); printk("%ld total pagecache pages\n", global_node_page_state(NR_FILE_PAGES)); @@ -7429,8 +7442,8 @@ static void __meminit pgdat_init_internals(struct pglist_data *pgdat) lruvec_init(&pgdat->__lruvec); } -static void __meminit zone_init_internals(struct zone *zone, enum zone_type idx, int nid, - unsigned long remaining_pages) +static void __init zone_init_internals(struct zone *zone, enum zone_type idx, int nid, + unsigned long remaining_pages, bool hotplug) { atomic_long_set(&zone->managed_pages, remaining_pages); zone_set_nid(zone, nid); @@ -7439,6 +7452,16 @@ static void __meminit zone_init_internals(struct zone *zone, enum zone_type idx, spin_lock_init(&zone->lock); zone_seqlock_init(zone); zone_pcp_init(zone); + if (hotplug) + zone->free_area = + kzalloc_node(sizeof(struct free_area) * MAX_ORDER, + GFP_KERNEL, nid); + else + zone->free_area = + memblock_alloc_node(sizeof(struct free_area) * MAX_ORDER, + sizeof(struct free_area), nid); + BUG_ON(!zone->free_area); + } /* @@ -7456,7 +7479,18 @@ void __ref free_area_init_core_hotplug(int nid) pgdat_init_internals(pgdat); for (z = 0; z < MAX_NR_ZONES; z++) - zone_init_internals(&pgdat->node_zones[z], z, nid, 0); + zone_init_internals(&pgdat->node_zones[z], z, nid, 0, true); +} + +void __ref free_area_deinit_core_hotplug(int nid) +{ + enum zone_type z; + pg_data_t *pgdat = NODE_DATA(nid); + + for (z = 0; z < MAX_NR_ZONES; z++) { + kfree(pgdat->node_zones[z].free_area); + pgdat->node_zones[z].free_area = NULL; + } } #endif @@ -7519,7 +7553,7 @@ static void __init free_area_init_core(struct pglist_data *pgdat) * when the bootmem allocator frees pages into the buddy system. * And all highmem pages will be managed by the buddy system. */ - zone_init_internals(zone, j, nid, freesize); + zone_init_internals(zone, j, nid, freesize, false); if (!size) continue; From patchwork Thu Aug 5 19:02:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 12421883 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 439D4C4338F for ; Thu, 5 Aug 2021 19:04:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DD61060EEA for ; Thu, 5 Aug 2021 19:04:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DD61060EEA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=sent.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 614D46B008A; Thu, 5 Aug 2021 15:03:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 59DB26B0092; Thu, 5 Aug 2021 15:03:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4427A8D0001; Thu, 5 Aug 2021 15:03:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0018.hostedemail.com [216.40.44.18]) by kanga.kvack.org (Postfix) with ESMTP id 244236B008A for ; Thu, 5 Aug 2021 15:03:58 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id D1CAC24886 for ; Thu, 5 Aug 2021 19:03:57 +0000 (UTC) X-FDA: 78441951714.27.1F78DFC Received: from new3-smtp.messagingengine.com (new3-smtp.messagingengine.com [66.111.4.229]) by imf07.hostedemail.com (Postfix) with ESMTP id 929C71001BF4 for ; Thu, 5 Aug 2021 19:03:57 +0000 (UTC) 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 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 929C71001BF4 Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=Ryn5X3bX; dkim=pass header.d=messagingengine.com header.s=fm3 header.b=HjLaHum4; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf07.hostedemail.com: domain of zi.yan@sent.com designates 66.111.4.229 as permitted sender) smtp.mailfrom=zi.yan@sent.com X-Stat-Signature: b4f4dara31uncyb1nkn6sgixasn1j98k X-HE-Tag: 1628190237-917205 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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/include/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, unsigned int nr_pages, int i; hyp_spin_lock_init(&pool->lock); - pool->max_order = min(MAX_ORDER, get_order(nr_pages << PAGE_SHIFT)); + + pool->max_order = min(MIN_MAX_ORDER, get_order(nr_pages << PAGE_SHIFT)); for (i = 0; i < pool->max_order; i++) INIT_LIST_HEAD(&pool->free_area[i]); pool->range_start = 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)) 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) <= 25 ? \ - (MAX_ORDER + PAGE_SHIFT - 1) : 25) +#define KMALLOC_SHIFT_HIGH ((MIN_MAX_ORDER + PAGE_SHIFT - 1) <= 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 = slab_max_order < 0 ? 0 : - min(slab_max_order, MAX_ORDER - 1); + min(slab_max_order, MIN_MAX_ORDER - 1); slab_max_order_set = true; 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 = slab_order(size, 1, MAX_ORDER, 1); - if (order < MAX_ORDER) + + order = 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=", setup_slub_min_order); static int __init setup_slub_max_order(char *str) { get_option(&str, (int *)&slub_max_order); - slub_max_order = min(slub_max_order, (unsigned int)MAX_ORDER - 1); + slub_max_order = min(slub_max_order, (unsigned int)MIN_MAX_ORDER - 1); return 1; } From patchwork Thu Aug 5 19:02:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 12421885 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 537A5C4338F for ; Thu, 5 Aug 2021 19:04:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0825560EEA for ; Thu, 5 Aug 2021 19:04:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0825560EEA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=sent.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 5F6D06B0093; Thu, 5 Aug 2021 15:04:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5A11F8D0001; Thu, 5 Aug 2021 15:04:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 441446B0096; Thu, 5 Aug 2021 15:04:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0252.hostedemail.com [216.40.44.252]) by kanga.kvack.org (Postfix) with ESMTP id 24C5A6B0093 for ; Thu, 5 Aug 2021 15:04:01 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id CF12422873 for ; Thu, 5 Aug 2021 19:04:00 +0000 (UTC) X-FDA: 78441951840.29.2C5754D Received: from new3-smtp.messagingengine.com (new3-smtp.messagingengine.com [66.111.4.229]) by imf30.hostedemail.com (Postfix) with ESMTP id 63DBEE00307C for ; Thu, 5 Aug 2021 19:03:58 +0000 (UTC) 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 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 63DBEE00307C Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=JyLRlPZX; dkim=pass header.d=messagingengine.com header.s=fm3 header.b=B5FDGE67; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf30.hostedemail.com: domain of zi.yan@sent.com designates 66.111.4.229 as permitted sender) smtp.mailfrom=zi.yan@sent.com X-Stat-Signature: sfedhku6cib7ox5f1f7kfe1r4kg3b5a4 X-HE-Tag: 1628190238-609089 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 >= 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/Documentation/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= See Documentation/admin-guide/media/bttv.rst bttv.tuner= + buddy_alloc_max_order= [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=off [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 = count; order = pindex_to_order(pindex); - BUILD_BUG_ON(MAX_ORDER >= (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);