From: Jesper Dangaard Brouer <brouer@redhat.com>
To: David Ahern <dsahern@gmail.com>
Cc: Daniel Borkmann <borkmann@iogearbox.net>,
Alexei Starovoitov <alexei.starovoitov@gmail.com>,
netdev@vger.kernel.org, gospo@broadcom.com,
bjorn.topel@intel.com, michael.chan@broadcom.com,
brouer@redhat.com, Saeed Mahameed <saeedm@mellanox.com>
Subject: Re: [bpf-next V1-RFC PATCH 01/14] xdp: base API for new XDP rx-queue info concept
Date: Thu, 21 Dec 2017 17:59:21 +0100 [thread overview]
Message-ID: <20171221175921.6c2a6ece@redhat.com> (raw)
In-Reply-To: <20171218115501.3f1fcf36@redhat.com>
On Mon, 18 Dec 2017 11:55:01 +0100
Jesper Dangaard Brouer <brouer@redhat.com> wrote:
> On Wed, 13 Dec 2017 19:34:40 -0700
> David Ahern <dsahern@gmail.com> wrote:
>
> > On 12/13/17 4:19 AM, Jesper Dangaard Brouer wrote:
> > > +
> > > +void xdp_rxq_info_unreg(struct xdp_rxq_info *xdp_rxq)
> > > +{
> > > + xdp_rxq->reg_state = REG_STATE_UNREGISTRED;
> > > +}
> > > +EXPORT_SYMBOL_GPL(xdp_rxq_info_unreg);
> > > +
> > > +void xdp_rxq_info_init(struct xdp_rxq_info *xdp_rxq)
> > > +{
> > > + if (xdp_rxq->reg_state == REG_STATE_REGISTRED) {
> > > + WARN(1, "Missing unregister, handled but fix driver\n");
> > > + xdp_rxq_info_unreg(xdp_rxq);
> > > + }
> > > + memset(xdp_rxq, 0, sizeof(*xdp_rxq));
> > > + xdp_rxq->queue_index = U32_MAX;
> > > + xdp_rxq->reg_state = REG_STATE_NEW;
> > > +}
> > > +EXPORT_SYMBOL_GPL(xdp_rxq_info_init);
> > > +
> > > +void xdp_rxq_info_reg(struct xdp_rxq_info *xdp_rxq)
> > > +{
> > > + WARN(!xdp_rxq->dev, "Missing net_device from driver");
> > > + WARN(xdp_rxq->queue_index == U32_MAX, "Miss queue_index from driver");
> > > + WARN(!(xdp_rxq->reg_state == REG_STATE_NEW),"API violation, miss init");
> > > + xdp_rxq->reg_state = REG_STATE_REGISTRED;
> > > +}
> > > +EXPORT_SYMBOL_GPL(xdp_rxq_info_reg);
> > >
> >
> > Rather than WARN()'s why not make the _reg and _init functions return an
> > int that indicates an error? For example you don't want to continue if
> > the dev is expected but missing.
>
> Handling return-errors in the drivers complicated the driver code, as it
> involves unraveling and deallocating other RX-rings etc (that were
> already allocated) if the reg fails. (Also notice next patch will allow
> dev == NULL, if right ptype is set).
>
> I'm not completely rejecting you idea, as this is a good optimization
> trick, which is to move validation checks to setup-time, thus allowing
> less validation checks at runtime. I sort-of actually already did
> this, as I allow bpf to deref dev without NULL check. I would argue
> this is good enough, as we will crash in a predictable way, as above
> WARN will point to which driver violated the API.
>
> If people think it is valuable I can change this API to return an err?
I will take Ahern's suggestion of returning an err-code, but only from
xdp_rxq_info_reg(). And I'm going to move xdp_rxq_info_init to be an
internal function (which Saeed also implicitly suggested).
I'm working through the drivers now, and only two drivers don't have a
proper error-return for handling xdp_rxq_info_reg() could fail.
I've also extended xdp_rxq_info_reg() to take args dev + idx, to reduce
the code-lines (given we now also have to check return code, this got
too big). Thus, reg is a single call with if-return-check.
> I guess, it would be more future-proof to do this, as we (Bjørn,
> Michael, Andy) want to extend this to implement a XDP frame/mem return
> code-path. And the register call will likely have to allocate some
> resource that could fail, which need to be handled...
I'm mostly doing it for above reason, as I'm hoping to avoid touching
every XDP driver once again. It is a real pain.
> If we do this, we might as well (slab) alloc the xdp_rxq_info
> structure to reduce the bloat in the drivers RX-rings to a single
> pointer (and a pointer to xdp_rxq_info is what xdp_buff.rxq need).
I've dropped my idea of (slab) allocating the xdp_rxq_info structure.
I started coding this up, but realized the number of lines added per
driver got too excessive for no apparent gain. (e.g. I also needed to
take the numa-node into account in some drivers).
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
LinkedIn: http://www.linkedin.com/in/brouer
next prev parent reply other threads:[~2017-12-21 16:59 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-13 11:19 [bpf-next V1-RFC PATCH 00/14] xdp: new XDP rx-queue info concept Jesper Dangaard Brouer
2017-12-13 11:19 ` [bpf-next V1-RFC PATCH 01/14] xdp: base API for " Jesper Dangaard Brouer
2017-12-14 2:34 ` David Ahern
2017-12-18 10:55 ` Jesper Dangaard Brouer
2017-12-18 13:23 ` David Ahern
2017-12-18 15:52 ` Jesper Dangaard Brouer
2017-12-21 16:59 ` Jesper Dangaard Brouer [this message]
2017-12-13 11:19 ` [bpf-next V1-RFC PATCH 02/14] xdp/mlx5: setup xdp_rxq_info and extend with qtype Jesper Dangaard Brouer
2017-12-13 12:27 ` Tariq Toukan
2017-12-13 13:44 ` Jesper Dangaard Brouer
2017-12-13 23:03 ` Saeed Mahameed
2017-12-14 6:46 ` Jesper Dangaard Brouer
2017-12-13 11:19 ` [Intel-wired-lan] [bpf-next V1-RFC PATCH 03/14] i40e: setup xdp_rxq_info Jesper Dangaard Brouer
2017-12-13 11:19 ` Jesper Dangaard Brouer
2017-12-18 10:52 ` [Intel-wired-lan] " =?unknown-8bit?q?Bj=C3=B6rn_T=C3=B6pel?=
2017-12-18 10:52 ` Björn Töpel
2017-12-18 13:05 ` Jesper Dangaard Brouer
2017-12-18 13:05 ` Jesper Dangaard Brouer
2017-12-13 11:19 ` [Intel-wired-lan] [bpf-next V1-RFC PATCH 04/14] ixgbe: " Jesper Dangaard Brouer
2017-12-13 11:19 ` Jesper Dangaard Brouer
2017-12-13 11:19 ` [bpf-next V1-RFC PATCH 05/14] xdp/qede: setup xdp_rxq_info and intro xdp_rxq_info_is_reg Jesper Dangaard Brouer
2017-12-13 11:19 ` [bpf-next V1-RFC PATCH 06/14] mlx4: setup xdp_rxq_info Jesper Dangaard Brouer
2017-12-13 12:42 ` Tariq Toukan
2017-12-13 14:00 ` Jesper Dangaard Brouer
2017-12-13 11:19 ` [bpf-next V1-RFC PATCH 07/14] bnxt_en: " Jesper Dangaard Brouer
2017-12-13 11:20 ` [bpf-next V1-RFC PATCH 08/14] nfp: " Jesper Dangaard Brouer
2017-12-14 2:34 ` Jakub Kicinski
2017-12-18 20:25 ` Jesper Dangaard Brouer
2017-12-13 11:20 ` [bpf-next V1-RFC PATCH 09/14] thunderx: " Jesper Dangaard Brouer
2017-12-13 11:20 ` Jesper Dangaard Brouer
2017-12-13 11:20 ` [bpf-next V1-RFC PATCH 10/14] tun: " Jesper Dangaard Brouer
2017-12-20 7:48 ` Jason Wang
2017-12-21 15:42 ` Jesper Dangaard Brouer
2017-12-13 11:20 ` [bpf-next V1-RFC PATCH 11/14] virtio_net: " Jesper Dangaard Brouer
2017-12-13 11:20 ` [bpf-next V1-RFC PATCH 12/14] xdp: generic XDP handling of xdp_rxq_info Jesper Dangaard Brouer
2017-12-13 22:50 ` Saeed Mahameed
2017-12-18 9:47 ` Jesper Dangaard Brouer
2017-12-13 11:20 ` [bpf-next V1-RFC PATCH 13/14] bpf: finally expose xdp_rxq_info to XDP bpf-programs Jesper Dangaard Brouer
2017-12-13 11:20 ` [bpf-next V1-RFC PATCH 14/14] samples/bpf: program demonstrating access to xdp_rxq_info 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=20171221175921.6c2a6ece@redhat.com \
--to=brouer@redhat.com \
--cc=alexei.starovoitov@gmail.com \
--cc=bjorn.topel@intel.com \
--cc=borkmann@iogearbox.net \
--cc=dsahern@gmail.com \
--cc=gospo@broadcom.com \
--cc=michael.chan@broadcom.com \
--cc=netdev@vger.kernel.org \
--cc=saeedm@mellanox.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.