public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Jiri Bohac <jbohac@suse.cz>
Cc: John Stultz <john.stultz@linaro.org>, linux-kernel@vger.kernel.org
Subject: Re: is printk() safe within a timekeeper_seq write section?
Date: Wed, 12 Mar 2014 10:18:41 +0100	[thread overview]
Message-ID: <20140312091841.GN30956@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <20140306174531.GA30634@midget.suse.cz>

On Thu, Mar 06, 2014 at 06:45:31PM +0100, Jiri Bohac wrote:
> Hi,
> 
> I'm looking at the printk call in
> __timekeeping_inject_sleeptime(), introduced in cb5de2f8
> (time: Catch invalid timespec sleep values in __timekeeping_inject_sleeptime)
> 
> Is it safe to call printk() while timekeeper_seq is held for
> writing?
> 
> What about this call chain?
>   printk
>     vprintk_emit
>       console_unlock
>         up(&console_sem)
>           __up
> 	    wake_up_process
> 	      try_to_wake_up
> 	        ttwu_do_activate
> 		  ttwu_activate
> 		    activate_task
> 		      enqueue_task
> 		        enqueue_task_fair
> 			  hrtick_update
> 			    hrtick_start_fair
> 			      hrtick_start_fair
> 			        get_time
> 				  ktime_get
> 				    --> endless loop on
> 				    read_seqcount_retry(&timekeeper_seq, ...)
> 		  
> 
> It looks like an unlikely but possible deadlock. 
> Or did I overlook something?

So HRTICK is disabled by default; but yes this is a problem when you
enable it.

The problem is that our timers are in an entirely different clock base
than our (scheduler) clocks.

On SNB+ hardware with TSC deadline timers we have the same clockbase I
suppose but I'm not sure that's something we can (and want) to rely on.

Now, I've long had the idea to mess up the hrtimer code to optimize this
particular timer, but I'm not entirely sure we can get around having to
use the timerkeeper_seq thing, we simply have to get into timer clock
space :/

      parent reply	other threads:[~2014-03-12  9:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-06 17:45 is printk() safe within a timekeeper_seq write section? Jiri Bohac
2014-03-11 19:29 ` John Stultz
2014-03-11 21:32   ` Thomas Gleixner
2014-03-11 21:54     ` John Stultz
2014-03-12  6:49       ` Peter Zijlstra
2014-03-12  9:21       ` Jiri Bohac
2014-03-28  0:49         ` John Stultz
2014-03-12  6:46     ` Peter Zijlstra
2014-03-12 14:34       ` Jan Kara
2014-03-12 15:06         ` Peter Zijlstra
2014-03-14 15:13           ` Jan Kara
2014-03-12 13:13     ` Jan Kara
2014-03-12  9:25   ` Peter Zijlstra
2014-03-12  9:18 ` Peter Zijlstra [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=20140312091841.GN30956@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=jbohac@suse.cz \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox