BPF List
 help / color / mirror / Atom feed
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 1/9] net: introduce preferred busy-polling
Date: Thu, 12 Nov 2020 15:43:01 +0100	[thread overview]
Message-ID: <55917726-33d0-7a1f-ea4e-0ed0c76ee039@intel.com> (raw)
In-Reply-To: <CANn89iL=j38rdsKhAm8_4pMbf=vyAZ8SVoUkUgEVUF0GEXRwRg@mail.gmail.com>

On 2020-11-12 15:38, 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>
>>
>> The existing busy-polling mode, enabled by the SO_BUSY_POLL socket
>> option or system-wide using the /proc/sys/net/core/busy_read knob, is
>> an opportunistic. That means that if the NAPI context is not
>> scheduled, it will poll it. If, after busy-polling, the budget is
>> exceeded the busy-polling logic will schedule the NAPI onto the
>> regular softirq handling.
>>
>> One implication of the behavior above is that a busy/heavy loaded NAPI
>> context will never enter/allow for busy-polling. Some applications
>> prefer that most NAPI processing would be done by busy-polling.
>>
>> This series adds a new socket option, SO_PREFER_BUSY_POLL, that works
>> in concert with the napi_defer_hard_irqs and gro_flush_timeout
>> knobs. The napi_defer_hard_irqs and gro_flush_timeout knobs were
>> introduced in commit 6f8b12d661d0 ("net: napi: add hard irqs deferral
>> feature"), and allows for a user to defer interrupts to be enabled and
>> instead schedule the NAPI context from a watchdog timer. When a user
>> enables the SO_PREFER_BUSY_POLL, again with the other knobs enabled,
>> and the NAPI context is being processed by a softirq, the softirq NAPI
>> processing will exit early to allow the busy-polling to be performed.
>>
>> If the application stops performing busy-polling via a system call,
>> the watchdog timer defined by gro_flush_timeout will timeout, and
>> regular softirq handling will resume.
>>
>> In summary; Heavy traffic applications that prefer busy-polling over
>> softirq processing should use this option.
>>
>> Example usage:
>>
>>    $ echo 2 | sudo tee /sys/class/net/ens785f1/napi_defer_hard_irqs
>>    $ echo 200000 | sudo tee /sys/class/net/ens785f1/gro_flush_timeout
>>
>> Note that the timeout should be larger than the userspace processing
>> window, otherwise the watchdog will timeout and fall back to regular
>> softirq processing.
>>
>> Enable the SO_BUSY_POLL/SO_PREFER_BUSY_POLL options on your socket.
>>
>> Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
> 
> ...
> 
>> diff --git a/net/core/sock.c b/net/core/sock.c
>> index 727ea1cc633c..248f6a763661 100644
>> --- a/net/core/sock.c
>> +++ b/net/core/sock.c
>> @@ -1159,6 +1159,12 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
>>                                  sk->sk_ll_usec = val;
>>                  }
>>                  break;
>> +       case SO_PREFER_BUSY_POLL:
>> +               if (valbool && !capable(CAP_NET_ADMIN))
>> +                       ret = -EPERM;
>> +               else
>> +                       sk->sk_prefer_busy_poll = valbool;
> 
>                              WRITE_ONCE(sk->sk_prefer_busy_poll, valbool);
> 
> So that KCSAN is happy while readers read this field while socket is not locked.
>

Thanks Eric, I'll fix that!

Also, in patch 5, READ_ONCE is missing. I'll address that as well.


  reply	other threads:[~2020-11-12 14:43 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 [this message]
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
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=55917726-33d0-7a1f-ea4e-0ed0c76ee039@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