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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 813BAC433EF for ; Fri, 18 Mar 2022 15:34:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238297AbiCRPf6 (ORCPT ); Fri, 18 Mar 2022 11:35:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237525AbiCRPfv (ORCPT ); Fri, 18 Mar 2022 11:35:51 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AE292156FE for ; Fri, 18 Mar 2022 08:33:45 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id 123-20020a1c1981000000b0038b3616a71aso4969597wmz.4 for ; Fri, 18 Mar 2022 08:33:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to; bh=Gr2YhPwvgZpgBsveCXruVfvvkxpPVjHLKS6QR66vLKY=; b=Q2iLocIpxlUrxhUjIIHcXjN5v/GW82TkXz8MgIuPcTMrGSuaP5I7Y/xaUZr6fKgpam 4m8YWAox3M7D7pz3p+51SGhUTewCAGRgmsLp1Xbl0Yc91YWZgMnWW3QxAa9rrKeIsqgS RADRmNgZ/66Nr/YsKZsfDKVHKN8KqEaR0bJnR2oTOgIRHCRRWw02JgHNuWCDmg9cscTW xUo2rVlW8yoDMoZd3KaRZEQF5nNkUGL6uuGsKieaSF6sBUlBe6EYGeY+2xE80s0zlWw9 2nh7o/NxC70ccr9y218hMQ5K3W88tIUef2s8E/sNFi0Sass6+2n2nvyXShWEqdSI062K q/wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to; bh=Gr2YhPwvgZpgBsveCXruVfvvkxpPVjHLKS6QR66vLKY=; b=upGkBtl1nJfd/4s1zhykeqwCkRmc6XmkvcHYhvTtV2DLpik9hgnkJ1tGQC/CbQyNT+ raUaNYVewYsFBdWV9Oye5v06n6nym2vmVr78NvTaUHT6xRDDopJnSevvlKkSFLOo0Qhb N8GBLJTq1j4H8sMZxoPxkT3u/oQirFuIeMgarlidmeRZIUOdnvKBZsG5ko2Gz41EXmeY XXjek+LgCagPoat0G1OOVfjjUE2jhNCFmppHqpkl/mN1kc972SFhpnbx0dRPxft4O3gH NMkQqrZbmtMePr32GMl65N4mhQwOrivKd7/sCPS9mpH7GpYK38vUK3kaeHbix+ymoTPg 364Q== X-Gm-Message-State: AOAM531/hqfb9O7pbC6FiZwsPqlGpvnOV+gOfo3cNLBaXxGBena74De4 ZQ+XOFbcxiOdrUeI8NKEwToxQVGAcEjnsQ== X-Google-Smtp-Source: ABdhPJzhhMV3yHOb7wvMKQkW2au5l8y9ELEwMvSQrBBkfZbHCc5NP6TwgAY5kyGsishgYy218BUCxQ== X-Received: by 2002:a1c:4e02:0:b0:38c:8a10:e899 with SMTP id g2-20020a1c4e02000000b0038c8a10e899mr2949304wmh.125.1647617624356; Fri, 18 Mar 2022 08:33:44 -0700 (PDT) Received: from [192.168.8.198] ([85.255.234.70]) by smtp.gmail.com with ESMTPSA id f15-20020a0560001a8f00b0020397ea11d2sm7421367wry.20.2022.03.18.08.33.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Mar 2022 08:33:43 -0700 (PDT) Content-Type: multipart/mixed; boundary="------------UKvVACAZxPdMJxPMxGbORF08" Message-ID: Date: Fri, 18 Mar 2022 15:32:15 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.0 Subject: Re: [PATCH 4/4] io_uring: optimise compl locking for non-shared rings Content-Language: en-US To: Jens Axboe , io-uring@vger.kernel.org References: <9c91a7dc445420230f7936d7f913eb212c1c07a3.1647610155.git.asml.silence@gmail.com> <3530662a-0ae0-996c-79ee-cc4db39b965a@kernel.dk> <7ef3335a-8e7c-d559-5a78-f48bf506f53c@gmail.com> From: Pavel Begunkov In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org This is a multi-part message in MIME format. --------------UKvVACAZxPdMJxPMxGbORF08 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 3/18/22 15:21, Jens Axboe wrote: > On 3/18/22 9:13 AM, Pavel Begunkov wrote: >> On 3/18/22 14:54, Jens Axboe wrote: >>> On 3/18/22 7:52 AM, Pavel Begunkov wrote: >>>> When only one task submits requests, most of CQEs are expected to be >>>> filled from that task context so we have natural serialisation. That >>>> would mean that in those cases we don't need spinlocking around CQE >>>> posting. One downside is that it also mean that io-wq workers can't emit >>>> CQEs directly but should do it through the original task context using >>>> task_works. That may hurt latency and performance and might matter much >>>> to some workloads, but it's not a huge deal in general as io-wq is a >>>> slow path and there is some additional merit from tw completion >>>> batching. >>> >>> Not too worried about io-wq task_work for cq filling, it is the slower >>> path after all. And I think we can get away with doing notifications as >>> it's just for CQ filling. If the task is currently waiting in >>> cqring_wait, then it'll get woken anyway and it will process task work. >>> If it's in userspace, it doesn't need a notification. That should make >>> it somewhat lighter than requiring using TIF_NOTIFY_SIGNAL for that. >>> >>>> The feature should be opted-in by the userspace by setting a new >>>> IORING_SETUP_PRIVATE_CQ flag. It doesn't work with IOPOLL, and also for >>>> now only the task that created a ring can submit requests to it. >>> >>> I know this is a WIP, but why do we need CQ_PRIVATE? And this needs to >> >> One reason is because of the io-wq -> tw punting, which is not optimal >> for e.g. active users of IOSQE_ASYNC. The second is because the >> fundamental requirement is that only one task should be submitting >> requests. Was thinking about automating it, e.g. when we register >> a second tctx we go through a slow path waiting for all current tw >> to complete and then removing an internal and not userspace visible >> CQ_PRIVATE flag. > > Was thinking something along those lines too. The alternative is setting > up the ring with SETUP_SINGLE_ISSUER or something like that, having the > application tell us that it is a single issuer and no submits are > shared across threads. Serves the same kind of purpose as CQ_PRIVATE, > but enables us to simply fail things if the task violates those > constraints. Would also be a better name I believe as it might enable > further optimizations in the future, like for example the mutex > reduction for submits. That's exactly what it is, including the failing part. And I like your name better, will take it >> Also, as SQPOLL task is by definition the only one submitting SQEs, >> was thinking about enabling it by default for them, but didn't do >> because of the io-wq / IOSQE_ASYNC. > > Gotcha. > >>> work with registered files (and ring fd) as that is probably a bigger >>> win than skipping the completion_lock if you're not shared anyway. >> >> It does work with fixed/registered files and registered io_uring fds. > > t/io_uring fails for me with registered files or rings, getting EINVAL. > Might be user error, but that's simply just setting CQ_PRIVATE for > setup. One thing I changed in the tool is that the ring should be created by the submitter task, so move setup_ring into the submitter thread. Plan to get rid of this restriction though. Weird that it works only for you only without reg files/rings, will take a look. Attached io_uring.c that I used, it's based on some old version, so do_nop can't be set in argv but should turned in the source code. IORING_ENTER_REGISTERED_RING is always enabled. >> In regards of "a bigger win", probably in many cases, but if you submit >> a good batch at once, and completion tw batching doesn't kick in (e.g. >> direct bdev read of not too high intensity), it might save >> N spinlock/unlock when registered ring fd would kill only one pair of >> fdget/fdput. > > Definitely, various cases where one would be a bigger win than the > other, agree on that. But let's just ensure that both work together :-) -- Pavel Begunkov --------------UKvVACAZxPdMJxPMxGbORF08 Content-Type: text/x-csrc; charset=UTF-8; name="io_uring.c" Content-Disposition: attachment; filename="io_uring.c" Content-Transfer-Encoding: base64 I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxlcnJuby5oPgojaW5jbHVkZSA8YXNzZXJ0 Lmg+CiNpbmNsdWRlIDxzdGRsa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