public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Carlos Bilbao <carlos.bilbao.osdev@gmail.com>
To: Sean Christopherson <seanjc@google.com>, carlos.bilbao@kernel.org
Cc: tglx@linutronix.de, jan.glauber@gmail.com, bilbao@vt.edu,
	pmladek@suse.com, akpm@linux-foundation.org,
	jani.nikula@intel.com, linux-kernel@vger.kernel.org,
	gregkh@linuxfoundation.org, takakura@valinux.co.jp,
	john.ogness@linutronix.de
Subject: Re: [PATCH v2 1/2] panic: Allow for dynamic custom behavior after panic
Date: Tue, 29 Apr 2025 09:25:04 -0500	[thread overview]
Message-ID: <5a5b1825-2ee7-455e-b52f-edc1a138d0dd@gmail.com> (raw)
In-Reply-To: <aBDoJLyiBcSZiAHm@google.com>

Hello,


Sean, thanks for getting back to me so fast!


On 4/29/25 09:54, Sean Christopherson wrote:
> On Mon, Apr 28, 2025, carlos.bilbao@kernel.org wrote:
>> diff --git a/kernel/panic.c b/kernel/panic.c
>> index a3889f38153d..2cdd83b4afb6 100644
>> --- a/kernel/panic.c
>> +++ b/kernel/panic.c
>> @@ -276,6 +276,30 @@ static void panic_other_cpus_shutdown(bool crash_kexec)
>>  		crash_smp_send_stop();
>>  }
>>  
>> +/*
>> + * This is the default function called after a kernel panic has been
>> + * handled. Higher priority alternatives can be set with function
>> + * panic_set_handling()
>> + *
>> + */
>> +static void after_panic_handling(void)
>> +{
>> +	mdelay(PANIC_TIMER_STEP);
>> +}
>> +
>> +static void (*panic_halt)(void) = after_panic_handling;
> The default implementation clearly doesn't halt, which makes this unnecessarily
> confusing.  And if you're going to provide a default implementation, why bother
> checking for NULL in panic()?  Just leave panic_halt NULL.


Agreed.


>
>> +static int panic_hlt_priority;
> Uber nit, pick one of halt or hlt.


True, will use halt.


>> +
>> +void panic_set_handling(void (*fn)(void), int priority)
>> +{
>> +	if (priority <= panic_hlt_priority)
> If panic_halt is NULL by default, maybe do?
>
> 	if (panic_halt && priority <= panic_halt_priority)
>
>> +		return;
>> +
>> +	panic_hlt_priority = priority;
>> +	panic_halt = fn;
>> +}
>> +EXPORT_SYMBOL_GPL(panic_set_handling);
> This doesn't seem like something that should be exported unless it's absolutely
> necessary, and it shouldn't be necessary as of this series.
>
>> +
>>  /**
>>   *	panic - halt the system
>>   *	@fmt: The text string to print
>> @@ -467,6 +491,9 @@ void panic(const char *fmt, ...)
>>  	console_flush_on_panic(CONSOLE_FLUSH_PENDING);
>>  	nbcon_atomic_flush_unsafe();
>>  
>> +	if (panic_halt)
>> +		panic_halt();
>> +
>>  	local_irq_enable();
>>  	for (i = 0; ; i += PANIC_TIMER_STEP) {
>>  		touch_softlockup_watchdog();
>> -- 
>> 2.47.1
>>

Agree with all. Will fix in v3.


Thanks,

Carlos


  reply	other threads:[~2025-04-29 16:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-28 21:59 [PATCH v2 0/2] panic: Reduce CPU consumption after panic carlos.bilbao
2025-04-28 21:59 ` [PATCH v2 1/2] panic: Allow for dynamic custom behavior " carlos.bilbao
2025-04-29 14:54   ` Sean Christopherson
2025-04-29 14:25     ` Carlos Bilbao [this message]
2025-04-28 21:59 ` [PATCH v2 2/2] x86/panic: Add x86_panic_handler as default post-panic behavior carlos.bilbao
2025-04-29 14:57   ` Sean Christopherson
2025-04-29 14:25     ` Carlos Bilbao
2025-04-29 16:53   ` John Ogness
2025-04-29 15:25     ` Carlos Bilbao
2025-04-30  7:58       ` John Ogness
2025-05-07 19:56         ` Carlos Bilbao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5a5b1825-2ee7-455e-b52f-edc1a138d0dd@gmail.com \
    --to=carlos.bilbao.osdev@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=bilbao@vt.edu \
    --cc=carlos.bilbao@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jan.glauber@gmail.com \
    --cc=jani.nikula@intel.com \
    --cc=john.ogness@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmladek@suse.com \
    --cc=seanjc@google.com \
    --cc=takakura@valinux.co.jp \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox