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 B607FD75BB3 for ; Thu, 21 Nov 2024 04:30:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 22F206B007B; Wed, 20 Nov 2024 23:30:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1DE7D6B0083; Wed, 20 Nov 2024 23:30:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0CDC36B0085; Wed, 20 Nov 2024 23:30:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id E414A6B007B for ; Wed, 20 Nov 2024 23:30:48 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 8344A40CEE for ; Thu, 21 Nov 2024 04:30:48 +0000 (UTC) X-FDA: 82808824980.23.7EB929B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf05.hostedemail.com (Postfix) with ESMTP id A2B2B100003 for ; Thu, 21 Nov 2024 04:29:07 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=J84psK8r; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf05.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732163354; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=1oRBVeUrG/30shRvr2+oS14u3aaQZd0tcZcIHNfuOZU=; b=MGJ9l9ktAMLgaBPkLJ4mKysKSLjMvIe3XcWkjA4RbjADKc1UvtAtwpReH1j4yNTuOkJMEx oVT6CKJkQ1ED69lVCKU7MTrjtTWvtkG66KBpAvljH5dL2mK1aCrqQbJJMq3Mmum1KryW6m LKpG9lrQEbB6PvyVLdz7a2YCDjjMui4= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=J84psK8r; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf05.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732163354; a=rsa-sha256; cv=none; b=Hmgbv8VnUKAZD9tcNR+Y8UpFPgeeNRI4x+JcBdYVLE8oeA/kVwdsPnv/Nr/T/aAKH32Yzx 5RwdadZfxuBfi9pa9Ri1jdqit6ENHppLd0kwKMkm4cu/klAHT9DApEyBp75NJaJWF13/cP pKXznYzchB995RHPYfnHZY6CbSURmfI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732163446; 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: in-reply-to:in-reply-to:references:references; bh=1oRBVeUrG/30shRvr2+oS14u3aaQZd0tcZcIHNfuOZU=; b=J84psK8riUgehvtC098BWXxDIKfhlN1i2qATQHVQSpkuoloJH/F3l1h6jjhJmDAu2mhX0X T9DILwqHsqE1HMRGAurauBE/ieh01vavzKcsQPpa6vynE06J5VASr7UYhmXFFnw/n5rwJK gIKpAV8BF9wpPhMVkTMkZlmaoqQmGv0= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-250-vNatiTkcPDWezXWdS3a--g-1; Wed, 20 Nov 2024 23:30:42 -0500 X-MC-Unique: vNatiTkcPDWezXWdS3a--g-1 X-Mimecast-MFC-AGG-ID: vNatiTkcPDWezXWdS3a--g Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 89EE219560B1; Thu, 21 Nov 2024 04:30:39 +0000 (UTC) Received: from localhost (unknown [10.72.113.10]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 361E81956086; Thu, 21 Nov 2024 04:30:36 +0000 (UTC) Date: Thu, 21 Nov 2024 12:30:32 +0800 From: Baoquan He To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-s390@vger.kernel.org, virtualization@lists.linux.dev, kvm@vger.kernel.org, linux-fsdevel@vger.kernel.org, kexec@lists.infradead.org, Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , Eugenio =?iso-8859-1?Q?P=E9rez?= , Vivek Goyal , Dave Young , Thomas Huth , Cornelia Huck , Janosch Frank , Claudio Imbrenda , Eric Farman , Andrew Morton Subject: Re: [PATCH v1 07/11] fs/proc/vmcore: introduce PROC_VMCORE_DEVICE_RAM to detect device RAM ranges in 2nd kernel Message-ID: References: <20241025151134.1275575-1-david@redhat.com> <20241025151134.1275575-8-david@redhat.com> <4b07a3eb-aad6-4436-9591-289c6504bb92@redhat.com> <3ed18ba1-e4b1-461e-a3a7-5de2df59ca60@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3ed18ba1-e4b1-461e-a3a7-5de2df59ca60@redhat.com> X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: A2B2B100003 X-Stat-Signature: ubda1pcuagh397ttcmxonicr5j3by7ai X-HE-Tag: 1732163347-894746 X-HE-Meta: U2FsdGVkX1+FeB+PNXWvGaYLayHrPluWDDNQ30uTrOjEn6Fcc0+qSJPCZ7tSzZBZR3mg+NoHCLM4nxr5rggn46fKZGQTklcMiQDSMmAx5/sRQbfS8UC3GUrDukLfIX3gRb6sAh/z7nHItVKPaqDI1AtWBXMsoxkupL5SmbeI8oGZT2yo5AgKza8VLKnOrpUhr5GrOhoSQDxkVapNgJyw1ND/Bzs6+IBWC1MnzCB7UofxcvjTzFg68E2PsGYWL0rgLuqo3l6u73DrXm2Vn9KTD/lCEIJf/gsNpdwTq+Ah7h77OW02q+OeCBHC/kfxCr0PpaAzHbvx+0Yq0Lcp7WL4Y1LJVEf9jn8gtG41A67bSOu1mgbalL9IVnNr6NmFIuPJCwNrRFkEmEpLGy6DoqeL1xlwiQcwyExRrcdgNpeV1RoBR9Dfl/yA+RnhjTZdq96ha9WJDMyR9AJcxsVbSzcpT9UmJrEViZHKZUgP0yXz0UUcl/wFZM2gs2hCiAcqjsHTzqUf1eneOHTDAqPkZoUSd8mJ9791zFpqmX/CEDH3DetNpYFRZUE0j4coLYNgysuZzZgoj0uf5dt2uF4iblCthRrSmzD4RzJbbCmVkMPD5XQKhgxWiSkn7K94/E9LRdxXA+yTingoesi0MIhZGyqwhuDWi2RSUx8rzXT2M2FKBrOiHcVnTbYG2cIKyuVN3bQj2zVfPx3FTS+XhOj5jEG8ipk+eAAIx1feax6Pn0CjiyRlkWeFfv+eFO5XIv99GRdtfd/7wffb9+5xZjKUXozICzicFIXtheVIoOAZu0gpo78oVwmXKOyVh+rjP0EfTdXhWeLQ/rBm05XxBbIW1tOnRCxjY3fG7p3MGzXs3933sSxigP9Q8+hbfdITyOvEfUr4FIxHakDf0Oe8dld3ZqM6dVZs6UO5msIKON63hHFb/SJHlPwu1rC6aAxcS+jFfvhDsmpe4Q/Bw1rbIckBldN fyARL5PV 1ohG5RbXsYMoPu5j51dSe7Kn4Iq29UJGlUcCTVJk9EMZ0OJpEZ8AYegFQdq4fRdDsmP/W0af+wh/kmhWDB3ZUJ1lbAsIU9uauWIKLfh+UH9dXkpdVDioNcdGsvSuHc6M6YYgSKSRjKCUl0ruRDeKw+05nU5WwnYTPs60dzQz530DtnKWhMESYGrkR2L8UTaCPFahZexyvJfVFVYTsnw7FgKWAJYCDS8QLrzI3oxlr7pikMOrycScyFt8AhkadT2lcGEcEbtJeKptiuhByhx98CD3kdNs8DN/VFHIESjZg22KAlXcfdmV5cgtnhaI/azuhm5sdRELoh6PA6HVbEarX2/U1oojN+HlTun/8fxZNNdUBAtH40/+uY5ZirNCo9L6jcv9cP+yezRBARN5PhwRk4207tuybcRJNux2yx0rNcV7rpmg= 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: List-Subscribe: List-Unsubscribe: On 11/20/24 at 03:39pm, David Hildenbrand wrote: > On 20.11.24 15:05, Baoquan He wrote: > > On 11/20/24 at 11:48am, David Hildenbrand wrote: > > > On 20.11.24 11:13, Baoquan He wrote: > > > > On 10/25/24 at 05:11pm, David Hildenbrand wrote: > > > > > s390 allocates+prepares the elfcore hdr in the dump (2nd) kernel, not in > > > > > the crashed kernel. > > > > > > > > > > RAM provided by memory devices such as virtio-mem can only be detected > > > > > using the device driver; when vmcore_init() is called, these device > > > > > drivers are usually not loaded yet, or the devices did not get probed > > > > > yet. Consequently, on s390 these RAM ranges will not be included in > > > > > the crash dump, which makes the dump partially corrupt and is > > > > > unfortunate. > > > > > > > > > > Instead of deferring the vmcore_init() call, to an (unclear?) later point, > > > > > let's reuse the vmcore_cb infrastructure to obtain device RAM ranges as > > > > > the device drivers probe the device and get access to this information. > > > > > > > > > > Then, we'll add these ranges to the vmcore, adding more PT_LOAD > > > > > entries and updating the offsets+vmcore size. > > > > > > > > > > Use Kconfig tricks to include this code automatically only if (a) there is > > > > > a device driver compiled that implements the callback > > > > > (PROVIDE_PROC_VMCORE_DEVICE_RAM) and; (b) the architecture actually needs > > > > > this information (NEED_PROC_VMCORE_DEVICE_RAM). > > > > > > > > > > The current target use case is s390, which only creates an elf64 > > > > > elfcore, so focusing on elf64 is sufficient. > > > > > > > > > > Signed-off-by: David Hildenbrand > > > > > --- > > > > > fs/proc/Kconfig | 25 ++++++ > > > > > fs/proc/vmcore.c | 156 +++++++++++++++++++++++++++++++++++++ > > > > > include/linux/crash_dump.h | 9 +++ > > > > > 3 files changed, 190 insertions(+) > > > > > > > > > > diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig > > > > > index d80a1431ef7b..1e11de5f9380 100644 > > > > > --- a/fs/proc/Kconfig > > > > > +++ b/fs/proc/Kconfig > > > > > @@ -61,6 +61,31 @@ config PROC_VMCORE_DEVICE_DUMP > > > > > as ELF notes to /proc/vmcore. You can still disable device > > > > > dump using the kernel command line option 'novmcoredd'. > > > > > +config PROVIDE_PROC_VMCORE_DEVICE_RAM > > > > > + def_bool n > > > > > + > > > > > +config NEED_PROC_VMCORE_DEVICE_RAM > > > > > + def_bool n > > > > > + > > > > > +config PROC_VMCORE_DEVICE_RAM > > > > > + def_bool y > > > > > + depends on PROC_VMCORE > > > > > + depends on NEED_PROC_VMCORE_DEVICE_RAM > > > > > + depends on PROVIDE_PROC_VMCORE_DEVICE_RAM > > > > > > > > Kconfig item is always a thing I need learn to master. > > > > > > Yes, it's usually a struggle to get it right. It took me a couple of > > > iterations to get to this point :) > > > > > > > When I checked > > > > this part, I have to write them down to deliberate. I am wondering if > > > > below 'simple version' works too and more understandable. Please help > > > > point out what I have missed. > > > > > > > > ===========simple version====== > > > > config PROC_VMCORE_DEVICE_RAM > > > > def_bool y > > > > depends on PROC_VMCORE && VIRTIO_MEM > > > > depends on NEED_PROC_VMCORE_DEVICE_RAM > > > > > > > > config S390 > > > > select NEED_PROC_VMCORE_DEVICE_RAM > > > > ============ > > > > Sorry, things written down didn't correctly reflect them in my mind. > > > > ===========simple version====== > > fs/proc/Kconfig: > > config PROC_VMCORE_DEVICE_RAM > > def_bool y > > depends on PROC_VMCORE && VIRTIO_MEM > > depends on NEED_PROC_VMCORE_DEVICE_RAM > > config NEED_PROC_VMCORE_DEVICE_RAM > > def y > > > > arch/s390/Kconfig: > > config NEED_PROC_VMCORE_DEVICE_RAM > > def y > > ================================== > > That would work, but I don't completely like it. > > (a) I want s390x to select NEED_PROC_VMCORE_DEVICE_RAM instead. Staring at a > bunch of similar cases (git grep "config NEED" | grep Kconfig, git grep > "config ARCH_WANTS" | grep Kconfig), "select" is the common way to do it. > > So unless there is a pretty good reason, I'll keep > NEED_PROC_VMCORE_DEVICE_RAM as is. That's easy to satify, see below: ============simple version===== fs/proc/Kconfig: config NEED_PROC_VMCORE_DEVICE_RAM def n config PROC_VMCORE_DEVICE_RAM def_bool y depends on PROC_VMCORE && VIRTIO_MEM depends on NEED_PROC_VMCORE_DEVICE_RAM arch/s390/Kconfig: config S390 select NEED_PROC_VMCORE_DEVICE_RAM ============================== > > (b) In the context of this patch, "depends on VIRTIO_MEM" does not make > sense. We could have an intermediate: > > config PROC_VMCORE_DEVICE_RAM > def_bool n > depends on PROC_VMCORE > depends on NEED_PROC_VMCORE_DEVICE_RAM > > And change that with VIRTIO_MEM support in the relevant patch. Oh, it's not comment for this patch, I made the simple version based on the whole patchset. When I had a glance at this patch, I also took several iterations to get it after I applied the whole patchset and tried to understand the whole code. > > > I faintly remember that we try avoiding such dependencies and prefer > selecting Kconfigs instead. Just look at the SPLIT_PTE_PTLOCKS mess we still > have to clean up. But as we don't expect that many providers for now, I > don't care. With the simple version, Kconfig learner as me can easily understand what they are doing. If it took you a couple of iterations to make them as you had mentioned earlier, and it took me several iterations to understand them, I believe there must be room to improve the presented ones in this patchset. These are only my humble opinion, and I am not aware of virtio-mem at all, I'll leave this to you and other virtio-mem dev to decide what should be taken. Thanks for your patience and provided information, I learned a lot from this discussion. =================== fs/proc/Kconfig: config PROVIDE_PROC_VMCORE_DEVICE_RAM def_bool n config NEED_PROC_VMCORE_DEVICE_RAM def_bool n config PROC_VMCORE_DEVICE_RAM def_bool y depends on PROC_VMCORE depends on NEED_PROC_VMCORE_DEVICE_RAM depends on PROVIDE_PROC_VMCORE_DEVICE_RAM drivers/virtio/Kconfig: config VIRTIO_MEM select PROVIDE_PROC_VMCORE_DEVICE_RAM if PROC_VMCORE ~~~~~~~~~~~~~~ arch/s390/Kconfig: config S390 select NEED_PROC_VMCORE_DEVICE_RAM if PROC_VMCORE ~~~~~~~~~~~~~~ ======================== One last thing I haven't got well, If PROC_VMCORE_DEVICE_RAM has had dependency on PROC_VMCORE, can we take off the ' if PROC_VMCORE' when select PROVIDE_PROC_VMCORE_DEVICE_RAM and NEED_PROC_VMCORE_DEVICE_RAM? Thanks Baoquan