lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 11 Dec 2020 17:00:52 -0800
From:   Saeed Mahameed <saeed@...nel.org>
To:     Lorenzo Bianconi <lorenzo@...nel.org>, bpf@...r.kernel.org,
        netdev@...r.kernel.org
Cc:     davem@...emloft.net, kuba@...nel.org, ast@...nel.org,
        daniel@...earbox.net, brouer@...hat.com,
        lorenzo.bianconi@...hat.com, alexander.duyck@...il.com,
        maciej.fijalkowski@...el.com
Subject: Re: [PATCH v2 bpf-next 2/2] net: xdp: introduce xdp_prepare_buff
 utility routine

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@...nel.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;


Powered by blists - more mailing lists