linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Galbraith <efault@gmx.de>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-rt-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	Thomas Gleixner <tglx@linutronix.de>,
	Steven Rostedt <rostedt@goodmis.org>,
	Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH RT 4/2] hrtimer: Don't lose state in cpu_chill()
Date: Mon, 25 Feb 2019 18:40:36 +0100	[thread overview]
Message-ID: <1551116436.5281.5.camel@gmx.de> (raw)
In-Reply-To: <20190225163440.ptw2ohijokhumn7i@linutronix.de>

On Mon, 2019-02-25 at 17:34 +0100, Sebastian Andrzej Siewior wrote:
> On 2019-02-25 15:43:35 [+0100], Mike Galbraith wrote:
> > Hi Sebastian,
> Hi Mike,
> 
> > My box claims that this patch is busted.  It argues its case by IO
> > deadlocking any kernel this patch is applied to when spinning rust is
> > flogged, including virgin 4.19-rt14, said kernel becoming stable again
> > when I whack the accused.
> 
> does the following hunk make any difference?

Ah.  Yup, box says you're right.

> diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
> index 6ecdb9469ca9..e154632b90b4 100644
> --- a/kernel/time/hrtimer.c
> +++ b/kernel/time/hrtimer.c
> @@ -1884,20 +1884,29 @@ COMPAT_SYSCALL_DEFINE2(nanosleep, struct old_timespec32 __user *, rqtp,
>   */
>  void cpu_chill(void)
>  {
> +	struct task_struct *self = current;
>  	ktime_t chill_time;
>  	unsigned int freeze_flag = current->flags & PF_NOFREEZE;
> -	long saved_state;
>  
> -	saved_state = current->state;
> -	chill_time = ktime_set(0, NSEC_PER_MSEC);
> +	raw_spin_lock_irq(&self->pi_lock);
> +	WARN_ON(self->saved_state != TASK_RUNNING);
> +	self->saved_state = self->state;
>  	__set_current_state_no_track(TASK_UNINTERRUPTIBLE);
> +	raw_spin_unlock_irq(&self->pi_lock);
> +
> +	chill_time = ktime_set(0, NSEC_PER_MSEC);
> +
>  	current->flags |= PF_NOFREEZE;
>  	sleeping_lock_inc();
>  	schedule_hrtimeout(&chill_time, HRTIMER_MODE_REL_HARD);
>  	sleeping_lock_dec();
>  	if (!freeze_flag)
>  		current->flags &= ~PF_NOFREEZE;
> -	__set_current_state_no_track(saved_state);
> +
> +	raw_spin_lock_irq(&self->pi_lock);
> +	__set_current_state_no_track(self->saved_state);
> +	self->saved_state = TASK_RUNNING;
> +	raw_spin_unlock_irq(&self->pi_lock);
>  }
>  EXPORT_SYMBOL(cpu_chill);
>  #endif
> 
> Sebastian

  reply	other threads:[~2019-02-25 17:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-18 16:31 [PATCH RT 1/2] softirq: Avoid "local_softirq_pending" messages if ksoftirqd is blocked Sebastian Andrzej Siewior
2019-02-18 16:31 ` [PATCH RT 2/2] x86: lazy-preempt: properly check against preempt-mask Sebastian Andrzej Siewior
2019-02-19 16:07   ` [PATCH RT 3/2] softirq: Avoid "local_softirq_pending" messages if task is in cpu_chill() Sebastian Andrzej Siewior
2019-02-19 16:08     ` [PATCH RT 4/2] hrtimer: Don't lose state " Sebastian Andrzej Siewior
2019-02-25 14:43       ` Mike Galbraith
2019-02-25 16:34         ` Sebastian Andrzej Siewior
2019-02-25 17:40           ` Mike Galbraith [this message]
2019-02-26 11:38             ` Sebastian Andrzej Siewior
2019-02-19 14:58 ` [PATCH RT 1/2] softirq: Avoid "local_softirq_pending" messages if ksoftirqd is blocked Juri Lelli
2019-02-19 16:06   ` Sebastian Andrzej Siewior
2019-02-19 16:27     ` Juri Lelli
2019-02-19 16:28       ` Sebastian Andrzej Siewior

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=1551116436.5281.5.camel@gmx.de \
    --to=efault@gmx.de \
    --cc=bigeasy@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.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;
as well as URLs for NNTP newsgroup(s).