Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp898095pxb; Tue, 1 Feb 2022 12:43:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJySl4L2Rct9dChlxFTMNPSwiDCU7LSJ2eI0z681OSPBzf+vym/k0pWX2wR5owBxo7LK1juq X-Received: by 2002:a63:1d07:: with SMTP id d7mr21962404pgd.414.1643748193657; Tue, 01 Feb 2022 12:43:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643748193; cv=none; d=google.com; s=arc-20160816; b=v5ydlWNmxYtcdqXhb7kaeU0Ds+XHar39QSTuS3WdjEUaY8Ds0uKUFk9rHC0DPdtI+r Yi7st1rhZ97QlAaXZ65gBTvqSsw/6VOQe5S+Gkb/Ujycp+qRS+7TBEmbpX4B/PPtsTyz H422Kv/w/CttZrEm08PCsglmbAOYblZegkUD4k0PwVZ4py7Fb3U95Wz8Ej/el6X/KUWD g+ISztii6I5g30xwzsGXTWSfM8VR++UPoVK7ldCqYX2cZNVfd6FsQuPFvR0fIHl+d/QQ KNkpDaPxfSGHxlPcZGsfNg0E2OzX7fIlJ1HI1Ox1tWEZGCE1ApNTcDlKSTtBx8y1Tzy6 vQxQ== 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=qc5uFheXk0XaZTfYuE1nZxBYJ9/v+WsFBLbPDZbz7PY=; b=F61LsqLZU0sIIwFTHZT6qoYPRuJFtINwFMnQ/NVKcLb/6vMTE+UwtviliXc+ehOSGx JSENOcjHxf1ZyY5dKCqnC1TW7c4YkcW9gRl9azVE+csiYn3kYegk335nv4KDHyLgJR8x n5V77H6ULxfT1XWEVTF9tdtsirok/UX44dezbhJK7jfIQy5yaRh2CKNE5IcuPJc1T6rp VjMY80SEcYtVQP6PPFRDdGu8nLa3VNlXPiT+Lf8LRgUrBz0QMKR3nFF6G6K5aKpegfTN xFxyQrCbQ39e47N+FeGQ6S00JAc5xivqcJbFvEgO1/+JHOpSPbv9CXeYoUVnBRvZS2Jv FhgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="U/vrkJJU"; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y11si19237150plg.343.2022.02.01.12.43.01; Tue, 01 Feb 2022 12:43:13 -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=@linaro.org header.s=google header.b="U/vrkJJU"; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349609AbiAaQHy (ORCPT + 99 others); Mon, 31 Jan 2022 11:07:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380039AbiAaQHv (ORCPT ); Mon, 31 Jan 2022 11:07:51 -0500 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3CDBC061741 for ; Mon, 31 Jan 2022 08:07:48 -0800 (PST) Received: by mail-lf1-x134.google.com with SMTP id n8so27844796lfq.4 for ; Mon, 31 Jan 2022 08:07:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qc5uFheXk0XaZTfYuE1nZxBYJ9/v+WsFBLbPDZbz7PY=; b=U/vrkJJUjzjB48elBk2hfP4kNGT8ELSVcRs0TQlT2Jo+OJ8OFgrw0UblWt2i8Ma9zV Kkf3ftSRxkBUe1/9hQUhl3BuvhKY+NU7000oD1Ec0EEOV3sniK1FX+8q/Lu21M/CgJOL NTM+uOyd/aKmEvHoTYfy6kCrYlZciBRl6HZVPsEX9jodm4OWL5eHwH8++W8L64sOAqOf 9j/6u7ytlc8Gi5RBsp758nPJc/AeM8v1RfPnwQ78KljKz+BouG9lNddOhwchnxBbgq16 QSILW/VPSHzkhk5VWvS4Xtrk9SG0G0fcos926IQ7d1196tE4czaOlUvXSqoxzitXvnv4 tnow== 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=qc5uFheXk0XaZTfYuE1nZxBYJ9/v+WsFBLbPDZbz7PY=; b=RLRnlhnfIoK4JRzIcaMooi/FJDxmhz0fUdi85r3M2bdBO1PNHoLc62hXTVgJzs4AnW yUkN8d6zBLkNFxK91v41pwfYiSOifyfI73TJUQsGMDqvYN60U2IDRHo8Ro6c+RQkrGp+ rCJgF3GXFUSaLedAZs50y/282M4Tt8gMdjownl/qOzeT/6Wgtm6vGqa8Y86l1J3LtU91 jxk4BpCEt9I/M884Qc42S7pVh3vOOFOP0KRH4v8S0JLkIhv6ec7OyFM9daD6e2mujxNP Pu+u6gvsc03VspCGB81MvnCfxVNwcswjy8F6UbIvqtdd2lmX9y0V7hHqlbKVl7qSxVic 30xw== X-Gm-Message-State: AOAM533HTLKZ09hA48/WZ1jDbPcQqBk/GjcF8gEOh5rrd8Akvnau73fA qomMbHVxmWaK2TwHsrAHDBLMsgJMBguTaMgSmNtZNg== X-Received: by 2002:ac2:4c08:: with SMTP id t8mr15582685lfq.358.1643645267227; Mon, 31 Jan 2022 08:07:47 -0800 (PST) MIME-Version: 1.0 References: <20220123183925.1052919-1-yury.norov@gmail.com> <20220123183925.1052919-31-yury.norov@gmail.com> In-Reply-To: <20220123183925.1052919-31-yury.norov@gmail.com> From: Ulf Hansson Date: Mon, 31 Jan 2022 17:07:10 +0100 Message-ID: Subject: Re: [PATCH 30/54] drivers/memstick: replace bitmap_weight with bitmap_weight_eq where appropriate To: Yury Norov Cc: Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Maxim Levitsky , Alex Dubov , Jens Axboe , Luis Chamberlain , Colin Ian King , Arnd Bergmann , Shubhankar Kuranagatti , linux-mmc@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 23 Jan 2022 at 19:41, Yury Norov wrote: > > msb_validate_used_block_bitmap() calls bitmap_weight() to compare the > weight of bitmap with a given number. We can do it more efficiently with > bitmap_weight_eq because conditional bitmap_weight may stop traversing the > bitmap earlier, as soon as condition is met. > > Signed-off-by: Yury Norov Acked-by: Ulf Hansson Kind regards Uffe > --- > drivers/memstick/core/ms_block.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/memstick/core/ms_block.c b/drivers/memstick/core/ms_block.c > index 0cda6c6baefc..5cdd987e78f7 100644 > --- a/drivers/memstick/core/ms_block.c > +++ b/drivers/memstick/core/ms_block.c > @@ -155,8 +155,8 @@ static int msb_validate_used_block_bitmap(struct msb_data *msb) > for (i = 0; i < msb->zone_count; i++) > total_free_blocks += msb->free_block_count[i]; > > - if (msb->block_count - bitmap_weight(msb->used_blocks_bitmap, > - msb->block_count) == total_free_blocks) > + if (bitmap_weight_eq(msb->used_blocks_bitmap, msb->block_count, > + msb->block_count - total_free_blocks)) > return 0; > > pr_err("BUG: free block counts don't match the bitmap"); > -- > 2.30.2 >