Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4361386pxu; Mon, 12 Oct 2020 17:34:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVQS+7TIlSSDhvAll+a3e6PXLAtE2TdMkPqlQXsi91q8S9Sm3boLejCD1j4sOrpUITmQYN X-Received: by 2002:aa7:de06:: with SMTP id h6mr17051128edv.31.1602549290913; Mon, 12 Oct 2020 17:34:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602549290; cv=none; d=google.com; s=arc-20160816; b=y8AnqtnYOUnpbXW3jgfTZpRtRewYC+BkCihpUvFEdNuD4drlgjNEsX+BGy9mi4k8Xp DTZe/PRFc2GR+fj0jqeiU+5eoozPvbNINc7T0BVWQPgFMhdEt4MXw4OKvvHrLWpY7+fm R9yVBhBPE2FwNeG/upbqSEXIjunEBf80vwAON2uaJnaOgxU8G5aVokn9HI9Grl2Q1yxb cDHtBUv23VzB7/DKHWdU3iplC1msmhyL+G/Tx971Z1jxCIlWnaNqklvPOONLlfGP9GCc N+Hyoqu9lCaxR2R8QZMzZLttgnUOgbIUeJNyuPJuTqwLZ4d6c2luHKjfrIz4JcLjSFY+ jscQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aWiwv5eRCNQxBz3QbenT1er5xrbEDaZdtO5XuHLvfTc=; b=JO7sEhJWtpuJLC3TIQxjlj4OelCpw1TiCgOaTNYxcpPZodpdGobg+Om/xCj8GE/0tF rf98QG/bAtOBQziq1lXBB9SRGwc7ea3xUJRKBMY1RWf5Ouwyiocztntai82wfHJoX12J 2Tg7pTf7vszekz3+p8kACTKb7ogycLhWqAYcujUKz5k5BRv/1xpRnrsw7m8YLwf+UiFD XTLrslBcBrigIHf80yg+4ytK/2XxEWH7bdedPcQs0syK1wKyxw/IUGu3U/jxLwpyFebi f82jx7f5aec7fWdrqiE+5Zu8f01JH1rmbTMg0S2TjJT7dPNlIHDtzgH1JavkAQo4bCUv gyFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eti8JrsB; 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 ot7si13127599ejb.663.2020.10.12.17.34.28; Mon, 12 Oct 2020 17:34:50 -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=eti8JrsB; 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 S2390702AbgJLN6d (ORCPT + 99 others); Mon, 12 Oct 2020 09:58:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:43450 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731468AbgJLNk4 (ORCPT ); Mon, 12 Oct 2020 09:40:56 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 C149A2224A; Mon, 12 Oct 2020 13:40:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602510039; bh=Cm8oRoMhqtPQ8VwK6tUug8MUgovYGLFNqrjpyTJLxKA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eti8JrsBf0zJk/AceTG6GZOjFZkwaAhmD2tvF0GW9hy3XNeavGD+xRf5+DKp3Fri8 hUofxqLv8U8hj9fXcEowvRHfe4OrIgtDdekDe8q58sPLycbGMuNEZIoAD/WMRvdfCI WDUwAKRC2DvnaUS6vNhhOWakS8wM+QL+lrV42n20= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, zhuyinyin@bytedance.com, Muchun Song" , Jens Axboe , Muchun Song Subject: [PATCH 5.4 07/85] io_uring: Fix remove irrelevant req from the task_list Date: Mon, 12 Oct 2020 15:26:30 +0200 Message-Id: <20201012132633.210398077@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201012132632.846779148@linuxfoundation.org> References: <20201012132632.846779148@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Muchun Song If the process 0 has been initialized io_uring is complete, and then fork process 1. If process 1 exits and it leads to delete all reqs from the task_list. If we kill process 0. We will not send SIGINT signal to the kworker. So we can not remove the req from the task_list. The io_sq_wq_submit_work() can do that for us. Fixes: 1c4404efcf2c ("io_uring: make sure async workqueue is canceled on exit") Signed-off-by: Muchun Song Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- fs/io_uring.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -2272,13 +2272,11 @@ restart: break; cond_resched(); } while (1); -end_req: - if (!list_empty(&req->task_list)) { - spin_lock_irq(&ctx->task_lock); - list_del_init(&req->task_list); - spin_unlock_irq(&ctx->task_lock); - } } +end_req: + spin_lock_irq(&ctx->task_lock); + list_del_init(&req->task_list); + spin_unlock_irq(&ctx->task_lock); /* drop submission reference */ io_put_req(req); @@ -3722,15 +3720,16 @@ static int io_uring_fasync(int fd, struc static void io_cancel_async_work(struct io_ring_ctx *ctx, struct files_struct *files) { + struct io_kiocb *req; + if (list_empty(&ctx->task_list)) return; spin_lock_irq(&ctx->task_lock); - while (!list_empty(&ctx->task_list)) { - struct io_kiocb *req; - req = list_first_entry(&ctx->task_list, struct io_kiocb, task_list); - list_del_init(&req->task_list); + list_for_each_entry(req, &ctx->task_list, task_list) { + if (files && req->files != files) + continue; /* * The below executes an smp_mb(), which matches with the @@ -3740,7 +3739,7 @@ static void io_cancel_async_work(struct */ smp_store_mb(req->flags, req->flags | REQ_F_CANCEL); /* B */ - if (req->work_task && (!files || req->files == files)) + if (req->work_task) send_sig(SIGINT, req->work_task, 1); } spin_unlock_irq(&ctx->task_lock);