From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x230.google.com (mail-oi1-x230.google.com [IPv6:2607:f8b0:4864:20::230]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.bufferbloat.net (Postfix) with ESMTPS id DA8143B29D for ; Wed, 31 Jan 2024 02:56:45 -0500 (EST) Received: by mail-oi1-x230.google.com with SMTP id 5614622812f47-3bbbc6e51d0so2938057b6e.3 for ; Tue, 30 Jan 2024 23:56:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706687804; x=1707292604; darn=lists.bufferbloat.net; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Qcq/WhRLX8UNwKqACrR0ZpX/1iD+I8HfTo283Qb4b5g=; b=Yj78QI0uRq6UZhJKuF/1ig+OF5/bKmWBg0GZwwMKKBllfnpEVd72paU7f9S5iFK48M VJ90vTF3AZrA7zqt947Gxx73CDz1Fkxm/423HqpmO39QF3bWh2LPCsGEds0W2EgTamoB Arv8ioseAjhmpqfEbGyeNBOga7zeD1ya4IZg5oBdhX6MWKdL0UPeSbhYm3XGYycCKO0v +DwR6eK7cO/4H4taERnF53o/6/+IX+CcQ9JItZN4P+K3Kfhi2oCuPV2YndOA7Gbu/uTu kSodC1EU03WIE4McIxzj8MkBjauoJ2csdeHbwdQIchFDj6zAM6pU9mptRH7QYqideAXW FCLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706687804; x=1707292604; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Qcq/WhRLX8UNwKqACrR0ZpX/1iD+I8HfTo283Qb4b5g=; b=MpoBBtQEPiP0abyPX7tPEPuBsDbBPkQOTeoc+cEypjsSxSA8Qb8kSNE8KzV6D8sq/n gGIRt6noq9TfreRqweEz9j15iAdU7lIKJRx5JHebFdtZuWKm1GGPPcW+N3H+ozaCnDnQ Tnjl9H9ksg/wXaQpoOElD1xl8uDwAeIXK89FvLb3n7niTvj0TxxQPm9KCZrJZqnsbifB n2GPG14uPRah2dGupEJ/sPH1mxfaXE28zzOfYFpq0xK7nV1kLaiogzUB/5bTdvY1nQGl zecgB7VoOv2qilJfmQG9sBRADwhcXHETHBrKd7+LGlRh/9jX4lWrV3D8CZyLHEEAFK1b VHPg== X-Gm-Message-State: AOJu0YxrEb3Xd9MGaoB3xp/lnCnqQQHAtRzj+kqtYLiUqt9RhHdOEtaQ PUC86NBmFFx7kFLZNEjY4EYmo9O50ufaBnekdwlL5YVGtgXKmfShfDYHlMZUt/8FcghVPd8Nfng OTnwbbjb6pOP49Vdsmvg+CjG70ZfT2D85 X-Google-Smtp-Source: AGHT+IEo0RlHvfqXNHTYKFLH2quTH2Bl62Ap7Iu4AO1AfTI1EQ/qU+Yl0YxCiKXWqHX/oFOD1K0ZneM8SAWd/RO1jgM= X-Received: by 2002:a05:6808:178f:b0:3be:65c6:2183 with SMTP id bg15-20020a056808178f00b003be65c62183mr959625oib.51.1706687804397; Tue, 30 Jan 2024 23:56:44 -0800 (PST) MIME-Version: 1.0 References: <20230608163839.2891748-1-shr@devkernel.io> In-Reply-To: <20230608163839.2891748-1-shr@devkernel.io> From: Dave Taht Date: Wed, 31 Jan 2024 02:56:31 -0500 Message-ID: To: libreqos Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: [LibreQoS] Fwd: [PATCH v15 0/7] io_uring: add napi busy polling support X-BeenThere: libreqos@lists.bufferbloat.net X-Mailman-Version: 2.1.20 Precedence: list List-Id: Many ISPs need the kinds of quality shaping cake can do List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Jan 2024 07:56:46 -0000 ---------- Forwarded message --------- From: Stefan Roesch Date: Thu, Jun 8, 2023 at 12:45=E2=80=AFPM Subject: [PATCH v15 0/7] io_uring: add napi busy polling support To: , Cc: , , , , , This adds the napi busy polling support in io_uring.c. It adds a new napi_list to the io_ring_ctx structure. This list contains the list of napi_id's that are currently enabled for busy polling. This list is used to determine which napi id's enabled busy polling. For faster access it also adds a hash table. When a new napi id is added, the hash table is used to locate if the napi id has already been added. When processing the busy poll loop the list is used to process the individual elements. io-uring allows specifying two parameters: - busy poll timeout and - prefer busy poll to call of io_napi_busy_loop() This sets the above parameters for the ring. The settings are passed with a new structure io_uring_napi. There is also a corresponding liburing patch series, which enables this feature. The name of the series is "liburing: add add api for napi busy poll timeout". It also contains two programs to test the this. Testing has shown that the round-trip times are reduced to 38us from 55us by enabling napi busy polling with a busy poll timeout of 100us. More detailled results are part of the commit message of the first patch. Changes: - V15: - Combined _napi_busy_loop() and __napi_busy_loop() function - Rephrased comment - V14: - Rephrased comment for napi_busy_loop_rcu() funnction - Added new function _napi_busy_loop() to remove code duplication in napi_busy_loop() and napi_busy_loop_rcu() - V13: - split off __napi_busy_loop() from napi_busy_loop() - introduce napi_busy_loop_no_lock() - use napi_busy_loop_no_lock in io_napi_blocking_busy_loop - V12: - introduce io_napi_hash_find() - use rcu for changes to the hash table - use rcu for searching if a napi id is in the napi hash table - use rcu hlist functions for adding and removing items from the hash table - add stale entry detection in __io_napi_do_busy_loop and remove stale entries in io_napi_blocking_busy_loop() and io_napi_sqpoll_busy_loop() - create io_napi_remove_stale() and __io_napi_remove_stale() - __io_napi_do_busy_loop() takes additional loop_end_arg and does stale entry detection - io_napi_multi_busy_loop is removed. Logic is moved to io_napi_blocking_busy_loop() - io_napi_free uses rcu function to free - io_napi_busy_loop no longer splices - io_napi_sqpoll_busy_poll uses rcu - V11: - Fixed long comment lines and whitespace issues - Refactor new code io_cqring_wait() - Refactor io_napi_adjust_timeout() and remove adjust_timeout - Rename io_napi_adjust_timeout to __io_napi_adjust_timeout - Add new function io_napi_adjust_timeout - Cleanup calls to list_is_singular() in io_napi_multi_busy_loop() and io_napi_blocking_busy_loop() - Cleanup io_napi_busy_loop_should_end() - Rename __io_napi_busy_loop to __io_napi_do_busy_loop() - V10: - Refreshed to io-uring/for-6.4 - Repeated performance measurements for 6.4 (same/similar results) - V9: - refreshed to io-uring/for-6.3 - folded patch 2 and 3 into patch 4 - fixed commit description for last 2 patches - fixed some whitespace issues - removed io_napi_busy_loop_on helper - removed io_napi_setup_busy helper - renamed io_napi_end_busy_loop to io_napi_busy_loop - removed NAPI_LIST_HEAD macro - split io_napi_blocking_busy_loop into two functions - added io_napi function - comment for sqpoll check - V8: - added new file napi.c and add napi functions to this file - added NAPI_LIST_HEAD function so no ifdef is necessary - added io_napi_init and io_napi_free function - added io_napi_setup_busy loop helper function - added io_napi_adjust_busy_loop helper function - added io_napi_end_busy_loop helper function - added io_napi_sqpoll_busy_poll helper function - some of the definitions in napi.h are macros to avoid ifdef definitions in io_uring.c, poll.c and sqpoll.c - changed signature of io_napi_add function - changed size of hashtable to 16. The number of entries is limited by the number of nic queues. - Removed ternary in io_napi_blocking_busy_loop - Rewrote io_napi_blocking_busy_loop to make it more readable - Split off 3 more patches - V7: - allow unregister with NULL value for arg parameter - return -EOPNOTSUPP if CONFIG_NET_RX_BUSY_POLL is not enabled - V6: - Add a hash table on top of the list for faster access during the add operation. The linked list and the hash table use the same data structure - V5: - Refreshed to 6.1-rc6 - Use copy_from_user instead of memdup/kfree - Removed the moving of napi_busy_poll_to - Return -EINVAL if any of the reserved or padded fields are not 0. - V4: - Pass structure for napi config, instead of individual parameters - V3: - Refreshed to 6.1-rc5 - Added a new io-uring api for the prefer napi busy poll api and wire it to io_napi_busy_loop(). - Removed the unregister (implemented as register) - Added more performance results to the first commit message. - V2: - Add missing defines if CONFIG_NET_RX_BUSY_POLL is not defined - Changes signature of function io_napi_add_list to static inline if CONFIG_NET_RX_BUSY_POLL is not defined - define some functions as static Stefan Roesch (7): net: split off __napi_busy_poll from napi_busy_poll net: add napi_busy_loop_rcu() io-uring: move io_wait_queue definition to header file io-uring: add napi busy poll support io-uring: add sqpoll support for napi busy poll io_uring: add register/unregister napi function io_uring: add prefer busy poll to register and unregister napi api include/linux/io_uring_types.h | 11 ++ include/net/busy_poll.h | 4 + include/uapi/linux/io_uring.h | 12 ++ io_uring/Makefile | 1 + io_uring/io_uring.c | 41 ++-- io_uring/io_uring.h | 26 +++ io_uring/napi.c | 331 +++++++++++++++++++++++++++++++++ io_uring/napi.h | 104 +++++++++++ io_uring/poll.c | 2 + io_uring/sqpoll.c | 4 + net/core/dev.c | 34 +++- 11 files changed, 544 insertions(+), 26 deletions(-) create mode 100644 io_uring/napi.c create mode 100644 io_uring/napi.h base-commit: f026be0e1e881e3395c3d5418ffc8c2a2203c3f3 -- 2.39.1 --=20 40 years of net history, a couple songs: https://www.youtube.com/watch?v=3DD9RGX6QFm5E Dave T=C3=A4ht CSO, LibreQos