Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp17852ybm; Tue, 26 May 2020 09:40:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvipxI80nEwDQFPDz9+zFIQg/lmN6ecilt4nXXbemK18jHcLRxpV/SPcn00kJQQTU2pepP X-Received: by 2002:a05:6402:417:: with SMTP id q23mr21022490edv.139.1590511203666; Tue, 26 May 2020 09:40:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590511203; cv=none; d=google.com; s=arc-20160816; b=u8pizaFi9yugrngXFdQHmA1mFQw8w+ZEvViPBNQDE5N5grLwiLTS78cpKKMc4Rlix3 uy62ZAKKoHQgEa1OoYJO9WMTfEuzo0PRHPF0A8AiH8asicU4Jqjz6zQPDEhXs5Y7a43l HH0MxXRfduvFEmIHj6CVI53RN/Kx9e8JGytuYvKXYCXt1XomeevEuWdCzqBM1lhHMVPX 23ebDiWi1AoxhhRZmEbc0ptqTPGGUHdxVMHFZy0hIxKf3W9k9/YoSze1IllpWv0I0uA6 wAx3b1U6dRCGj9BGAEiBKlf0nSH0ahB1BP4by0CC1A8PXWcHqWXQi4aHVDIgysEjQPZw Vs4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=/Y1XFpYq+VWdtjupCyFwAf7EguBImZleOki8LQXDOtM=; b=Jp9hrvQX5FhjMbxcIj9v4GzoM525HRBJT3wgehgNz0F5KhukJElSNeNaMZmu0Lakwj ZSkk9/+HY/PcTkBq4kjprhxUYe2v3w4zRrQd8+R3az4qz1idM/N0plKG6v1rFn+yY4CP hVSC5G5EtKqjpGGU41OaJTVeBl5Rorwnjm08GROgkO8ITQo5uWyfNAq7MzsIsO2SA3PF 8gq9X/qgkBvdJ7Ba/Q8JVItyEwB+l59eUn1irw26LERPm3n4Fk/GakTPOKxGOEeRto3h s3X9IUo9UsUh9VS007F5Cb2p9CWKCYYru+VAVJ7azJ5tq3cjYlM385L0H0Qzq3fQlw3n kGqw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c102si180510edf.562.2020.05.26.09.39.40; Tue, 26 May 2020 09:40:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728570AbgEZQhi (ORCPT + 99 others); Tue, 26 May 2020 12:37:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726930AbgEZQhi (ORCPT ); Tue, 26 May 2020 12:37:38 -0400 Received: from Galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81DACC03E96D; Tue, 26 May 2020 09:37:38 -0700 (PDT) Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jdca4-0006ac-9Y; Tue, 26 May 2020 18:37:32 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id DAEC51C00FA; Tue, 26 May 2020 18:37:31 +0200 (CEST) Date: Tue, 26 May 2020 16:37:31 -0000 From: "tip-bot2 for Jens Axboe" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/urgent] sched/fair: Don't NUMA balance for kthreads Cc: Stefano Garzarella , Jens Axboe , Ingo Molnar , Peter Zijlstra , x86 , LKML In-Reply-To: <865de121-8190-5d30-ece5-3b097dc74431@kernel.dk> References: <865de121-8190-5d30-ece5-3b097dc74431@kernel.dk> MIME-Version: 1.0 Message-ID: <159051105169.17951.7766343551502727932.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/urgent branch of tip: Commit-ID: 18f855e574d9799a0e7489f8ae6fd8447d0dd74a Gitweb: https://git.kernel.org/tip/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: task_work_run+0x68/0xa0 io_sq_thread+0x252/0x3d0 kthread+0xf9/0x130 ret_from_fork+0x35/0x40 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 Link: https://lore.kernel.org/r/865de121-8190-5d30-ece5-3b097dc74431@kernel.dk --- 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) return; /*