Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp2253724rwi; Tue, 1 Nov 2022 05:48:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM72thJSnKGfJH5Ot3mB6z0n8b/b2Z2QXCRUMTTgmd2BJr03M6r8KuQHJWS91AHuR/XW+w/i X-Received: by 2002:a17:902:dac4:b0:186:c372:732a with SMTP id q4-20020a170902dac400b00186c372732amr19672749plx.174.1667306912597; Tue, 01 Nov 2022 05:48:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667306912; cv=none; d=google.com; s=arc-20160816; b=HdIrIAe/+ddWU91c7pOB0/a9ZSrMdHO/I+t8ANQshPn5kehNY3pEhz5fkNpX61Xhv7 81qeAMt3lO5dcI5mG9DOk/In7hVBhjmGM+czayC/MF+DsGW6yOuNkyoYfcEqJ/lm2IFo wgIn+CH3tTLte4tFCP48Uc+ZWqT2lXGhD+GPJIjIA2Sn9wE8E/zuYrQ3i27HQinogWcX 2ohZBhYub8IbX2jwshfBDlktnw6VQCkTybHor0LbHwN0JSWT3trWEkWzTexct4V7jMJ3 eheIbEOa2P806T6SFoORmNqHxfyS95g3bArBT11EcQ8mv/45LGl6lGgd6nCKt5sacEoA mIHQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6XU8jkxuoeBpU79dnEbDSAYVinXpKrTwW8ytU7vhpvY=; b=qarl3y/7VZQ8l1ZdIGk2h7M3HPGkdvQGqK0ilGl3vpmTV9iH4tMTS38C7TDSpioH1j xXSoB1NtwAdGYeIcLsKT5giwK91JpS0OEmzaohtkUl3HTcakxjJtsmr7b9zyyZ9jnywB duyGnufa3Hd/K4sQ/Y6wlGE8dnG+9WLPQZ3EmJFrrHjNvBH54SBas6H8/j8sOQTDLH9r +nOcTrozkBf2uhhHgdoeRGc1HA9J3kUisy9xf57lRbII3V3d1bt2eOaXrr+lSSlNlRvF HOm8fNYX+3blpDdmhCRKvli+Fi/56BMI8QnrSZN1RRuCczWnGRceModQUAVmlhM3aYtG iMmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cZPcWEZi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a14-20020aa78e8e000000b0056cf9ed8f10si11754437pfr.329.2022.11.01.05.48.19; Tue, 01 Nov 2022 05:48:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cZPcWEZi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230431AbiKALaI (ORCPT + 97 others); Tue, 1 Nov 2022 07:30:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230365AbiKAL3P (ORCPT ); Tue, 1 Nov 2022 07:29:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4060B15; Tue, 1 Nov 2022 04:28:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 62A2E615D4; Tue, 1 Nov 2022 11:28:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28361C433D6; Tue, 1 Nov 2022 11:28:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667302112; bh=zR2VOIOlFiLeKD8mLniZemC5q0Y54iEGRXSvder+ekc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cZPcWEZiWHrt1EpgEzjnXqZxauOR9MN0341VlmZV/tyjDZxOlrOhzEgdEraS2+uv+ H2K24ujmc0HIsyxCDvabWpcAIW9z28yYnd5qLGCZ3Rb9Rq+80UanoJxfSI+izZD7wd zMTmgHRaaS+ydsILigcgqTj64mJLE08JbVyJLvMAndtQ4QQio1KNXsWiuNKmkfY+GU TMSGHwkqw0Pxw7tU8/hkpfA6WUym7QAytPo84h8QTKQzcXd9IZSjn2RzpNFh8r3Ulr /erx/fIf7p944fl4kW17Fj9fWot8fZTqG5cJvFc6rs6doQyrLBf8k2Y+KQChtp7QtY G0PBlT3ocH31w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Pavel Begunkov , Jens Axboe , Sasha Levin , io-uring@vger.kernel.org Subject: [PATCH AUTOSEL 6.0 23/34] io_uring: don't iopoll from io_ring_ctx_wait_and_kill() Date: Tue, 1 Nov 2022 07:27:15 -0400 Message-Id: <20221101112726.799368-23-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221101112726.799368-1-sashal@kernel.org> References: <20221101112726.799368-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pavel Begunkov [ Upstream commit 02bac94bd8efd75f615ac7515dd2def75b43e5b9 ] We should not be completing requests from a task context that has already undergone io_uring cancellations, i.e. __io_uring_cancel(), as there are some assumptions, e.g. around cached task refs draining. Remove iopolling from io_ring_ctx_wait_and_kill() as it can be called later after PF_EXITING is set with the last task_work run. Signed-off-by: Pavel Begunkov Link: https://lore.kernel.org/r/7c03cc91455c4a1af49c6b9cbda4e57ea467aa11.1665891182.git.asml.silence@gmail.com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- io_uring/io_uring.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index c5dd483a7de2..d29f397f095e 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -2653,15 +2653,12 @@ static __cold void io_ring_ctx_wait_and_kill(struct io_ring_ctx *ctx) io_poll_remove_all(ctx, NULL, true); mutex_unlock(&ctx->uring_lock); - /* failed during ring init, it couldn't have issued any requests */ - if (ctx->rings) { + /* + * If we failed setting up the ctx, we might not have any rings + * and therefore did not submit any requests + */ + if (ctx->rings) io_kill_timeouts(ctx, NULL, true); - /* if we failed setting up the ctx, we might not have any rings */ - io_iopoll_try_reap_events(ctx); - /* drop cached put refs after potentially doing completions */ - if (current->io_uring) - io_uring_drop_tctx_refs(current); - } INIT_WORK(&ctx->exit_work, io_ring_exit_work); /* -- 2.35.1