Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3462698pxp; Tue, 8 Mar 2022 15:07:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJwb/axeFuhu30IKTaBXg3zft4SXEySOIC/Xn1GXJIHYdYflJ6pKxSL6SP7ynrPmMa3vOEcH X-Received: by 2002:a17:902:db0b:b0:151:fa8c:d6cd with SMTP id m11-20020a170902db0b00b00151fa8cd6cdmr7267412plx.147.1646780829588; Tue, 08 Mar 2022 15:07:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646780829; cv=none; d=google.com; s=arc-20160816; b=VVIAUBQd2wJN8enXR2qKUUD5FfyBE1CJen+Usm7RT2gbvqt35zCEG1WoaWt6e2lLR3 MklRBGFd0nfxZ1zyPHfm6m/51nyI2+UHn4YhU+8F1Ec8HXX2PbUFydMoyoiqdjfKOojY znKgMgE/KXDlPYxMWPg2rSoezA73ksfMtxe4mumFe8voLRIdEvU8Gi6wlxwh2lo9WZzw wbL1phQTkLb1yrkLj/CWSPZiNVzhkPNajZgbsoMWwICO5IUqB97jDgR6kGn5Gsg7detr Frdm20yi4U8vO7ynx7gX+LxVYj29OhxwhWC6fQLIOaPSCPNtoflomVV1/auAJTlMf9jZ iCcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:message-id:date; bh=2R+FXPTneDzZ2S3TdGOs5EOALhfKNYp96VcXJfvJU4w=; b=q9lzsZTu27snRWkxwYS8Qu/U9vONFejbpf9SdCTNSNIRUuxz5DIrstgc/TfgeENnqM dQDzsTVVrS5O4rTNga9yCZBnMjnipouihQtXCbWtATNqDHY77N0rdqa32d+Z3KpgitFM Qb/+R9PKg7uQGPGFhGgGJDonRshz7nG6nDlZD1ZsW7uanQnkUUuo/KSxLoV0rv8glDdD nhxU0q0a3296fPPca0u6+DSeO4EaiwDsbiJLXK/K2rVOO0aDTUqWWWogI3UHHZpW3nor kx2xjGM6PkmkanVyh+d45jL6QMIXrhFg2HPXmUiK4BWymzjsunLTYp9E0IgUjA3gTPoK RXVg== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id j2-20020a655582000000b003787fb48464si152799pgs.650.2022.03.08.15.07.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 15:07:09 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2B051652DC; Tue, 8 Mar 2022 15:05:56 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348611AbiCHWSX (ORCPT + 99 others); Tue, 8 Mar 2022 17:18:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350929AbiCHWSR (ORCPT ); Tue, 8 Mar 2022 17:18:17 -0500 Received: from cloud48395.mywhc.ca (cloud48395.mywhc.ca [173.209.37.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A63C5749F; Tue, 8 Mar 2022 14:17:16 -0800 (PST) Received: from [45.44.224.220] (port=42886 helo=localhost) by cloud48395.mywhc.ca with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nRi8p-0000SK-Dp; Tue, 08 Mar 2022 17:17:15 -0500 Date: Tue, 08 Mar 2022 17:17:14 -0500 Message-Id: From: Olivier Langlois To: Jens Axboe , Pavel Begunkov Cc: Hao Xu , io-uring , linux-kernel Subject: [PATCH v5 0/2] io_uring: Add support for napi_busy_poll X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cloud48395.mywhc.ca X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - trillion01.com X-Get-Message-Sender-Via: cloud48395.mywhc.ca: authenticated_id: olivier@trillion01.com X-Authenticated-Sender: cloud48395.mywhc.ca: olivier@trillion01.com X-Source: X-Source-Args: X-Source-Dir: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The sqpoll thread can be used for performing the napi busy poll in a similar way that it does io polling for file systems supporting direct access bypassing the page cache. The other way that io_uring can be used for napi busy poll is by calling io_uring_enter() to get events. If the user specify a timeout value, it is distributed between polling and sleeping by using the systemwide setting /proc/sys/net/core/busy_poll. The changes have been tested with this program: https://github.com/lano1106/io_uring_udp_ping and the result is: Without sqpoll: NAPI busy loop disabled: rtt min/avg/max/mdev = 40.631/42.050/58.667/1.547 us NAPI busy loop enabled: rtt min/avg/max/mdev = 30.619/31.753/61.433/1.456 us With sqpoll: NAPI busy loop disabled: rtt min/avg/max/mdev = 42.087/44.438/59.508/1.533 us NAPI busy loop enabled: rtt min/avg/max/mdev = 35.779/37.347/52.201/0.924 us v2: * Evaluate list_empty(&ctx->napi_list) outside io_napi_busy_loop() to keep __io_sq_thread() execution as fast as possible * In io_cqring_wait(), move up the sig block to avoid needless computation if the block exits the function * In io_cqring_wait(), protect ctx->napi_list from race condition by splicing it into a local list * In io_cqring_wait(), allow busy polling when uts is missing * Fix kernel test robot issues v3: * Fix do_div() type mismatch warning * Reduce uring_lock contention by creating a spinlock for protecting napi_list * Support correctly MULTISHOT poll requests v4: * Put back benchmark result in commit text v5: * Protect napi_list from concurrent access from io_workers threads Olivier Langlois (2): io_uring: minor io_cqring_wait() optimization io_uring: Add support for napi_busy_poll fs/io_uring.c | 248 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 239 insertions(+), 9 deletions(-) -- 2.35.1