LKML Archive on
 help / color / Atom feed
From: Sebastian Andrzej Siewior <>
Cc: Ingo Molnar <>,
	Peter Zijlstra <>,,
	Sebastian Andrzej Siewior <>
Subject: [PATCH] sched/core: Schedule new worker even if PI-blocked
Date: Fri, 16 Aug 2019 18:06:26 +0200
Message-ID: <> (raw)

If a task is PI-blocked (blocking on sleeping spinlock) then we don't want to
schedule a new kworker if we schedule out due to lock contention because !RT
does not do that as well. A spinning spinlock disables preemption and a worker
does not schedule out on lock contention (but spin).

On RT the RW-semaphore implementation uses an rtmutex so
tsk_is_pi_blocked() will return true if a task blocks on it. In this case we
will now start a new worker which may deadlock if one worker is waiting on
progress from another worker. Since a RW-semaphore starts a new worker on !RT,
we should do the same on RT.

XFS is able to trigger this deadlock.

Allow to schedule new worker if the current worker is PI-blocked.

Signed-off-by: Sebastian Andrzej Siewior <>
 kernel/sched/core.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3945,7 +3945,7 @@ void __noreturn do_task_dead(void)
 static inline void sched_submit_work(struct task_struct *tsk)
-	if (!tsk->state || tsk_is_pi_blocked(tsk))
+	if (!tsk->state)
@@ -3961,6 +3961,9 @@ static inline void sched_submit_work(str
+	if (tsk_is_pi_blocked(tsk))
+		return;
 	 * If we are going to sleep and we have plugged IO queued,
 	 * make sure to submit it to avoid deadlocks.

             reply index

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-16 16:06 Sebastian Andrzej Siewior [this message]
2019-08-19  9:52 ` [tip:sched/urgent] " tip-bot for Sebastian Andrzej Siewior
2019-08-20 13:50 ` [PATCH] " Peter Zijlstra
2019-08-20 14:59   ` Sebastian Andrzej Siewior
2019-08-20 15:20     ` Peter Zijlstra
2019-08-20 15:54       ` Sebastian Andrzej Siewior
2019-08-20 16:02         ` Peter Zijlstra
2019-08-20 16:14           ` 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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

LKML Archive on

Archives are clonable:
	git clone --mirror lkml/git/0.git
	git clone --mirror lkml/git/1.git
	git clone --mirror lkml/git/2.git
	git clone --mirror lkml/git/3.git
	git clone --mirror lkml/git/4.git
	git clone --mirror lkml/git/5.git
	git clone --mirror lkml/git/6.git
	git clone --mirror lkml/git/7.git
	git clone --mirror lkml/git/8.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ \
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone