All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RT] printk: Shortcut out of waiter spinning on PREEMPT_RT
@ 2019-01-15 17:39 Steven Rostedt
  2019-01-15 18:54 ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 6+ messages in thread
From: Steven Rostedt @ 2019-01-15 17:39 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior, Thomas Gleixner
  Cc: LKML, linux-rt-users, Petr Mladek, Sergey Senozhatsky

From: Steven Rostedt (VMware) <rostedt@goodmis.org>

As the consoles are written with preemption enabled in PREEMPT_RT, we
must not have any task spinning waiting on them. Currently, the code
that would make the task spin is #ifdef out when PREEMPT_RT is
enabled, but why go through grabbing of the locks to see if an owner is
set, when it never will be?

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index a43d07d4e043..1a61132deec1 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1742,6 +1742,13 @@ static int console_trylock_spinning(void)
 	if (console_trylock())
 		return 1;
 
+	/*
+	 * The consoles are preemptable in PREEMPT_RT, which can cause
+	 * spinning to deadlock.
+	 */
+	if (IS_ENABLED(CONFIG_PREEMPT_RT_FULL))
+		return 0;
+
 	printk_safe_enter_irqsave(flags);
 
 	raw_spin_lock(&console_owner_lock);

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH RT] printk: Shortcut out of waiter spinning on PREEMPT_RT
  2019-01-15 17:39 [PATCH RT] printk: Shortcut out of waiter spinning on PREEMPT_RT Steven Rostedt
@ 2019-01-15 18:54 ` Sebastian Andrzej Siewior
  2019-01-15 19:58   ` Steven Rostedt
  0 siblings, 1 reply; 6+ messages in thread
From: Sebastian Andrzej Siewior @ 2019-01-15 18:54 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Thomas Gleixner, LKML, linux-rt-users, Petr Mladek, Sergey Senozhatsky

On 2019-01-15 12:39:10 [-0500], Steven Rostedt wrote:
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -1742,6 +1742,13 @@ static int console_trylock_spinning(void)
>  	if (console_trylock())
>  		return 1;
>  
> +	/*
> +	 * The consoles are preemptable in PREEMPT_RT, which can cause
> +	 * spinning to deadlock.
> +	 */
> +	if (IS_ENABLED(CONFIG_PREEMPT_RT_FULL))
> +		return 0;
> +
>  	printk_safe_enter_irqsave(flags);
>  
>  	raw_spin_lock(&console_owner_lock);

So my ("printk: Make rt aware") patch does:

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 6553508ff3889..d983c509f74a2 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1617,6 +1617,7 @@ SYSCALL_DEFINE3(syslog, int, type, char __user *, buf, int, len)
        return do_syslog(type, buf, len, SYSLOG_FROM_READER);
 }
 
+#ifndef CONFIG_PREEMPT_RT_FULL
 /*
  * Special console_lock variants that help to reduce the risk of soft-lockups.
  * They allow to pass console_lock to another printk() call using a busy wait.
@@ -1757,6 +1758,15 @@ static int console_trylock_spinning(void)
        return 1;
 }
 
+#else
+
+static int console_trylock_spinning(void)
+{
+       return console_trylock();
+}
+
+#endif
+
 /*
  * Call the console drivers, asking them to write out
  * log_buf[start] to log_buf[end - 1].


So it never gets into the codepath where you try to avoid spinning.
Right?

Sebastian

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH RT] printk: Shortcut out of waiter spinning on PREEMPT_RT
  2019-01-15 18:54 ` Sebastian Andrzej Siewior
@ 2019-01-15 19:58   ` Steven Rostedt
  2019-01-16 10:07     ` Petr Mladek
  0 siblings, 1 reply; 6+ messages in thread
From: Steven Rostedt @ 2019-01-15 19:58 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: Thomas Gleixner, LKML, linux-rt-users, Petr Mladek, Sergey Senozhatsky

On Tue, 15 Jan 2019 19:54:33 +0100
Sebastian Andrzej Siewior <bigeasy@linutronix.de> wrote:

> On 2019-01-15 12:39:10 [-0500], Steven Rostedt wrote:
> > --- a/kernel/printk/printk.c
> > +++ b/kernel/printk/printk.c
> > @@ -1742,6 +1742,13 @@ static int console_trylock_spinning(void)
> >  	if (console_trylock())
> >  		return 1;
> >  
> > +	/*
> > +	 * The consoles are preemptable in PREEMPT_RT, which can cause
> > +	 * spinning to deadlock.
> > +	 */
> > +	if (IS_ENABLED(CONFIG_PREEMPT_RT_FULL))
> > +		return 0;
> > +
> >  	printk_safe_enter_irqsave(flags);
> >  
> >  	raw_spin_lock(&console_owner_lock);  
> 
> So my ("printk: Make rt aware") patch does:
> 
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index 6553508ff3889..d983c509f74a2 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -1617,6 +1617,7 @@ SYSCALL_DEFINE3(syslog, int, type, char __user *, buf, int, len)
>         return do_syslog(type, buf, len, SYSLOG_FROM_READER);
>  }
>  
> +#ifndef CONFIG_PREEMPT_RT_FULL
>  /*
>   * Special console_lock variants that help to reduce the risk of soft-lockups.
>   * They allow to pass console_lock to another printk() call using a busy wait.
> @@ -1757,6 +1758,15 @@ static int console_trylock_spinning(void)
>         return 1;
>  }
>  
> +#else
> +
> +static int console_trylock_spinning(void)
> +{
> +       return console_trylock();
> +}
> +
> +#endif
> +
>  /*
>   * Call the console drivers, asking them to write out
>   * log_buf[start] to log_buf[end - 1].
> 
> 
> So it never gets into the codepath where you try to avoid spinning.
> Right?
>

You right! Which appears to be missing from my 4.14, and I thought I
looked for that in 4.19-rt too, but I guess I was still looking at
4.14 :-/. OK, ignore. Sorry for the noise.

Well, it wasn't a total waste. I now know what to backport to 4.14-rt
;-)

-- Steve

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH RT] printk: Shortcut out of waiter spinning on PREEMPT_RT
  2019-01-15 19:58   ` Steven Rostedt
@ 2019-01-16 10:07     ` Petr Mladek
  2019-01-16 11:43       ` Sergey Senozhatsky
  0 siblings, 1 reply; 6+ messages in thread
From: Petr Mladek @ 2019-01-16 10:07 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Sebastian Andrzej Siewior, Thomas Gleixner, LKML, linux-rt-users,
	Sergey Senozhatsky

On Tue 2019-01-15 14:58:15, Steven Rostedt wrote:
> On Tue, 15 Jan 2019 19:54:33 +0100
> Sebastian Andrzej Siewior <bigeasy@linutronix.de> wrote:
> 
> > On 2019-01-15 12:39:10 [-0500], Steven Rostedt wrote:
> > > --- a/kernel/printk/printk.c
> > > +++ b/kernel/printk/printk.c
> > > @@ -1742,6 +1742,13 @@ static int console_trylock_spinning(void)
> > >  	if (console_trylock())
> > >  		return 1;
> > >  
> > > +	/*
> > > +	 * The consoles are preemptable in PREEMPT_RT, which can cause
> > > +	 * spinning to deadlock.
> > > +	 */
> > > +	if (IS_ENABLED(CONFIG_PREEMPT_RT_FULL))
> > > +		return 0;
> > > +
> > >  	printk_safe_enter_irqsave(flags);
> > >  
> > >  	raw_spin_lock(&console_owner_lock);  
> > 
> > So my ("printk: Make rt aware") patch does:
> > 
> > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> > index 6553508ff3889..d983c509f74a2 100644
> > --- a/kernel/printk/printk.c
> > +++ b/kernel/printk/printk.c
> > @@ -1617,6 +1617,7 @@ SYSCALL_DEFINE3(syslog, int, type, char __user *, buf, int, len)
> >         return do_syslog(type, buf, len, SYSLOG_FROM_READER);
> >  }
> >  
> > +#ifndef CONFIG_PREEMPT_RT_FULL
> >  /*
> >   * Special console_lock variants that help to reduce the risk of soft-lockups.
> >   * They allow to pass console_lock to another printk() call using a busy wait.
> > @@ -1757,6 +1758,15 @@ static int console_trylock_spinning(void)
> >         return 1;
> >  }
> >  
> > +#else
> > +
> > +static int console_trylock_spinning(void)
> > +{
> > +       return console_trylock();
> > +}
> > +
> > +#endif
> > +
> >  /*
> >   * Call the console drivers, asking them to write out
> >   * log_buf[start] to log_buf[end - 1].
> > 
> > 
> > So it never gets into the codepath where you try to avoid spinning.
> > Right?
> >
> 
> You right! Which appears to be missing from my 4.14, and I thought I
> looked for that in 4.19-rt too, but I guess I was still looking at
> 4.14 :-/. OK, ignore. Sorry for the noise.
> 
> Well, it wasn't a total waste. I now know what to backport to 4.14-rt
> ;-)

The patch makes perfect sense. But it is not ready for upstream
because CONFIG_PREEMPT_RT_FULL is not there yet. Do I get it
correctly, please?

Best Regards,
Petr

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH RT] printk: Shortcut out of waiter spinning on PREEMPT_RT
  2019-01-16 10:07     ` Petr Mladek
@ 2019-01-16 11:43       ` Sergey Senozhatsky
  2019-01-16 12:27         ` Steven Rostedt
  0 siblings, 1 reply; 6+ messages in thread
From: Sergey Senozhatsky @ 2019-01-16 11:43 UTC (permalink / raw)
  To: Petr Mladek
  Cc: Steven Rostedt, Sebastian Andrzej Siewior, Thomas Gleixner, LKML,
	linux-rt-users, Sergey Senozhatsky

On (01/16/19 11:07), Petr Mladek wrote:
> The patch makes perfect sense. But it is not ready for upstream
> because CONFIG_PREEMPT_RT_FULL is not there yet. Do I get it
> correctly, please?

Yes. Hence Cc linux-rt-users.

	-ss

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH RT] printk: Shortcut out of waiter spinning on PREEMPT_RT
  2019-01-16 11:43       ` Sergey Senozhatsky
@ 2019-01-16 12:27         ` Steven Rostedt
  0 siblings, 0 replies; 6+ messages in thread
From: Steven Rostedt @ 2019-01-16 12:27 UTC (permalink / raw)
  To: Sergey Senozhatsky
  Cc: Petr Mladek, Sebastian Andrzej Siewior, Thomas Gleixner, LKML,
	linux-rt-users

On Wed, 16 Jan 2019 20:43:40 +0900
Sergey Senozhatsky <sergey.senozhatsky@gmail.com> wrote:

> On (01/16/19 11:07), Petr Mladek wrote:
> > The patch makes perfect sense. But it is not ready for upstream
> > because CONFIG_PREEMPT_RT_FULL is not there yet. Do I get it
> > correctly, please?  
> 
> Yes. Hence Cc linux-rt-users.
> 
>

Actually it's the Subject line. We use "[PATCH RT]" to denote changes
caused by PREEMPT_RT existing.

-- Steve

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-01-16 12:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-15 17:39 [PATCH RT] printk: Shortcut out of waiter spinning on PREEMPT_RT Steven Rostedt
2019-01-15 18:54 ` Sebastian Andrzej Siewior
2019-01-15 19:58   ` Steven Rostedt
2019-01-16 10:07     ` Petr Mladek
2019-01-16 11:43       ` Sergey Senozhatsky
2019-01-16 12:27         ` Steven Rostedt

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.