Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp4086786pxt; Tue, 10 Aug 2021 19:55:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwb5HupBW3/5f5Lnz6UmCliEJfnPeSBQ0+YA2JKvZi/sfwJdh8ybmdU4UsU/4Gvo0XfGiU7 X-Received: by 2002:a05:6402:5251:: with SMTP id t17mr8379693edd.157.1628650506982; Tue, 10 Aug 2021 19:55:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628650506; cv=none; d=google.com; s=arc-20160816; b=rwvcz70d88pFuUiiF4p/PebMMAj0sN0BH+MDoY89vojzihNVmyuPpkYfLhUIhovcku GJ7MGeg1OXwzuewUUfrftNy3MCk0Vndj2peUzrJWjSc4UUUk6vJftmBX4LdNO8cDpn0t rsm/7W/WGm/mve+wf4aGme4Szq3fyrCZLrWxeD8ZGke1QcB8q5tp7EXEbDTOIqWSN6rj QGaIB5K7Z0xvbqIaGHAUn9gaKWfiMOyInvLfy2OlT+mvb5apXwLOOjnrpeHcT95b16WS 2v4P7ftvoDAw166VQc6GdEpHjioW6ya1e0yp5IX9zy+d7ezQVWak9CuJs570EkDdu1+X CsoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=e85ojSaiIVjal3bsYM8q4OvF6ZBVlMxFadBj2rR3fC4=; b=b3Ff2zZ9zPqvlGSuTy2ixgj7mXejwNJVpNSopmtFzLFZ13Yyq8zZodaRXDafYH9zM5 ef4L1xWeR1CwYD3+4RvnItc206WEaGaDyRtZUV9zf7TgZJ/jWin0VXzoly3Uc/v96wzG JpnoXs4pti7+lz1vznC3U+Lu91GFLBt9e8UmywokZhMLhnLe9wf7w2Lwc/Rqm/TpTrEX zB8vg5yf3AcNelSwaspYACuhVM6wGz8v5SkbscuFUGyMN4v/jEdFxg7LHpF3flNw/NGw 5+FrBNw8xBCcuovMiPNo/m8ywnc09v0niGY4HrRrU88OmOPjhB0OVBlSLL++hdF0pGDA QzFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b="Xu+/TdqH"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bi20si21937751ejb.575.2021.08.10.19.54.40; Tue, 10 Aug 2021 19:55:06 -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-dk.20150623.gappssmtp.com header.s=20150623 header.b="Xu+/TdqH"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232363AbhHKCwG (ORCPT + 99 others); Tue, 10 Aug 2021 22:52:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232169AbhHKCwF (ORCPT ); Tue, 10 Aug 2021 22:52:05 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D3F9C0613D3 for ; Tue, 10 Aug 2021 19:51:43 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id fa24-20020a17090af0d8b0290178bfa69d97so2392549pjb.0 for ; Tue, 10 Aug 2021 19:51:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=e85ojSaiIVjal3bsYM8q4OvF6ZBVlMxFadBj2rR3fC4=; b=Xu+/TdqHz31WewRv1l+fWI6IyV875qMMYe/KKjOFnsoCQYcDCjTq8AARwhSxnBKyjs gr9zuOKarlPTDzdyhp7rMQUuWEkolAf/cMVEwNKv2OBaFTwuNbiMVdOWZni+O6po5cXs 66mxR1z2UJi4Gi9TLIo2Stv1vZthXryfj3lfB/gS7kVOq2GylLcrMQi0bn/5GGiTepV8 TPyOhWzA74UkEKY5zLY1VWeL06UNOr6cLMRqLE6Oq+e2RZ6cXWgdprr03Ntfxisqfwtw 4suCC1vHpsFTB+UgO/afatN4eIWVJWj2EpzhijwsCuAFpRzkiYkWiPMJUYdIqhVlxfJ9 BxUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=e85ojSaiIVjal3bsYM8q4OvF6ZBVlMxFadBj2rR3fC4=; b=bbwAgWMlRFtJoaExn3nJ7vQVQVgRdQhihBUlROWsd5ER2niC1SgTT9JX7ogzoh9nGD UP0uBQT5Q+6NqXZxfTLANSX0m3xV3d3ausZjKwfcugjl+iPegqJt8koL1czulEXZkufy 1ZSmBngtlY3jz1PZc4eU+SbZwKzgIpmk++xt6NfZm717AkFEXNu4A9N0OWCFwHui6OsI 4wtqhrgtR5+USzVO3rf/RxsNFt8kaBncQm0fMCg0Q95m0JldIPKqFOnqLKpubb0WioDR 44mDphClTqgxj6MR8UxP3GsB6bD05bPzyRQOD3xvHzLo1z/vrMe3K8+qWBsb+Z1BzSfv SyiA== X-Gm-Message-State: AOAM5337TGqVyB3pHsi8iQvueqHd2spQVSXfsG46QiHEw1LUbcqBYdrU JskJoKMg/A5LvUim6ULnGiJd6klRDjh6eYCe X-Received: by 2002:a65:5c89:: with SMTP id a9mr318004pgt.433.1628650302278; Tue, 10 Aug 2021 19:51:42 -0700 (PDT) Received: from [192.168.1.116] ([66.219.217.159]) by smtp.gmail.com with ESMTPSA id on15sm4390666pjb.19.2021.08.10.19.51.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 10 Aug 2021 19:51:41 -0700 (PDT) Subject: Re: [PATCH 1/2] io_uring: clear TIF_NOTIFY_SIGNAL when running task work To: Nadav Amit , Pavel Begunkov Cc: Olivier Langlois , io-uring@vger.kernel.org, Linux Kernel Mailing List References: <20210808001342.964634-1-namit@vmware.com> <20210808001342.964634-2-namit@vmware.com> From: Jens Axboe Message-ID: <1bf56100-e904-65b5-bbb8-fa313d85b01a@kernel.dk> Date: Tue, 10 Aug 2021 20:51:40 -0600 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: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/10/21 8:33 PM, Nadav Amit wrote: > > >> On Aug 10, 2021, at 2:32 PM, Pavel Begunkov wrote: >> >> On 8/10/21 9:28 AM, Nadav Amit wrote: >>> >>> Unfortunately, there seems to be yet another issue (unless my code >>> somehow caused it). It seems that when SQPOLL is used, there are cases >>> in which we get stuck in io_uring_cancel_sqpoll() when tctx_inflight() >>> never goes down to zero. >>> >>> Debugging... (while also trying to make some progress with my code) >> >> It's most likely because a request has been lost (mis-refcounted). >> Let us know if you need any help. Would be great to solve it for 5.14. >> quick tips: >> >> 1) if not already, try out Jens' 5.14 branch >> git://git.kernel.dk/linux-block io_uring-5.14 >> >> 2) try to characterise the io_uring use pattern. Poll requests? >> Read/write requests? Send/recv? Filesystem vs bdev vs sockets? >> >> If easily reproducible, you can match io_alloc_req() with it >> getting into io_dismantle_req(); > > So actually the problem is more of a missing IO-uring functionality > that I need. When an I/O is queued for async completion (i.e., after > returning -EIOCBQUEUED), there should be a way for io-uring to cancel > these I/Os if needed. There's no way to cancel file/bdev related IO, and there likely never will be. That's basically the only exception, everything else can get canceled pretty easily. Many things can be written on why that is the case, and they have (myself included), but it boils down to proper hardware support which we'll likely never have as it's not a well tested path. For other kind of async IO, we're either waiting in poll (which is trivially cancellable) or in an async thread (which is also easily cancellable). For DMA+irq driven block storage, we'd need to be able to reliably cancel on the hardware side, to prevent errant DMA after the fact. None of this is really io_uring specific, io_uring just suffers from the same limitations as others would (or are). > Otherwise they might potentially never complete, as happens in my > use-case. If you see that, that is most certainly a bug. While bdev/reg file IO can't really be canceled, they all have the property that they complete in finite time. Either the IO completes normally in a "short" amount of time, or a timeout will cancel it and complete it in error. There are no unbounded execution times for uncancellable IO. > AIO has ki_cancel() for this matter. So I presume the proper solution > would be to move ki_cancel() from aio_kiocb to kiocb so it can be used > by both io-uring and aio. And then - to use this infrastructure. There is no infrastructure, I'm fraid. ki_cancel() is just a random hook that nobody (outside of USB gadget??) ever implemented or used. > But it is messy. There is already a bug in the (few) uses of > kiocb_set_cancel_fn() that blindly assume AIO is used and not > IO-uring. Then, I am not sure about some things in the AIO code. Oh > boy. I’ll work on an RFC. ki_cancel is a non-starter, it doesn't even work for the single case that it's intended for, and I'm actually surprised it hasn't been removed yet. It's one of those things that someone added a hook for, but never really grew into something that is useful. -- Jens Axboe