Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1131456ybt; Tue, 7 Jul 2020 08:27:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXi92LoNhOUAGijXS1e6poWYaJ7tLlVTYGishR+Q6buMWxpwQknQuXXB7LU8mXZv+3zJGG X-Received: by 2002:a17:906:469a:: with SMTP id a26mr45412546ejr.198.1594135643884; Tue, 07 Jul 2020 08:27:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594135643; cv=none; d=google.com; s=arc-20160816; b=wGaWlFtqhX4rxYZ2F/JxqdQBZw36Q/mXB0B0gzMU4dEpm1A0iYPVTDYREKXFiybv0f +utOQtSnyDC5NdDS1N0DYtXOwvmOOMqyeivs++YF+7xN5mTG8a42QTbHQP63iq56azbk u9Q9HIbTIcW19aHGR/uKPM6emEICwSpiw5varJSpbwOCKK4gLLyiHq0wiNULd/SSgPVw wKgFdGPnXsfY6YBPFRNKTS6XZ8wYMEPKX6zx6VfgX65s8KN1LeUbf1v6XWu47S/x0L6P HMI7iZGcbFaiCKNECt18FXzGle0BLoZQjmG04NqiRzVrxoNBcuVXko1UxweO2feNIKVP K1wg== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4MOBgwdv3HvvBCzBiD9Xybqzi8GjyRj/Ws3e5+9I3nY=; b=C4hsNckuiYTlCIMMY+MuoJByXmVDjTEBuFN3oYtD/5mLnuWPKxhCiycgUTIuO5O9Au KdYm+OPRvj4GfEAItz9p3ujnPZHReJ8DvsIrBwsgX5E/g+SldsmirRp/vgyG2kLR9IwZ HoDhzLa7Cph4IAjpBHpUHQvqrF/lexXbfW8Y1cAC7ApzdoSeb+LyfyGNaFgpuj6YtL/t 0SfQ+XtRith4PjRqb19MtpxNR3wX5v3wpPAQxkX+sfvj5J8+eKD1uXqxNrtDAeaeglgk wdb6mjeLCAbTg9slWVsRfd5V+XTN2tSQirp4ZoENSkpAIkHpVMgSyETFnnbjMtyuU/kd LZuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1+ow4+93; 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 v18si15022886edy.249.2020.07.07.08.27.00; Tue, 07 Jul 2020 08:27:23 -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; dkim=pass header.i=@kernel.org header.s=default header.b=1+ow4+93; 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 S1729991AbgGGPXm (ORCPT + 99 others); Tue, 7 Jul 2020 11:23:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:36810 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728879AbgGGPXh (ORCPT ); Tue, 7 Jul 2020 11:23:37 -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 40ABD2065D; Tue, 7 Jul 2020 15:23:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594135416; bh=icEx2rs1FcIm/j9Jcdb7xo63CLckXhpCa6bWSvF59U8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1+ow4+93qKnwU3rnNF+5EUk2SseCgzyPLxZyM2gUmbMMmCdoV9K+VUcudtnGmBJdx b44LkiX+FoIq3a16d38tZRI8ieWPRyj4n3y2lkaYwt1oza1zImzVbBm+DtzhBc2SBt QYgZ9upexy9kafqtJa9i+6nakJvO8ziJ/cYeJtcw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jens Axboe , Xuan Zhuo , Sasha Levin Subject: [PATCH 5.7 033/112] io_uring: fix io_sq_thread no schedule when busy Date: Tue, 7 Jul 2020 17:16:38 +0200 Message-Id: <20200707145802.563255670@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200707145800.925304888@linuxfoundation.org> References: <20200707145800.925304888@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xuan Zhuo [ Upstream commit b772f07add1c0b22e02c0f1e96f647560679d3a9 ] When the user consumes and generates sqe at a fast rate, io_sqring_entries can always get sqe, and ret will not be equal to -EBUSY, so that io_sq_thread will never call cond_resched or schedule, and then we will get the following system error prompt: rcu: INFO: rcu_sched self-detected stall on CPU or watchdog: BUG: soft lockup-CPU#23 stuck for 112s! [io_uring-sq:1863] This patch checks whether need to call cond_resched() by checking the need_resched() function every cycle. Suggested-by: Jens Axboe Signed-off-by: Xuan Zhuo Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- fs/io_uring.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index bb74e45941af2..63a456921903e 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -6084,7 +6084,7 @@ static int io_sq_thread(void *data) * If submit got -EBUSY, flag us as needing the application * to enter the kernel to reap and flush events. */ - if (!to_submit || ret == -EBUSY) { + if (!to_submit || ret == -EBUSY || need_resched()) { /* * Drop cur_mm before scheduling, we can't hold it for * long periods (or over schedule()). Do this before @@ -6100,7 +6100,7 @@ static int io_sq_thread(void *data) * more IO, we should wait for the application to * reap events and wake us up. */ - if (!list_empty(&ctx->poll_list) || + if (!list_empty(&ctx->poll_list) || need_resched() || (!time_after(jiffies, timeout) && ret != -EBUSY && !percpu_ref_is_dying(&ctx->refs))) { if (current->task_works) -- 2.25.1