Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1363281

Re: [RFC][PATCH v6 1/2] printk: Make printk() completely async

From Petr Mladek <pmladek@suse.com>
Newsgroups linux.kernel
Subject Re: [RFC][PATCH v6 1/2] printk: Make printk() completely async
Date 2016-03-23 11:10 +0100
Message-ID <rfNTI-1NT-19@gated-at.bofh.it> (permalink)
References <rfbOq-qS-11@gated-at.bofh.it> <rfbOq-qS-9@gated-at.bofh.it> <rfuo2-4SV-11@gated-at.bofh.it> <rfF07-3MW-41@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed 2016-03-23 09:37:25, Sergey Senozhatsky wrote:
> Hello Petr,
> 
> On (03/22/16 14:11), Petr Mladek wrote:
> > > +	 * Set printing_func() sleep condition early, under the @logbuf_lock.
> > > +	 * So printing kthread (if RUNNING) will go to console_lock() and spin
> > > +	 * on @logbuf_lock.
> > > +	 */
> > > +	if (!printk_sync)
> > > +		need_flush_console = true;
> > 
> > We set this variable for each call and also when printk_kthread is
> > NULL or when sync_printk is false.
> 
> hm, yes. (printk_kthread && !need_flush_console) makes more sense.
> so we it doesn't get re-dirty if already set.

This does not solve the problem mentioned below. There still might be
extra cycle if the kthread is inside console_unclock().

> > We migth want to clear it also from console_unlock(). I think that
> > a good place would be in the check:
> > 
> > 	raw_spin_lock(&logbuf_lock);
> > 	retry = console_seq != log_next_seq;
> > 	raw_spin_unlock_irqrestore(&logbuf_lock, flags);
> 
> hm, what's wrong with clearing it in printk_kthread  printing function?

I though about the following scenario:

CPU0					CPU1

vprintk_emit()
  need_flush_console = true;

  wake_up_process(printk_thread)

					printing_func()

					  need_flush_console = false;

					  console_lock()
					  console_unlock()

vprintk_emit()

  need_flush_console = true;

					    # flush 1st message
					    # flush 2nd message

					    if (!need_flush_console)
					      # fails and continues

					    console_lock()
					    console_unlock()

					    # nope because 2nd
					    # message already flushed

					  if (!need_flush_console)
					     schedule()

					     # did one unnecessary
					     # cycle to get asleep


Best Regards,
Petr

PS: If you touch the code, please rename printing_func() to
printk_kthread_func() to make it more clear what it does.
I am sorry for nitpicking.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC][PATCH v6 1/2] printk: Make printk() completely async Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-03-21 18:30 +0100
  Re: [RFC][PATCH v6 1/2] printk: Make printk() completely async Petr Mladek <pmladek@suse.com> - 2016-03-22 14:20 +0100
    Re: [RFC][PATCH v6 1/2] printk: Make printk() completely async Petr Mladek <pmladek@suse.com> - 2016-03-22 15:10 +0100
    Re: [RFC][PATCH v6 1/2] printk: Make printk() completely async Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-03-23 01:40 +0100
      Re: [RFC][PATCH v6 1/2] printk: Make printk() completely async Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-03-23 09:50 +0100
      Re: [RFC][PATCH v6 1/2] printk: Make printk() completely async Petr Mladek <pmladek@suse.com> - 2016-03-23 11:10 +0100
        Re: [RFC][PATCH v6 1/2] printk: Make printk() completely async Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-03-24 03:30 +0100
  Re: [RFC][PATCH v6 1/2] printk: Make printk() completely async Petr Mladek <pmladek@suse.com> - 2016-03-22 17:40 +0100
    Re: [RFC][PATCH v6 1/2] printk: Make printk() completely async Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-03-23 02:30 +0100
      Re: [RFC][PATCH v6 1/2] printk: Make printk() completely async Petr Mladek <pmladek@suse.com> - 2016-03-23 10:30 +0100
        Re: [RFC][PATCH v6 1/2] printk: Make printk() completely async Jan Kara <jack@suse.cz> - 2016-03-23 14:20 +0100
          Re: [RFC][PATCH v6 1/2] printk: Make printk() completely async Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-03-23 15:40 +0100
            Re: [RFC][PATCH v6 1/2] printk: Make printk() completely async Jan Kara <jack@suse.cz> - 2016-03-23 15:50 +0100

csiph-web