Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3517746pxb; Mon, 24 Jan 2022 11:13:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJxVNAfIyp6FQzjdkq1FMPhqGn6Era21vdm16h6w75sZfzYicdP3tFdoDFVjQ8T+Rcne51Kw X-Received: by 2002:a17:90b:3b46:: with SMTP id ot6mr3323464pjb.104.1643051614103; Mon, 24 Jan 2022 11:13:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643051614; cv=none; d=google.com; s=arc-20160816; b=YGprG4KStI6OI6LE72O3zBhDVPEC8rtAMRi5aXsLYctrTlkswg+jNk9CdSrWHFxjzw i2W0tA3EBon6tF49LGdAudDi5CegLJ4+4w/h14evaZUzlzItcl9OmRa/fl7th1YWw2Vd WwjLmkydMjVG/HQDthuq21EO3lfAk/RTZoGni8pSU2rNmoNnTgDUQekOlFkLD2r4CXKB HN9sGFBtceATzkqdB8EOPqEgjuouggOLOKRSR6hrnlQof+8E7l2ETiR35ML3yFpJX8yB TGDfRrNBuoV6fF/osNNW7uqYD2QUxvjWJD5q042BONtAbnCVWAIJfIlmiY2rAxLtwMg4 HRrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=JxHVwsFWei3UEjXOVpxsHssZNzVtIIeCxsrgFEWs1ms=; b=AkErfHCM8X5dYyN+hNUzBNkHw15xKKIcd0ygu5XIyjeh9L35GsASZU+yQqYsQyjpDF /YbzeRDTDCChV+goBpWQWR+i2UG+s9ev9uPVWudKzqMKpExkG1v1oA+BNNGzQ4YjH0Go qgetFIvE3hf5EhCTZM/4GZ4udEY9RAQ4a22xE5jljWyoJIL6d++TFkw6uRE1ee9wDcGe U1vlYMY8c23ye8/mol1KXHkRihYo9Zdyh/DE0guKkMOpxVEADeSuyebSSu1/cUetQE21 oQyewmvFfXDQYfq0+qLuvHEMldzbaTiszFPxaQOCK3/OwNu3NM3Kd8gwn/EyDYTfwbou q/vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="c//zWTFA"; 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u17si5585418pfc.332.2022.01.24.11.13.22; Mon, 24 Jan 2022 11:13:34 -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=@intel.com header.s=Intel header.b="c//zWTFA"; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242224AbiAXMr5 (ORCPT + 99 others); Mon, 24 Jan 2022 07:47:57 -0500 Received: from mga01.intel.com ([192.55.52.88]:54060 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240117AbiAXMr4 (ORCPT ); Mon, 24 Jan 2022 07:47:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643028476; x=1674564476; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=t4XLhenzUQSF8a6/n12cTXUdVH0+2ekbL4ehTIMp2HE=; b=c//zWTFAsQ+ZuNj4tXVU8VGmWzEf+iNqgr2exQ0aJewjoQf9CoFLeaca Aqq8EQttYndqGVQ7SGD8a+WKZEb1nYUid1Rc6WsMfhZpsHMs+Z7/CpjXO Db/9hPyG3YbR1B6Yk8OnYZBBv99ds5U8ASlj1r1UDhRIX6xp44dQJ6HnB s6z9vOuep5lW23V9oJKQnlGDz8+v1ERMmSPFvIMvyt4rfM57sQLGgoSN6 ZGwm6Y3TZZcYRS2qQ0bI0ECEgB4Vpj0GwbVQMVJHdo4fNHqD8oGqXQP0r 1KywlvEk59Vkz+f/8ILCCG7vKbsbyYqUk7cqJfWdD5n4BDpQznUQTNVGq w==; X-IronPort-AV: E=McAfee;i="6200,9189,10236"; a="270471496" X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="270471496" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2022 04:47:56 -0800 X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="562645653" Received: from smile.fi.intel.com ([10.237.72.61]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2022 04:47:51 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.95) (envelope-from ) id 1nByk7-00DtHD-LL; Mon, 24 Jan 2022 14:46:43 +0200 Date: Mon, 24 Jan 2022 14:46:43 +0200 From: Andy Shevchenko To: Yury Norov Cc: 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, Jonathan Cameron , 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: References: <20220123183925.1052919-1-yury.norov@gmail.com> <20220123183925.1052919-30-yury.norov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220123183925.1052919-30-yury.norov@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? -- With Best Regards, Andy Shevchenko