From: Yu Kuai <yukuai1@huaweicloud.com>
To: yukuai@kernel.org, Jan Kara <jack@suse.cz>,
Yu Kuai <yukuai1@huaweicloud.com>
Cc: axboe@kernel.dk, akpm@linux-foundation.org, yang.yang@vivo.com,
dlemoal@kernel.org, ming.lei@redhat.com,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
yi.zhang@huawei.com, yangerkun@huawei.com,
johnny.chenyi@huawei.com, Omar Sandoval <osandov@fb.com>,
"yukuai (C)" <yukuai3@huawei.com>
Subject: Re: [PATCH v2 1/2] lib/sbitmap: convert shallow_depth from one word to the whole sbitmap
Date: Thu, 31 Jul 2025 10:38:58 +0800 [thread overview]
Message-ID: <c748a3ee-bf33-e13e-d507-984277acbb32@huaweicloud.com> (raw)
In-Reply-To: <223acbc1-60d4-4687-8eea-5306aa44ae24@kernel.org>
Hi,
在 2025/07/31 2:24, Yu Kuai 写道:
> hi, Jan!
>
> 在 2025/7/30 21:03, Jan Kara 写道:
>> I think having two APIs will be even more confusing than the current
>> state.
>> But as I wrote I think you can have API to specify shallow depth in total
>> size and in sbitmap_queue_get_shallow() do:
>>
>> shallow_per_word = (shallow_depth << sb->shift) / sb->depth;
In order to consider the last word, I think we should use __map_depth()
here.
>> rounding_index = shallow_depth - shallow_per_word * sb->depth;
And then it's not possible to calculate this rounding index easily. How
about following, although the reminder handling is not perfect.
static unsigned int __map_depth_with_shallow(const struct sbitmap *sb,
int index,
unsigned int shallow_depth)
{
unsigned int word_depth = __map_depth(sb, index);
unsigned int shallow_word_depth = word_depth * shallow_depth;
unsigned reminder = do_div(shallow_word_depth, sb->depth);
if (reminder && !(index & 0x1))
shallow_word_depth++;
return shallow_word_depth;
}
>>
>> and allow depth shallow_per_word + 1 if current index < rounding_index
>> and
>> exactly shallow_per_word if current index >= rounding_index. This will
>> still evenly distribute shallow depth among words and I don't think the
>> additional overhead of the several arithmetic operations will be visible.
> Yes, you're right, I did not get your idea before. Thanks for the
> explanation
> and the suggestion :) Will follow this idea in the next version.
>
> Thanks
>
> .
>
next prev parent reply other threads:[~2025-07-31 2:39 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-29 3:19 [PATCH v2 0/2] " Yu Kuai
2025-07-29 3:19 ` [PATCH v2 1/2] " Yu Kuai
2025-07-29 10:16 ` Jan Kara
2025-07-30 2:03 ` Yu Kuai
2025-07-30 13:03 ` Jan Kara
2025-07-30 18:24 ` Yu Kuai
2025-07-31 2:38 ` Yu Kuai [this message]
2025-07-31 16:27 ` Jan Kara
2025-08-01 0:24 ` Yu Kuai
2025-08-01 7:44 ` Yu Kuai
2025-07-29 3:19 ` [PATCH v2 2/2] lib/sbitmap: make sbitmap_get_shallow() static Yu Kuai
2025-07-29 9:36 ` Jan Kara
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=c748a3ee-bf33-e13e-d507-984277acbb32@huaweicloud.com \
--to=yukuai1@huaweicloud.com \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=dlemoal@kernel.org \
--cc=jack@suse.cz \
--cc=johnny.chenyi@huawei.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=osandov@fb.com \
--cc=yang.yang@vivo.com \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@huawei.com \
--cc=yukuai3@huawei.com \
--cc=yukuai@kernel.org \
/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
all inboxes | Powered by JetHome®