Linux block layer
 help / color / mirror / Atom feed
From: John Garry <john.garry@huawei.com>
To: Ming Lei <ming.lei@redhat.com>, Jens Axboe <axboe@kernel.dk>
Cc: <linux-block@vger.kernel.org>, Martin Wilck <martin.wilck@suse.com>
Subject: Re: [PATCH V2] lib/sbitmap: kill 'depth' from sbitmap_word
Date: Tue, 8 Feb 2022 09:02:49 +0000	[thread overview]
Message-ID: <2fbebb37-625a-918e-ff53-98d6e6bc979e@huawei.com> (raw)
In-Reply-To: <20220110072945.347535-1-ming.lei@redhat.com>

On 10/01/2022 07:29, Ming Lei wrote:
> Only the last sbitmap_word can have different depth, and all the others
> must have same depth of 1U << sb->shift, so not necessary to store it in
> sbitmap_word, and it can be retrieved easily and efficiently by adding
> one internal helper of __map_depth(sb, index).
> 
> Remove 'depth' field from sbitmap_word, then the annotation of
> ____cacheline_aligned_in_smp for 'word' isn't needed any more.
> 
> Not see performance effect when running high parallel IOPS test on
> null_blk.
> 
> This way saves us one cacheline(usually 64 words) per each sbitmap_word.
> 
> Cc: Martin Wilck <martin.wilck@suse.com>
> Signed-off-by: Ming Lei <ming.lei@redhat.com>

Reviewed-by: John Garry <john.garry@huawei.com>

> ---
> V2:
> 	- remove the annotation of ____cacheline_aligned_in_smp for 'word'
> 	as suggested by Jens
> 
>   include/linux/sbitmap.h | 17 ++++++++++-------
>   lib/sbitmap.c           | 34 ++++++++++++++--------------------
>   2 files changed, 24 insertions(+), 27 deletions(-)
> 
> diff --git a/include/linux/sbitmap.h b/include/linux/sbitmap.h
> index fc0357a6e19b..3754dc45f890 100644
> --- a/include/linux/sbitmap.h
> +++ b/include/linux/sbitmap.h
> @@ -27,15 +27,10 @@ struct seq_file;
>    * struct sbitmap_word - Word in a &struct sbitmap.
>    */
>   struct sbitmap_word {
> -	/**
> -	 * @depth: Number of bits being used in @word/@cleared
> -	 */
> -	unsigned long depth;
> -
>   	/**
>   	 * @word: word holding free bits
>   	 */
> -	unsigned long word ____cacheline_aligned_in_smp;
> +	unsigned long word;
>   
>   	/**
>   	 * @cleared: word holding cleared bits
> @@ -164,6 +159,14 @@ struct sbitmap_queue {
>   int sbitmap_init_node(struct sbitmap *sb, unsigned int depth, int shift,
>   		      gfp_t flags, int node, bool round_robin, bool alloc_hint);
>   
> +/* sbitmap internal helper */
> +static inline unsigned int __map_depth(const struct sbitmap *sb, int index)
> +{
> +	if (index == sb->map_nr - 1)

Do you think that unlikely may be useful?

> +		return sb->depth - (index << sb->shift);
> +	return 1U << sb->shift;
> +}
> +

  parent reply	other threads:[~2022-02-08  9:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-10  7:29 [PATCH V2] lib/sbitmap: kill 'depth' from sbitmap_word Ming Lei
2022-02-08  3:23 ` Ming Lei
2022-02-08  7:46 ` Martin Wilck
2022-02-08  9:02 ` John Garry [this message]
2022-02-08 13:54 ` Jens Axboe

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=2fbebb37-625a-918e-ff53-98d6e6bc979e@huawei.com \
    --to=john.garry@huawei.com \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=martin.wilck@suse.com \
    --cc=ming.lei@redhat.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