On Dec 11, Saeed Mahameed wrote:
> On Fri, 2020-12-11 at 20:28 +0100, Lorenzo Bianconi wrote:
> > Introduce xdp_prepare_buff utility routine to initialize per-
> > descriptor
> > xdp_buff fields (e.g. xdp_buff pointers). Rely on xdp_prepare_buff()
> > in
> > all XDP capable drivers.
> > 
> > Signed-off-by: Lorenzo Bianconi <lore...@kernel.org>
> > 
> ...
> > +static inline void
> > +xdp_prepare_buff(struct xdp_buff *xdp, unsigned char *hard_start,
> > +            int headroom, int data_len)
> > +{
> > +   xdp->data_hard_start = hard_start;
> > +   xdp->data = hard_start + headroom;
> > +   xdp->data_end = xdp->data + data_len;
> > +   xdp->data_meta = xdp->data;
> 
> You might want to compute data = hard_start + headroom; on a local var,
> and hopefully gcc will put it into a register, then reuse it three
> times instead of the 2 xdp->data de-references you got at the end of
> the function.
> 
> unsigned char *data = hard_start + headroom;
> 
> xdp->data_hard_start = hard_start;
> xdp->data = data;
> xdp->data_end = data + data_len;
> xdp->data_meta = data;

ack, I will fix it in v3.

Regards,
Lorenzo

> 
> 

Attachment: signature.asc
Description: PGP signature

Reply via email to