* [PATCH v1] kernel/printk: check return value of console_trylock()
@ 2022-09-17 1:58 Li Zhong
2022-09-18 13:11 ` Sergey Senozhatsky
0 siblings, 1 reply; 3+ messages in thread
From: Li Zhong @ 2022-09-17 1:58 UTC (permalink / raw)
To: linux-kernel
Cc: tony.luck, ccross, anton, keescook, john.ogness, rostedt,
senozhatsky, pmladek, Li Zhong
Check the console_trylock() return value in case it fails.
Signed-off-by: Li Zhong <floridsleeves@gmail.com>
---
kernel/printk/printk.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index a1a81fd9889b..2c6a0484315b 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2937,7 +2937,8 @@ void console_flush_on_panic(enum con_flush_mode mode)
* context and we don't want to get preempted while flushing,
* ensure may_schedule is cleared.
*/
- console_trylock();
+ if (!console_trylock())
+ return;
console_may_schedule = 0;
if (mode == CONSOLE_REPLAY_ALL) {
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v1] kernel/printk: check return value of console_trylock()
2022-09-17 1:58 [PATCH v1] kernel/printk: check return value of console_trylock() Li Zhong
@ 2022-09-18 13:11 ` Sergey Senozhatsky
2022-09-19 22:28 ` Li Zhong
0 siblings, 1 reply; 3+ messages in thread
From: Sergey Senozhatsky @ 2022-09-18 13:11 UTC (permalink / raw)
To: Li Zhong
Cc: linux-kernel, tony.luck, ccross, anton, keescook, john.ogness,
rostedt, senozhatsky, pmladek
On (22/09/16 18:58), Li Zhong wrote:
> Check the console_trylock() return value in case it fails.
[..]
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index a1a81fd9889b..2c6a0484315b 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -2937,7 +2937,8 @@ void console_flush_on_panic(enum con_flush_mode mode)
> * context and we don't want to get preempted while flushing,
> * ensure may_schedule is cleared.
> */
> - console_trylock();
> + if (!console_trylock())
> + return;
It supposed to be ignored and the comment above (in the code)
explains why: this is panic flush, we want to proceed regardless.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] kernel/printk: check return value of console_trylock()
2022-09-18 13:11 ` Sergey Senozhatsky
@ 2022-09-19 22:28 ` Li Zhong
0 siblings, 0 replies; 3+ messages in thread
From: Li Zhong @ 2022-09-19 22:28 UTC (permalink / raw)
To: Sergey Senozhatsky
Cc: linux-kernel, tony.luck, ccross, anton, keescook, john.ogness,
rostedt, pmladek
On Sun, Sep 18, 2022 at 6:11 AM Sergey Senozhatsky
<senozhatsky@chromium.org> wrote:
>
> On (22/09/16 18:58), Li Zhong wrote:
> > Check the console_trylock() return value in case it fails.
> [..]
> > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> > index a1a81fd9889b..2c6a0484315b 100644
> > --- a/kernel/printk/printk.c
> > +++ b/kernel/printk/printk.c
> > @@ -2937,7 +2937,8 @@ void console_flush_on_panic(enum con_flush_mode mode)
> > * context and we don't want to get preempted while flushing,
> > * ensure may_schedule is cleared.
> > */
> > - console_trylock();
> > + if (!console_trylock())
> > + return;
>
> It supposed to be ignored and the comment above (in the code)
> explains why: this is panic flush, we want to proceed regardless.
Thanks for your explanation.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-09-19 22:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-17 1:58 [PATCH v1] kernel/printk: check return value of console_trylock() Li Zhong
2022-09-18 13:11 ` Sergey Senozhatsky
2022-09-19 22:28 ` Li Zhong
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.