Re: [PATCH 4/4] printk: Drop console_sem during panic
From: John Ogness
Date: Mon Jan 24 2022 - 11:26:34 EST
On 2022-01-24, John Ogness <john.ogness@xxxxxxxxxxxxx> wrote:
> Something like:
>
> @@ -2731,7 +2731,8 @@ void console_unlock(void)
> * there's a new owner and the console_unlock() from them will do the
> * flush, no worries.
> */
> - retry = prb_read_valid(prb, next_seq, NULL);
> + retry = (pcpu != raw_smp_processor_id()) &&
> + prb_read_valid(prb, next_seq, NULL);
> if (retry && console_trylock())
> goto again;
> }
Sorry, that hunk is obviously garbage. I meant something like:
@@ -2731,7 +2731,10 @@ void console_unlock(void)
* there's a new owner and the console_unlock() from them will do the
* flush, no worries.
*/
- retry = prb_read_valid(prb, next_seq, NULL);
+ if (panic_in_progress())
+ retry = (pcpu == raw_smp_processor_id()) && prb_read_valid(prb, next_seq, NULL);
+ else
+ retry = prb_read_valid(prb, next_seq, NULL);
if (retry && console_trylock())
goto again;
}
I'm sure there is a cleaner way to code that.
John