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  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191118151001.2f5cdcc5@cakuba.netronome.com>
Date:   Mon, 18 Nov 2019 15:10:01 -0800
From:   Jakub Kicinski <jakub.kicinski@...ronome.com>
To:     Luigi Rizzo <lrizzo@...gle.com>
Cc:     magnus.karlsson@...el.com, bjorn.topel@...el.com,
        jonathan.lemon@...il.com, netdev@...r.kernel.org,
        bpf@...r.kernel.org, rizzo@....unipi.it
Subject: Re: [PATCH] net-af_xdp: use correct number of channels from ethtool

On Mon, 18 Nov 2019 14:55:23 -0800, Luigi Rizzo wrote:
> Drivers use different fields to report the number of channels, so take
> the maximum of all fields (rx, tx, other, combined) when determining the
> size of the xsk map. The current code used only 'combined' which was set
> to 0 in some drivers e.g. mlx4.
> 
> Tested: compiled and run xdpsock -q 3 -r -S on mlx4
> Signed-off-by: Luigi Rizzo <lrizzo@...gle.com>

thanks, this seems mostly correct

> diff --git a/tools/lib/bpf/xsk.c b/tools/lib/bpf/xsk.c
> index 74d84f36a5b24..8e12269428d08 100644
> --- a/tools/lib/bpf/xsk.c
> +++ b/tools/lib/bpf/xsk.c
> @@ -412,6 +412,11 @@ static int xsk_load_xdp_prog(struct xsk_socket *xsk)
>  	return 0;
>  }
>  
> +static inline int max_i(int a, int b)
> +{
> +	return a > b ? a : b;
> +}

There's already a max in tools/lib/bpf/libbpf_internal.h, could you
possible just use that?

>  static int xsk_get_max_queues(struct xsk_socket *xsk)
>  {
>  	struct ethtool_channels channels = { .cmd = ETHTOOL_GCHANNELS };
> @@ -431,13 +436,18 @@ static int xsk_get_max_queues(struct xsk_socket *xsk)
>  		goto out;
>  	}
>  
> -	if (err || channels.max_combined == 0)
> +	if (err) {
>  		/* If the device says it has no channels, then all traffic
>  		 * is sent to a single stream, so max queues = 1.
>  		 */
>  		ret = 1;
> -	else
> -		ret = channels.max_combined;
> +	} else {
> +		/* Take the max of rx, tx, other, combined. Drivers return
> +		 * the number of channels in different ways.
> +		 */
> +		ret = max_i(max_i(channels.max_rx, channels.max_tx),
> +			      max_i(channels.max_other, channels.max_combined));

The continuation line should be aligned to the opening bracket.

I don't think we need to care about other, other is for non-traffic
interrupts.

> +	}
>  
>  out:
>  	close(fd);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ