]> git.karo-electronics.de Git - karo-tx-linux.git/commit
timekeeping: use printk_deferred when holding timekeeping seqlock
authorJohn Stultz <john.stultz@linaro.org>
Wed, 14 May 2014 00:02:28 +0000 (10:02 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 14 May 2014 00:02:28 +0000 (10:02 +1000)
commitc6042d891e071eb7d8f116f35f75aa6b6d774757
treede1f91fe6c536b96dcbe40b47d9715bd6fb4e5a6
parent7a0f1128d34c18b85cc8c52225dfa97e4eaa40ff
timekeeping: use printk_deferred when holding timekeeping seqlock

Jiri Bohac pointed out that there are rare but potential deadlock
possibilities when calling printk while holding the timekeeping
seqlock.

This is due to printk() triggering console sem wakeup, which can
cause scheduling code to trigger hrtimers which may try to read
the time.

Specifically, as Jiri pointed out, that path is:
  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, ...)

This patch tries to avoid this issue by using printk_deferred (previously
named printk_sched) which should defer printing via a irq_work_queue.

Signed-off-by: John Stultz <john.stultz@linaro.org>
Reported-by: Jiri Bohac <jbohac@suse.cz>
Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
kernel/time/ntp.c
kernel/time/timekeeping.c