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=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham 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 DE777C43603 for ; Mon, 9 Dec 2019 11:08:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A044C207FF for ; Mon, 9 Dec 2019 11:08:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A044C207FF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4ED4F6B2658; Mon, 9 Dec 2019 06:08:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 49E446B2659; Mon, 9 Dec 2019 06:08:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3B4206B265A; Mon, 9 Dec 2019 06:08:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0206.hostedemail.com [216.40.44.206]) by kanga.kvack.org (Postfix) with ESMTP id 282056B2658 for ; Mon, 9 Dec 2019 06:08:53 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id B7624180AD802 for ; Mon, 9 Dec 2019 11:08:52 +0000 (UTC) X-FDA: 76245330504.25.bread38_6a8d96de02259 X-HE-Tag: bread38_6a8d96de02259 X-Filterd-Recvd-Size: 5797 Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Mon, 9 Dec 2019 11:08:52 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 7F531AEEC; Mon, 9 Dec 2019 11:08:50 +0000 (UTC) Subject: Re: [PATCH] mm/hotplug: Only respect mem= parameter during boot stage To: David Hildenbrand , Michal Hocko , Baoquan He Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, william.kucharski@oracle.com, mingo@kernel.org, akpm@linux-foundation.org References: <20191206150524.14687-1-bhe@redhat.com> <20191209100717.GC6156@dhcp22.suse.cz> <7fc610be-df56-c5ae-33fb-53b471aa76d1@suse.com> <94aead35-1541-6c1a-d172-70dc613410c2@redhat.com> From: =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= Message-ID: <1089517e-4454-be5e-1320-7f246c4efefe@suse.com> Date: Mon, 9 Dec 2019 12:08:49 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.1 MIME-Version: 1.0 In-Reply-To: <94aead35-1541-6c1a-d172-70dc613410c2@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable 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: On 09.12.19 12:01, David Hildenbrand wrote: > On 09.12.19 11:24, J=C3=BCrgen Gro=C3=9F wrote: >> On 09.12.19 11:07, Michal Hocko wrote: >>> On Fri 06-12-19 23:05:24, Baoquan He wrote: >>>> 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 which is parsed from 'mem=3D '. This truly stops those >>>> DIMM from being added into system memory during boot. >>>> >>>> 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 du= ring >>>> boot, but not impact the system memory adding/removing after booting= . >>>> >>>> mem=3Dnn[KMG] [KNL,BOOT] Force usage of a specific amount of= memory >>>> >>>> So fix it by also checking if it's during SYSTEM_BOOTING stage when >>>> restrict memory adding. Otherwise, skip the restriction. >>> >>> Could you be more specific about why the boot vs. later hotplug makes >>> any difference? The documentation is explicit about the boot time but >>> considering this seems to be like that since ever I strongly suspect >>> that this is just an omission. >>> >>> Btw. how have you tested the situation fixed by 357b4da50a62? >> >> I guess he hasn't. >> >> The backtrace of the problem at that time was: >> >> [ 8321.876844] [] dump_trace+0x59/0x340 >> [ 8321.882683] [] show_stack_log_lvl+0xea/0x170 >> [ 8321.889298] [] show_stack+0x21/0x40 >> [ 8321.895043] [] dump_stack+0x5c/0x7c >> [ 8321.900779] [] warn_slowpath_common+0x81/0xb0 >> [ 8321.907482] [] xen_alloc_pte+0x1d4/0x390 >> [ 8321.913718] [] >> pmd_populate_kernel.constprop.6+0x40/0x80 >> [ 8321.921498] [] phys_pmd_init+0x210/0x255 >> [ 8321.927724] [] phys_pud_init+0x1da/0x247 >> [ 8321.933951] [] kernel_physical_mapping_init+0xf5= /0x1d4 >> [ 8321.941533] [] init_memory_mapping+0x18d/0x380 >> [ 8321.948341] [] arch_add_memory+0x59/0xf0 >> [ 8321.954570] [] add_memory_resource+0x8d/0x160 >> [ 8321.961283] [] add_memory+0x32/0xf0 >> [ 8321.967025] [] acpi_memory_device_add+0x131/0x2e= 0 >> [ 8321.974128] [] acpi_bus_attach+0xe2/0x190 >> [ 8321.980453] [] acpi_bus_attach+0x5e/0x190 >> [ 8321.986778] [] acpi_bus_attach+0x5e/0x190 >> [ 8321.993103] [] acpi_bus_attach+0x5e/0x190 >> [ 8321.999428] [] acpi_bus_scan+0x37/0x70 >> [ 8322.005461] [] acpi_scan_init+0x77/0x1b4 >> [ 8322.011690] [] acpi_init+0x297/0x2b3 >> [ 8322.017530] [] do_one_initcall+0xca/0x1f0 >> [ 8322.023855] [] kernel_init_freeable+0x194/0x226 >> [ 8322.030760] [] kernel_init+0xa/0xe0 >> [ 8322.036503] [] ret_from_fork+0x55/0x80 >> >> So this patch would break it again. >> >> I'd recommend ... >> >>> >>>> Fixes: 357b4da50a62 ("x86: respect memory size limiting via mem=3D p= arameter") >>>> Signed-off-by: Baoquan He >>>> --- >>>> mm/memory_hotplug.c | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c >>>> index 55ac23ef11c1..5466a0a00901 100644 >>>> --- a/mm/memory_hotplug.c >>>> +++ b/mm/memory_hotplug.c >>>> @@ -105,7 +105,7 @@ static struct resource *register_memory_resource= (u64 start, u64 size) >>>> unsigned long flags =3D IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY= ; >>>> char *resource_name =3D "System RAM"; >>>> =20 >>>> - if (start + size > max_mem_size) >>>> + if (start + size > max_mem_size && system_state =3D=3D SYSTEM_BOOT= ING) >> >> ... changing this to: ... && system_state !=3D SYSTEM_RUNNING >=20 > I think we usually use system_state < SYSTEM_RUNNING >=20 Works for me as well. :-) Juergen