[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2c0c1a4f-95d4-40c9-9ede-6f92b173f05d@stanley.mountain>
Date: Mon, 3 Mar 2025 15:31:05 +0300
From: Dan Carpenter <dan.carpenter@...aro.org>
To: "Malladi, Meghana" <m-malladi@...com>
Cc: rogerq@...nel.org, danishanwar@...com, pabeni@...hat.com,
kuba@...nel.org, edumazet@...gle.com, davem@...emloft.net,
andrew+netdev@...n.ch, bpf@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
netdev@...r.kernel.org, u.kleine-koenig@...libre.com,
matthias.schiffer@...tq-group.com, schnelle@...ux.ibm.com,
diogo.ivo@...mens.com, glaroque@...libre.com, macro@...am.me.uk,
john.fastabend@...il.com, hawk@...nel.org, daniel@...earbox.net,
ast@...nel.org, srk@...com, Vignesh Raghavendra <vigneshr@...com>
Subject: Re: [EXTERNAL] Re: [PATCH net-next v3 3/3] net: ti: icssg-prueth:
Add XDP support
On Mon, Mar 03, 2025 at 05:36:41PM +0530, Malladi, Meghana wrote:
> > > +static int emac_run_xdp(struct prueth_emac *emac, struct xdp_buff *xdp,
> > > + struct page *page)
> > > +{
> > > + struct net_device *ndev = emac->ndev;
> > > + int err, result = ICSSG_XDP_PASS;
> > > + struct bpf_prog *xdp_prog;
> > > + struct xdp_frame *xdpf;
> > > + int q_idx;
> > > + u32 act;
> > > +
> > > + xdp_prog = READ_ONCE(emac->xdp_prog);
> > > + act = bpf_prog_run_xdp(xdp_prog, xdp);
> > > + switch (act) {
> > > + case XDP_PASS:
> > > + break;
> > > + case XDP_TX:
> > > + /* Send packet to TX ring for immediate transmission */
> > > + xdpf = xdp_convert_buff_to_frame(xdp);
> > > + if (unlikely(!xdpf))
> >
> > This is the second unlikely() macro which is added in this patchset.
> > The rule with likely/unlikely() is that it should only be added if it
> > likely makes a difference in benchmarking. Quite often the compiler
> > is able to predict that valid pointers are more likely than NULL
> > pointers so often these types of annotations don't make any difference
> > at all to the compiled code. But it depends on the compiler and the -O2
> > options.
> >
>
> Do correct me if I am wrong, but from my understanding, XDP feature depends
> alot of performance and benchmarking and having unlikely does make a
> difference. Atleast in all the other drivers I see this being used for XDP.
>
Which compiler are you on when you say that "having unlikely does make a
difference"?
I'm on gcc version 14.2.0 (Debian 14.2.0-16) and it doesn't make a
difference to the compiled code. This matches what one would expect from
a compiler. Valid pointers are fast path and NULL pointers are slow path.
Adding an unlikely() is a micro optimization. There are so many other
things you can do to speed up the code. I wouldn't start with that.
regards,
dan
Powered by blists - more mailing lists