Received: by 2002:ab2:2997:0:b0:1ec:cbc4:63fb with SMTP id n23csp508790lqb; Thu, 29 Feb 2024 07:17:48 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWyv559NTX8HwuqjQPQWx9222Mrj+nGvfONmAjTSF3QejpXLf7Zhq+pQPe1wPSGrHJ8QCZDC0fYlOjRicM8DxX8nWTgyE3TqRpGa9IVZw== X-Google-Smtp-Source: AGHT+IGg9+E3rBj5Rg3WQAG0Q4z+xd9L9cxvY7fMTTM+mjg24uQD6SQWErCuF4uOwwG9Po0ALsG1 X-Received: by 2002:a05:620a:12ce:b0:787:c62f:3fbf with SMTP id e14-20020a05620a12ce00b00787c62f3fbfmr2789208qkl.31.1709219868098; Thu, 29 Feb 2024 07:17:48 -0800 (PST) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id m20-20020ae9e014000000b007876443a843si1525610qkk.214.2024.02.29.07.17.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 07:17:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86911-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=KIgh2tni; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-86911-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86911-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 725BD1C21081 for ; Thu, 29 Feb 2024 15:17:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A643213B7A0; Thu, 29 Feb 2024 15:17:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=intel.com header.i=@intel.com header.b="KIgh2tni" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A81813777D; Thu, 29 Feb 2024 15:17:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709219859; cv=none; b=GXV0hJsjV9E3WksOmSORctJPJrburmMeBPRXL7jgrNt/Da/mzjjWitA098dWhocM65ESAhFNM0q2EynbADBWKYJXGUI3XL6OJIGu4Nluhn+7G5I2o8b4UMkCSd/oM4cMgoirg2CPgYp9LTb8TODKPtxI/L4QAfP8jTqDVcR5tCU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709219859; c=relaxed/simple; bh=oLRc3WhRkuCv1lTZmfKgUONC6J83KWsGVD8/2oxXDPE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=VKcdpHg69pLoZENCjyLQIzGk4E9aV3CyUmS5wCn5oCQ9lI9cm+UolHAtc8CIBz7akJnNZiaYhQH62lEmwIE96N7A/fylsaJxEpJuPgabEcq9HmPNiBqwnVyAtHIPM13UEBxNgN5dLp4uWzyQEZYETTqBI4SmI3qlvGDA8ZCyI+o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=KIgh2tni; arc=none smtp.client-ip=198.175.65.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709219858; x=1740755858; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=oLRc3WhRkuCv1lTZmfKgUONC6J83KWsGVD8/2oxXDPE=; b=KIgh2tnikL8vv6bV06S5h4wM1r7zSkRgnLA3r2RTkmyokC3Op37pXCqn yyJktZgdHpHAp2eeWs7Vjp5v18K2PrCEtxGeUkCYTU2Q2aGGXqaDkZr9J EQ/pl8GsZMRNCoGd1BFvFhfJIA2raAl5jEzsYoD487152JuV0OnswE0j4 XErqCidp0NpWVDw1QeDfyhKWoXOz3Quu67BfS9OBuawVYF1kjMnAAiBVJ i4hpfST33lYeuJ+1/1ybcWad+uhAv8uY85EjU3V7+xd3K7fQ/wkizCPqH tdxUKXqaFAfhtlmimKWWWSU3HmqiNFTTl12ZXGPePOr8oJAFEHvk0DbLI g==; X-IronPort-AV: E=McAfee;i="6600,9927,10999"; a="3574306" X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="3574306" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Feb 2024 07:17:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10999"; a="913984318" X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="913984318" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga002.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Feb 2024 07:17:33 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.97) (envelope-from ) id 1rfiA5-00000008he7-36Q0; Thu, 29 Feb 2024 17:17:29 +0200 Date: Thu, 29 Feb 2024 17:17:29 +0200 From: Andy Shevchenko To: Herve Codina Cc: Vadim Fedorenko , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Yury Norov , Rasmus Villemoes , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Andrew Lunn , Mark Brown , Christophe Leroy , Thomas Petazzoni Subject: Re: [PATCH v5 3/5] lib/bitmap: Introduce bitmap_scatter() and bitmap_gather() helpers Message-ID: References: <20240229141554.836867-1-herve.codina@bootlin.com> <20240229141554.836867-4-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240229141554.836867-4-herve.codina@bootlin.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo On Thu, Feb 29, 2024 at 03:15:51PM +0100, Herve Codina wrote: > From: Andy Shevchenko > > These helpers scatters or gathers a bitmap with the help of the mask > position bits parameter. > > bitmap_scatter() does the following: > src: 0000000001011010 > |||||| > +------+||||| > | +----+|||| > | |+----+||| > | || +-+|| > | || | || > mask: ...v..vv...v..vv > ...0..11...0..10 > dst: 0000001100000010 > > and bitmap_gather() performs this one: > mask: ...v..vv...v..vv > src: 0000001100000010 > ^ ^^ ^ 0 > | || | 10 > | || > 010 > | |+--> 1010 > | +--> 11010 > +----> 011010 > dst: 0000000000011010 > > bitmap_gather() can the seen as the reverse bitmap_scatter() operation. > The original work was done by Andy Shevchenko. As I said, it's too much credit :-) .. > + * A relationship exists between bitmap_gather() and bitmap_scatter(). See > + * bitmap_scatter() for the bitmap scatter detailed operations. > + * Suppose scattered computed using bitmap_scatter(scattered, src, mask, n). > + * The operation bitmap_gather(result, scattered, mask, n) leads to a result > + * equal or equivalent to src. > + * > + * The result can be 'equivalent' because bitmap_scatter() and bitmap_gather() > + * are not bijective. > + * The result and src values are equivalent in that sense that a call to > + * bitmap_scatter(res, src, mask, n) and a call to bitmap_scatter(res, result, > + * mask, n) will lead to the same res value. For better readability I wouldn't break API calls, hence The result and src values are equivalent in that sense that a call to bitmap_scatter(res, src, mask, n) and a call to bitmap_scatter(res, result, mask, n) will lead to the same res value. -- With Best Regards, Andy Shevchenko