Re: [PATCH v2 bpf-next 2/2] net: xdp: introduce xdp_prepare_buff utility routine

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <lorenzo@xxxxxxxxxx>
> > 
> ...
> > +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


[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux