Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5103202pxb; Wed, 26 Jan 2022 05:01:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJys+J9w1rf9SxzNmi1HBbpEjznE3ALHSzEJzKAbQ4wt9SYKPgjQ9ALdubaTk1BeLkbWsZQC X-Received: by 2002:a17:907:96ac:: with SMTP id hd44mr15667697ejc.68.1643202090892; Wed, 26 Jan 2022 05:01:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643202090; cv=none; d=google.com; s=arc-20160816; b=BUvuStf7ihL/gL9Kq6RG2ZTTnlvGnHqnZ+KevYF/ZlUVVjis0v9wB0dJZkocMhu06f FtPyon4SZklRaSJdBh3umc476MjLpcFBPiQQD1b4N0+vQWIM4WyQpGTgqGT8MCiz4tes TxRf7f5paKAGf1GFnfbl7J6GYK5qa5OftzmcL3L8WrTu329a8uayKsR3wnQK6FDwe7xG cafZISoWs5nY3a0FWc4SfgyWqkFS6SZBZI99es9KHafzd4e2JtSR65cvV0eMNjYTPwZA X4kzSs3fO3HdPEvH+gn7G5Kr56xW1Tlj0oPmtPG64VjIjL9cD2PSbXodYUU1PZrBhiev hPOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=o8ok+yx3CpNyWAo+hZwQcGMusI+MSV0R31Eo88H3Tvs=; b=XpWTEU9WaWQTc0US44EIe0y0fPvrY1omzj22lp0uRkFUvY8MYWQjeiFiJN/fKioPZi uF9BcSJKvhEc84/QodDn6AtXBmItUdN/CntSBNEPXdWKquK1OLEp5FHRbolk0eNqR079 DygYrEa3VfElxQI1DwPEGlxGZrYsx5F0Qs4pvo7+4avlJ1jEKJjQSvkrprgeVeYb76Ag GrVHwng7TDZVv376bTH7CDHTVlwBuPUi43ekWEX6WhJG+130NSwqIAkDO4YvITlAGAQ2 d3uPrZ+p7QzgG60yb1SiEFHJujzUpR1B3mzWG1+cVzm3Oe8E1MSsqnNqkxHTIqe38197 OS4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=DWuVhOqm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oz16si2341316ejc.791.2022.01.26.05.01.04; Wed, 26 Jan 2022 05:01:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=DWuVhOqm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234287AbiAYXKR (ORCPT + 99 others); Tue, 25 Jan 2022 18:10:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234246AbiAYXKN (ORCPT ); Tue, 25 Jan 2022 18:10:13 -0500 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3CA1C06161C; Tue, 25 Jan 2022 15:10:12 -0800 (PST) Received: by mail-pg1-x52d.google.com with SMTP id g2so19562801pgo.9; Tue, 25 Jan 2022 15:10:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=o8ok+yx3CpNyWAo+hZwQcGMusI+MSV0R31Eo88H3Tvs=; b=DWuVhOqmYpDgPLQ0wkQ3FpovddbNqP/WIHh2XJo5TBIS8qyWUaCfNF8Bue6lseS+d/ SCVTQGpoW+5Yl8O9oMl/JQXSE1NmlkoaxYemxt7FSMNVlzF+aZ4ZChVjAIWeaTFjOyzk kfLdHf26tKjfw5zbOoSqL6imDmUbhy6ysvDE/J8MuNA4Z5MydfyEIaRg+iUBnVVVUwqu /I3l2YfSrRG5iZGKyltz8yeNZYXmCJfS/FKFKJ0zcuO07zcbBO8UZ/QVZJlWNAoMemDK QypAoyidvOpWKHEBc4Ssje2dhGPGoeQy4hU5ZJjI6LK3jIE4XjK3LJhlKj0GpgdzUoww qHCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=o8ok+yx3CpNyWAo+hZwQcGMusI+MSV0R31Eo88H3Tvs=; b=aPmEYOo0WgD+tdogRztEdNpHICSxKWTPgFyh/Iw1ydXTi6XVY8YrYELcqVnMwfHZH4 c662hznSJGndXKcew/NenmBmnxtHRBNl0JSTA/3NCe/WvPqyMeBHQQJV0+7JjK3qLGhe K5afDoFM67qEmhoaPWbax9676PBHqKJN7OibIF6Sy3/oxY2AG6xZaF8NtrAxUEl2kpne uvVmj6BemfHNDgoHIeWmqiWcn54+VdiTfWODWYPpIhUnKRd0nDmoo0zD+YB2jwH5PB9G JNSlzf8HrCb0g57EsuIb6x8Uqb4nDOGBq9/gdmyo7cXF94iXNrh0SoeJFamsoh1xAHTj 8f+Q== X-Gm-Message-State: AOAM531+GBQpWgN/KPAo0oNl9fdh4WFSw1OQi8Yrimycx815V2D0pkvP AC0Ixjxzz1QxdaYAanwVCjeGiJ9E6whZ5z3P9QU= X-Received: by 2002:a63:91c4:: with SMTP id l187mr16702237pge.513.1643152212326; Tue, 25 Jan 2022 15:10:12 -0800 (PST) MIME-Version: 1.0 References: <20220123183925.1052919-1-yury.norov@gmail.com> <20220123183925.1052919-11-yury.norov@gmail.com> <58c222c15b2d43689f43d31afb5cb914@AcuMS.aculab.com> In-Reply-To: <58c222c15b2d43689f43d31afb5cb914@AcuMS.aculab.com> From: Yury Norov Date: Tue, 25 Jan 2022 15:10:00 -0800 Message-ID: Subject: Re: [PATCH 10/54] net: ethernet: replace bitmap_weight with bitmap_empty for qlogic To: David Laight Cc: Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= , Greg Kroah-Hartman , Peter Zijlstra , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , "linux-kernel@vger.kernel.org" , Ariel Elior , Manish Chopra , "David S. Miller" , Jakub Kicinski , "netdev@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 25, 2022 at 2:15 PM David Laight wrote: > > From: Yury Norov > > Sent: 25 January 2022 21:10 > > On Mon, Jan 24, 2022 at 4:29 AM Andy Shevchenko > > 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? > > It'll be wrong on BE systems. The bitmap_weigh() result will be correct. As you can see, the address is 64-bit aligned anyways. The array boundary violation will never happen as well. DP_NOTICE() may be wrong, or may not. It depends on how important the absolute position of the bit in the printed bitmap is. Nevertheless, printk("%pb") is better and should be used. This whole concern may be simply irrelevant if QED is not supported on 32-bit BE machines. From what I can see, at least Infiniband requires 64BIT. Thanks, Yury > You just can't cast the argument it has to be long[]. > > David > > - > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK > Registration No: 1397386 (Wales)