Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp478832rdh; Thu, 26 Oct 2023 07:27:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF8+59CzTqZoy/XFRJwnT8vpmk8weBgqQiCabeNNJ/MorVbOyNTuZ0kDjnv6Oqi65ydREDF X-Received: by 2002:a25:d405:0:b0:da0:caba:9017 with SMTP id m5-20020a25d405000000b00da0caba9017mr320633ybf.16.1698330424254; Thu, 26 Oct 2023 07:27:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698330424; cv=none; d=google.com; s=arc-20160816; b=UMfby8whA6WIPTUwU2JIWTi0T/yTP60hSnLBacFTPBdWZt3AYNBYLso/ZuwF8bfrDL N8SoZVMf04z7HC0kIp5FjqZCDwZqJvcQhCLoOu4N15pmjmOlDMd92SlAxGQJgCx5RZtR qOteSWdKmelD9VqLOJIpbCxXqeik0GvyyZZxRSsvsKzZPoZj5ea0CWdcXy7IiBaebv2u S/ZzGWwi37J5d8wmF1wsBaxPprEyHrwsbauExhiLkJel9zrxQMREFmiWr0GmtT2L4ARN bhGqFWn2B4u8ybzhoruZP/z4XdQ9jL97GeA1GSl1eMbFCil3QMTwQlPnMCaIEoMcWGXq qOcA== 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 :dkim-signature; bh=9LPTB3ywCssw3IAgxyx+lyZFCgtT7DfaS2eL/Ezc+n8=; fh=QEGGfnzgLB1PJNzeZDNHIJJxryNQqqD8yjdtP5TLpzQ=; b=egqUeZRafXvz/zCSVZIZwkK7UX5N9ntUYIq+/PW5/ck0uQcTNU2IXO0MldqDV7+VfO YZ7MzPOI76wmJ3Hd2HqMkg+mium9Rr6fEW7c9Pp49//1bu1InqPWvmq1EMM5N8ae77Np LcTR/Azxoe7TMdECPGIq3xHn/KqPliyNV0P9TuHziey3iTtzL3pTrY3Fwtnf2yYlloGv vj10BTe/TggaDnQseFn4r20cb0+Da1c+buuHDe5eft1M1ApooijnSkfdjiLRSE7iZR54 BquJYxR3sbyUhQRIe7wpYMyxJLPaWNaxnsdMO07o40GcjYjYQXMnZfU0byPbeXgh/qhH bD0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MQ0ozVdv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id l16-20020a25b310000000b00d865bcd93besi14625589ybj.588.2023.10.26.07.27.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 07:27:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MQ0ozVdv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 3E117808DB75; Thu, 26 Oct 2023 07:25:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345255AbjJZOY5 (ORCPT + 99 others); Thu, 26 Oct 2023 10:24:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345244AbjJZOYq (ORCPT ); Thu, 26 Oct 2023 10:24:46 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3D121B6 for ; Thu, 26 Oct 2023 07:24:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698330281; x=1729866281; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=jJndrHrOXUiiFrLeo6KN+w75k8epoGoi9EtFUnIB18s=; b=MQ0ozVdv2jM4QpB1H5ZdJbkdRr4Sbjt9xsEICEkdZMWpmo8FoYCGOuSI pEXce+mYfEyav1pGQImiBK3wPIb1tLLJtl2QjUNl6EymVTeqZYmBtUdp2 Wy/fR156/n6FFTq+pN0qVJ9eIg44voCSbg2V7f12scW+nEiFSP3Xxnx43 /ZzTVH1jXmEMq/ajMf0L3bfncF4PJprCofduuv3Q9kmt5LTC2SaHCigYZ QZKCJW88P9Gtl4AMXvOvfNLt+oupD2X48VyWvetNSlBV1we58cEHVvczY qVigAVcpHt0AF7/8ZIh47t0088TxB0MeYJslZ7MI48KK1y83nfatuEOqr w==; X-IronPort-AV: E=McAfee;i="6600,9927,10875"; a="384766951" X-IronPort-AV: E=Sophos;i="6.03,253,1694761200"; d="scan'208";a="384766951" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2023 07:24:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10875"; a="932757730" X-IronPort-AV: E=Sophos;i="6.03,253,1694761200"; d="scan'208";a="932757730" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga005.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2023 07:24:35 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.97-RC3) (envelope-from ) id 1qw1Hk-00000008sxg-1Kst; Thu, 26 Oct 2023 17:24:32 +0300 Date: Thu, 26 Oct 2023 17:24:32 +0300 From: Andy Shevchenko To: Alexander Potapenko Cc: catalin.marinas@arm.com, will@kernel.org, pcc@google.com, andreyknvl@gmail.com, aleksander.lobakin@intel.com, linux@rasmusvillemoes.dk, yury.norov@gmail.com, alexandru.elisei@arm.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, eugenis@google.com, syednwaris@gmail.com, william.gray@linaro.org, Arnd Bergmann Subject: Re: [PATCH v10 1/2] lib/bitmap: add bitmap_{read,write}() Message-ID: References: <20231026135912.1214302-1-glider@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231026135912.1214302-1-glider@google.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 26 Oct 2023 07:25:33 -0700 (PDT) On Thu, Oct 26, 2023 at 03:59:11PM +0200, Alexander Potapenko wrote: > From: Syed Nayyar Waris > > The two new functions allow reading/writing values of length up to > BITS_PER_LONG bits at arbitrary position in the bitmap. > > The code was taken from "bitops: Introduce the for_each_set_clump macro" > by Syed Nayyar Waris with a number of changes and simplifications: > - instead of using roundup(), which adds an unnecessary dependency > on , we calculate space as BITS_PER_LONG-offset; > - indentation is reduced by not using else-clauses (suggested by > checkpatch for bitmap_get_value()); > - bitmap_get_value()/bitmap_set_value() are renamed to bitmap_read() > and bitmap_write(); > - some redundant computations are omitted. Reviewed-by: Andy Shevchenko One nit below, though. ... > +/** > + * bitmap_write - write n-bit value within a memory region > + * @map: address to the bitmap memory region > + * @value: value to write, clamped to nbits > + * @start: bit offset of the n-bit value > + * @nbits: size of value in bits, nonzero, up to BITS_PER_LONG. > + * > + * bitmap_write() behaves as-if implemented as @nbits calls of __assign_bit(), > + * i.e. bits beyond @nbits are ignored: > + * > + * for (bit = 0; bit < nbits; bit++) > + * __assign_bit(start + bit, bitmap, val & BIT(bit)); > + * > + * For @nbits > BITS_PER_LONG no writes are performed. nbits == 0 hasn't been mentioned. (no, the main nit below) > + */ > +static inline void bitmap_write(unsigned long *map, > + unsigned long value, > + unsigned long start, unsigned long nbits) While noticing strange indentation (you have space for the parameter on the previous line, I realized that this is a counter-intuitive interface. Can you actually make value the last parameter? -- With Best Regards, Andy Shevchenko