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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6CE17E81E1C for ; Fri, 6 Oct 2023 16:54:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=j1ohDI8S8nmNKZLjnfngK1C3VwbVrS0d/mqxsg5FYHg=; b=KM0XBQ6Zyj2hiD fKbK7WTD8i+S9vL7b3HXtO9ixR2GuYGbz4AysD3SVgRQNUW2t/MlLA9cD5VyVEB46HZZje/p8gua/ bp7YfUhYIA6IvBYjsPtKqaZmDI1GVmgjLXXIbV31Gbvi5m5CcGJuojjiureHQ64EYBsPodf8o0y9A v5vZVVByRlNWzYoyhz/YpoWlAtWrKvyKKgSuv6aswMb8wPTYr4np+Hf1jqX2BR8i1fUdMqF07KRxl VeO/hPI+PvkUrfHM13Fug8W1jKBB8FpDRrH3Qm8Ie9jMcCZw0hkcSGEC2uw43jNvDGT8riSOPp/Wv ip8a0AhE6jwJPxUKrzGA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qoo5O-006Dgv-2n; Fri, 06 Oct 2023 16:53:58 +0000 Received: from mail-yw1-x1132.google.com ([2607:f8b0:4864:20::1132]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qoo5L-006DgK-2w for linux-arm-kernel@lists.infradead.org; Fri, 06 Oct 2023 16:53:57 +0000 Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-5a22eaafd72so28945567b3.3 for ; Fri, 06 Oct 2023 09:53:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696611233; x=1697216033; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=2RRHPsvPdMlUlp1HTcO5ss/dErjauxHiRYZDTLP9NQY=; b=C5jlhQiLeaZwPxVI2QpgfDDmqfKpF0oPiGogWt2M6moGAWjmc8TAo/BS7PtA5xkNNj Jegk8l0gIVK71O2na99H1JD1TtQg7UZ8UDzaTflqEl6y8iqqcgIPK5hmzbGfyPv6k4Qw AZPKWrVJwHaon//CnbhqlJBdHG71+lnFO0MacuZZoDooVwxf3mw9sIx1kCymLW4h5Bna RPFDVPNppm5u3FqbzsKcIZsxAsRet6sdMyb7+4hKzwTaMJnnueffmLYxFI6YBK40b7GZ z9umCRCgQru2BD4MI34zAzIMTWn+LdE8jHGrPanmsEB/UGLkyGdGgeT7ZyJuJutx2Jj5 mwgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696611233; x=1697216033; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=2RRHPsvPdMlUlp1HTcO5ss/dErjauxHiRYZDTLP9NQY=; b=gaNyzlo6xaizBbXFRetXjkv07+t+si8uSTKlTPzGI5wLhfn373R335JyIgAP2GOpzT bFHZPe8L7hcbGPbf09gCwxyhSzt9fLKWconY33qf4rjNPiKgHQkBTfjkG2UKDnTk0fyt 5zF00VqhwWnQXABR+5sR9oHULRM00U8uFLgC2dT9+prTpZH1IOA0b+GLUZ+Sbsb+9h85 HnL5tuo/CYBBPi+yi8+oGOrg+3Nd41kKID/5G9pH9KpnVVB7KeprcdOR26QxU67QG4JY Z+sXeQkFHJv263qx7XuYEvxP0tLsqWxn2zJWT5I9TJHTG8YVgqqfMg35BsLh8H4zbmfI VjBQ== X-Gm-Message-State: AOJu0YxgshfLrbVhYqUsnDtlDLwe8suoy8i2wKjLHRiw8G114Vh373EE U4DBJY7GJds8ASvGn5kh6gg= X-Google-Smtp-Source: AGHT+IEENVGdTDMRdiCUd7WaIpDQn16TvgmGMQgvE/IoUwFSER5IRtuhNaX/A0e3QB7cxqjkMN+ghA== X-Received: by 2002:a25:da8a:0:b0:d81:97c:c01e with SMTP id n132-20020a25da8a000000b00d81097cc01emr8596149ybf.5.1696611232872; Fri, 06 Oct 2023 09:53:52 -0700 (PDT) Received: from localhost (76-202-118-196.lightspeed.jcvlfl.sbcglobal.net. [76.202.118.196]) by smtp.gmail.com with ESMTPSA id d82-20020a254f55000000b00d728a2738f1sm1159048ybb.61.2023.10.06.09.53.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 09:53:52 -0700 (PDT) Date: Fri, 6 Oct 2023 09:53:51 -0700 From: Yury Norov To: Andy Shevchenko Cc: Alexander Potapenko , catalin.marinas@arm.com, will@kernel.org, pcc@google.com, andreyknvl@gmail.com, aleksander.lobakin@intel.com, linux@rasmusvillemoes.dk, 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 v6 1/5] lib/bitmap: add bitmap_{read,write}() Message-ID: References: <20231006134529.2816540-1-glider@google.com> <20231006134529.2816540-2-glider@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231006_095355_955750_4680F392 X-CRM114-Status: GOOD ( 25.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Oct 06, 2023 at 05:47:49PM +0300, Andy Shevchenko wrote: > On Fri, Oct 06, 2023 at 03:45:25PM +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. > > ... > > > v6: > > - As suggested by Yury Norov, do not require bitmap_read(..., 0) to > > return 0. > > Hmm... See below. [...] > > +static inline unsigned long bitmap_read(const unsigned long *map, > > + unsigned long start, > > + unsigned long nbits) > > +{ > > + size_t index = BIT_WORD(start); > > + unsigned long offset = start % BITS_PER_LONG; > > + unsigned long space = BITS_PER_LONG - offset; > > + unsigned long value_low, value_high; > > > + if (unlikely(!nbits)) > > + return 0; > > Hmm... I didn't get was the comment to add or to remove these checks? The sentence relates to the test, and the comment that confused you should to to the 2nd patch. I.e., bitmap_read(..., 0) is not required to return 0, and it's purely an implementation details. > > > + if (space >= nbits) > > + return (map[index] >> offset) & GENMASK(nbits - 1, 0); > > And don't you want to replace this GENMASK() as well? +1 > > + value_low = map[index] & BITMAP_FIRST_WORD_MASK(start); > > + value_high = map[index + 1] & BITMAP_LAST_WORD_MASK(start + nbits); > > + return (value_low >> offset) | (value_high << space); > > +} > > -- > With Best Regards, > Andy Shevchenko > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel