From: Daniel Borkmann <daniel@iogearbox•net>
To: Jesper Dangaard Brouer <brouer@redhat•com>, netdev@vger•kernel.org
Cc: jakub.kicinski@netronome•com,
"Michael S. Tsirkin" <mst@redhat•com>,
pavel.odintsov@gmail•com, Jason Wang <jasowang@redhat•com>,
mchan@broadcom•com, John Fastabend <john.fastabend@gmail•com>,
peter.waskiewicz.jr@intel•com,
Daniel Borkmann <borkmann@iogearbox•net>,
Alexei Starovoitov <alexei.starovoitov@gmail•com>,
Andy Gospodarek <andy@greyhouse•net>
Subject: Re: [net-next V4 PATCH 3/5] bpf: cpumap xdp_buff to skb conversion and allocation
Date: Thu, 05 Oct 2017 12:22:43 +0200 [thread overview]
Message-ID: <59D607F3.6090306@iogearbox.net> (raw)
In-Reply-To: <150711863521.9499.3702385818650624585.stgit@firesoul>
On 10/04/2017 02:03 PM, Jesper Dangaard Brouer wrote:
[...]
> static int cpu_map_kthread_run(void *data)
> {
> struct bpf_cpu_map_entry *rcpu = data;
>
> set_current_state(TASK_INTERRUPTIBLE);
> while (!kthread_should_stop()) {
> + unsigned int processed = 0, drops = 0;
> struct xdp_pkt *xdp_pkt;
>
> - schedule();
> - /* Do work */
> - while ((xdp_pkt = ptr_ring_consume(rcpu->queue))) {
> - /* For now just "refcnt-free" */
> - page_frag_free(xdp_pkt);
> + /* Release CPU reschedule checks */
> + if (__ptr_ring_empty(rcpu->queue)) {
> + schedule();
> + } else {
> + cond_resched();
> + }
> +
> + /* Process packets in rcpu->queue */
> + local_bh_disable();
> + /*
> + * The bpf_cpu_map_entry is single consumer, with this
> + * kthread CPU pinned. Lockless access to ptr_ring
> + * consume side valid as no-resize allowed of queue.
> + */
> + while ((xdp_pkt = __ptr_ring_consume(rcpu->queue))) {
> + struct sk_buff *skb;
> + int ret;
> +
> + skb = cpu_map_build_skb(rcpu, xdp_pkt);
> + if (!skb) {
> + page_frag_free(xdp_pkt);
> + continue;
> + }
> +
> + /* Inject into network stack */
> + ret = netif_receive_skb_core(skb);
Don't we need to hold RCU read lock for above netif_receive_skb_core()?
> + if (ret == NET_RX_DROP)
> + drops++;
> +
> + /* Limit BH-disable period */
> + if (++processed == 8)
> + break;
> }
> + local_bh_enable(); /* resched point, may call do_softirq() */
> +
> __set_current_state(TASK_INTERRUPTIBLE);
> }
> put_cpu_map_entry(rcpu);
> @@ -463,13 +582,6 @@ static int bq_flush_to_queue(struct bpf_cpu_map_entry *rcpu,
next prev parent reply other threads:[~2017-10-05 10:22 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-04 12:03 [net-next V4 PATCH 0/5] New bpf cpumap type for XDP_REDIRECT Jesper Dangaard Brouer
2017-10-04 12:03 ` [net-next V4 PATCH 1/5] bpf: introduce new bpf cpu map type BPF_MAP_TYPE_CPUMAP Jesper Dangaard Brouer
2017-10-04 19:02 ` Alexei Starovoitov
2017-10-05 18:01 ` John Fastabend
2017-10-06 9:03 ` Jesper Dangaard Brouer
2017-10-05 9:40 ` Daniel Borkmann
2017-10-06 10:50 ` Jesper Dangaard Brouer
2017-10-06 14:52 ` Daniel Borkmann
2017-10-06 15:58 ` Jesper Dangaard Brouer
2017-10-25 16:53 ` [bpf] 3ea693a925: BUG:unable_to_handle_kernel kernel test robot
2017-10-25 16:59 ` Michael S. Tsirkin
2017-10-25 10:02 ` [LKP] " Ye Xiaolong
2017-10-25 12:09 ` Ye Xiaolong
2017-10-25 16:54 ` kernel test robot
2017-10-04 12:03 ` [net-next V4 PATCH 2/5] bpf: XDP_REDIRECT enable use of cpumap Jesper Dangaard Brouer
2017-10-05 10:10 ` Daniel Borkmann
2017-10-06 11:17 ` Jesper Dangaard Brouer
2017-10-06 12:01 ` Jesper Dangaard Brouer
2017-10-06 15:45 ` Jesper Dangaard Brouer
2017-10-06 8:30 ` kbuild test robot
2017-10-04 12:03 ` [net-next V4 PATCH 3/5] bpf: cpumap xdp_buff to skb conversion and allocation Jesper Dangaard Brouer
2017-10-05 10:22 ` Daniel Borkmann [this message]
2017-10-06 12:11 ` Jesper Dangaard Brouer
2017-10-04 12:04 ` [net-next V4 PATCH 4/5] bpf: cpumap add tracepoints Jesper Dangaard Brouer
2017-10-04 12:04 ` [net-next V4 PATCH 5/5] samples/bpf: add cpumap sample program xdp_redirect_cpu Jesper Dangaard Brouer
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=59D607F3.6090306@iogearbox.net \
--to=daniel@iogearbox$(echo .)net \
--cc=alexei.starovoitov@gmail$(echo .)com \
--cc=andy@greyhouse$(echo .)net \
--cc=borkmann@iogearbox$(echo .)net \
--cc=brouer@redhat$(echo .)com \
--cc=jakub.kicinski@netronome$(echo .)com \
--cc=jasowang@redhat$(echo .)com \
--cc=john.fastabend@gmail$(echo .)com \
--cc=mchan@broadcom$(echo .)com \
--cc=mst@redhat$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=pavel.odintsov@gmail$(echo .)com \
--cc=peter.waskiewicz.jr@intel$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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