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 F037CC64E7C for ; Wed, 2 Dec 2020 18:52:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 958252173E for ; Wed, 2 Dec 2020 18:52:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389585AbgLBSwL (ORCPT ); Wed, 2 Dec 2020 13:52:11 -0500 Received: from mga04.intel.com ([192.55.52.120]:56541 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729000AbgLBSwK (ORCPT ); Wed, 2 Dec 2020 13:52:10 -0500 IronPort-SDR: aiHqgaIgp9BtKoyXKlFVwYb0v5HRmAslhcvHXqkC/XVy+Y8LwR1HL+IAMMktBZCu6by/t9qWKo L6Dq5BF6zUUg== X-IronPort-AV: E=McAfee;i="6000,8403,9823"; a="170502004" X-IronPort-AV: E=Sophos;i="5.78,387,1599548400"; d="scan'208";a="170502004" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2020 10:50:30 -0800 IronPort-SDR: f5ZeDIycbNzT7S5s+5pjjkfqOQELvXr/smb2b9H4sD2vZZ15lwZmwASAPT9mTVVJTVePb59Oli uoHsXSrAdc5Q== X-IronPort-AV: E=Sophos;i="5.78,387,1599548400"; d="scan'208";a="335664784" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2020 10:50:26 -0800 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1kkXDr-00Ba4b-LT; Wed, 02 Dec 2020 20:51:27 +0200 Date: Wed, 2 Dec 2020 20:51:27 +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: <20201202185127.GO4077@smile.fi.intel.com> References: <20201202094717.GX4077@smile.fi.intel.com> <20201202173701.GM4077@smile.fi.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. -- With Best Regards, Andy Shevchenko