Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5134353ybl; Tue, 10 Dec 2019 00:46:28 -0800 (PST) X-Google-Smtp-Source: APXvYqxscyEtv6y1mih2pJglDD/+hNro485Ax9NrVFg8q/Y17hymRM9d2jACoDTW4D0JzxuuuLj8 X-Received: by 2002:aca:54cc:: with SMTP id i195mr2918034oib.126.1575967588011; Tue, 10 Dec 2019 00:46:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575967588; cv=none; d=google.com; s=arc-20160816; b=nVC6BgD73P2b6u/QSVTmsrCWefCfaovqG0uCSMscey8IWXBfKNZwAtMtb4tGlWeMP1 hMmvPzshlooHku1Z8i/kvicpPAvEo1ZsKjAQHfuDrOVkGdxgbrY/kJk90lt8S41vUUod NNsEv6QGFV2FTkHkZXq9oLldV0Dy0jxLEnD58PAcccH5nV01MSikP2/hb7fnJGIFnhlE gNkzRyKBsoZAjNzl6+K0YL/6NYoq84KijHT4P2QOP1KodYVezXOtw32VrHDdZ1wE2Iv9 NEUAjavdS8eDSzX0eWNgiIZNzrdEshVTdYqpNgIr1VjKP7QrPLhznm6DOCq9rOWgFc64 tCWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:message-id:date :subject:cc:to:from:dkim-signature; bh=85iuBCTeUInaX84Dg3t6InbKz06LRvBV1i1vwBmGbVM=; b=rvrgkSh4/P9nq9XqzGF6vYEcjWpV8FfFnqf/wR6oGi63vJGFa+12+4GYu83axhA6LS ilh4M2JC9NY5vGudM53k+U806emw2Y+JWcpVJ6MLF5a8PyRqCp+m+XBnPzo7yenzhNvW uYQFLCKJgVgWg2YfMHqSF6kl9ioufLwjrxXe3DzaJAfjcbEiEo5Vmgmt05NDpbg3BDCA Z3H1tm3yAoV8vU/Z57q3OKzn+RQ6APNI4D3X7WfZYwtdSqGx3S5RE3NQPe9PX7lJpnMT VPI83hHu9Xu5MDQbnG5/9JXKsZR8DqQI9Ffs2ae0ISruy44RwutN+0FSYO8p4VajjX6k mLMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hhYnPCAG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l16si1541003otr.106.2019.12.10.00.46.14; Tue, 10 Dec 2019 00:46:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hhYnPCAG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726949AbfLJIo0 (ORCPT + 99 others); Tue, 10 Dec 2019 03:44:26 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:49406 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726750AbfLJIo0 (ORCPT ); Tue, 10 Dec 2019 03:44:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575967465; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=85iuBCTeUInaX84Dg3t6InbKz06LRvBV1i1vwBmGbVM=; b=hhYnPCAGLTr8DMa2DXs0f6rdYdtmlwaGe0qfBoDpaFMGB/E2sfS6L1+gM7JvZJlecuM/iv pHUF+vaWaEGGUeEnyLSGTU9k9KTunJzaASvRqMTFbA33E9+y1Tb1ehmvEXrXbhrUJ/M5Qq n39OSxZiqbIF/2X4UoMbBmkB6yeze6w= 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-328-kGjaGIe6MWKsbAXT11_fOw-1; Tue, 10 Dec 2019 03:44:22 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 88E9A189DF5E; Tue, 10 Dec 2019 08:44:20 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-38.pek2.redhat.com [10.72.12.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2FD0360BF3; Tue, 10 Dec 2019 08:44:14 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, mhocko@kernel.org, david@redhat.com, jgross@suse.com, akpm@linux-foundation.org, bhe@redhat.com Subject: [Patch v2] mm/hotplug: Only respect mem= parameter during boot stage Date: Tue, 10 Dec 2019 16:44:13 +0800 Message-Id: <20191210084413.21957-1-bhe@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: kGjaGIe6MWKsbAXT11_fOw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In commit 357b4da50a62 ("x86: respect memory size limiting via mem=3D parameter") a global varialbe global max_mem_size is added to store the value parsed from 'mem=3D ', then checked when memory region is added. This truly stops those DIMM from being added into system memory during boot-time. However, it also limits the later memory hotplug functionality. Any memory board can't be hot added any more if its region is beyond the max_mem_size. System will print error like below: [ 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 From document of 'mem=3D ' parameter, it should be a restriction during boot, but not impact the system memory adding/removing after booting. mem=3Dnn[KMG] [KNL,BOOT] Force usage of a specific amount of memory =09 ... So fix it by also checking if it's during boot-time when restrict memory adding. Otherwise, skip the restriction. Fixes: 357b4da50a62 ("x86: respect memory size limiting via mem=3D paramete= r") Signed-off-by: Baoquan He --- mm/memory_hotplug.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 55ac23ef11c1..989707295d15 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -105,7 +105,11 @@ static struct resource *register_memory_resource(u64 s= tart, u64 size) =09unsigned long flags =3D IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; =09char *resource_name =3D "System RAM"; =20 -=09if (start + size > max_mem_size) +=09/* +=09 * Make sure value parsed from 'mem=3D' only restricts memory adding +=09 * during boot-time, so that memory hotplug won't be impacted. +=09 */ +=09if (start + size > max_mem_size && system_state < SYSTEM_RUNNING) =09=09return ERR_PTR(-E2BIG); =20 =09/* --=20 2.17.2