Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp3765090pxb; Fri, 4 Feb 2022 16:19:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJy9hJq/Z0ZkX8m7fqvady9hnkkrHr+BOBXKNRhmfTU5se4P1npSXCUoVE/ZV3ty0pGh7nC7 X-Received: by 2002:a17:907:94d5:: with SMTP id dn21mr1218815ejc.77.1644020362434; Fri, 04 Feb 2022 16:19:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644020362; cv=none; d=google.com; s=arc-20160816; b=l10Pk3RLTvqCcoG+lx3ftyV2xzTaKxwZrlk/dKQ+PnUjD0fH8QNFs2Mfgw6HkaQhjP bAGbCi+h/7RA+Fn5mVt6icfrBInyN3wyuGey/Ft2QaHe1VP/2JgFTbDGsA+LTZTZi5Zc dlfZiZNBH6tnGqdiVmuFZ2HUPBi+YKGBdxfHU6hw1NyPVFj43//gLDnlmFC06D5bAY9B 6vN+rcWZhbPh7tA5nQ7g8eEyMnFkXlj4uDPi2JiQCY+On0Y7bImJo1LEJBonThogdXJa bBdbVSaeEPnZByPmnxumWbdx1dz03GbuZxl2PMikz3AmrVZLm0tkq1LScOgB3Ex5Cv+q Tc6w== 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=R0/VRC6MJ23IQ50AYwFq/GKus1/XLDPRN4c2rFVnHh4=; b=LT8QdfQH1aDtPoSIUoDU97MX2oxJ33PMzCk0zYzjMQhBaZvMGT76gl5sTbibnLhn6m axqKHgQVUifiQTE9OOaGQ1ykJiPzp6UJAR1O2RJSoNc2K+NYcfa5BUqPjXn2jKEXBHkN bEQYuSk5zfz8DIhnF1h9xVWys1k1BdJ6VB5oy9Bl5wYMtnXjO0d4FH7LfBI/iObmq0WN UkpNq/nQpZTYSPl8DsmsWjSOTJ6N08AMhPlDwUhLHy3+HQ9Uxp3MF5z+1lMh3wOPEaH+ 9e7LD1p6IWTIwI4O0oYTyi68tru7kJvKT6rhIOocUihx4Bf563dkjjALr4nIuWZrkZGM zIGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20210112.gappssmtp.com header.s=20210112 header.b="y8WVG/cr"; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z12si3029660edd.396.2022.02.04.16.18.56; Fri, 04 Feb 2022 16:19:22 -0800 (PST) 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-dk.20210112.gappssmtp.com header.s=20210112 header.b="y8WVG/cr"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236830AbiBDPxH (ORCPT + 99 others); Fri, 4 Feb 2022 10:53:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376283AbiBDPxE (ORCPT ); Fri, 4 Feb 2022 10:53:04 -0500 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CF37C06173E for ; Fri, 4 Feb 2022 07:53:04 -0800 (PST) Received: by mail-io1-xd32.google.com with SMTP id p63so7804375iod.11 for ; Fri, 04 Feb 2022 07:53:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20210112.gappssmtp.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=R0/VRC6MJ23IQ50AYwFq/GKus1/XLDPRN4c2rFVnHh4=; b=y8WVG/cr2hESo2ZAmi6wf+elNqaLhdSNLWBcBWKyCXqFmTfgBdvPdjEBItKIio9jrS XvpGKHKh1MJ/GE6NqPmUQev2b5VYblmBdJKMq3aXJxvNs55OOV0F690ipyORSDJvxoKv UDrI3wUyCybjZdImtwSs7C7HQhtrRy60DW1rxfvkoWI4NeVV5FDS1FfuVBv/tVR7OjS4 NhIu+MVi2LAhjrQXZbAw44SUhFWzv1t8b0GdIVFqoNMEkyEoSWY4J3SOnCPUDbctpqfk HbgHNxyg4sREsA5kipSkq+ufpfWYUxa6U7YsCXWAir6Wr7Yhj26vbWshuQaEtBS+Fpow 30ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=R0/VRC6MJ23IQ50AYwFq/GKus1/XLDPRN4c2rFVnHh4=; b=Xlh/Eh3+Tc6ii02AR25h2KtwwQP2LIKSvNH12c4t8CgTJWv7Uzmfz+HTHLIwYSIdLt i6HPcT7srnaAAZi6DBN9Ao4XEBjxjkWja5ZXSCB0YOYzB/poiVCwzJ2+b/CWSb6JrD3/ c1x7za2X/xXvNHTzgI9iWeWtr0b09/7v/DdrMiU9DZXBovQl3NNmlSvKSOsmXDubW9eV CadFb1uv6Q7l7lntRlI2zYKfmTMTrDtdDT0gB4QNMsKkYWeIuRzz0M0+Vk/SwFqdYmMw dXjmCMfyy0I/DkNIDpxdV0FYPO+JAvJdPVI2li/9VzafTNt6xCJfP6P3/Z7mxFwtuS2k pNRA== X-Gm-Message-State: AOAM530IX63LxcbTV4gSyLnBMEVUwqnVQumCVo5ETZjbfwW9hl/srWWi o0yWwD/LPbAfolnxPP17sFI35W3RU9rwmw== X-Received: by 2002:a02:7417:: with SMTP id o23mr1653087jac.145.1643989983674; Fri, 04 Feb 2022 07:53:03 -0800 (PST) Received: from [192.168.1.30] ([207.135.234.126]) by smtp.gmail.com with ESMTPSA id s18sm1132681iov.5.2022.02.04.07.53.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Feb 2022 07:53:03 -0800 (PST) Subject: Re: [PATCH v6 0/5] io_uring: remove ring quiesce in io_uring_register To: Usama Arif , io-uring@vger.kernel.org, asml.silence@gmail.com, linux-kernel@vger.kernel.org Cc: fam.zheng@bytedance.com References: <20220204145117.1186568-1-usama.arif@bytedance.com> From: Jens Axboe Message-ID: Date: Fri, 4 Feb 2022 08:53:02 -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: <20220204145117.1186568-1-usama.arif@bytedance.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/4/22 7:51 AM, Usama Arif wrote: > Ring quiesce is currently used for registering/unregistering eventfds, > registering restrictions and enabling rings. > > For opcodes relating to registering/unregistering eventfds, ring quiesce > can be avoided by creating a new RCU data structure (io_ev_fd) as part > of io_ring_ctx that holds the eventfd_ctx, with reads to the structure > protected by rcu_read_lock and writes (register/unregister calls) > protected by a mutex. > > With the above approach ring quiesce can be avoided which is much more > expensive then using RCU lock. On the system tested, io_uring_reigster with > IORING_REGISTER_EVENTFD takes less than 1ms with RCU lock, compared to 15ms > before with ring quiesce. > > IORING_SETUP_R_DISABLED prevents submitting requests and > so there will be no requests until IORING_REGISTER_ENABLE_RINGS > is called. And IORING_REGISTER_RESTRICTIONS works only before > IORING_REGISTER_ENABLE_RINGS is called. Hence ring quiesce is > not needed for these opcodes. I wrote a simple test case just verifying register+unregister, and also doing a loop to catch any issues around that. Here's the current kernel: [root@archlinux liburing]# time test/eventfd-reg real 0m7.980s user 0m0.004s sys 0m0.000s [root@archlinux liburing]# time test/eventfd-reg real 0m8.197s user 0m0.004s sys 0m0.000s which is around ~80ms for each register/unregister cycle, and here are the results with this patchset: [root@archlinux liburing]# time test/eventfd-reg real 0m0.002s user 0m0.001s sys 0m0.000s [root@archlinux liburing]# time test/eventfd-reg real 0m0.001s user 0m0.001s sys 0m0.000s which looks a lot more reasonable. I'll look over this one and see if I've got anything to complain about, just ran it first since I wrote the test anyway. Here's the test case, btw: https://git.kernel.dk/cgit/liburing/commit/?id=5bde26e4587168a439cabdbe73740454249e5204 -- Jens Axboe