From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70B2EC2D0A3 for ; Mon, 16 Nov 2020 20:42:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 23A672223D for ; Mon, 16 Nov 2020 20:42:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20150623.gappssmtp.com header.i=@kernel-dk.20150623.gappssmtp.com header.b="2CS6kPYb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731770AbgKPUmT (ORCPT ); Mon, 16 Nov 2020 15:42:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727764AbgKPUmT (ORCPT ); Mon, 16 Nov 2020 15:42:19 -0500 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D00EC0613CF for ; Mon, 16 Nov 2020 12:42:18 -0800 (PST) Received: by mail-pl1-x644.google.com with SMTP id s2so8978737plr.9 for ; Mon, 16 Nov 2020 12:42:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=aJSNc+5TGusbh/DQjBs739mKWDGoTkCryoU5FuRghNo=; b=2CS6kPYbN/XKViwYQHMljUEmD700S0FwJIaYonoeuUm3mdq2APkUESgRV14JyatQrm BY6oCB+80xuZwYnSrVG83ZNT8pEf+JMjeaRaNacp/Odo3tWOfav0MN/hPegAt3bQSYlY eoB9ySaS9yHRkrCqhc5ll366gZMl4rxqnytxmf0RFjroISu/IhufZO1SKLr8+haJ+Nfr Ln4E+ue3RG447QnIEk+H5N/acluP/ULB+ygbsHKUmzeXvvUZDutvG07DomcqFOc9eaM1 3U3/+kv1p1enPvLy+iAD9WmOM1242ypzNaYEVwLCFk+sd/+MyhwlTNxp90MPDGCkEkzS Uc5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=aJSNc+5TGusbh/DQjBs739mKWDGoTkCryoU5FuRghNo=; b=QAx9TMZmyn852fjkK47D9t6+jNRewpq/Fr0gaMGJ/Q7lUZynQHcdOH/gdWpqQDErii ZM8fobAAJkQKyAhAEUSjHr8juiSCxniHdfvCXym4HVI0HwVRkx+5/tEOyHYicCZXHyPb xB6EuZ6yFY73XN4jwa737HjSj/sCaNABz/qiOvdebAq+ILwAGskWrvoyLESsN/rCBwaJ 4OumXJ2XYxb7b8hSDvWy2Y4MYgkkyScQF92lsPK5VH6Nc4t7trbiKQIymGS2hpBEXOqY /ZmMngZQsPIE8yvwkpuLnUMge9xbxJzFnf+7OPOutceICCaJNBT1R1Y9odOl0iomnXCP KaOA== X-Gm-Message-State: AOAM531h3UPMQOe+Hde/cJBX5Za7binjX/pmO6mEyHc6K5P+URdtEj5q KLDPGP/QuClk3S4gOZLVFV1vBzDoB3OsbQ== X-Google-Smtp-Source: ABdhPJx/Ixx5KJEisWl5gxn78o8kKSztHBbOW+gbnl9RC07ay7xoolQF4qNkNOL+ZKWTJCcCBHqc2Q== X-Received: by 2002:a17:902:6a84:b029:d8:c8a9:e04d with SMTP id n4-20020a1709026a84b02900d8c8a9e04dmr14787358plk.74.1605559337152; Mon, 16 Nov 2020 12:42:17 -0800 (PST) Received: from [192.168.1.134] ([66.219.217.173]) by smtp.gmail.com with ESMTPSA id w63sm324737pjj.12.2020.11.16.12.42.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 16 Nov 2020 12:42:16 -0800 (PST) Subject: Re: [PATCH 1/1] io_uring: replace inflight_wait with tctx->wait To: Pavel Begunkov , io-uring@vger.kernel.org References: <463ac36b-974d-f88c-d178-6e4d24fa4c93@kernel.dk> <6f58c74f-19d8-497b-e73e-8655a29601a8@gmail.com> <980e4479-5923-f776-e2d6-54e46014a0c7@kernel.dk> <7751bed7-2dc0-d72d-297f-de0c2e8fa5d9@gmail.com> From: Jens Axboe Message-ID: Date: Mon, 16 Nov 2020 13:42:14 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <7751bed7-2dc0-d72d-297f-de0c2e8fa5d9@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org On 11/16/20 10:16 AM, Pavel Begunkov wrote: > On 16/11/2020 16:57, Jens Axboe wrote: >> On 11/16/20 9:48 AM, Pavel Begunkov wrote: >>> On 16/11/2020 16:33, Jens Axboe wrote: >>>> On 11/15/20 5:56 AM, Pavel Begunkov wrote: >>>>> As tasks now cancel only theirs requests, and inflight_wait is awaited >>>>> only in io_uring_cancel_files(), which should be called with ->in_idle >>>>> set, instead of keeping a separate inflight_wait use tctx->wait. >>>>> >>>>> That will add some spurious wakeups but actually is safer from point of >>>>> not hanging the task. >>>>> >>>>> e.g. >>>>> task1 | IRQ >>>>> | *start* io_complete_rw_common(link) >>>>> | link: req1 -> req2 -> req3(with files) >>>>> *cancel_files() | >>>>> io_wq_cancel(), etc. | >>>>> | put_req(link), adds to io-wq req2 >>>>> schedule() | >>>>> >>>>> So, task1 will never try to cancel req2 or req3. If req2 is >>>>> long-standing (e.g. read(empty_pipe)), this may hang. >>>> >>>> This looks like it's against 5.11, but also looks like we should add >>>> it for 5.10? >>> >>> Yeah, 5.10 completely slipped my mind, I'll resend >> >> I applied it to 5.10, and fixed up the 5.11 side of things. So all good, >> just wanted to confirm. > > Hmm, this won't work with 5.10, at least without > > b7e7fb9960b03c ("io_uring: cancel only requests of current task") > https://git.kernel.dk/cgit/linux-block/commit/?h=for-5.11/io_uring&id=b7e7fb9960b03ca07866b5c016ac3ce5373ef207 > > That's because tctx->wait is kicked only by requests of current task, > but 5.10 cancels everything with specified ->files, including owned > by other tasks. Ah good point, let's leave it 5.11 for now. -- Jens Axboe