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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24259C2FC18 for ; Thu, 17 Aug 2023 09:37:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349737AbjHQJhP (ORCPT ); Thu, 17 Aug 2023 05:37:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242661AbjHQJhK (ORCPT ); Thu, 17 Aug 2023 05:37:10 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 913DC10E9 for ; Thu, 17 Aug 2023 02:37:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692265028; x=1723801028; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=t3/SPQdJPP8CQBTiozltnkQKxqUKbLueTkLOM6UaZYs=; b=Mine5dRf5Qwzg8SDUka5KsQrlhUYMn9yXu9S/Xh6shuah5xp6Iw7N+nG /sXRBaC1jsm74ITGVhs4vxwIGGYHLlsrDLrIkXgUNBbsME708TBVx89dO e+RhLvBhcmQbHns2s6HZvr7GNaCX7t6EioSgN1phR9Z7nopj3IJ5cE6GF AD/Ov5j+STNCzkbu4QMJIOrwXYoV4DmMU2yUltaA3Du66qWRpda1ycS8Y U4Mjz9Ul8ZjSaAhF05VCDGfnpAmc7aAYv6LH/HRJHYatHohj6H8+Qy6EN uHGn2PY+IzjmJmZbrn149z/k8xPNp7JAKc+hKnxhbFlS4WiwH7pSlmKTD g==; X-IronPort-AV: E=McAfee;i="6600,9927,10803"; a="362912186" X-IronPort-AV: E=Sophos;i="6.01,179,1684825200"; d="scan'208";a="362912186" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2023 02:37:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10803"; a="1065176433" X-IronPort-AV: E=Sophos;i="6.01,179,1684825200"; d="scan'208";a="1065176433" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga005.fm.intel.com with ESMTP; 17 Aug 2023 02:37:06 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1qWZRB-005TSz-0d; Thu, 17 Aug 2023 12:37:05 +0300 Date: Thu, 17 Aug 2023 12:37:04 +0300 From: Andy Shevchenko To: Yury Norov Cc: linux-kernel@vger.kernel.org, Rasmus Villemoes Subject: Re: [PATCH] bitmap: optimize bitmap_remap() Message-ID: References: <20230815235934.47782-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230815235934.47782-1-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 Tue, Aug 15, 2023 at 04:59:34PM -0700, Yury Norov wrote: > When 'new' map is empty, i.e. identity mapping, we can simply copy > src to dst, which is significantly faster than setting bits one by > one in a for-loop. > While here, replace set_bit() with non-atomic __set_bit(). I believe this requires a separate change with additional words why it's okay to drop atomicity. ... > for_each_set_bit(oldbit, src, nbits) { > int n = bitmap_pos_to_ord(old, oldbit, nbits); > > + bit = (n < 0) ? oldbit : /* identity map */ Can't you also optimize this case? Something like bitmap_xor(tmp, old, new) // maybe even better approach, dunno bitmap_empty(tmp) // can be replaced by find first bit ? > + find_nth_bit(new, nbits, n % w); > + __set_bit(bit, dst); > } -- With Best Regards, Andy Shevchenko