From mboxrd@z Thu Jan 1 00:00:00 1970 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=-3.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 762BAC2BA1A for ; Tue, 7 Apr 2020 03:06:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3A5A920801 for ; Tue, 7 Apr 2020 03:06:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="x/E8EZ9B" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3A5A920801 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DD7688E003C; Mon, 6 Apr 2020 23:06:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D60DE8E0001; Mon, 6 Apr 2020 23:06:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C4F2A8E003C; Mon, 6 Apr 2020 23:06:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0078.hostedemail.com [216.40.44.78]) by kanga.kvack.org (Postfix) with ESMTP id A77548E0001 for ; Mon, 6 Apr 2020 23:06:52 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 69D5A181AEF31 for ; Tue, 7 Apr 2020 03:06:52 +0000 (UTC) X-FDA: 76679571864.13.spoon17_762c218e2e83a X-HE-Tag: spoon17_762c218e2e83a X-Filterd-Recvd-Size: 5245 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf09.hostedemail.com (Postfix) with ESMTP for ; Tue, 7 Apr 2020 03:06:51 +0000 (UTC) Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D1173214DB; Tue, 7 Apr 2020 03:06:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586228811; bh=hIGQ7n54sxNIkM333NIICoIFcps4D/MlOHp/FF1K1pQ=; h=Date:From:To:Subject:In-Reply-To:From; b=x/E8EZ9BOjV/sPHTYrwUTitDcxhm8ARr5vUA4UdOKRDH6EhUSloiu4N7V4WYTraiE hFTHYvnhF+Xaa8F+dXBsL0RaRU2VPzztmeb9deTiceQc8Db4bUXq0uDD604JU/ERrt RnLXc3GqVSKEZgxNUuoL5J9vy/fdoY2gOizHk238= Date: Mon, 06 Apr 2020 20:06:50 -0700 From: Andrew Morton To: akpm@linux-foundation.org, bhe@redhat.com, bsingharora@gmail.com, david@redhat.com, jgross@suse.com, linux-mm@kvack.org, mhocko@suse.com, mingo@kernel.org, mm-commits@vger.kernel.org, torvalds@linux-foundation.org, william.kucharski@oracle.com Subject: [patch 055/166] mm/memory_hotplug.c: only respect mem= parameter during boot stage Message-ID: <20200407030650.ZaaSb2Cv0%akpm@linux-foundation.org> In-Reply-To: <20200406200254.a69ebd9e08c4074e41ddebaf@linux-foundation.org> User-Agent: s-nail v14.8.16 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: Baoquan He Subject: mm/memory_hotplug.c: only respect mem= parameter during boot stage In commit 357b4da50a62 ("x86: respect memory size limiting via mem= parameter") a global varialbe max_mem_size is added to store the value parsed from 'mem= ', then checked when memory region is added. This truly stops those DIMMs from being added into system memory during boot-time. However, it also limits the later memory hotplug functionality. Any DIMM can't be hotplugged any more if its region is beyond the max_mem_size. We will get errors like: [ 216.387164] acpi PNP0C80:02: add_memory failed [ 216.389301] acpi PNP0C80:02: acpi_memory_enable_device() error [ 216.392187] acpi PNP0C80:02: Enumeration failure This will cause issue in a known use case where 'mem=' is added to the hypervisor. The memory that lies after 'mem=' boundary will be assigned to KVM guests. After commit 357b4da50a62 merged, memory can't be extended dynamically if system memory on hypervisor is not sufficient. So fix it by also checking if it's during boot-time restricting to add memory. Otherwise, skip the restriction. And also add this use case to document of 'mem=' kernel parameter. Link: http://lkml.kernel.org/r/20200204050643.20925-1-bhe@redhat.com Fixes: 357b4da50a62 ("x86: respect memory size limiting via mem= parameter") Signed-off-by: Baoquan He Reviewed-by: Juergen Gross Acked-by: Michal Hocko Cc: Ingo Molnar Cc: William Kucharski Cc: David Hildenbrand Cc: Balbir Singh Signed-off-by: Andrew Morton --- Documentation/admin-guide/kernel-parameters.txt | 13 +++++++++++-- mm/memory_hotplug.c | 8 +++++++- 2 files changed, 18 insertions(+), 3 deletions(-) --- a/Documentation/admin-guide/kernel-parameters.txt~mm-hotplug-only-respect-mem=-parameter-during-boot-stage +++ a/Documentation/admin-guide/kernel-parameters.txt @@ -2573,13 +2573,22 @@ For details see: Documentation/admin-guide/hw-vuln/mds.rst mem=nn[KMG] [KNL,BOOT] Force usage of a specific amount of memory - Amount of memory to be used when the kernel is not able - to see the whole system memory or for test. + Amount of memory to be used in cases as follows: + + 1 for test; + 2 when the kernel is not able to see the whole system memory; + 3 memory that lies after 'mem=' boundary is excluded from + the hypervisor, then assigned to KVM guests. + [X86] Work as limiting max address. Use together with memmap= to avoid physical address space collisions. Without memmap= PCI devices could be placed at addresses belonging to unused RAM. + Note that this only takes effects during boot time since + in above case 3, memory may need be hot added after boot + if system memory of hypervisor is not sufficient. + mem=nopentium [BUGS=X86-32] Disable usage of 4MB pages for kernel memory. --- a/mm/memory_hotplug.c~mm-hotplug-only-respect-mem=-parameter-during-boot-stage +++ a/mm/memory_hotplug.c @@ -105,7 +105,13 @@ static struct resource *register_memory_ unsigned long flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; char *resource_name = "System RAM"; - if (start + size > max_mem_size) + /* + * Make sure value parsed from 'mem=' only restricts memory adding + * while booting, so that memory hotplug won't be impacted. Please + * refer to document of 'mem=' in kernel-parameters.txt for more + * details. + */ + if (start + size > max_mem_size && system_state < SYSTEM_RUNNING) return ERR_PTR(-E2BIG); /* _