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]
Date:   Tue, 25 Jan 2022 13:09:58 -0800
From:   Yury Norov <yury.norov@...il.com>
To:     Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc:     Rasmus Villemoes <linux@...musvillemoes.dk>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Michał Mirosław <mirq-linux@...e.qmqm.pl>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Peter Zijlstra <peterz@...radead.org>,
        David Laight <David.Laight@...lab.com>,
        Joe Perches <joe@...ches.com>, Dennis Zhou <dennis@...nel.org>,
        Emil Renner Berthing <kernel@...il.dk>,
        Nicholas Piggin <npiggin@...il.com>,
        Matti Vaittinen <matti.vaittinen@...rohmeurope.com>,
        Alexey Klimov <aklimov@...hat.com>,
        linux-kernel@...r.kernel.org, Ariel Elior <aelior@...vell.com>,
        Manish Chopra <manishc@...vell.com>,
        "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>, netdev@...r.kernel.org
Subject: Re: [PATCH 10/54] net: ethernet: replace bitmap_weight with
 bitmap_empty for qlogic

On Mon, Jan 24, 2022 at 4:29 AM Andy Shevchenko
<andriy.shevchenko@...ux.intel.com> wrote:
>
> On Sun, Jan 23, 2022 at 10:38:41AM -0800, Yury Norov wrote:
> > qlogic/qed code calls bitmap_weight() to check if any bit of a given
> > bitmap is set. It's better to use bitmap_empty() in that case because
> > bitmap_empty() stops traversing the bitmap as soon as it finds first
> > set bit, while bitmap_weight() counts all bits unconditionally.
>
> > -             if (bitmap_weight((unsigned long *)&pmap[item], 64 * 8))
> > +             if (!bitmap_empty((unsigned long *)&pmap[item], 64 * 8))
>
> > -         (bitmap_weight((unsigned long *)&pmap[item],
> > +         (!bitmap_empty((unsigned long *)&pmap[item],
>
> Side note, these castings reminds me previous discussion and I'm wondering
> if you have this kind of potentially problematic places in your TODO as
> subject to fix.

In the discussion you mentioned above, the u32* was cast to u64*,
which is wrong. The code
here is safe because in the worst case, it casts u64* to u32*. This
would be OK wrt
 -Werror=array-bounds.

The function itself looks like doing this unsigned long <-> u64
conversions just for printing
purpose. I'm not a qlogic expert, so let's wait what people say?

The printing part may be refactored although to use %pb" format,
similarly to the snippet below
(not tested).

Thanks,
Yury

diff --git a/drivers/net/ethernet/qlogic/qed/qed_rdma.c
b/drivers/net/ethernet/qlogic/qed/qed_rdma.c
index 23b668de4640..72505517ced1 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_rdma.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_rdma.c
@@ -336,17 +336,8 @@ void qed_rdma_bmap_free(struct qed_hwfn *p_hwfn,

        /* print aligned non-zero lines, if any */
        for (item = 0, line = 0; line < last_line; line++, item += 8)
-               if (bitmap_weight((unsigned long *)&pmap[item], 64 * 8))
-                       DP_NOTICE(p_hwfn,
-                                 "line 0x%04x: 0x%016llx 0x%016llx
0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%016llx\n",
-                                 line,
-                                 pmap[item],
-                                 pmap[item + 1],
-                                 pmap[item + 2],
-                                 pmap[item + 3],
-                                 pmap[item + 4],
-                                 pmap[item + 5],
-                                 pmap[item + 6], pmap[item + 7]);
+               if (bitmap_weight(bmap->bitmap, 64 * 8))
+                       DP_NOTICE(p_hwfn, "line 0x%04x: %512pb\n",
line, bmap->bitmap);

        /* print last unaligned non-zero line, if any */
        if ((bmap->max_count % (64 * 8)) &&

Powered by blists - more mailing lists