From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9ADC7BA49 for ; Tue, 7 Mar 2023 18:31:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DCABBC433EF; Tue, 7 Mar 2023 18:31:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1678213918; bh=4DD6UMs/Kp7C205tvqfOYPFXx1CLsiPgjKiJk5oWt64=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2eV5m2lYzNAM96B76djscwOWIAEgUuZX5qpQoycbR+SCU12KHcekJ4zx1aKLg3nO6 iglKG8Mo/NXZ4hDlEkE2lo5HOithMaAYRxYB06obWqJvnZJwB5Fo0eeQwlM8VOmrge 1yKxpMJohJZLsmMdN8zNOQdgUvAw5J8A7z5+tUXg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jens Axboe Subject: [PATCH 6.1 661/885] io_uring: add reschedule point to handle_tw_list() Date: Tue, 7 Mar 2023 17:59:55 +0100 Message-Id: <20230307170030.875304017@linuxfoundation.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307170001.594919529@linuxfoundation.org> References: <20230307170001.594919529@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Jens Axboe commit f58680085478dd292435727210122960d38e8014 upstream. If CONFIG_PREEMPT_NONE is set and the task_work chains are long, we could be running into issues blocking others for too long. Add a reschedule check in handle_tw_list(), and flush the ctx if we need to reschedule. Cc: stable@vger.kernel.org # 5.10+ Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- io_uring/io_uring.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -1030,10 +1030,16 @@ static unsigned int handle_tw_list(struc /* if not contended, grab and improve batching */ *locked = mutex_trylock(&(*ctx)->uring_lock); percpu_ref_get(&(*ctx)->refs); - } + } else if (!*locked) + *locked = mutex_trylock(&(*ctx)->uring_lock); req->io_task_work.func(req, locked); node = next; count++; + if (unlikely(need_resched())) { + ctx_flush_and_put(*ctx, locked); + *ctx = NULL; + cond_resched(); + } } return count;