LKML Archive on
 help / color / Atom feed
From: "tip-bot2 for Jens Axboe" <>
Cc: Stefano Garzarella <>,
	Jens Axboe <>, Ingo Molnar <>,
	Peter Zijlstra <>, x86 <>,
	LKML <>
Subject: [tip: sched/urgent] sched/fair: Don't NUMA balance for kthreads
Date: Tue, 26 May 2020 16:37:31 -0000
Message-ID: <159051105169.17951.7766343551502727932.tip-bot2@tip-bot2> (raw)
In-Reply-To: <>

The following commit has been merged into the sched/urgent branch of tip:

Commit-ID:     18f855e574d9799a0e7489f8ae6fd8447d0dd74a
Author:        Jens Axboe <>
AuthorDate:    Tue, 26 May 2020 09:38:31 -06:00
Committer:     Ingo Molnar <>
CommitterDate: Tue, 26 May 2020 18:34:58 +02:00

sched/fair: Don't NUMA balance for kthreads

Stefano reported a crash with using SQPOLL with io_uring:

  BUG: kernel NULL pointer dereference, address: 00000000000003b0
  CPU: 2 PID: 1307 Comm: io_uring-sq Not tainted 5.7.0-rc7 #11
  RIP: 0010:task_numa_work+0x4f/0x2c0
  Call Trace:

which is task_numa_work() oopsing on current->mm being NULL.

The task work is queued by task_tick_numa(), which checks if current->mm is
NULL at the time of the call. But this state isn't necessarily persistent,
if the kthread is using use_mm() to temporarily adopt the mm of a task.

Change the task_tick_numa() check to exclude kernel threads in general,
as it doesn't make sense to attempt ot balance for kthreads anyway.

Reported-by: Stefano Garzarella <>
Signed-off-by: Jens Axboe <>
Signed-off-by: Ingo Molnar <>
Acked-by: Peter Zijlstra <>
 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 538ba5d..da3e5b5 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -2908,7 +2908,7 @@ static void task_tick_numa(struct rq *rq, struct task_struct *curr)
 	 * We don't care about NUMA placement if we don't have memory.
-	if (!curr->mm || (curr->flags & PF_EXITING) || work->next != work)
+	if ((curr->flags & (PF_EXITING | PF_KTHREAD)) || work->next != work)

  reply index

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-26 15:38 [PATCH] sched/fair: don't " Jens Axboe
2020-05-26 16:37 ` tip-bot2 for Jens Axboe [this message]
2020-05-26 16:40 ` Valentin Schneider
2020-05-26 20:00   ` Peter Zijlstra
2020-05-26 23:42     ` Valentin Schneider

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 \
    --in-reply-to=159051105169.17951.7766343551502727932.tip-bot2@tip-bot2 \ \ \ \ \ \ \ \ \

* 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