Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp241617pxb; Fri, 16 Apr 2021 04:39:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRrEx+9/lcZ7Byrl0mWrrQikxFNQwY2AX06h2eROjpi2Xv5+DKQYvW6JNaEmO6i4D96PyV X-Received: by 2002:aa7:c1c8:: with SMTP id d8mr9452100edp.236.1618573189957; Fri, 16 Apr 2021 04:39:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618573189; cv=none; d=google.com; s=arc-20160816; b=n1oF9FcSRcG5JRRKDsUXxgiPAXeKJ/cNmdd1Ndzj5tOwyrNq1JXN2NKPUiEABTUL8/ zNFKdpM4MiGo2+7huI8GGnqqfIFUq72fyD367uwL7tzcpvSwN7tTAcYEln/76z+Cr02E z1OYSA/0oHWyENsTgmLhWffA5wcflkxsa1VhNVOqjzXEflUmLpeDwEFZNPa4JRxI567p hOQOIzElGVSUASUafB+T4x3A8qpnxfFv87ahsYOEJUAvViFeyptrk1dsFAyjsKQ2x6ci kiigrz//Pk8mqMYJ1VbOVi8TUaTqsUsC5FZaUBje+AJv1u8yAhH0Cc/gwvPgTAVkCELa n0zw== 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=QrYYNmrq8FLaTY1ZgRTCMQXVLL6mwPhVsup3SkbtbHM=; b=olx3SKluJ15Vex4fi+qnMI4krH06b21UhA9AxjlcrGWAk9l3QZMBkOqHDdhbSA7Ynx jR8buVIYJ18AYaV6LKADDIfgRd5esGmXvOF7jMoJXDl9fP0LuxG0AAmPFjGAdQP4JNCY LQiKu+75G3xMPg9MDztJHenQAaC9TgDoNTVHQYg8iWiOXqD9jZqXg5rjvI+iHRq7CKOi ngcUgj/TouHPEkmDh+c372jrIew/N5K47NEcu8DO2Y+Wxq3P7xc/i5eJU3nPC27laB6m SKacnQe+/rx2LMqH5VpVi6jyquEd5Q0eHBO6whZUd53puLRTN6Cs3Wz9WukChQ5JWHRV i0PA== 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 t4si4466586ejs.517.2021.04.16.04.39.26; Fri, 16 Apr 2021 04:39:49 -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 S242590AbhDPLZD (ORCPT + 99 others); Fri, 16 Apr 2021 07:25:03 -0400 Received: from mx2.suse.de ([195.135.220.15]:48650 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241949AbhDPLYv (ORCPT ); Fri, 16 Apr 2021 07:24:51 -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 B58CBB01F; Fri, 16 Apr 2021 11:24:26 +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 v9 6/8] mm,memory_hotplug: Add kernel boot option to enable memmap_on_memory Date: Fri, 16 Apr 2021 13:24:09 +0200 Message-Id: <20210416112411.9826-7-osalvador@suse.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210416112411.9826-1-osalvador@suse.de> References: <20210416112411.9826-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 5ef626926449..b93949a84d4a 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