Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp307520pxy; Wed, 21 Apr 2021 03:36:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVXGVjX/wZImhYVp9pROFkrb46DuX/PwbP/D/QQwpZUsa2CijeKYWARspkNEt+bFV27xXh X-Received: by 2002:a17:906:3e97:: with SMTP id a23mr32506578ejj.440.1619001371829; Wed, 21 Apr 2021 03:36:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619001371; cv=none; d=google.com; s=arc-20160816; b=UnZBF0Myj7hS9OfXqzKRSMCBf6ZwD08z9/N8VETWBnvqS+EVDo2KswHbFWLN0GOp11 jgfsH04pNmCjo2JWoR0VqkgKFqRP3zTtU7e5oNHwBihmv2WQ8wK72+8M7+Wv385BA6lP +tny6D7sF2pg+QgfuDLz0G1ETacfcmrR6ZNP5LVW8t3lK3SqjfDtsE6/qI4mU3rrHTlS gIL12n3iO0ByG9fwdqxOIYfE4WmMKAWOxMH+oj6H3fLKcriBfYzUNZ7pc64DQMC7V3Yv SyrQTP3J1yB32lFhcZxKSZPXn5OXfbRTETgYoPudnP0WIrD65VEcQCuZTIXZpq5UI9mB 0FKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=Lk+HdHpxvlMU5R/lNHsMcZyg0TGCTmbwm63kRusTV30=; b=KROpubKG0NzvuLVzbBNmwS09gWq2EXymW+cflhVWWJGq5zS/hiwr1MsDqAqqs0w3S4 I1o5q4BcQytIzb49Sm4OTeBBbMe8pQaFyPP/T+XS+OMGDJYnZXs7VA82M26uYGp1Keum oCP2elzaYB+lFitLhBGh4Q6iGI+fDGSu79XScwmU4sQc6UW7UcWTaWBFp9znwdgI+dFH 9FPgwmQijG5lakIU2R2vlmzSd4Z9RlvE9QD19N/EOzNexdm+N7gZ40PnUxYQIupLM9zY ZiINa3ChmOVrZtgd3tHehMAw81w2AfzwK/7rgna50oVMD33sVp6R2a2ex/sPJe3ZlgB4 K/cQ== 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 r3si1476114edx.603.2021.04.21.03.35.48; Wed, 21 Apr 2021 03:36:11 -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 S239453AbhDUK2G (ORCPT + 99 others); Wed, 21 Apr 2021 06:28:06 -0400 Received: from mx2.suse.de ([195.135.220.15]:38094 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239292AbhDUK1o (ORCPT ); Wed, 21 Apr 2021 06:27:44 -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 76BEDB2D6; Wed, 21 Apr 2021 10:27:10 +0000 (UTC) From: Oscar Salvador To: Andrew Morton Cc: David Hildenbrand , Michal Hocko , Anshuman Khandual , Vlastimil Babka , Pavel Tatashin , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador Subject: [PATCH v10 6/8] mm,memory_hotplug: Add kernel boot option to enable memmap_on_memory Date: Wed, 21 Apr 2021 12:26:59 +0200 Message-Id: <20210421102701.25051-7-osalvador@suse.de> X-Mailer: git-send-email 2.13.7 In-Reply-To: <20210421102701.25051-1-osalvador@suse.de> References: <20210421102701.25051-1-osalvador@suse.de> 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 d2de1fab75e2..e39db4321f71 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