public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: Petr Mladek <pmladek@suse.com>
Cc: "Sergey Senozhatsky" <sergey.senozhatsky.work@gmail.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Sergey Senozhatsky" <sergey.senozhatsky@gmail.com>,
	"Steven Rostedt" <rostedt@goodmis.org>,
	"Tetsuo Handa" <penguin-kernel@i-love.sakura.ne.jp>,
	linux-kernel@vger.kernel.org
Subject: Re: Regression in dbdda842fe96 ("printk: Add console owner and waiter logic to load balance console writes") [Was: Regression in fd5f7cde1b85 ("...")]
Date: Fri, 27 Sep 2019 13:26:14 +0900	[thread overview]
Message-ID: <20190927042614.GA784@jagdpanzerIV> (raw)
In-Reply-To: <20190926085855.debu7t46s7kgb26p@pathway.suse.cz>

On (09/26/19 10:58), Petr Mladek wrote:
[..]
> > -	spin_lock(&sport->port.lock);
> > -
> > +	uart_port_lock_irqsave(&sport->port, flags);
> 
> uart_port_lock_irqsave() does not exist.

... Oh. Good catch! Apparently I still carry around my patch set
which added printk_safe to TTY/UART locking API.

> Instead the current users do:
> 
>      spin_lock_irqsave(&port->lock, flags);

Right.

[..]

> I like this approach. It allows to remove hacks with locks.

[..]

> Or I would keep the locking as is and add some API
> just for the sysrq handling:
>
>
>    int uart_store_sysrq_char(struct uart_port *port, unsigned int ch);
>    unsigned int uart_get_sysrq_char(struct uart_port *port);

Looks good. We also probably can remove struct uart_port's
->sysrq member and clean up locking in drivers' ->write()
callbacks:

	if (sport->sysrq)
		locked = 0;
	else if (oops_in_progress)
		locked = spin_trylock_irqsave(&sport->lock, flags);
	else
		spin_lock_irqsave(&sport->lock, flags);

Because this ->sysrq branch makes driver completely lockless globally,
for all CPUs, not only for sysrq-CPU.

> And use it the following way:
> 
> 	int handle_irq()
> 	{
> 		unsined int sysrq, sysrq_ch;
> 
> 		spin_lock(&port->lock);
> 		[...]
> 			sysrq = uart_store_sysrq_char(port, ch);
> 			if (!sysrq)
> 				[...]
> 		[...]
> 
> 	out:
> 		sysrq_ch = uart_get_sysrq_char(port);
> 		spin_unlock(&port->lock);
> 
> 		if (sysrq_ch)
> 			handle_sysrq(sysrq_ch);
> 	}

Looks good.

	-ss

      reply	other threads:[~2019-09-27  4:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-17 14:10 Regression in fd5f7cde1b85 ("printk: Never set console_may_schedule in console_trylock()") Uwe Kleine-König
2019-09-18  1:30 ` Sergey Senozhatsky
2019-09-18  7:11   ` Regression in dbdda842fe96 ("printk: Add console owner and waiter logic to load balance console writes") [Was: Regression in fd5f7cde1b85 ("...")] Uwe Kleine-König
2019-09-18  7:52     ` Sergey Senozhatsky
2019-09-26  8:58       ` Petr Mladek
2019-09-27  4:26         ` Sergey Senozhatsky [this message]

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=20190927042614.GA784@jagdpanzerIV \
    --to=sergey.senozhatsky.work@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=u.kleine-koenig@pengutronix.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