All of lore.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@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Jan Kara <jack@suse.com>, Tejun Heo <tj@kernel.org>,
	Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
	linux-kernel@vger.kernel.org,
	Byungchul Park <byungchul.park@lge.com>,
	Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
	Jan Kara <jack@suse.cz>
Subject: Re: [RFC][PATCH v8 1/2] printk: Make printk() completely async
Date: Fri, 1 Apr 2016 10:08:03 +0900	[thread overview]
Message-ID: <20160401010803.GA501@swordfish> (raw)
In-Reply-To: <20160331111229.GB1023@pathway.suse.cz>

Hello Petr,

On (03/31/16 13:12), Petr Mladek wrote:
> > +	 * Set printing kthread sleep condition early, under the
> > +	 * logbuf_lock, so it (if RUNNING) will go to console_lock()
> > +	 * and spin on logbuf_lock.
> > +	 */
> > +	if (!in_panic && printk_kthread && !need_flush_console)
> > +		need_flush_console = true;
> 
> I would remove the if-statement and always set it:
> 
>   + It does not matter if we set it in panic. It will not affect
>     anything.

hm... yes, you're right.

>   + The check for printk_kthread is racy. It might be false here
>     and it might be true later when check whether to wakeup
>     the kthread or try to get console directly.

which is fine, isn't it? we will wakeup the printing kthread, it will
console_lock()/console_unlock() (regardless the state of need_flush_console).
printing thread checks need_flush_console only when it decides whether
it shall schedule.

>   + We might set it true even when it was true before.
> 
> I think that this was an attempt to avoid a spurious wake up.
> But we solve it better way now.

we also may have 'printk.synchronous = 1', which will purposelessly
dirty need_flush_console from various CPUs from every printk /* and
upon every return from console_unlock() */; that's why I added both
printk_kthread and !need_flush_console (re-dirty already dirtied)
checks.

> >  	raw_spin_lock(&logbuf_lock);
> >  	retry = console_seq != log_next_seq;
> > +	if (!retry && printk_kthread)
> > +		need_flush_console = false;
> 
> Similar here. I remove the if-statement and always set it. We will
> either retry or it should be false anyway.

well, 'printk.synchronous = 1'. seems that `!retry' check can be
dropped, I agree.

a side nano-note,
apart from 'printk.synchronous = 1', we also can have !printk_kthread
because kthread_run(printk_kthread_func) failed. it's quite unlikely,
but still.

[..]
> > +	while (1) {
> > +		set_current_state(TASK_INTERRUPTIBLE);
> > +		if (!need_flush_console)
> > +			schedule();
> > +
> > +		__set_current_state(TASK_RUNNING);
> 
> 
> We still must do here:
> 
> 		need_flush_console = false;

oh, wow! that's a major mistake. thanks a lot for catching this!
shame on me.

> 		/*
> 		 * Avoid an infinite loop when console_unlock() cannot
> 		 * access consoles, e.g. because of a suspend. We
> 		 * could get asleep here. Someone else will call
> 		 * consoles if conditions change.
> 		 */

looks ok.

> Also another name might help. If we set it false here, the value
> does describe a global state. The variable describes if this
> kthread needs to flush the console. So, more precise name would be
> 
> 	printk_kthread_need_flush_console

yes, makes sense.

> I think that we are close. I really like the current state of
> the patch and how minimalistic it is.


thanks for your review.

I'll re-spin.

	-ss

  parent reply	other threads:[~2016-04-01  1:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-24 15:43 [RFC][PATCH v8 0/2] printk: Make printk() completely async Sergey Senozhatsky
2016-03-24 15:43 ` [RFC][PATCH v8 1/2] " Sergey Senozhatsky
2016-03-29  9:14   ` Jan Kara
2016-04-01  1:14     ` Sergey Senozhatsky
2016-03-31 11:12   ` Petr Mladek
2016-03-31 11:52     ` Jan Kara
2016-04-04  9:41       ` Petr Mladek
2016-04-04 17:01         ` Sergey Senozhatsky
2016-04-01  1:08     ` Sergey Senozhatsky [this message]
2016-04-01  8:59       ` Petr Mladek
2016-04-01  9:36         ` Sergey Senozhatsky
2016-04-01 11:30           ` Petr Mladek
2016-03-24 15:43 ` [RFC][PATCH v8 2/2] printk: Make wake_up_klogd_work_func() async Sergey Senozhatsky
2016-03-31 11:14   ` Petr Mladek

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=20160401010803.GA501@swordfish \
    --to=sergey.senozhatsky.work@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=byungchul.park@lge.com \
    --cc=jack@suse.com \
    --cc=jack@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    --cc=pmladek@suse.com \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=tj@kernel.org \
    /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 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.