Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp142249pxf; Tue, 6 Apr 2021 17:33:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNVfj1msSJ+aQvAqbJG9krf6mI4nQfGpuwm4y/6tXUXCHgAEeU6ViqPMz1v+ft2+nNn4JP X-Received: by 2002:a05:6602:2156:: with SMTP id y22mr441170ioy.10.1617755632278; Tue, 06 Apr 2021 17:33:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617755632; cv=none; d=google.com; s=arc-20160816; b=cVoC2d61GTVy2h0rqyMpTC6G8vMhvswOR9Y4Wb8ZOi9hTtodXJBo7U043bOZOuCPXk fIcKYGegwTcZ26b5n7eZukSuQ99uK3Ixnu8gbh7HTsyauuFFn9CeGBrnzw/YjH8LtzvM UofZwhwA4DHs23lbHwAHyOudqyv/udFAxMZSpCcgDhYWhMWY++IyLPTQ9IjnD/fgBtE3 38g1sslfrL+k5l4rvfCbyH4mxH/BArnqVz29/34ubAOMTV90f/541RHdal6teDa3UZmG FeI4cTWPrWbPj/x2MLZgSGBNDClWLwidBhEjG0dq73IFp6Es8Ffj+4NLvPxhzYLXMICD 0t4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=gUHmdxbEfQi798UoBnaL+v3+tgCkPokES2LtU4J48mg=; b=zUOBN0VBFEPNiTEJlLUs+X3Kr++n5uwv/AagVdsyT/OAXebD5DPgBlZ75Hum12SmhD MysFBdse5GW17D0eYGOM5wOFjsaKOiRxTAhxYTSICyWJ5Ppidp61OcxVs9foE3pcqO02 ejA80McK/6Q6e4sC9AMiZ4efDLbKBvoBWNDgFG5yyOi5kH0qXumi5CmRWfD8u4QLBaKJ W6YjMOf6+cYu0GZ9zdmbnY6d+CoDbPrrAxCaKo5I6ay1hegQWWqgCBNkPJRTM5+BLsRn NVBxTkmxitNNOvGB44NeYB4fv5iHpRL50xJuATE1OCa7qqDO1rpwLr4tal0aojVTUel3 QhJA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k9si19189496jap.68.2021.04.06.17.33.14; Tue, 06 Apr 2021 17:33:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245405AbhDFLME (ORCPT + 99 others); Tue, 6 Apr 2021 07:12:04 -0400 Received: from mx2.suse.de ([195.135.220.15]:49826 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234279AbhDFLLk (ORCPT ); Tue, 6 Apr 2021 07:11:40 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 4C876B163; Tue, 6 Apr 2021 11:11:29 +0000 (UTC) From: Oscar Salvador To: Andrew Morton Cc: David Hildenbrand , Michal Hocko , Anshuman Khandual , Pavel Tatashin , Vlastimil Babka , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador , Michal Hocko Subject: [PATCH v6 6/8] mm,memory_hotplug: Add kernel boot option to enable memmap_on_memory Date: Tue, 6 Apr 2021 13:11:13 +0200 Message-Id: <20210406111115.8953-7-osalvador@suse.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210406111115.8953-1-osalvador@suse.de> References: <20210406111115.8953-1-osalvador@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Self stored memmap leads to a sparse memory situation which is unsuitable for workloads that requires large contiguous memory chunks, so make this an opt-in which needs to be explicitly enabled. To control this, let memory_hotplug have its own memory space, as suggested by David, so we can add memory_hotplug.memmap_on_memory parameter. Signed-off-by: Oscar Salvador Reviewed-by: David Hildenbrand Acked-by: Michal Hocko --- Documentation/admin-guide/kernel-parameters.txt | 17 +++++++++++++++++ mm/Makefile | 5 ++++- mm/memory_hotplug.c | 10 +++++++++- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 04545725f187..af32c17cd4eb 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -2794,6 +2794,23 @@ seconds. Use this parameter to check at some other rate. 0 disables periodic checking. + memory_hotplug.memmap_on_memory + [KNL,X86,ARM] Boolean flag to enable this feature. + Format: {on | off (default)} + When enabled, runtime hotplugged memory will + allocate its internal metadata (struct pages) + from the hotadded memory which will allow to + hotadd a lot of memory without requiring + additional memory to do so. + This feature is disabled by default because it + has some implication on large (e.g. GB) + allocations in some configurations (e.g. small + memory blocks). + The state of the flag can be read in + /sys/module/memory_hotplug/parameters/memmap_on_memory. + Note that even when enabled, there are a few cases where + the feature is not effective. + memtest= [KNL,X86,ARM,PPC] Enable memtest Format: default : 0 diff --git a/mm/Makefile b/mm/Makefile index 72227b24a616..82ae9482f5e3 100644 --- a/mm/Makefile +++ b/mm/Makefile @@ -58,9 +58,13 @@ obj-y := filemap.o mempool.o oom_kill.o fadvise.o \ page-alloc-y := page_alloc.o page-alloc-$(CONFIG_SHUFFLE_PAGE_ALLOCATOR) += shuffle.o +# Give 'memory_hotplug' its own module-parameter namespace +memory-hotplug-$(CONFIG_MEMORY_HOTPLUG) += memory_hotplug.o + obj-y += page-alloc.o obj-y += init-mm.o obj-y += memblock.o +obj-y += $(memory-hotplug-y) ifdef CONFIG_MMU obj-$(CONFIG_ADVISE_SYSCALLS) += madvise.o @@ -83,7 +87,6 @@ obj-$(CONFIG_SLUB) += slub.o obj-$(CONFIG_KASAN) += kasan/ obj-$(CONFIG_KFENCE) += kfence/ obj-$(CONFIG_FAILSLAB) += failslab.o -obj-$(CONFIG_MEMORY_HOTPLUG) += memory_hotplug.o obj-$(CONFIG_MEMTEST) += memtest.o obj-$(CONFIG_MIGRATION) += migrate.o obj-$(CONFIG_TRANSPARENT_HUGEPAGE) += huge_memory.o khugepaged.o diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 43f0daf922e6..5cecc3a7d5a5 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -42,7 +42,15 @@ #include "internal.h" #include "shuffle.h" -static bool memmap_on_memory; + +/* + * memory_hotplug.memmap_on_memory parameter + */ +static bool memmap_on_memory __ro_after_init; +#ifdef CONFIG_MHP_MEMMAP_ON_MEMORY +module_param(memmap_on_memory, bool, 0444); +MODULE_PARM_DESC(memmap_on_memory, "Enable memmap on memory for memory hotplug"); +#endif /* * online_page_callback contains pointer to current page onlining function. -- 2.16.3