ntfs3.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Yury Norov <yury.norov@gmail.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: agk@redhat.com, snitzer@kernel.org, dm-devel@redhat.com,
	vneethv@linux.ibm.com, oberpar@linux.ibm.com, hca@linux.ibm.com,
	gor@linux.ibm.com, agordeev@linux.ibm.com,
	borntraeger@linux.ibm.com, svens@linux.ibm.com,
	almaz.alexandrovich@paragon-software.com,
	andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk,
	linux-s390@vger.kernel.org, ntfs3@lists.linux.dev,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 3/4] bitmap: Introduce bitmap_size()
Date: Sat, 2 Jul 2022 14:09:46 -0700	[thread overview]
Message-ID: <YsC0GpltMVaCPhkJ@yury-laptop> (raw)
In-Reply-To: <98f5d3d855a9c687ccc035edf62016b02a6876b7.1656785856.git.christophe.jaillet@wanadoo.fr>

On Sat, Jul 02, 2022 at 08:29:36PM +0200, Christophe JAILLET wrote:
> The new bitmap_size() function returns the size, in bytes, of a bitmap.
> 
> Remove the already existing bitmap_size() functions and macro in some
> files.
> These files already use the bitmap API and will use the new function
> in bitmap.h automatically.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/md/dm-clone-metadata.c | 5 -----
>  include/linux/bitmap.h         | 6 ++++++
>  lib/math/prime_numbers.c       | 2 --
>  3 files changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/md/dm-clone-metadata.c b/drivers/md/dm-clone-metadata.c
> index c43d55672bce..47c1fa7aad8b 100644
> --- a/drivers/md/dm-clone-metadata.c
> +++ b/drivers/md/dm-clone-metadata.c
> @@ -465,11 +465,6 @@ static void __destroy_persistent_data_structures(struct dm_clone_metadata *cmd)
>  
>  /*---------------------------------------------------------------------------*/
>  
> -static size_t bitmap_size(unsigned long nr_bits)
> -{
> -	return BITS_TO_LONGS(nr_bits) * sizeof(long);
> -}
> -
>  static int __dirty_map_init(struct dirty_map *dmap, unsigned long nr_words,
>  			    unsigned long nr_regions)
>  {
> diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
> index f091a1664bf1..f66fb98a4126 100644
> --- a/include/linux/bitmap.h
> +++ b/include/linux/bitmap.h
> @@ -48,6 +48,7 @@ struct device;
>   *  bitmap_equal(src1, src2, nbits)             Are *src1 and *src2 equal?
>   *  bitmap_intersects(src1, src2, nbits)        Do *src1 and *src2 overlap?
>   *  bitmap_subset(src1, src2, nbits)            Is *src1 a subset of *src2?
> + *  bitmap_size(nbits)                          Size, in bytes, of a bitmap
>   *  bitmap_empty(src, nbits)                    Are all bits zero in *src?
>   *  bitmap_full(src, nbits)                     Are all bits set in *src?
>   *  bitmap_weight(src, nbits)                   Hamming Weight: number set bits
> @@ -124,6 +125,11 @@ unsigned long *bitmap_alloc_node(unsigned int nbits, gfp_t flags, int node);
>  unsigned long *bitmap_zalloc_node(unsigned int nbits, gfp_t flags, int node);
>  void bitmap_free(const unsigned long *bitmap);
>  
> +static __always_inline size_t bitmap_size(unsigned long nbits)
> +{
> +	return BITS_TO_LONGS(nbits) * sizeof(unsigned long);
> +}
> +
>  /* Managed variants of the above. */
>  unsigned long *devm_bitmap_alloc(struct device *dev,
>  				 unsigned int nbits, gfp_t flags);
> diff --git a/lib/math/prime_numbers.c b/lib/math/prime_numbers.c
> index d42cebf7407f..d3b64b10da1c 100644
> --- a/lib/math/prime_numbers.c
> +++ b/lib/math/prime_numbers.c
> @@ -6,8 +6,6 @@
>  #include <linux/prime_numbers.h>
>  #include <linux/slab.h>
>  
> -#define bitmap_size(nbits) (BITS_TO_LONGS(nbits) * sizeof(unsigned long))
> -

This should be dropped, for sure, and kmalloc() at line 128 should be
replaced with bitmap_alloc().

For the driver, we need to introduce bitmap_kvmalloc/bitmap_kvfree etc. 

>  struct primes {
>  	struct rcu_head rcu;
>  	unsigned long last, sz;
> -- 
> 2.34.1

  parent reply	other threads:[~2022-07-02 21:09 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-02 18:28 [PATCH 0/4] Introduce bitmap_size() Christophe JAILLET
2022-07-02 18:29 ` [PATCH 1/4] s390/cio: Rename bitmap_size() as idset_bitmap_size() Christophe JAILLET
2022-07-02 18:54   ` Andy Shevchenko
2022-07-02 19:24     ` Christophe JAILLET
2022-07-02 19:32       ` Andy Shevchenko
2022-07-02 19:42         ` Christophe JAILLET
2022-07-02 20:46   ` Yury Norov
2022-07-04  4:28   ` Vineeth Vijayan
2022-07-02 18:29 ` [PATCH 2/4] fs/ntfs3: Rename bitmap_size() as ntfs3_bitmap_size() Christophe JAILLET
2022-07-02 18:58   ` Andy Shevchenko
2022-07-02 19:37     ` Christophe JAILLET
2022-07-02 20:57   ` Yury Norov
2022-07-02 18:29 ` [PATCH 3/4] bitmap: Introduce bitmap_size() Christophe JAILLET
2022-07-02 18:59   ` Andy Shevchenko
2022-07-02 21:09   ` Yury Norov [this message]
2022-07-03  6:50     ` Christophe JAILLET
2022-07-03 15:20       ` Andy Shevchenko
2022-07-03 19:13         ` Yury Norov
2022-07-03 20:41           ` Christophe JAILLET
2022-07-02 18:29 ` [PATCH 4/4] bitmap: Use bitmap_size() Christophe JAILLET
2022-07-02 20:44 ` [PATCH 0/4] Introduce bitmap_size() Yury Norov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YsC0GpltMVaCPhkJ@yury-laptop \
    --to=yury.norov@gmail.com \
    --cc=agk@redhat.com \
    --cc=agordeev@linux.ibm.com \
    --cc=almaz.alexandrovich@paragon-software.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=dm-devel@redhat.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=ntfs3@lists.linux.dev \
    --cc=oberpar@linux.ibm.com \
    --cc=snitzer@kernel.org \
    --cc=svens@linux.ibm.com \
    --cc=vneethv@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).