From patchwork Fri Jun 19 14:30:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 223758 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B01FC433E1 for ; Fri, 19 Jun 2020 16:30:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3C4DE2100A for ; Fri, 19 Jun 2020 16:30:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592584225; bh=EX0j6+M/+UdwY/4QdsFpQQKwXC4s7i5x/rj9KTC31EI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=g26XYDDNOqUe/GHe9vqL7GHpi4f8vrMXvxVQiYjoOzaAlqcNmxCVoMbJe64722CMB qSdYjcuxpdCFnZY24g4wFLkQ5U65gDov1LPaJCytrtDa2wgHvVaIxkwAvRLqsj25QM IniK288C/q3NGWh51YN7CuExAEk3uWRvC1xK+aKw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389758AbgFSOxp (ORCPT ); Fri, 19 Jun 2020 10:53:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:48148 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389751AbgFSOxo (ORCPT ); Fri, 19 Jun 2020 10:53:44 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B301F21556; Fri, 19 Jun 2020 14:53:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592578424; bh=EX0j6+M/+UdwY/4QdsFpQQKwXC4s7i5x/rj9KTC31EI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DoDxa1rxC1VwXpToKxME5XTbpfjUk8dYElaYkkePqTuTWk6LWFXSn12lYuQ5r9Xtb hTeCHh6OJEtbAyPKXRGWh7hmZ87ascUqhg6zGv2C0nx35RzFZl6HKWQCe8olgzq28E aKukLswyY/zv2NUgg02+LxGnYmG3B2hCegFTbaHY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stefano Garzarella , Jens Axboe , Ingo Molnar , Peter Zijlstra , Sasha Levin Subject: [PATCH 4.19 017/267] sched/fair: Dont NUMA balance for kthreads Date: Fri, 19 Jun 2020 16:30:02 +0200 Message-Id: <20200619141649.697544229@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141648.840376470@linuxfoundation.org> References: <20200619141648.840376470@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jens Axboe [ Upstream commit 18f855e574d9799a0e7489f8ae6fd8447d0dd74a ] 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 Signed-off-by: Sasha Levin --- 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 86ccaaf0c1bf..92b1e71f13c8 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -2697,7 +2697,7 @@ 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; /*