Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1095784pxu; Wed, 2 Dec 2020 10:54:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJzl3c2MDDCRhCuTnj18NhNxshvXfZ5381PHwrWJt7C4M/qbaJn3JSkI8pNWj8i+uR6BUZix X-Received: by 2002:a50:9ea3:: with SMTP id a32mr1427591edf.40.1606935289681; Wed, 02 Dec 2020 10:54:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606935289; cv=none; d=google.com; s=arc-20160816; b=i2CPRFazqob1izHV9UYL6UMu02UOBNMkr+EpPV275gh15eeTiZuKKpHliaxkArKX+4 va0R8Kk1+dJ9swd+uQNOSWcdMgA8f/HKJAEt4EygXQsaDuKnhagEG7JHjaVPqA5k5J8a B4k08DdO8dt/Jb1qxomQO4Xz8X54D+NKwLksjfP/qozMSSPhmGDSDtC3CgtDN4EnAc1K OF5AulEDSEcw5ZWiQcuLoHYreP6Z4Ijs26U4s5E5GuvBG0FHSajk4j9KduM07cMIFLpA h7ku0lqOJuByFEIilVcAmsYcxP9GAj1ooT1ktYpISZUyLpx7Sa8sfa7c+AoySUq88Srz Z/5A== 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 :ironport-sdr:ironport-sdr; bh=Vb9Jl2hvnCN22/PuJlIly8Iipb/TxWCnt2Kn3o6sNJ8=; b=DIAxViyZUw7Pat6S8/EbsF0E5DXs5JngeuWdcV04epSlgu2ICB/Ix4aZ2VN/Eo0vIE f0M4mRV4CLbNNrpC54u8gSY+fvPB/8e+2fm4ZBf+UaWMf6ry1uzcKiysDIvja3kRlAPT rTz4hQBxW63W2UtHOHS0n8v3ZXlKR01L0tazgCoNMU68YVmrJZ88v3WUt0j4fvC9fvnY hY8b14rQFMIDhGSYJg3dWtKxqFTfmHn3mfYRuR2sInBmmQXIyYbgvylxqDYij6QoszH6 7nktwRHiOMDmGvrEFIUPlyX4cNXQWJIdtGQZ+J+opAigfZaCkIBOIEkyCsuvjM0Kcpzl QVeQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (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 j26si467714eds.457.2020.12.02.10.54.26; Wed, 02 Dec 2020 10:54:49 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389570AbgLBSwL (ORCPT + 99 others); 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