Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1528270rdb; Wed, 24 Jan 2024 20:09:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IHG/ik5kTn3AA4mrvK4TRoTlbpCxfRiwup2+S5uebGtkQYukaztqCaACaBB6JAYYeKH2L81 X-Received: by 2002:a17:906:29c7:b0:a31:42a5:93fc with SMTP id y7-20020a17090629c700b00a3142a593fcmr75375eje.75.1706155799055; Wed, 24 Jan 2024 20:09:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706155799; cv=pass; d=google.com; s=arc-20160816; b=v9tHG+84s0iPLMepdgfqF1hQr+2P6ZCdLcoISTgbDa33gQQxcmHE9qw1B2HivA0/OX GsuuUcVAC+usZWopvqP5Y5SmNIGYXuweZoIda3PBuRhk3PJz03+TGGkcBW17h+2ADy9y qFYbQ4u0Qdmr1+ObwEH7oXj6XLXWiArxjWolT+CkBK79l5zT020oBFFIl1p6FM65y0eS KWgtn/TMGuMWu1tYDamffFoUuqIAuoOnK8eGQDupR9jO7WCUGAjNWxd953GH8wukTgrN UMB2fZ9On6ExnoLFauLLUmJ5jII/lvKnhaak8KSuGsG/NtFT7otNSJBI6ltszGIWHHmx q+0A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=mWkqIM1QddKJmlHq/W4wKL7ORpJYC0uhF5yya8pqsJ8=; fh=9iQhJu24CUKJ+a+fAT7WH09dniYDpucrWaUxVpH4YB8=; b=cWsMOAFdXPdXzmOCpNlIrXEGjWOFaDMm8qChU2SSqP8gaAvW32UkOhdAIEVmypSdf4 PKlhrv7gpxNZa5kIiBeJx59ABiMeeOHqLML6Hcgi2SQ5Cbrndx0W8jucFGDs16fiwIeR 19ODTvttYeq/MJJjRQ6znFhy8tc6syxpUav/B4OMZuiz/iYajw9lnNZU9uP0iYF8HYYU mqxCenEWjD2JQOLys6LsvyvdpOuTfQYQLm5FHPpUc7CtIa3ipniii2P93WutCgbb4Mus qgEPbsgPCo4cVND/veY5dD9A40ufAMcxZNz0Bjuz2lZO6stFIymIADfIm/ER1r0viwTZ sr5g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KFN61ZOx; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-37939-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37939-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id gu11-20020a170906f28b00b00a2a637c5f15si536521ejb.871.2024.01.24.20.09.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 20:09:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-37939-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KFN61ZOx; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-37939-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37939-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 9EADF1F23199 for ; Thu, 25 Jan 2024 04:09:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A733579EC; Thu, 25 Jan 2024 04:09:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="KFN61ZOx" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5455A79C7 for ; Thu, 25 Jan 2024 04:09:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706155789; cv=none; b=ClMwwljcrKEYoByWujvNYjlNz38fDxFcyn/zXe3hR+UL9actqxwstfwB3cBZo6oyU1m1iP4PlHyrMviXUw42M7Ketrz2wINsyzbQyuYiV7R5OkGUWxG46OlngkPS/88mfBYSQoILcHGOaqCL0LiarxhYeaiiQkvkOm2P1dYtDyw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706155789; c=relaxed/simple; bh=zupGSwZyGzMVwBtWOwdtEe+wGr5W8ImseAYZk+EG1cI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=m8UdAqwTloa/FJMZMkTiiviKq2kdLcW3YGJa5c3wIqcHk/XGNNhun6MnKE3nMJ0ovMymrYzsHXqahLZpmL3CsrL2GvEMEfnmVzus82OQMZKE6dRK6tgdbsf0B8MJkblpydHPnunb4VnrvgSt38jdEx/nQa/v8S6fJ8laRp72fDM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=KFN61ZOx; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706155787; 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=mWkqIM1QddKJmlHq/W4wKL7ORpJYC0uhF5yya8pqsJ8=; b=KFN61ZOx//sOLbwMHH12W5hqnowT/bBsyvfAJMtC6EoWe8EV/xfyzV1O9x3R6jeVhEqRGt EA4oUT+gUd+WaZByzGvp5L5WK9A49tvSUXFK6jV6Ijlt4xCtPN5GmMcY4IhkVrjla/ZeZN J7yyGgp1OUYvl/2E2oDJmbTjcgkK958= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-400-AvLrlMuiMWWq7ooKHP2nsQ-1; Wed, 24 Jan 2024 23:09:41 -0500 X-MC-Unique: AvLrlMuiMWWq7ooKHP2nsQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7936A38143C1; Thu, 25 Jan 2024 04:09:40 +0000 (UTC) Received: from localhost (unknown [10.72.116.117]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 71F7F40C1430; Thu, 25 Jan 2024 04:09:39 +0000 (UTC) Date: Thu, 25 Jan 2024 12:09:36 +0800 From: Baoquan He To: Michael Kelley Cc: "linux-kernel@vger.kernel.org" , "kexec@lists.infradead.org" , "x86@kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linuxppc-dev@lists.ozlabs.org" , "linux-s390@vger.kernel.org" , "linux-sh@vger.kernel.org" , "linux-mips@vger.kernel.org" , "linux-riscv@lists.infradead.org" , "loongarch@lists.linux.dev" , "akpm@linux-foundation.org" , "ebiederm@xmission.com" , "hbathini@linux.ibm.com" , "piliu@redhat.com" , "viro@zeniv.linux.org.uk" Subject: Re: [PATCH linux-next v3 06/14] x86, crash: wrap crash dumping code into crash related ifdefs Message-ID: References: <20240124051254.67105-1-bhe@redhat.com> <20240124051254.67105-7-bhe@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 On 01/24/24 at 11:02pm, Michael Kelley wrote: > > diff --git a/arch/x86/kernel/cpu/mshyperv.c > > b/arch/x86/kernel/cpu/mshyperv.c > > index 01fa06dd06b6..f8163a59026b 100644 > > --- a/arch/x86/kernel/cpu/mshyperv.c > > +++ b/arch/x86/kernel/cpu/mshyperv.c > > @@ -210,6 +210,7 @@ static void hv_machine_shutdown(void) > > hyperv_cleanup(); > > } > > > > +#ifdef CONFIG_CRASH_DUMP > > static void hv_machine_crash_shutdown(struct pt_regs *regs) > > { > > if (hv_crash_handler) > > @@ -221,6 +222,7 @@ static void hv_machine_crash_shutdown(struct > > pt_regs *regs) > > /* Disable the hypercall page when there is only 1 active CPU. */ > > hyperv_cleanup(); > > } > > +#endif > > #endif /* CONFIG_KEXEC_CORE */ > > Note that the #ifdef CONFIG_CRASH_DUMP is nested inside > #ifdef CONFIG_KEXEC_CODE here, and in the other Hyper-V code > just below. It's also nested in xen_hvm_guest_init() at the bottom > of this patch. But the KVM case of setting crash_shutdown is > not nested -- you changed #ifdef CONFIG_KEXEC_CORE to #ifdef > CONFIG_CRASH_DUMP. > > I think both approaches work because CONFIG_CRASH_DUMP implies > CONFIG_KEXEC_CORE, but I wonder if it would be better to *not* nest > in all cases. I'd like to see the cases be consistent so in the future > someone doesn't wonder why there's a difference (unless there's > a reason for the difference that I missed). I agree with you, it's a great suggestion. Thanks. Do you think below draft patch includes all changes you are concerned about? diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c index f8163a59026b..2e8cd5a4ae85 100644 --- a/arch/x86/kernel/cpu/mshyperv.c +++ b/arch/x86/kernel/cpu/mshyperv.c @@ -209,6 +209,7 @@ static void hv_machine_shutdown(void) if (kexec_in_progress) hyperv_cleanup(); } +#endif /* CONFIG_KEXEC_CORE */ #ifdef CONFIG_CRASH_DUMP static void hv_machine_crash_shutdown(struct pt_regs *regs) @@ -222,8 +223,7 @@ static void hv_machine_crash_shutdown(struct pt_regs *regs) /* Disable the hypercall page when there is only 1 active CPU. */ hyperv_cleanup(); } -#endif -#endif /* CONFIG_KEXEC_CORE */ +#endif /* CONFIG_CRASH_DUMP */ #endif /* CONFIG_HYPERV */ static uint32_t __init ms_hyperv_platform(void) @@ -497,9 +497,11 @@ static void __init ms_hyperv_init_platform(void) no_timer_check = 1; #endif -#if IS_ENABLED(CONFIG_HYPERV) && defined(CONFIG_KEXEC_CORE) +#if IS_ENABLED(CONFIG_HYPERV) +#if defined(CONFIG_KEXEC_CORE) machine_ops.shutdown = hv_machine_shutdown; -#ifdef CONFIG_CRASH_DUMP +#endif +#if defined(CONFIG_CRASH_DUMP) machine_ops.crash_shutdown = hv_machine_crash_shutdown; #endif #endif diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c index 1287b0d5962f..f3130f762784 100644 --- a/arch/x86/kernel/reboot.c +++ b/arch/x86/kernel/reboot.c @@ -826,7 +826,7 @@ void machine_halt(void) machine_ops.halt(); } -#ifdef CONFIG_KEXEC_CORE +#ifdef CONFIG_CRASH_DUMP void machine_crash_shutdown(struct pt_regs *regs) { machine_ops.crash_shutdown(regs);