Commit Graph

4 Commits

Author SHA1 Message Date
Jeff Moyer 2d421fea35 io_uring/napi: check napi_enabled in io_napi_add() before proceeding
JIRA: https://issues.redhat.com/browse/RHEL-64867
Conflicts: RHEL does not have commit 342b2e395d5f ("io_uring/napi: use
ktime in busy polling"), which renames napi_busy_poll_to to
napi_busy_poll_dt.

commit 84f2eecf95018386c145ada19bb45b03bdb80d9e
Author: Olivier Langlois <olivier@trillion01.com>
Date:   Sun Aug 11 14:07:11 2024 -0400

    io_uring/napi: check napi_enabled in io_napi_add() before proceeding
    
    doing so avoids the overhead of adding napi ids to all the rings that do
    not enable napi.
    
    if no id is added to napi_list because napi is disabled,
    __io_napi_busy_loop() will not be called.
    
    Signed-off-by: Olivier Langlois <olivier@trillion01.com>
    Fixes: b4ccc4dd1330 ("io_uring/napi: enable even with a timeout of 0")
    Link: https://lore.kernel.org/r/bd989ccef5fda14f5fd9888faf4fefcf66bd0369.1723400131.git.olivier@trillion01.com
    Signed-off-by: Jens Axboe <axboe@kernel.dk>

Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
2024-12-02 11:14:52 -05:00
Jeff Moyer 99e9be3e6c io_uring: add register/unregister napi function
JIRA: https://issues.redhat.com/browse/RHEL-64867

commit ef1186c1a875bfa8a8cbfc2a9670b14b082187a9
Author: Stefan Roesch <shr@devkernel.io>
Date:   Thu Jun 8 09:38:38 2023 -0700

    io_uring: add register/unregister napi function
    
    This adds an api to register and unregister the napi for io-uring. If
    the arg value is specified when unregistering, the current napi setting
    for the busy poll timeout is copied into the user structure. If this is
    not required, NULL can be passed as the arg value.
    
    Signed-off-by: Stefan Roesch <shr@devkernel.io>
    Acked-by: Jakub Kicinski <kuba@kernel.org>
    Link: https://lore.kernel.org/r/20230608163839.2891748-7-shr@devkernel.io
    Signed-off-by: Jens Axboe <axboe@kernel.dk>

Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
2024-11-28 15:42:44 -05:00
Jeff Moyer 2a41c78e02 io-uring: add sqpoll support for napi busy poll
JIRA: https://issues.redhat.com/browse/RHEL-64867

commit ff183d427da0a733b0dbe11bd7acaf2dcb37b4cc
Author: Stefan Roesch <shr@devkernel.io>
Date:   Thu Jun 8 09:38:37 2023 -0700

    io-uring: add sqpoll support for napi busy poll
    
    This adds the sqpoll support to the io-uring napi.
    
    Signed-off-by: Stefan Roesch <shr@devkernel.io>
    Suggested-by: Olivier Langlois <olivier@trillion01.com>
    Link: https://lore.kernel.org/r/20230608163839.2891748-6-shr@devkernel.io
    Signed-off-by: Jens Axboe <axboe@kernel.dk>

Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
2024-11-28 15:41:44 -05:00
Jeff Moyer 7abbe65ada io-uring: add napi busy poll support
JIRA: https://issues.redhat.com/browse/RHEL-64867

commit 8d0c12a80cdeb80d5e0510e96d38fe551ed8e9b5
Author: Stefan Roesch <shr@devkernel.io>
Date:   Thu Jun 8 09:38:36 2023 -0700

    io-uring: add napi busy poll support
    
    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. The list is
    synchronized by the new napi_lock spin lock. The current default napi
    busy polling time is stored in napi_busy_poll_to. If napi busy polling
    is not enabled, the value is 0.
    
    In addition there is also a hash table. The hash table store the napi
    id and the pointer to the above list nodes. The hash table is used to
    speed up the lookup to the list elements. The hash table is synchronized
    with rcu.
    
    The NAPI_TIMEOUT is stored as a timeout to make sure that the time a
    napi entry is stored in the napi list is limited.
    
    The busy poll timeout is also stored as part of the io_wait_queue. This
    is necessary as for sq polling the poll interval needs to be adjusted
    and the napi callback allows only to pass in one value.
    
    This has been tested with two simple programs from the liburing library
    repository: the napi client and the napi server program. The client
    sends a request, which has a timestamp in its payload and the server
    replies with the same payload. The client calculates the roundtrip time
    and stores it to calculate the results.
    
    The client is running on host1 and the server is running on host 2 (in
    the same rack). The measured times below are roundtrip times. They are
    average times over 5 runs each. Each run measures 1 million roundtrips.
    
                       no rx coal          rx coal: frames=88,usecs=33
    Default              57us                    56us
    
    client_poll=100us    47us                    46us
    
    server_poll=100us    51us                    46us
    
    client_poll=100us+   40us                    40us
    server_poll=100us
    
    client_poll=100us+   41us                    39us
    server_poll=100us+
    prefer napi busy poll on client
    
    client_poll=100us+   41us                    39us
    server_poll=100us+
    prefer napi busy poll on server
    
    client_poll=100us+   41us                    39us
    server_poll=100us+
    prefer napi busy poll on client + server
    
    Signed-off-by: Stefan Roesch <shr@devkernel.io>
    Suggested-by: Olivier Langlois <olivier@trillion01.com>
    Acked-by: Jakub Kicinski <kuba@kernel.org>
    Link: https://lore.kernel.org/r/20230608163839.2891748-5-shr@devkernel.io
    Signed-off-by: Jens Axboe <axboe@kernel.dk>

Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
2024-11-28 15:40:44 -05:00