From patchwork Tue Feb 4 05:06:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 11363993 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ECAAA139A for ; Tue, 4 Feb 2020 05:06:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AF21A2166E for ; Tue, 4 Feb 2020 05:06:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="T2ad0Ht9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AF21A2166E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CDCC56B0003; Tue, 4 Feb 2020 00:06:57 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C8DA86B0005; Tue, 4 Feb 2020 00:06:57 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BA2ED6B0006; Tue, 4 Feb 2020 00:06:57 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0200.hostedemail.com [216.40.44.200]) by kanga.kvack.org (Postfix) with ESMTP id 9E8886B0003 for ; Tue, 4 Feb 2020 00:06:57 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 40AB3181AEF1A for ; Tue, 4 Feb 2020 05:06:57 +0000 (UTC) X-FDA: 76451260074.19.blow88_76d3ddb42e21b X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,bhe@redhat.com,:linux-kernel@vger.kernel.org::akpm@linux-foundation.org:mhocko@kernel.org:david@redhat.com:jgross@suse.com:bsingharora@gmail.com,RULES_HIT:30003:30005:30012:30054:30070:30074:30090,0,RBL:207.211.31.81:@redhat.com:.lbl8.mailshell.net-62.18.0.100 66.10.201.10,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ft,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: blow88_76d3ddb42e21b X-Filterd-Recvd-Size: 5424 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Tue, 4 Feb 2020 05:06:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580792815; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=77aFIeWZ6g7NaVIYQN/nFVqyjpYjPXX41AYEjCL1ybk=; b=T2ad0Ht9nbpBk3+sOleVFlJT2ERzNXk1rGXe4RyY0sHP97pfmmygT8YtgX5r4khxN3umUM ogf0olEiyAxpU4ObHQqMLZeCTElrd1LbMGgDUOYcr06UrNfYY/sHIMklGzas/sWl3z097R F6q5KIVgBCdHjjOr1iFkUhxvKhL6dvM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-61-4xlkwQ1bMKSfm9fi0BiRng-1; Tue, 04 Feb 2020 00:06:51 -0500 X-MC-Unique: 4xlkwQ1bMKSfm9fi0BiRng-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3ABE48018A3; Tue, 4 Feb 2020 05:06:50 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-129.pek2.redhat.com [10.72.13.129]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D8F38E9E5; Tue, 4 Feb 2020 05:06:44 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, mhocko@kernel.org, david@redhat.com, jgross@suse.com, bsingharora@gmail.com Subject: [PATCH v3] mm/hotplug: Only respect mem= parameter during boot stage Date: Tue, 4 Feb 2020 13:06:43 +0800 Message-Id: <20200204050643.20925-1-bhe@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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: 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. Fixes: 357b4da50a62 ("x86: respect memory size limiting via mem= parameter") Signed-off-by: Baoquan He Reviewed-by: Juergen Gross Acked-by: Michal Hocko --- v2->v3: In discussion of v1 and v2, People have concern about the use case related to the code change. So add the use case into patch log and document of 'mem=' in kernel-parameters.txt. Documentation/admin-guide/kernel-parameters.txt | 13 +++++++++++-- mm/memory_hotplug.c | 8 +++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index ddc5ccdd4cd1..b809767e5f74 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -2533,13 +2533,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. diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 36d80915ddc2..e6c75ceacf9a 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -105,7 +105,13 @@ static struct resource *register_memory_resource(u64 start, u64 size) 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); /*