Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp410871pxb; Tue, 1 Feb 2022 02:37:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJz2aL4YaUnztg2xqRFXj/5zaK1ix8gsOGtjStS1hHMgkIiQFPY53v7oIfcPG0IG6fRJsOBq X-Received: by 2002:a17:902:a505:: with SMTP id s5mr25025008plq.157.1643711845296; Tue, 01 Feb 2022 02:37:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643711845; cv=none; d=google.com; s=arc-20160816; b=JrXx/Q5i1ajssHOXY4TxLN8Ok+mp5KH0f8PjrNulFyMvGghsKeb+Kza35TrIYJ325/ k9MxdB8UMjQKZ+9x/SH9cr6kkJXTN4jiz/AYlXBkTl0+jzS09HV84PNQQlOloALSGWnP upiF3tjhb87eBF3LEWi8gogd5YCdPrP0CkwUUt1swZOOrawDQ6A4znqrFqbMaKBFtKeI lz6fluY2WNh5prm0eJ65rJ2T2oCX9s76NbXnJg/oerW9n5PDORPumI7OIdM0+H+mwF/3 pWShImTm8a20kg//F8bEEaFTU0WIMYAu8z6i7kFNI+xryBYH7T8NHLNBMVJA2db289sJ D1/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=/MXRZTWiFBqu6PPfwYiYvb1z0MtOeHtMkgHHuFXKoKc=; b=nvedICmqniBj/+L0ZO6NFBcV+XQEUNS6pMI37TqyWZcKo/YO//c30iX1nC3vU87MXo tV2zwQ4+QCMrXwzrZqSIqBC3sB3bSueFaO7TsUakbZH/yiY7nh323s0KKycBYlOu74nu QJVoZPuzKJg7Zo9lSgnyLlXyBvUJc7DawitDgGBYu54GFWy5nfsquMEiTSb+E62+HwUY 5HbXuj5h3ljI3qkfjEnlXaPfjBcirm/uQ/DAAbBS9Li002wL0cdDHEIx+gZ4ipUzCqpR ITJGTNNSCL39P6DGGA55eeU5A63sW4a2QpgK7cpu9nbQmku5xKKkKD2aZ/6xEdNt9Nwb JC5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Nq98CGrI; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s15si16761909pgs.627.2022.02.01.02.37.13; Tue, 01 Feb 2022 02:37:25 -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=@kernel.org header.s=k20201202 header.b=Nq98CGrI; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354789AbiA3Mr7 (ORCPT + 99 others); Sun, 30 Jan 2022 07:47:59 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:60180 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354798AbiA3Mrt (ORCPT ); Sun, 30 Jan 2022 07:47:49 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 196FAB82923; Sun, 30 Jan 2022 12:47:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE6ABC340E4; Sun, 30 Jan 2022 12:47:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1643546866; bh=aVDc8Yu/ogmHGWUx29IlMTDDegp/e73DqnCrg8ODuZM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Nq98CGrIZ9nAbhUKlKnlO1se4qC21zkur0zkN9RF0QmQi7sRv3hgrCPDO3KeXkk/N LwBhir3pOpKJ/eYM+PMrYYsBVEgUJ715DysFda3xnH4J8wHJLxPsSvcRDVvUp+Nuek VdiLYIxlTlaLWEgDRGPFTxoCkk8BsMe4ql2/Ok1jVsBoIwotEswkzlZAkYtMKOiTFU Nk+Twtf1OSlTXocd5i6I+l6Wm6/wIxVDa/yDzA5C1yegc297stc0eESw2yjI/vpWuz mruHdwN6FwQX77xQckDBK4qNhwh91pAeUCwpzQHpovNMO4iHJ4R+CiMtLpoK2esNSu /GpbCT5mXKvWw== Date: Sun, 30 Jan 2022 12:54:08 +0000 From: Jonathan Cameron To: Andy Shevchenko Cc: Yury Norov , 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, Lars-Peter Clausen , Nathan Chancellor , Alexandru Ardelean , linux-iio@vger.kernel.org Subject: Re: [PATCH 29/54] drivers/iio: replace bitmap_weight() with bitmap_weight_{eq,gt} where appropriate Message-ID: <20220130125408.0cca0b66@jic23-huawei> In-Reply-To: References: <20220123183925.1052919-1-yury.norov@gmail.com> <20220123183925.1052919-30-yury.norov@gmail.com> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 24 Jan 2022 14:46:43 +0200 Andy Shevchenko wrote: > On Sun, Jan 23, 2022 at 10:39:00AM -0800, Yury Norov wrote: > > drivers/iio calls bitmap_weight() to compare the weight of bitmap with > > a given number. We can do it more efficiently with bitmap_weight_{eq, gt} > > because conditional bitmap_weight may stop traversing the bitmap earlier, > > as soon as condition is met. > > ... > > > int i, j; > > > > for (i = 0, j = 0; > > - i < bitmap_weight(indio_dev->active_scan_mask, > > - indio_dev->masklength); > > + bitmap_weight_gt(indio_dev->active_scan_mask, > > + indio_dev->masklength, i); > > i++, j++) { > > j = find_next_bit(indio_dev->active_scan_mask, > > indio_dev->masklength, j); > > This smells like room for improvement. Have you checked this deeply? > I have no idea what I was smoking that day. It was near 10 years ago, so I'll blame my younger self ;) Jonathan