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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88740C001DC for ; Wed, 26 Jul 2023 13:08:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E98A56B0071; Wed, 26 Jul 2023 09:08:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E48736B0072; Wed, 26 Jul 2023 09:08:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D100F6B0074; Wed, 26 Jul 2023 09:08:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C202E6B0071 for ; Wed, 26 Jul 2023 09:08:30 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 29B231A02A1 for ; Wed, 26 Jul 2023 13:08:30 +0000 (UTC) X-FDA: 81053791980.26.353B896 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf29.hostedemail.com (Postfix) with ESMTP id 416E9120034 for ; Wed, 26 Jul 2023 13:08:25 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Ye9OdI5E; spf=pass (imf29.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690376906; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=avrBEUTuEMAIDicd1OwUA012koY+T/4dTdNNwPp3WGw=; b=f1WT49QHbK2YRMyJeOpdhuPOi/+XHRyFX4TxhE/9USyPQOM9n+PuFdd4qpQhQW2tiMnLS7 IczBfiI2aBYovKwZyFjdQNWM+1kWbfuL2MS2eT4lEbMcffppDUvuOpVsilB7UYBBd6YdDu l3uSE0DtduFf/KGaq6fzn69/1cxRX3Q= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690376906; a=rsa-sha256; cv=none; b=NHRDXCvXcg5FmxEkWS+9grZsn4pLleo7k0dSzqHw36+fZlbhc8l5ZOmSQZCUxnKjNYRpwn PJMs9np4oET+kVmvxLL7dPwUP9tQ9vfKfOxLJKhVBblLooEVxayPDBFXdDciEISTJxuLlq S7whFyrgQjzTM8Ra1u93L0AYrjL5t8o= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Ye9OdI5E; spf=pass (imf29.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690376905; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=avrBEUTuEMAIDicd1OwUA012koY+T/4dTdNNwPp3WGw=; b=Ye9OdI5EA43pf8Grwd3qSdMX/ps60UPAzU1e74LlDpf6AKhMkQAYyF3z06C96lDGZc05cg 8rqlqO3uZOwuaJ8g2mwSXyXVoYPWSVysbtpRBTFGOBW+a2V1scBQABpWCXTlW/vmHzM+JS Wj0MxSpMrzUgDU7v4Bz/V1f4pWwgUjs= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-336-JxQPgtyvNEelfhVMaONUXg-1; Wed, 26 Jul 2023 09:08:24 -0400 X-MC-Unique: JxQPgtyvNEelfhVMaONUXg-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-316f24a72e8so3940377f8f.1 for ; Wed, 26 Jul 2023 06:08:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690376903; x=1690981703; h=content-transfer-encoding:in-reply-to:organization:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=avrBEUTuEMAIDicd1OwUA012koY+T/4dTdNNwPp3WGw=; b=iYjABWEbUce7+8T2ikCwn6KwJyvwMaLRVsgE2T2m46sn5M0/asHwA2RQUvDHnd8alh iWS8mHkOCqYmONoAFuEog6jt6BHP8EqyR7mOUccvK2/SHMx3+e/mzQCrNod88XtKiGzL sF40D1dAc2LVDC/0OXcE5UCJrYFvfSvK4EoPIfCgabSxwv4EeEvUymFC2M07FrZ1qr2k CAOCk6vWYQ5rWmQvbX9k3+NbZAhkAiLfLSYZ7GL8ZdfHa/JgsWT5PxCwCjzt1MxbLI23 JqFVp2bf2cn7Q0eyyiQxukeOb/xfu8iQ1JEz7zqVg9VjYm7O+hF2M2e9cqz5qeLlBsRQ NlXA== X-Gm-Message-State: ABy/qLafHx+eMh3VPHpU9Wuv5FW1YGyYGnDoYl7YJtLUM4zV/3TVYH9X J1bVDn6MI837DIAc4RoV4SeayXXhMGNFNfF33unYQGKwO0cx/yuFrPWxYJeF8/TuNc8i8SfMgkG fQNEU0cS3foc= X-Received: by 2002:adf:ec4d:0:b0:313:ecd3:7167 with SMTP id w13-20020adfec4d000000b00313ecd37167mr1273680wrn.42.1690376902867; Wed, 26 Jul 2023 06:08:22 -0700 (PDT) X-Google-Smtp-Source: APBJJlHUkIfUehug4Ptv1ARzzTssnb/6d+JMTWFEK0q14fqtkTNQ62TNbqeKlGg8UAoh56+n2Q/6iQ== X-Received: by 2002:adf:ec4d:0:b0:313:ecd3:7167 with SMTP id w13-20020adfec4d000000b00313ecd37167mr1273668wrn.42.1690376902441; Wed, 26 Jul 2023 06:08:22 -0700 (PDT) Received: from ?IPV6:2003:cb:c705:f600:a519:c50:799b:f1e3? (p200300cbc705f600a5190c50799bf1e3.dip0.t-ipconnect.de. [2003:cb:c705:f600:a519:c50:799b:f1e3]) by smtp.gmail.com with ESMTPSA id q13-20020adff94d000000b003143c9beeaesm19932371wrr.44.2023.07.26.06.08.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 26 Jul 2023 06:08:21 -0700 (PDT) Message-ID: Date: Wed, 26 Jul 2023 15:08:20 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: collision between ZONE_MOVABLE and memblock allocations From: David Hildenbrand To: Ross Zwisler , Michal Hocko Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Mike Rapoport , Andrew Morton , Matthew Wilcox , Mel Gorman , Vlastimil Babka References: <20230718220106.GA3117638@google.com> <20230719224821.GC3528218@google.com> <9ef757dc-da4b-9fa1-de84-1328a74f18a7@redhat.com> Organization: Red Hat In-Reply-To: <9ef757dc-da4b-9fa1-de84-1328a74f18a7@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 416E9120034 X-Rspam-User: X-Stat-Signature: 9s5csw1u8rz9webbaq98a1yes4pq5xsc X-Rspamd-Server: rspam03 X-HE-Tag: 1690376905-73027 X-HE-Meta: U2FsdGVkX19LwbFyxDDON3qVXfJPWSPqnausW7j99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MQi1wG1knlmrhfVpyONf1WQrIMeX6EwLU22LSZEeJRpfQwp7EkvCv66wYbz4SQ1PO1LPoW1SlSFywgour3yW9+GT9Zi0SCN2dKS9ezm0HPy3wDInlQkvA6rKZE+m/EFcLz/m7UynF7V+y54PTlLmNUx/JG+eIBkGBqW51q/nATWYhMA73jjqXH2PJOABNGFVhOdG428YmI2DxYRGXNyJx7YBzCkFs3XuE1/Bpo+yXHzG+2kr9QEogD/PQ+uDi2af0kT/jlZDL9DF6kVMWBu/2gn5BmXp82MV0J46UtdN+UkS8hW4E= 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 26.07.23 10:44, David Hildenbrand wrote: > On 20.07.23 00:48, Ross Zwisler wrote: >> On Wed, Jul 19, 2023 at 08:14:48AM +0200, Michal Hocko wrote: >>> On Tue 18-07-23 16:01:06, Ross Zwisler wrote: >>> [...] >>>> I do think that we need to fix this collision between ZONE_MOVABLE and memmap >>>> allocations, because this issue essentially makes the movablecore= kernel >>>> command line parameter useless in many cases, as the ZONE_MOVABLE region it >>>> creates will often actually be unmovable. >>> >>> movablecore is kinda hack and I would be more inclined to get rid of it >>> rather than build more into it. Could you be more specific about your >>> use case? >> >> The problem that I'm trying to solve is that I'd like to be able to get kernel >> core dumps off machines (chromebooks) so that we can debug crashes. Because >> the memory used by the crash kernel ("crashkernel=" kernel command line >> option) is consumed the entire time the machine is booted, there is a strong >> motivation to keep the crash kernel as small and as simple as possible. To >> this end I'm trying to get away without SSD drivers, not having to worry about >> encryption on the SSDs, etc. > > Okay, so you intend to keep the crashkernel area as small as possible. > >> >> So, the rough plan right now is: >> > 1) During boot set aside some memory that won't contain kernel > allocations. >> I'm trying to do this now with ZONE_MOVABLE, but I'm open to better ways. >> >> We set aside memory for a crash kernel & arm it so that the ZONE_MOVABLE >> region (or whatever non-kernel region) will be set aside as PMEM in the crash >> kernel. This is done with the memmap=nn[KMG]!ss[KMG] kernel command line >> parameter passed to the crash kernel. >> >> So, in my sample 4G VM system, I see: >> >> # lsmem --split ZONES --output-all >> RANGE SIZE STATE REMOVABLE BLOCK NODE ZONES >> 0x0000000000000000-0x0000000007ffffff 128M online yes 0 0 None >> 0x0000000008000000-0x00000000bfffffff 2.9G online yes 1-23 0 DMA32 >> 0x0000000100000000-0x000000012fffffff 768M online yes 32-37 0 Normal >> 0x0000000130000000-0x000000013fffffff 256M online yes 38-39 0 Movable >> >> Memory block size: 128M >> Total online memory: 4G >> Total offline memory: 0B >> >> so I'll pass "memmap=256M!0x130000000" to the crash kernel. >> >> 2) When we hit a kernel crash, we know (hope?) that the PMEM region we've set >> aside only contains user data, which we don't want to store anyway. > > I raised that in different context already, but such assumptions are not > 100% future proof IMHO. For example, we might at one point be able to > make user page tables movable and place them on there. > > But yes, most kernel data structures (which you care about) will > probably never be movable and never end up on these regions. > >> We make a >> filesystem in there, and create a kernel crash dump using 'makedumpfile': >> >> mkfs.ext4 /dev/pmem0 >> mount /dev/pmem0 /mnt >> makedumpfile -c -d 31 /proc/vmcore /mnt/kdump >> >> We then set up the next full kernel boot to also have this same PMEM region, >> using the same memmap kernel parameter. We reboot back into a full kernel. >> >> 3) The next full kernel will be a normal boot with a full networking stack, >> SSD drivers, disk encryption, etc. We mount up our PMEM filesystem, pull out >> the kdump and either store it somewhere persistent or upload it somewhere. We >> can then unmount the PMEM and reconfigure it back to system ram so that the >> live system isn't missing memory. >> >> ndctl create-namespace --reconfig=namespace0.0 -m devdax -f >> daxctl reconfigure-device --mode=system-ram dax0.0 >> >> This is the flow I'm trying to support, and have mostly working in a VM, >> except up until now makedumpfile would crash because all the memblock >> structures it needed were in the PMEM area that I had just wiped out by making >> a new filesystem. :) > > > Thinking out loud (and remembering that some architectures relocate the > crashkernel during kexec, if I am not wrong), maybe the following would > also work and make your setup eventually easier: > > 1) Don't reserve a crashkernel area in the traditional way, instead > reserve that area using CMA. It can be used for MOVABLE allocations. > > 2) Let kexec load the crashkernel+initrd into ordinary memory only > (consuming as much as you would need there). Oh, I realized that one might be able to place the kernel+initrd directly in the area by allocating via CMA. -- Cheers, David / dhildenb