From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1D19C64E7C for ; Wed, 2 Dec 2020 18:57:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 976BF2173E for ; Wed, 2 Dec 2020 18:57:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389572AbgLBS5c (ORCPT ); Wed, 2 Dec 2020 13:57:32 -0500 Received: from mga18.intel.com ([134.134.136.126]:41673 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387784AbgLBS5c (ORCPT ); Wed, 2 Dec 2020 13:57:32 -0500 IronPort-SDR: VgJFp9Z0cGFMgr3cYOymhhPSp1gVz2C9mODCwDvT91XJvJ22RpUP6lGVab/5NpIk85qeoY7GOM G2T0iSwYaaxg== X-IronPort-AV: E=McAfee;i="6000,8403,9823"; a="160838543" X-IronPort-AV: E=Sophos;i="5.78,387,1599548400"; d="scan'208";a="160838543" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2020 10:55:33 -0800 IronPort-SDR: 9pF10d0HmH3irEVZYigo5mCPyQXJtKfIC8I0GY0wWLkdTy7Qr+1ynmH+qfBtC9yiXwiEEUJq+3 T1kdNiddENHw== X-IronPort-AV: E=Sophos;i="5.78,387,1599548400"; d="scan'208";a="330562629" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2020 10:55:30 -0800 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1kkXIl-00Ba88-PW; Wed, 02 Dec 2020 20:56:31 +0200 Date: Wed, 2 Dec 2020 20:56:31 +0200 From: Andy Shevchenko To: Yun Levi Cc: Yury Norov , Rasmus Villemoes , dushistov@mail.ru, Arnd Bergmann , Andrew Morton , "Gustavo A. R. Silva" , William Breathitt Gray , richard.weiyang@linux.alibaba.com, joseph.qi@linux.alibaba.com, skalluru@marvell.com, Josh Poimboeuf , Linux Kernel Mailing List , linux-arch@vger.kernel.org Subject: Re: your mail Message-ID: <20201202185631.GQ4077@smile.fi.intel.com> References: <20201202094717.GX4077@smile.fi.intel.com> <20201202173701.GM4077@smile.fi.intel.com> <20201202185127.GO4077@smile.fi.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201202185127.GO4077@smile.fi.intel.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 Wed, Dec 02, 2020 at 08:51:27PM +0200, Andy Shevchenko wrote: > On Thu, Dec 03, 2020 at 03:27:33AM +0900, Yun Levi wrote: > > On Thu, Dec 3, 2020 at 2:36 AM Andy Shevchenko > > wrote: > > > On Wed, Dec 02, 2020 at 09:26:05AM -0800, Yury Norov wrote: ... > > > Side note: speaking of performance, any plans to fix for_each_*_bit*() for > > > cases when the nbits is known to be <= BITS_PER_LONG? > > > > > > Now it makes an awful code generation (something like few hundred bytes of > > > code). > > > Frankly Speaking, I don't have an idea in now..... > > Could you share your idea or wisdom? > > Something like (I may be mistaken by names, etc, I'm not a compiler expert, > and this is in pseudo language, I don't remember all API names by hart, > just to express the idea) as a rough first step > > __builtin_constant(nbits, find_next_set_bit_long, find_next_set_bit) > > find_next_set_bit_long() > { > unsigned long v = BIT_LAST_WORD(i); > return ffs_long(v); > } > > Same for find_first_set_bit() -> map it to ffs_long(). > > And I believe it can be optimized more. Btw it will also require to reconsider test cases where such constant small nbits values are passed (forcing compiler to avoid optimization somehow, one way is to try random nbits for some test cases). -- With Best Regards, Andy Shevchenko