Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2656867pxa; Mon, 17 Aug 2020 15:42:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSMqPgpcWY1OPxn+WtTIlpNDZTdzlDM3VQOlkcVkuXOlRrHHniXWyZaZ3eYVPXPvHmxPmK X-Received: by 2002:a17:906:d159:: with SMTP id br25mr16742428ejb.16.1597704143636; Mon, 17 Aug 2020 15:42:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597704143; cv=none; d=google.com; s=arc-20160816; b=EJZ9DF7HXM8wz6q+ZPFE1YNGnIMGTRzxoXsaHQl8TK4E2zhmg6Dxaj6cCEY8jESjNz kmaQ87JqIjXDwO2XIqcmi49clL6L2RicAHxSReLhMLb+/eRan7WrzczRMfhgoBsbQIVe QlGfEhgXyMUlF771e1ILQWyi09uztDqexhLQ204BG7OCQ14LtVhll8RYp7A6RmU3xKTO Fsj9yw1x6SfJF3KoIFH5onqQNsbHVAfT9i4Kz33c3eJvny0jXdlrXpFYlAc5GrjjQsMS AVPsMMewnx8GU2P1FgAvXJV3h/2+BYSlJppwl+sFwuTWR2vUzYYD8+g3pTCUj16KyMwC sLRA== 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=ATD08YhkcS5u1aFeKku7Po0clfRhfE9bBSk2m5uXPr8=; b=KS6PI49e3Bn7/yVu437IMvmIN9lOeAA24Yq7enlastp+yyF/yXqyUejlLErqLnh1WF /AiFHKcCHRmuMlzmD77kSxezCq8jG8AT2ybqZjTOL1B9/TBNFDy2bb3E43dtiq3hkCmb T3YW4qDbzhW5wHLkYKbu0zinCnNRHQJhNAk89NOu0Kj8HcqTXgOvZhWcKFJz94+wS/Ca BzEL+jJe5Fzg98fN0avHAwCV86EP5OFhSK7NV+QXw+tv65PTZMg8p0QqjdAZF3/wCe0m TBbZAEoXcP+mnUehKeyVuCS19aK0VY/qiP2Anx8p58qeHyVCUyA6FQCJKrwltOyIIF0g 9ywg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="af/XlmM/"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ch17si11774964ejb.627.2020.08.17.15.42.00; Mon, 17 Aug 2020 15:42: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="af/XlmM/"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731012AbgHQShi (ORCPT + 99 others); Mon, 17 Aug 2020 14:37:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:46278 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730945AbgHQP7D (ORCPT ); Mon, 17 Aug 2020 11:59:03 -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 27920206FA; Mon, 17 Aug 2020 15:58:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597679940; bh=bG8t/xepkdf4mxiEc3Yj/rM9RKATeDbJ8MdTAc8pIqU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=af/XlmM/TAUvgHJLkHlp1FowPdXDp+9D+NGgKiy94JAUBEDhecy4icxyOwHhsKAhN ORWMEOX1iIOFD6k6I/VC5xJzBHIShY7+MwmuV9oQxhLwwlEVa9Ncp/xoRfSbJHGnwm K/629xnoCuN5gTUIOgSt6k+rSicfI1c+6v5AbMNI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Josef , Jens Axboe Subject: [PATCH 5.7 356/393] io_uring: use TWA_SIGNAL for task_work uncondtionally Date: Mon, 17 Aug 2020 17:16:46 +0200 Message-Id: <20200817143836.867157350@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143819.579311991@linuxfoundation.org> References: <20200817143819.579311991@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: Jens Axboe commit 0ba9c9edcd152158a0e321a4c13ac1dfc571ff3d upstream. An earlier commit: b7db41c9e03b ("io_uring: fix regression with always ignoring signals in io_cqring_wait()") ensured that we didn't get stuck waiting for eventfd reads when it's registered with the io_uring ring for event notification, but we still have cases where the task can be waiting on other events in the kernel and need a bigger nudge to make forward progress. Or the task could be in the kernel and running, but on its way to blocking. This means that TWA_RESUME cannot reliably be used to ensure we make progress. Use TWA_SIGNAL unconditionally. Cc: stable@vger.kernel.org # v5.7+ Reported-by: Josef Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- fs/io_uring.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -4161,22 +4161,22 @@ static int io_req_task_work_add(struct i { struct task_struct *tsk = req->task; struct io_ring_ctx *ctx = req->ctx; - int ret, notify = TWA_RESUME; + int ret, notify; /* - * SQPOLL kernel thread doesn't need notification, just a wakeup. - * If we're not using an eventfd, then TWA_RESUME is always fine, - * as we won't have dependencies between request completions for - * other kernel wait conditions. + * SQPOLL kernel thread doesn't need notification, just a wakeup. For + * all other cases, use TWA_SIGNAL unconditionally to ensure we're + * processing task_work. There's no reliable way to tell if TWA_RESUME + * will do the job. */ - if (ctx->flags & IORING_SETUP_SQPOLL) - notify = 0; - else if (ctx->cq_ev_fd) + notify = 0; + if (!(ctx->flags & IORING_SETUP_SQPOLL)) notify = TWA_SIGNAL; ret = task_work_add(tsk, cb, notify); if (!ret) wake_up_process(tsk); + return ret; }