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 51400D6395B for ; Wed, 20 Nov 2024 14:05:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BE07C6B008A; Wed, 20 Nov 2024 09:05:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B90D16B0092; Wed, 20 Nov 2024 09:05:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A58616B0095; Wed, 20 Nov 2024 09:05:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 89D8B6B008A for ; Wed, 20 Nov 2024 09:05:34 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 0AA3AC0BC9 for ; Wed, 20 Nov 2024 14:05:34 +0000 (UTC) X-FDA: 82806643836.19.E30B770 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf28.hostedemail.com (Postfix) with ESMTP id 81D74C000D for ; Wed, 20 Nov 2024 14:04:37 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Wl15zyix; spf=pass (imf28.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@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=1732111382; 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=lZ8zkxd9i0HO8zyxRsaMmA5VwckXIWnTVoItJwHtzes=; b=dfpSwa5JwyQ0Pf/QU5TSMOFWeCgQLDTUYxdDiqPdIR0pz3ydDwE3wfyH1MC4JxgIZi9e8n /lBfWUTFESGIC41iG2cB9KoDAAsLUj5WeYcwu4Ft5Sroct8syx6LwQovJ90rVnlshxUZeZ EaYOaA/d1TEBCwyG44r4qLtW+ovE2mU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732111382; a=rsa-sha256; cv=none; b=8K7KN61iJVBIL2t1hMGYhovU3X23ouEtU0vS7kUMXerjB7dKCdtYrN3/LknU9BhfN1rDC3 r8trKYpoMChauiRYw+AOIda312QkC8iISdRXpxe2x49uwGZI1SQv9Sr2loxAmka2xmhQiO Bis/0uaZo7j+V9PJO9ydYaCCStBpNBY= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Wl15zyix; spf=pass (imf28.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@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=1732111531; 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=lZ8zkxd9i0HO8zyxRsaMmA5VwckXIWnTVoItJwHtzes=; b=Wl15zyixUAuitzeVJhu8Jef65HiAc4ZKexFzh9zCYtALlAU8htc96sHH1nqs0ba8RVdKgc 7vEnh1gxpNYEPfr8tSE5beypgmyQFxbQrQBxyrEdF+vUKAK6x8S+6NW9Q/gulQwhn4usil jdB9SH8cC0a3XjkmV8DIFJncytS6d/k= Received: from mx-prod-mc-02.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-128-fEP9m0A0NhyClwF0cvKrGQ-1; Wed, 20 Nov 2024 09:05:28 -0500 X-MC-Unique: fEP9m0A0NhyClwF0cvKrGQ-1 X-Mimecast-MFC-AGG-ID: fEP9m0A0NhyClwF0cvKrGQ Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 307F91953944; Wed, 20 Nov 2024 14:05:25 +0000 (UTC) Received: from localhost (unknown [10.72.113.10]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CFA9230001A0; Wed, 20 Nov 2024 14:05:22 +0000 (UTC) Date: Wed, 20 Nov 2024 22:05:15 +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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4b07a3eb-aad6-4436-9591-289c6504bb92@redhat.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 81D74C000D X-Stat-Signature: ck1xk65hkocugkip76wnzdhm5jucz9ut X-HE-Tag: 1732111477-249122 X-HE-Meta: U2FsdGVkX1+aVt+x+aELELYfs+qqRJG9dcv+bhAwAfpl8SsuOzejQrhWBJcTKEDSkYFShZNcCNC+SdMdni3/3bhyu7AqOJYd2uSAUdO6irfEOeSZw6PhK3i9Ov1qx2VLmkxIiXTcCWMdyeYY87TeizDjw0Z6SBxraWS5Z9YlAwL9OhLMSzFbRUErWnBpti4afS9M9HZYUKzidWMM94IOngcZF7+8Wbg9WFunT6PhlslbRyJsopzhHgoG05FcJzsCiaRupno8aRTna1mxacv96Wxlxlra3K8+exeVFIeAWxemIl/DC+6QVYmkT2VlNHkgWtkYhPwbjCWsh+GKsKmyTt0wY9nb3K9X73cEXfJZXZxltsUzS1RgA02R5QT/a5kG6bxOKzwDWaXnG24Qf7ELfkKLgxYmf8/bsKCQhz+EMTBtf7vXt6vfTgjRNwPE6B2CalGqCLPmEBFVDZnQrlmUTlq7qLwFNDk7ZM3XBYo74kJVeJ9mD/XL6aE6B29XC5eUFi93y4hwB3UJea7BaZZyDHBKSMjTF/+fY9NXltNACxRyIk46L9mA4RBC+0tJHjvDoS5BCtpu3GHrb+QWMqvJ+vjhB24lX350fAXgsV4A58oeYU+F8z2S1Ub3IrVRsWlMtqrnUGstHwX6D0GezO5sIBEg7ImzpahNwmb/aUCRoEwRRyxcl+oZkTxWnTQvKM9yvsUjIWgc+t1dCKTV/TJ6YxJlzsa3xMfckZKuEYo31OYENUrG6q9jmgidVcplQYId9gNJ5MrD6w2W47lJbyBXi64WUAwlk4h7gyerHqcXnKVSrbBSZP9XqDa8FXl7KGiKkvK/7tnfsXAZbSOVyqlAG3QXYKgcWk79sIf+qsZLvhGP36DvHuzE/Vlz4MZ/1Nviq2d7H8gRMtpfbL4VVJcMRKsmj4U/4zPlYhbSVrhmTiwVZyM8RTGqZ66TEeIDAfMFeAoQKSD2sK/VmBtbpfN 97CTVwNp Z3SVJrCE6tpCPoFU9F4Brggdgswm/hIexEzJoRFCcWLvffbATXhUF0L/3mi/xhCB4JZYmQICnXtdcadR8YbGtqtiRPA5uvD/VGU3KGP+hhbCJaMr2m+sPBaLrPuozIF48EXiDaIWnKR66e/N+mrfPLb+CfOmloAguR3eS3SVuUH/H79wbL6PNuxE2TQNEs8HHDfLutjzajCbrgfeHFpceq+q83ghPolyB4nesBXxSJ4jakcArqrWoxUz55iSJpW7wiRhY5JihftZ3kWQaDIZqi6Mu/16dszLJEEGzk4HZ2KjX4OaF9Gsn+jC9FFhXx5wLDUVUmX7J5zQfA2LHRf+KhND1BFQK2GITNCh3ICba1w+deamA3WJpaXoJFweCwJF0iZi4OmuEB9kynB/mARhgL773yPkmL5wbyVbhR92ZWwCntVE= 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 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 arch/s390/Kconfig: config NEED_PROC_VMCORE_DEVICE_RAM def y ================================== > > So the three changes you did are > > (a) Remove the config option but select/depend on them. > > (b) Remove the "depends on PROC_VMCORE" from PROC_VMCORE_DEVICE_RAM, > and the "if PROC_VMCORE" from s390. > > (c) Remove the PROVIDE_PROC_VMCORE_DEVICE_RAM > > > Regarding (a), that doesn't work. If you select a config option that doesn't > exist, it is silently dropped. It's always treated as if it wouldn't be set. > > Regarding (b), I think that's an anti-pattern (having config options enabled > that are completely ineffective) and I don't see a benefit dropping them. > > Regarding (c), it would mean that s390x unconditionally includes that code > even if virtio-mem is not configured in. > > So while we could drop PROVIDE_PROC_VMCORE_DEVICE_RAM -- (c), it would that > we end up including code in configurations that don't possibly need it. > That's why I included that part. > > > > > > > ======= config items extracted from this patchset==== > > 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 > > > > config VIRTIO_MEM > > depends on X86_64 || ARM64 || RISCV > > ~~~~~ I don't get why VIRTIO_MEM dones't depend on S390 if > > s390 need PROC_VMCORE_DEVICE_RAM. > > This series depends on s390 support for virtio-mem, which just went > upstream. Got It, I just applied this series on top of the latest mainline's master branch. Thanks for telling. > > > commit 38968bcdcc1d46f2fdcd3a72599d5193bf8baf84 > Author: David Hildenbrand > Date: Fri Oct 25 16:14:49 2024 +0200 > > virtio-mem: s390 support > > > > ...... > > select PROVIDE_PROC_VMCORE_DEVICE_RAM if PROC_VMCORE > > > > config S390 > > select NEED_PROC_VMCORE_DEVICE_RAM if PROC_VMCORE > > ================================================= > > > > Thanks for having a look! > > -- > Cheers, > > David / dhildenb >