From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 4FB87320397 for ; Wed, 20 Aug 2025 13:36:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755696974; cv=none; b=Bw3Exw48UorLgL8F7PK6IwX1bN4n9C1M12YqixPi0hlQzxI172cOK7Xut6iZpH6yoAEed/1rYSXnKbs+eQfxPicT1cdhzAl1vVMhlUSt2HY7uY8mBWpk4lHgEVAhxqFnWQzd2RZVeIBnJqjiPbAEgxDKHzTd2ImyRtVzbdEdUz4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755696974; c=relaxed/simple; bh=0WbeVggTn3zfkRyQvVt7Frs2qIi1OG0DUl+B7d1w/qQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LlD/xHEX9qQVdFtjYb2g8zZIuqpOo10pv+rQtjmPAWL63RknAc6bwQJRjI58YGa6b94chpCi2i17Lrtl68xPwAk4mXs/gNaxgspVNkDEE6s5ktQNLUuKqWrL2mCsK0i0/zsLWzRhv9WVsQOzttqkpbcU3UZshB6WtAKy8RY69a4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=iI7gEdaA; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="iI7gEdaA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1755696971; 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=Su/OHazANarelKIlAJ/fg6d4xixyDxFKScYwQAQvY7I=; b=iI7gEdaAXDh5yqpg+qNc1chwx8K7FOp+NjdBIuOhjALPPH49STi2xXEnsAXFubMTF3/L2s /1Z8afUWNSEuvAAtimAngwklbV56/Sub7eDKMYBxSoyyszQSadkluubNR+VKn4Lzqtc0R7 jvoUU7ztJ1QaicWKK4wgOHbcK6RfiJA= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-347-cerMHnjiOS2Tes0Va8V6QQ-1; Wed, 20 Aug 2025 09:36:07 -0400 X-MC-Unique: cerMHnjiOS2Tes0Va8V6QQ-1 X-Mimecast-MFC-AGG-ID: cerMHnjiOS2Tes0Va8V6QQ_1755696966 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5749D18004A7; Wed, 20 Aug 2025 13:36:05 +0000 (UTC) Received: from localhost (unknown [10.72.112.99]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A8F8419A4C9C; Wed, 20 Aug 2025 13:36:02 +0000 (UTC) Date: Wed, 20 Aug 2025 21:35:57 +0800 From: Baoquan He To: Jinchao Wang Cc: pmladek@suse.com, akpm@linux-foundation.org, Vivek Goyal , Dave Young , linux-kernel@vger.kernel.org, feng.tang@linux.alibaba.com, joel.granados@kernel.org, john.ogness@linutronix.de, namcao@linutronix.de, sravankumarlpu@gmail.com, kexec@lists.infradead.org Subject: Re: [PATCH 3/9] crash_core: use panic_try_start() in crash_kexec() Message-ID: References: <20250820091702.512524-1-wangjinchao600@gmail.com> <20250820091702.512524-2-wangjinchao600@gmail.com> <20250820091702.512524-3-wangjinchao600@gmail.com> <20250820091702.512524-4-wangjinchao600@gmail.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: <20250820091702.512524-4-wangjinchao600@gmail.com> X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 On 08/20/25 at 05:14pm, Jinchao Wang wrote: > crash_kexec() had its own code to exclude > parallel execution by setting panic_cpu. > This is already handled by panic_try_start(). > > Switch to panic_try_start() to remove the > duplication and keep the logic consistent. > > Signed-off-by: Jinchao Wang > --- > kernel/crash_core.c | 15 +++------------ > 1 file changed, 3 insertions(+), 12 deletions(-) > > diff --git a/kernel/crash_core.c b/kernel/crash_core.c > index a4ef79591eb2..bb38bbaf3a26 100644 > --- a/kernel/crash_core.c > +++ b/kernel/crash_core.c > @@ -4,6 +4,7 @@ > * Copyright (C) 2002-2004 Eric Biederman > */ > > +#include "linux/panic.h" > #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt > > #include > @@ -143,17 +144,7 @@ STACK_FRAME_NON_STANDARD(__crash_kexec); > > __bpf_kfunc void crash_kexec(struct pt_regs *regs) > { > - int old_cpu, this_cpu; > - > - /* > - * Only one CPU is allowed to execute the crash_kexec() code as with > - * panic(). Otherwise parallel calls of panic() and crash_kexec() > - * may stop each other. To exclude them, we use panic_cpu here too. > - */ > - old_cpu = PANIC_CPU_INVALID; > - this_cpu = raw_smp_processor_id(); > - > - if (atomic_try_cmpxchg(&panic_cpu, &old_cpu, this_cpu)) { > + if (panic_try_start()) { Seriously, where can I find this panic_try_start() and the panic_reset()? > /* This is the 1st CPU which comes here, so go ahead. */ > __crash_kexec(regs); > > @@ -161,7 +152,7 @@ __bpf_kfunc void crash_kexec(struct pt_regs *regs) > * Reset panic_cpu to allow another panic()/crash_kexec() > * call. > */ > - atomic_set(&panic_cpu, PANIC_CPU_INVALID); > + panic_reset(); > } > } > > -- > 2.43.0 >