linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org,
	linux-rt-users <linux-rt-users@vger.kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Carsten Emde <C.Emde@osadl.org>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	John Kacur <jkacur@redhat.com>,
	Paul Gortmaker <paul.gortmaker@windriver.com>,
	Julia Cartwright <julia@ni.com>,
	Daniel Wagner <daniel.wagner@siemens.com>,
	tom.zanussi@linux.intel.com, stable-rt@vger.kernel.org,
	Daniel Bristot de Oliveira <bristot@redhat.com>
Subject: [PATCH RT 09/13] hrtimer: move state change before hrtimer_cancel in do_nanosleep()
Date: Mon, 07 Jan 2019 14:53:01 -0500	[thread overview]
Message-ID: <20190107195333.322706801@goodmis.org> (raw)
In-Reply-To: 20190107195252.599921907@goodmis.org

4.14.87-rt50-rc1 stable review patch.
If anyone has any objections, please let me know.

------------------

From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

[ Upstream commit 8115ac730fd5aa27134f002cf710204b5dd7cd5e ]

There is a small window between setting t->task to NULL and waking the
task up (which would set TASK_RUNNING). So the timer would fire, run and
set ->task to NULL while the other side/do_nanosleep() wouldn't enter
freezable_schedule(). After all we are peemptible here (in
do_nanosleep() and on the timer wake up path) and on KVM/virt the
virt-CPU might get preempted.
So do_nanosleep() wouldn't enter freezable_schedule() but cancel the
timer which is still running and wait for it via
hrtimer_wait_for_timer(). Then wait_event()/might_sleep() would complain
that it is invoked with state != TASK_RUNNING.
This isn't a problem since it would be reset to TASK_RUNNING later
anyway and we don't rely on the previous state.

Move the state update to TASK_RUNNING before hrtimer_cancel() so there
are no complains from might_sleep() about wrong state.

Cc: stable-rt@vger.kernel.org
Reviewed-by: Daniel Bristot de Oliveira <bristot@redhat.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/time/hrtimer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index b59e009087a9..c8d806126381 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -1753,12 +1753,12 @@ static int __sched do_nanosleep(struct hrtimer_sleeper *t, enum hrtimer_mode mod
 		if (likely(t->task))
 			freezable_schedule();
 
+		__set_current_state(TASK_RUNNING);
 		hrtimer_cancel(&t->timer);
 		mode = HRTIMER_MODE_ABS;
 
 	} while (t->task && !signal_pending(current));
 
-	__set_current_state(TASK_RUNNING);
 
 	if (!t->task)
 		return 0;
-- 
2.19.2



  parent reply	other threads:[~2019-01-07 19:54 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-07 19:52 [PATCH RT 00/13] Linux 4.14.87-rt50-rc1 Steven Rostedt
2019-01-07 19:52 ` [PATCH RT 01/13] work-simple: drop a shit statement in SWORK_EVENT_PENDING Steven Rostedt
2019-01-08  3:06   ` Sergey Senozhatsky
2019-01-08  3:26     ` Steven Rostedt
2019-01-08  4:47       ` Sergey Senozhatsky
2019-01-08  9:00         ` Sebastian Andrzej Siewior
2019-01-07 19:52 ` [PATCH RT 02/13] kthread: convert worker lock to raw spinlock Steven Rostedt
2019-01-07 19:52 ` [PATCH RT 03/13] mm/kasan: make quarantine_lock a raw_spinlock_t Steven Rostedt
2019-01-07 19:52 ` [PATCH RT 05/13] sched/migrate_disable: Add export_symbol_gpl for __migrate_disabled Steven Rostedt
2019-01-07 19:52 ` [PATCH RT 06/13] pinctrl: bcm2835: Use raw spinlock for RT compatibility Steven Rostedt
2019-01-07 19:52 ` [PATCH RT 07/13] rcu: make RCU_BOOST default on RT without EXPERT Steven Rostedt
2019-01-07 19:53 ` [PATCH RT 08/13] x86/fpu: Disable preemption around local_bh_disable() Steven Rostedt
2019-01-07 19:53 ` Steven Rostedt [this message]
2019-01-07 19:53 ` [PATCH RT 10/13] drm/i915: disable tracing on -RT Steven Rostedt
2019-01-07 20:10   ` Sebastian Andrzej Siewior
2019-01-07 19:53 ` [PATCH RT 11/13] x86/mm/pat: disable preemption __split_large_page() after spin_lock() Steven Rostedt
2019-01-07 19:53 ` [PATCH RT 13/13] Linux 4.14.87-rt50-rc1 Steven Rostedt

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=20190107195333.322706801@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=C.Emde@osadl.org \
    --cc=bigeasy@linutronix.de \
    --cc=bristot@redhat.com \
    --cc=daniel.wagner@siemens.com \
    --cc=jkacur@redhat.com \
    --cc=julia@ni.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=paul.gortmaker@windriver.com \
    --cc=stable-rt@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=tom.zanussi@linux.intel.com \
    /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).