All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [v2] mlx5: stop warning for 64KB pages
@ 2021-10-15 15:20 Arnd Bergmann
  2021-10-20  8:39 ` David Laight
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2021-10-15 15:20 UTC (permalink / raw)
  To: Saeed Mahameed, Leon Romanovsky
  Cc: Arnd Bergmann, David S. Miller, Jakub Kicinski,
	Nathan Chancellor, Nick Desaulniers, Tariq Toukan,
	Maxim Mikityanskiy, Aya Levin, Eran Ben Elisha, Daniel Borkmann,
	Jonathan Lemon, netdev, linux-rdma, linux-kernel, llvm

From: Arnd Bergmann <arnd@arndb.de>

When building with 64KB pages, clang points out that xsk->chunk_size
can never be PAGE_SIZE:

drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c:19:22: error: result of comparison of constant 65536 with expression of type 'u16' (aka 'unsigned short') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
        if (xsk->chunk_size > PAGE_SIZE ||
            ~~~~~~~~~~~~~~~ ^ ~~~~~~~~~

In older versions of this code, using PAGE_SIZE was the only
possibility, so this would have never worked on 64KB page kernels,
but the patch apparently did not address this case completely.

As Maxim Mikityanskiy suggested, 64KB chunks are really not all that
useful, so just shut up the warning by adding a cast.

Fixes: 282c0c798f8e ("net/mlx5e: Allow XSK frames smaller than a page")
Link: https://lore.kernel.org/netdev/20211013150232.2942146-1-arnd@kernel.org/
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c
index 538bc2419bd8..228257010f32 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c
@@ -15,8 +15,10 @@ bool mlx5e_validate_xsk_param(struct mlx5e_params *params,
 			      struct mlx5e_xsk_param *xsk,
 			      struct mlx5_core_dev *mdev)
 {
-	/* AF_XDP doesn't support frames larger than PAGE_SIZE. */
-	if (xsk->chunk_size > PAGE_SIZE ||
+	/* AF_XDP doesn't support frames larger than PAGE_SIZE,
+	 * and xsk->chunk_size is limited to 65535 bytes.
+	 */
+	if ((size_t)xsk->chunk_size > PAGE_SIZE ||
 			xsk->chunk_size < MLX5E_MIN_XSK_CHUNK_SIZE)
 		return false;
 
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: [PATCH] [v2] mlx5: stop warning for 64KB pages
  2021-10-15 15:20 [PATCH] [v2] mlx5: stop warning for 64KB pages Arnd Bergmann
@ 2021-10-20  8:39 ` David Laight
  0 siblings, 0 replies; 2+ messages in thread
From: David Laight @ 2021-10-20  8:39 UTC (permalink / raw)
  To: 'Arnd Bergmann', Saeed Mahameed, Leon Romanovsky
  Cc: Arnd Bergmann, David S. Miller, Jakub Kicinski,
	Nathan Chancellor, Nick Desaulniers, Tariq Toukan,
	Maxim Mikityanskiy, Aya Levin, Eran Ben Elisha, Daniel Borkmann,
	Jonathan Lemon, netdev, linux-rdma, linux-kernel, llvm

From: Arnd Bergmann
> Sent: 15 October 2021 16:21
> 
> From: Arnd Bergmann <arnd@arndb.de>
> 
> When building with 64KB pages, clang points out that xsk->chunk_size
> can never be PAGE_SIZE:
> 
> drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c:19:22: error: result of comparison of constant
> 65536 with expression of type 'u16' (aka 'unsigned short') is always false [-Werror,-Wtautological-
> constant-out-of-range-compare]
>         if (xsk->chunk_size > PAGE_SIZE ||
>             ~~~~~~~~~~~~~~~ ^ ~~~~~~~~~
> 
> In older versions of this code, using PAGE_SIZE was the only
> possibility, so this would have never worked on 64KB page kernels,
> but the patch apparently did not address this case completely.
> 
> As Maxim Mikityanskiy suggested, 64KB chunks are really not all that
> useful, so just shut up the warning by adding a cast.
> 
> Fixes: 282c0c798f8e ("net/mlx5e: Allow XSK frames smaller than a page")
> Link: https://lore.kernel.org/netdev/20211013150232.2942146-1-arnd@kernel.org/
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c
> b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c
> index 538bc2419bd8..228257010f32 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c
> @@ -15,8 +15,10 @@ bool mlx5e_validate_xsk_param(struct mlx5e_params *params,
>  			      struct mlx5e_xsk_param *xsk,
>  			      struct mlx5_core_dev *mdev)
>  {
> -	/* AF_XDP doesn't support frames larger than PAGE_SIZE. */
> -	if (xsk->chunk_size > PAGE_SIZE ||
> +	/* AF_XDP doesn't support frames larger than PAGE_SIZE,
> +	 * and xsk->chunk_size is limited to 65535 bytes.
> +	 */
> +	if ((size_t)xsk->chunk_size > PAGE_SIZE ||
>  			xsk->chunk_size < MLX5E_MIN_XSK_CHUNK_SIZE)
>  		return false;

How much smaller does the kernel get if you change 'chunk_size' from
_u16 to 'unsigned int'. ?
Especially for a non-x86 build?
Or is it a hardware constrained size??

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-20  8:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-15 15:20 [PATCH] [v2] mlx5: stop warning for 64KB pages Arnd Bergmann
2021-10-20  8:39 ` David Laight

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.