Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp4001246pxm; Tue, 1 Mar 2022 09:15:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJzoA0bHFqNJjFjwnW6O92tR1O51Ivy8AfNtOJNa8Fujqa+lYFkubS6OCv7QLtEwWDPxX1Af X-Received: by 2002:a17:906:6b8f:b0:6cd:7984:26fc with SMTP id l15-20020a1709066b8f00b006cd798426fcmr19510178ejr.701.1646154950965; Tue, 01 Mar 2022 09:15:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646154950; cv=none; d=google.com; s=arc-20160816; b=u+vXzzgjlYSzrVxAUeGWICevBQ+yo1O96T29dNP8smFucSqzC9cEaYq17QKBjNcUFO hz/bhj6P5pX2tALTQxsiD7TmZeVqtujbo7tGlo402HcuEHO7MoW0WPLKGKmHNZHrw3yd QKaw3rUaHFdel+okubSMJ0Gj+hpIezr7jHrmPHtzvdLg8WRfzcQuUD2m88pWaiMMRjJS OfdiSHwrGxuJC9aQajG6vb5j4IBcUNJJtkO6GO1KjYeMEt65Sz+qcQDXAoz0TE7oMmkW dyLngnh9Wll01W5zlWA+O8H9/73J1VcVNtUXoBR/D3ZgXy7u5UUuB7JvU4yAhSoAJ7IR fBkg== 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=hKYwPPatGT31MHb8NxoKhc2caYUu7Qjwqz88vZWhd2g=; b=PTAUvX29FGDve5XKNIOCfnkM+kJtukGfGbfESOR+7zbwINRF4NPOXeMiackw3ByxO4 f952z0sKIBbDnql7elSHNpQbE+Ng4zhs87nCQkkP5NyttzMf5osCQYEVlbKq7Md+aA4e W3WRDyfgLjKhBwudKQ4AnPibbXx4aS56FPWZwVpEFrUKY32d8F03kS75NB1lsKH1v0vD kWvj6GJO9PMwxD3h6nS0kcS32QxrbsWQbLTwxxUkkPXN5mQHKbfIj4IVEZ2ENgTBsIdT 5SjAW1t4eWnUFG1yucB1ddvAJ0/VhADqDqZvSce4rZRL/J33TdoqEMjhHIOeSazF0rvD KWLw== ARC-Authentication-Results: i=1; mx.google.com; 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 n24-20020a509358000000b00415a0c7aee3si625900eda.316.2022.03.01.09.15.27; Tue, 01 Mar 2022 09:15:50 -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; 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 S234952AbiCANsD (ORCPT + 99 others); Tue, 1 Mar 2022 08:48:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233904AbiCANsC (ORCPT ); Tue, 1 Mar 2022 08:48:02 -0500 Received: from cloud48395.mywhc.ca (cloud48395.mywhc.ca [173.209.37.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96CE29F39B; Tue, 1 Mar 2022 05:47:20 -0800 (PST) Received: from [45.44.224.220] (port=56376 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 1nP2qV-0002GI-4T; Tue, 01 Mar 2022 08:47:19 -0500 Date: Tue, 01 Mar 2022 08:47:18 -0500 Message-Id: From: Olivier Langlois To: Jens Axboe , Pavel Begunkov Cc: Hao Xu , io-uring , linux-kernel Subject: [PATCH v4 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,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Olivier Langlois (2): io_uring: minor io_cqring_wait() optimization io_uring: Add support for napi_busy_poll fs/io_uring.c | 246 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 237 insertions(+), 9 deletions(-) base-commit: 719fce7539cd3e186598e2aed36325fe892150cf -- 2.35.1