Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1098506pxu; Wed, 2 Dec 2020 10:59:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJzyow50jXm7CvGOCp5NOWEc5VQiqSP8mEaFNiWfYffM09t4TD99WgYOQb/PUApe6L/tOjOP X-Received: by 2002:a05:6402:128d:: with SMTP id w13mr1401277edv.56.1606935593526; Wed, 02 Dec 2020 10:59:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606935593; cv=none; d=google.com; s=arc-20160816; b=Ik5qESwQScMeUi89idNhuqWZHP/EoySW1XCAAcuU6+G2ahYr5eBbClHIY5p0pstDbO IEDLA/25F4wTuyL/hT2SwuLkzTSrxpd7r5UBr/szGEGxLE+e72gNKpj3dwoV2J2p5DBT K8J1ngkE8CIOZlWq2dmZyOSDrpNQXE+XjDv/i7qUMDqcGnoEe2gLtFayJkE9/ouTBRLE p/RFZTZAWwbHrn6fVAgHtGAZ7BoBl1FD2QXGqAjWEeirNHZh/ZdjJ+71VYh+f2mafxdW qX1lKnwskh5SMQVo1tOoFogzxFFrZD/euAvpHJt3jdGsleE/tg4xbryXq2ISJyQVJMSP 3GOQ== 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=n7kGe24oW83Lxiiq8w9Nt64fIWPoMXKGstzSvjUhT7M=; b=dpd/msas9sv51K4J1q1YHTIJIeSqHw09fLDw1NksaCS4Je2xILq0oiwBGzmwwiaX/M iC9GjXyJphShtbCZKxMEPePKcxB1u+62bWayTzwJM9o+j1TliIpUz0neFJx53CWG0Aki Jy6zkfbdh3liA9ERJAMMPYPsT5veRDcDxQkUj4B4cejMDgViGEj8DXxGICs5osNJRicv n3tO0dPPxLGIIPdetV0C7jR6C3EOJXPPqReBBWHr3ao8tarkye0Z+EnnSZg5yejCkQqI aof+e4uO5UnHBGS1MNfhxKFJpuIzPISozSL04VPdzaQqHjW2tXh0+aJupb1sViXj6xRN FV3A== 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 v6si515216edj.204.2020.12.02.10.59.30; Wed, 02 Dec 2020 10:59:53 -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 S2389365AbgLBS5c (ORCPT + 99 others); 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