Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp3621950pxb; Fri, 4 Feb 2022 12:35:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJxswXeNVrF7CCWvBe4ZfS2qpmFCocgPxxi+KhWBgM57WK520jVjf2YyUPQiCkx3vTYQFYii X-Received: by 2002:a63:2a45:: with SMTP id q66mr601746pgq.484.1644006930268; Fri, 04 Feb 2022 12:35:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644006930; cv=none; d=google.com; s=arc-20160816; b=MjZvbWuiDx9qCZQ3aqZUaTphO5tXW0eMhqgkclcQffnpUIMmexKL73h5+vlm3LMuh7 IF0wyG9zVNLZdw2U6SyO/Gs/40gNDhKZDlQQqkpfyo0JwRLkTSLdozI5EiVvq91Z7ubm cXsWp6H0wdwy6mCeJsoMtwwwUdvuEE0Ye2Kp8NCoiNNctCYzQSPx6b8CsC16agFfhwTi lwM0j1b/Ivj9RsX/mdTKY+6pkFCxW7RCJGy3q8XoY1Niv7NN3X+l7wozvQRZT0qtEOPD vSyAckkl/9YwPgyIOTypLU6hlmJcO4v8SPO1ifMByaNgAbTHN1Sz9yv9J6030CC3G38e EqaA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=FPOz8xdK3mu3IlbLy0Cgt0QVaMof28Afhuj4OwC3evg=; b=Rmg3gkl2+B4AlcISKtkDidIAf4bksqVZbrWZynnLvqQ5UaNmkC85MlXqdTjhlsotE5 BXs6G2SXRNH6rb0DPVX++P8MQl3QO5JDVRaQn+nNudDfMgZhwBajN4v37kbnckKFKNbx FrDpRi3QnzMMc71d7AnLjXpWbgy4rhBchuqVJGSl6nFf0Ka5Sq7cmHzkuH9BBEw3MBxz 8/At2RNNxJEjePfC3jEh51zR0LjPJhV7BauagZerKt/xSlyYh+XaTpWLOOuozLIQtmpd 3nDHwmfGT8ShsD75u5Mz/UCeZJTtkgkbZv31TN9+5chMN9zCps5XaIWVxVJR50waBTaH bbeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=umAwh8Qx; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y184si2874779pgd.377.2022.02.04.12.35.18; Fri, 04 Feb 2022 12:35:30 -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=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=umAwh8Qx; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359465AbiBDOvY (ORCPT + 99 others); Fri, 4 Feb 2022 09:51:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348779AbiBDOvW (ORCPT ); Fri, 4 Feb 2022 09:51:22 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 883DEC061714 for ; Fri, 4 Feb 2022 06:51:22 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id u15so11849945wrt.3 for ; Fri, 04 Feb 2022 06:51:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=FPOz8xdK3mu3IlbLy0Cgt0QVaMof28Afhuj4OwC3evg=; b=umAwh8Qx03ObZU5SEan58et+4+onfkoHH3Dyl9pVgt7ENuK72PjpLhEswYoLiFzM5/ j5+y3dq9BVFpRRVF08Og2+DNE7g/DXBhgirJUtror9WVAb9O1okN2JzHQzIySfkk7edp sd0JHkNmmPsk9cWqj25QX3AfKAyw4FTdFaq5DXlcK4ZhGFUUBglSKovpmjoYEn3Fq1ZJ Ek9E9RXQ3slyyTczuQcuOSKuZEy2jZxdAmkeQ74jTdJpWDX6ElkGismkTyt9tCKwqaRh 5/EJwh2HgHV0JiOGN80zO4Rg3RECPiFdGdCyTxsjS/GNz6GjiCJvclwo95YAwAb0nOGF WbDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=FPOz8xdK3mu3IlbLy0Cgt0QVaMof28Afhuj4OwC3evg=; b=WlQWZhN7kP08pQWh7k0SAMLzCpi7XpLmJhW2ljqb/u6t7fFAK4pSqF/QwSnNmGwsEP SkxEfOMJiPgBCLWLV+b89ij5h3mj6lGieeLe0enVD81yzkLbEzbZMWebF7+8OhPpTG8Q 4mmGPrN9rp9Jmgl0iZJeF3qnaXYII6pPeBHvNEzMPr2TeAfQPz94wTJpisMbF4s67btz tUmlrOnqgN1Vd2QwkH95/5SPEDPpoFiPCOtTWW6xTLWMtYgQObZMx+Xxi8pj+fcAy8KY lp9iVDx6aeW13jV3cVoMHMscsb2q2QEA54mZaCIuXgcXH9l67VzMf5h+YAgyXYSKQx6+ MxVQ== X-Gm-Message-State: AOAM532o8zeC+zaYsXFaEAL4dXdQ7yCruKezqnOTppL+H65ho48fWeTp rPJbfG59t+BgoZKgAahcfm7iXg== X-Received: by 2002:a5d:47a9:: with SMTP id 9mr2814375wrb.31.1643986281163; Fri, 04 Feb 2022 06:51:21 -0800 (PST) Received: from usaari01.cust.communityfibre.co.uk ([2a02:6b6d:f804:0:e94c:d0f2:1084:a0d3]) by smtp.gmail.com with ESMTPSA id c11sm2552898wri.43.2022.02.04.06.51.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 06:51:20 -0800 (PST) From: Usama Arif To: io-uring@vger.kernel.org, axboe@kernel.dk, asml.silence@gmail.com, linux-kernel@vger.kernel.org Cc: fam.zheng@bytedance.com, Usama Arif Subject: [PATCH v6 0/5] io_uring: remove ring quiesce in io_uring_register Date: Fri, 4 Feb 2022 14:51:12 +0000 Message-Id: <20220204145117.1186568-1-usama.arif@bytedance.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. --- v5->v6: - Split removing ring quiesce completely from io_uring_register into 2 patches (Pavel Begunkov) - Removed extra mutex while registering/unregistering eventfd as uring_lock can be used (Pavel Begunkov) - Move setting ctx->evfd to NULL from io_eventfd_put to before call_rcu (Pavel Begunkov) v4->v5: - Remove ring quiesce completely from io_uring_register (Pavel Begunkov) - Replaced rcu_barrier with unregistering flag (Jens Axboe) - Created a faster check for ctx->io_ev_fd in io_eventfd_signal and cleaned up io_eventfd_unregister (Jens Axboe) v3->v4: - Switch back to call_rcu and use rcu_barrier incase io_eventfd_register fails to make sure all rcu callbacks have finished. v2->v3: - Switched to using synchronize_rcu from call_rcu in io_eventfd_unregister. v1->v2: - Added patch to remove eventfd from tracepoint (Patch 1) (Jens Axboe) - Made the code of io_should_trigger_evfd as part of io_eventfd_signal (Jens Axboe) Usama Arif (5): io_uring: remove trace for eventfd io_uring: avoid ring quiesce while registering/unregistering eventfd io_uring: avoid ring quiesce while registering async eventfd io_uring: avoid ring quiesce while registering restrictions and enabling rings io_uring: remove ring quiesce for io_uring_register fs/io_uring.c | 179 +++++++++++++------------------- include/trace/events/io_uring.h | 13 +-- 2 files changed, 75 insertions(+), 117 deletions(-) -- 2.25.1