From: Pavel Begunkov <asml.silence@gmail.com>
To: Paolo Abeni <pabeni@redhat.com>, David Wei <dw@davidwei.uk>,
io-uring@vger.kernel.org, netdev@vger.kernel.org
Cc: Jens Axboe <axboe@kernel.dk>, Jakub Kicinski <kuba@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jesper Dangaard Brouer <hawk@kernel.org>,
David Ahern <dsahern@kernel.org>,
Mina Almasry <almasrymina@google.com>,
Stanislav Fomichev <stfomichev@gmail.com>,
Joe Damato <jdamato@fastly.com>,
Pedro Tammela <pctammela@mojatatu.com>
Subject: Re: [PATCH v6 08/15] net: add helper executing custom callback from napi
Date: Mon, 21 Oct 2024 18:16:16 +0100 [thread overview]
Message-ID: <9d2c123d-9e1e-4365-a047-e4fe84444ab9@gmail.com> (raw)
In-Reply-To: <cd9c2290-f874-49e6-bc99-5336a096cffb@redhat.com>
On 10/21/24 15:25, Paolo Abeni wrote:
> Hi,
>
> On 10/16/24 20:52, David Wei wrote:
>> @@ -6503,6 +6511,41 @@ void napi_busy_loop(unsigned int napi_id,
>> }
>> EXPORT_SYMBOL(napi_busy_loop);
>>
>> +void napi_execute(unsigned napi_id,
>> + void (*cb)(void *), void *cb_arg)
>> +{
>> + struct napi_struct *napi;
>> + void *have_poll_lock = NULL;
>
> Minor nit: please respect the reverse x-mas tree order.
>
>> +
>> + guard(rcu)();
>
> Since this will land into net core code, please use the explicit RCU
> read lock/unlock:
>
> https://elixir.bootlin.com/linux/v6.12-rc3/source/Documentation/process/maintainer-netdev.rst#L387
I missed the doc update, will change it, thanks
>> + napi = napi_by_id(napi_id);
>> + if (!napi)
>> + return;
>> +
>> + if (!IS_ENABLED(CONFIG_PREEMPT_RT))
>> + preempt_disable();
>> +
>> + for (;;) {
>> + local_bh_disable();
>> +
>> + if (napi_state_start_busy_polling(napi, 0)) {
>> + have_poll_lock = netpoll_poll_lock(napi);
>> + cb(cb_arg);
>> + local_bh_enable();
>> + busy_poll_stop(napi, have_poll_lock, 0, 1);
>> + break;
>> + }
>> +
>> + local_bh_enable();
>> + if (unlikely(need_resched()))
>> + break;
>> + cpu_relax();
>
> Don't you need a 'loop_end' condition here?
As you mentioned in 14/15, it can indeed spin for long and is bound only
by need_resched(). Do you think it's reasonable to wait for it without a
time limit with NAPI_STATE_PREFER_BUSY_POLL? softirq should yield napi
after it exhausts the budget, it should limit it well enough, what do
you think?
The only ugly part is that I don't want it to mess with the
NAPI_F_PREFER_BUSY_POLL in busy_poll_stop()
busy_poll_stop() {
...
clear_bit(NAPI_STATE_IN_BUSY_POLL, &napi->state);
if (flags & NAPI_F_PREFER_BUSY_POLL) {
napi->defer_hard_irqs_count = READ_ONCE(napi->dev->napi_defer_hard_irqs);
timeout = READ_ONCE(napi->dev->gro_flush_timeout);
if (napi->defer_hard_irqs_count && timeout) {
hrtimer_start(&napi->timer, ns_to_ktime(timeout), HRTIMER_MODE_REL_PINNED);
skip_schedule = true;
}
}
}
Is it fine to set PREFER_BUSY_POLL but do the stop call without? E.g.
set_bit(NAPI_STATE_PREFER_BUSY_POLL, &napi->state);
...
busy_poll_stop(napi, flags=0);
--
Pavel Begunkov
next prev parent reply other threads:[~2024-10-21 17:15 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-16 18:52 [PATCH v6 00/15] io_uring zero copy rx David Wei
2024-10-16 18:52 ` [PATCH v6 01/15] net: prefix devmem specific helpers David Wei
2024-10-16 18:52 ` [PATCH v6 02/15] net: generalise net_iov chunk owners David Wei
2024-10-23 7:20 ` Christoph Hellwig
2024-10-23 14:34 ` Pavel Begunkov
2024-10-24 9:23 ` Christoph Hellwig
2024-10-24 14:23 ` Pavel Begunkov
2024-10-24 16:06 ` Christoph Hellwig
2024-10-24 16:40 ` Pavel Begunkov
2024-10-28 12:11 ` Christoph Hellwig
2024-10-29 16:35 ` Pavel Begunkov
2024-10-30 14:57 ` Christoph Hellwig
2024-10-16 18:52 ` [PATCH v6 03/15] net: page_pool: create hooks for custom page providers David Wei
2024-10-16 18:52 ` [PATCH v6 04/15] net: prepare for non devmem TCP memory providers David Wei
2024-10-16 18:52 ` [PATCH v6 05/15] net: page_pool: add ->scrub mem provider callback David Wei
2024-10-16 18:52 ` [PATCH v6 06/15] net: page pool: add helper creating area from pages David Wei
2024-10-16 18:52 ` [PATCH v6 07/15] net: page_pool: introduce page_pool_mp_return_in_cache David Wei
2024-10-16 18:52 ` [PATCH v6 08/15] net: add helper executing custom callback from napi David Wei
2024-10-21 14:25 ` Paolo Abeni
2024-10-21 15:49 ` Jens Axboe
2024-10-21 16:34 ` Pavel Begunkov
2024-10-21 17:16 ` Pavel Begunkov [this message]
2024-10-22 7:47 ` Paolo Abeni
2024-10-22 15:36 ` Pavel Begunkov
2024-10-16 18:52 ` [PATCH v6 09/15] io_uring/zcrx: add interface queue and refill queue David Wei
2024-10-21 15:33 ` Jens Axboe
2024-10-16 18:52 ` [PATCH v6 10/15] io_uring/zcrx: add io_zcrx_area David Wei
2024-10-21 15:35 ` Jens Axboe
2024-10-21 16:28 ` Pavel Begunkov
2024-10-21 16:29 ` Jens Axboe
2024-10-21 16:39 ` Pavel Begunkov
2024-10-16 18:52 ` [PATCH v6 11/15] io_uring/zcrx: implement zerocopy receive pp memory provider David Wei
2024-10-21 15:46 ` Jens Axboe
2024-10-16 18:52 ` [PATCH v6 12/15] io_uring/zcrx: add io_recvzc request David Wei
2024-10-21 16:05 ` Jens Axboe
2024-10-16 18:52 ` [PATCH v6 13/15] io_uring/zcrx: set pp memory provider for an rx queue David Wei
2024-10-21 16:30 ` Jens Axboe
2024-10-16 18:52 ` [PATCH v6 14/15] io_uring/zcrx: add copy fallback David Wei
2024-10-21 14:40 ` Paolo Abeni
2024-10-21 18:31 ` David Wei
2024-10-22 7:48 ` Paolo Abeni
2024-10-16 18:52 ` [PATCH v6 15/15] io_uring/zcrx: throttle receive requests David Wei
2024-10-21 16:36 ` Jens Axboe
2024-10-21 15:27 ` [PATCH v6 00/15] io_uring zero copy rx Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9d2c123d-9e1e-4365-a047-e4fe84444ab9@gmail.com \
--to=asml.silence@gmail.com \
--cc=almasrymina@google.com \
--cc=axboe@kernel.dk \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=dw@davidwei.uk \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=io-uring@vger.kernel.org \
--cc=jdamato@fastly.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pctammela@mojatatu.com \
--cc=stfomichev@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).