From: "Björn Töpel" <bjorn.topel@intel.com>
To: "Eric Dumazet" <edumazet@google.com>,
"Björn Töpel" <bjorn.topel@gmail.com>
Cc: netdev <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
magnus.karlsson@intel.com, Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
maciej.fijalkowski@intel.com, "Samudrala,
Sridhar" <sridhar.samudrala@intel.com>,
Jesse Brandeburg <jesse.brandeburg@intel.com>,
qi.z.zhang@intel.com, Jakub Kicinski <kuba@kernel.org>,
Jonathan Lemon <jonathan.lemon@gmail.com>,
maximmi@nvidia.com
Subject: Re: [PATCH bpf-next 2/9] net: add SO_BUSY_POLL_BUDGET socket option
Date: Thu, 12 Nov 2020 15:45:35 +0100 [thread overview]
Message-ID: <03a5a7d5-e5c9-5c61-8e8e-9393e8772d88@intel.com> (raw)
In-Reply-To: <CANn89i+Zumgn+phZEYPb9yCQRrJ7UYh1wY7SBio6ykg2noYz2w@mail.gmail.com>
On 2020-11-12 15:36, Eric Dumazet wrote:
> On Thu, Nov 12, 2020 at 12:41 PM Björn Töpel <bjorn.topel@gmail.com> wrote:
>>
>> From: Björn Töpel <bjorn.topel@intel.com>
>>
>> This option lets a user set a per socket NAPI budget for
>> busy-polling. If the options is not set, it will use the default of 8.
>>
>> Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
>> ---
>>
>
> ...
>
>> #else /* CONFIG_NET_RX_BUSY_POLL */
>> static inline unsigned long net_busy_loop_on(void)
>> @@ -106,7 +108,8 @@ static inline void sk_busy_loop(struct sock *sk, int nonblock)
>>
>> if (napi_id >= MIN_NAPI_ID)
>> napi_busy_loop(napi_id, nonblock ? NULL : sk_busy_loop_end, sk,
>> - READ_ONCE(sk->sk_prefer_busy_poll));
>> + READ_ONCE(sk->sk_prefer_busy_poll),
>> + sk->sk_busy_poll_budget ?: BUSY_POLL_BUDGET);
>
> Please use :
>
> READ_ONCE(sk->sk_busy_poll_budget) ?: BUSY_POLL_BUDGET
>
> Because sk_busy_loop() is usually called without socket lock being held.
>
> This will prevent yet another KCSAN report.
>
>> #endif
>> }
>>
>
> ...
>
>> --- a/net/core/sock.c
>> +++ b/net/core/sock.c
>> @@ -1165,6 +1165,16 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
>> else
>> sk->sk_prefer_busy_poll = valbool;
>> break;
>> + case SO_BUSY_POLL_BUDGET:
>> + if (val > sk->sk_busy_poll_budget && !capable(CAP_NET_ADMIN)) {
>> + ret = -EPERM;
>> + } else {
>> + if (val < 0)
>
> if (val < 0 || val > (u16)~0)
>
>> + ret = -EINVAL;
>> + else
>> + sk->sk_busy_poll_budget = val;
>
>
> WRITE_ONCE(sk->sk_busy_poll_budget, val);
>
Thanks for the review! I'll address it all.
next prev parent reply other threads:[~2020-11-12 14:45 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-12 11:40 [PATCH bpf-next 0/9] Introduce preferred busy-polling Björn Töpel
2020-11-12 11:40 ` [PATCH bpf-next 1/9] net: introduce " Björn Töpel
2020-11-12 14:38 ` Eric Dumazet
2020-11-12 14:43 ` Björn Töpel
2020-11-12 11:40 ` [PATCH bpf-next 2/9] net: add SO_BUSY_POLL_BUDGET socket option Björn Töpel
2020-11-12 14:36 ` Eric Dumazet
2020-11-12 14:45 ` Björn Töpel [this message]
2020-11-12 11:40 ` [PATCH bpf-next 3/9] xsk: add support for recvmsg() Björn Töpel
2020-11-12 11:40 ` [PATCH bpf-next 4/9] xsk: check need wakeup flag in sendmsg() Björn Töpel
2020-11-12 11:40 ` [PATCH bpf-next 5/9] xsk: add busy-poll support for {recv,send}msg() Björn Töpel
2020-11-12 11:40 ` [PATCH bpf-next 6/9] xsk: propagate napi_id to XDP socket Rx path Björn Töpel
2020-11-15 4:48 ` Ilias Apalodimas
2020-11-12 11:40 ` [PATCH bpf-next 7/9] samples/bpf: use recvfrom() in xdpsock Björn Töpel
2020-11-12 11:40 ` [PATCH bpf-next 8/9] samples/bpf: add busy-poll support to xdpsock Björn Töpel
2020-11-12 11:40 ` [PATCH bpf-next 9/9] samples/bpf: add option to set the busy-poll budget Björn Töpel
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=03a5a7d5-e5c9-5c61-8e8e-9393e8772d88@intel.com \
--to=bjorn.topel@intel.com \
--cc=ast@kernel.org \
--cc=bjorn.topel@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=edumazet@google.com \
--cc=jesse.brandeburg@intel.com \
--cc=jonathan.lemon@gmail.com \
--cc=kuba@kernel.org \
--cc=maciej.fijalkowski@intel.com \
--cc=magnus.karlsson@intel.com \
--cc=maximmi@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=qi.z.zhang@intel.com \
--cc=sridhar.samudrala@intel.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