Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1083416ybt; Wed, 1 Jul 2020 18:26:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAFj2W2vbz0JaILygAGE/bCsCTb9RuuE/BAR0BHmvHkPOjrBX0+zGpl0nU0RHszPJf5bIF X-Received: by 2002:aa7:cf82:: with SMTP id z2mr17216611edx.15.1593653213227; Wed, 01 Jul 2020 18:26:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593653213; cv=none; d=google.com; s=arc-20160816; b=Hdm/FFoS5F/CEKwBqCzvgL7LrQLmMGpbqtkwvE3vqydaKp1omAG7riKPDwu8a/rT7H aw/C4+xomw/Na/Cbq1MNnzDLXD1YEmKXKNIJ6k+VPkkeHbe9Tx2JQpT4aX6ZKxRcW2F3 2EsZayOekg73YlPOVvKkOvv5VzNucWqa3lFsgNxkDQGQjlwsIgtbQXQKplDS7RaRL+Qe QdDV/MPUoXi2imKoFiA2rVXVtshuLNtkglfXCRB/Pv1EDEJcHK/sr8SwJDJMzVZacCsX iD5IBzbVPrMK7ZUtU1I91cWta5z39xxTfdo+dhqbK8lNlejcgB5FQlH5d0HlHipnfRU0 dXgQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hswuPa8libbVrXMijTWoPKPT6jIHcF+QFT+ccVwL2yE=; b=m4L/5IWCfFDZ3OyyaB1htmI0xB0htbJrxUYKSWsOrs8+9hVJFqu35+dYt9uf7UgBeQ dOvNXqdfSJolwMnahX4iRbneJfZtuTE4np7C9KK1Dwfb2+p6OBQP0q6X2LzHlNHCgCzq RHNOpWwMygBUkyPr9qeY0z26sTwmc+D6CP9agqkmC4UJbhFcX+/8QUhNq6EB/CsutMj/ +Caz0x5XAoaZnJkki557q1rF1coevOEqkBrLRcajEm/J1e6JhUXR4G6v1yzi57UrTeNH 6i1rEb7j6MHstBOfWpAPkeMxK0QfzkdZeHRvltPrtevBnJcoaxcG69OBjKEZmmEC1Hif dC6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1HbT+18n; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ck29si4772622edb.236.2020.07.01.18.26.29; Wed, 01 Jul 2020 18:26:53 -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=1HbT+18n; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728792AbgGBBZ0 (ORCPT + 99 others); Wed, 1 Jul 2020 21:25:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:54434 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728366AbgGBBXo (ORCPT ); Wed, 1 Jul 2020 21:23:44 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DC2F620885; Thu, 2 Jul 2020 01:23:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593653023; bh=hVnObDxVcx1RGwFLMx3QUPjXV49Wc2ghcsfqJzOTPC0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1HbT+18n77Dp4VD448UuLPBCw5oukfo1SXQXVtRnflduA9ShOVyDi9ic8vBLwto6U Ey98YBOQJkzamtsrCjUg6cH2NPQF/VNAy0s7cqDQeAfFFOuuNUx3sD45yK/nS3iSDZ O2kOja7fEC7muaij5pw6U3LQ3IvC/HNnie8ViO6M= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Xuan Zhuo , Jens Axboe , Sasha Levin , io-uring@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH AUTOSEL 5.7 39/53] io_uring: fix io_sq_thread no schedule when busy Date: Wed, 1 Jul 2020 21:21:48 -0400 Message-Id: <20200702012202.2700645-39-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200702012202.2700645-1-sashal@kernel.org> References: <20200702012202.2700645-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 1829be7f63a35..6cf9d509371e2 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -6071,7 +6071,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 @@ -6087,7 +6087,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