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] [day] [month] [year] [list]
Message-ID: <CAK8P3a0QR8a6vxp6r_RtN5QvwxR-umKy6Ye7VNyyt_1BS4yQ7Q@mail.gmail.com>
Date:   Fri, 15 Oct 2021 17:16:42 +0200
From:   Arnd Bergmann <arnd@...nel.org>
To:     Maxim Mikityanskiy <maximmi@...dia.com>
Cc:     Tariq Toukan <ttoukan.linux@...il.com>,
        Saeed Mahameed <saeedm@...dia.com>,
        Leon Romanovsky <leon@...nel.org>,
        "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Arnd Bergmann <arnd@...db.de>,
        Nathan Chancellor <nathan@...nel.org>,
        Nick Desaulniers <ndesaulniers@...gle.com>,
        Aya Levin <ayal@...dia.com>,
        Eran Ben Elisha <eranbe@...dia.com>,
        Vladyslav Tarasiuk <vladyslavt@...dia.com>,
        Jonathan Lemon <jonathan.lemon@...il.com>,
        Daniel Borkmann <daniel@...earbox.net>,
        Networking <netdev@...r.kernel.org>,
        linux-rdma <linux-rdma@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        llvm@...ts.linux.dev
Subject: Re: [PATCH] mlx5: allow larger xsk chunk_size

On Fri, Oct 15, 2021 at 3:27 PM Maxim Mikityanskiy <maximmi@...dia.com> wrote:
> > On 10/13/2021 6:02 PM, Arnd Bergmann wrote:
> >> From: Arnd Bergmann <arnd@...db.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 ||
> >>              ~~~~~~~~~~~~~~~ ^ ~~~~~~~~~
> >>
> >> I'm not familiar with the details of this code, but from a quick look
> >> I found that it gets assigned from a 32-bit variable that can be
> >> PAGE_SIZE, and that the layout of 'xsk' is not part of an ABI or
> >> a hardware structure, so extending the members to 32 bits as well
> >> should address both the behavior on 64KB page kernels, and the
> >> warning I saw.
>
> This change is not enough to fix the behavior. mlx5e_xsk_is_pool_sane
> checks that chunk_size <= 65535. Your patch just silences the warning,
> but doesn't improve 64 KB page support.
>
> While mlx5e_xsk_is_pool_sane is simply a sanity check, it's not enough
> to remove it to support 64 KB pages. It will need careful review of
> assumptions in data path, because many places use 16-bit values for
> packet size and headroom, and it comes down to the hardware interface
> (see mpwrq_get_cqe_byte_cnt - the hardware passes the incoming packet
> size as a 16-bit value) and hardware limitations.
>
> For example, MLX5_MPWQE_LOG_STRIDE_SZ_MAX is defined to 13 (Tariq, is it
> a hardware limitation or just an arbitrary value?), which means the max
> stride size in striding RQ is 2^13 = 8192, which will make the driver
> fall back to legacy RQ (slower). We also need to check if legacy RQ
> works fine with such large buffers, but so far I didn't find any reason
> why not.
>
> I genuinely think allocating 64 KB per packet is waste of memory, and
> supporting it isn't very useful, as long as it's possible to use smaller
> frame sizes, and given that it would be slower because of lack of
> striding RQ support.

Fair enough. I wouldn't be concerned about wasting memory here,
as 64KB pages are much more wasteful in other areas already, but
if there are no possible upsides and making it work is hard, then
we don't need to bother.

> It could be implemented as a feature for net-next, though, but only
> after careful testing and expanding all relevant variables (the hardware
> also uses a few bits as flags, so the max frame size will be smaller
> than 2^32 anyway, but hopefully bigger than 2^16 if there are no other
> limitations).
>
> For net, I suggest to silence the warning in some other way (cast type
> before comparing?)

Ok, sending the trivial workaround as v2 now.

        Arnd

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ