From: Jens Axboe <axboe@kernel.dk>
To: Stephen Zhang <starzhangzsd@gmail.com>, Coly Li <colyli@fnnas.com>
Cc: Kent Overstreet <kent.overstreet@linux.dev>,
Sasha Levin <sashal@kernel.org>,
Christoph Hellwig <hch@infradead.org>,
linux-bcache@vger.kernel.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
zhangshida <zhangshida@kylinos.cn>
Subject: Re: Fwd: [PATCH v2] bcache: use bio cloning for detached device requests
Date: Wed, 21 Jan 2026 07:50:37 -0700 [thread overview]
Message-ID: <9a928d95-f027-4f0d-b34b-ca028ad36046@kernel.dk> (raw)
In-Reply-To: <CANubcdUT+PoGs3j=0ZN5jsntU-hNGHRFQoucKJZvYGXxFC75ng@mail.gmail.com>
On 1/21/26 4:55 AM, Stephen Zhang wrote:
> Coly Li <colyli@fnnas.com> 于2026年1月21日周三 09:34写道:
>>
>> On Tue, Jan 20, 2026 at 08:01:52AM +0800, Jens Axboe wrote:
>>> On 1/20/26 7:46 AM, Coly Li wrote:
>>>>> @@ -949,6 +950,11 @@ static int bcache_device_init(struct
>>>>> bcache_device *d, unsigned int block_size,
>>>>> BIOSET_NEED_BVECS|BIOSET_NEED_RESCUER))
>>>>> goto out_ida_remove;
>>>>>
>>>>> + if (bioset_init(&d->bio_detach, 4,
>>>> ^^^^^-> I feel 4 might be a bit small
>>>> here. bio_detached set is for normal IO when backing device is not
>>>> attached to a cache device. I would suggest to set the pool size to
>>>> 128 or 256.
>>>
>>> Absolutely not, 4 is more than plenty. The pool elements are only ever
>>> used if allocations fail, to guarantee forward progress. Setting aside
>>> 128 or 256 for that case is utterly wasteful, you only need a couple. 4
>>> is a good number, if anything it should be smaller (2).
>>
>> Hi Jens,
>>
>> Thanks for the information. Please correct me if I am wrong for the following
>> text,
>> - If the backing is a normal SSD raid0, the IOPS without attached cache device
>> might be more than thousands. In this case, I assume 128 or 256 might be more
>> tolerant.
>> - I see what ‘4’ means, just not sure/comfortable when memory pressure is high.
>> And reserving 128/256 will occupy around 0.5~1MB memory, I feel such extra
>> memory is acceptable in bcache use case.
>>
>> Don't get me wrong, I totally trust you. If '4' works well enough for high
>> memory pressure condition for detached bcache device, it is cool.
>>
>> Thanks in advance.
>>
>> Coly Li
>
> Hi Jens, Coly,
>
> Regarding the discussion on the bio_detached pool size: while 4 is
> sufficient to guarantee forward progress, some high-load environments
> may prefer a larger reserve to minimize allocation latency under
> extreme memory pressure.
>
> To provide a middle ground, I propose adding a generic bioset_resize()
> interface to the block layer and exposing it through a new bcache
> sysfs attribute 'detached_pool_size'.
>
> This allows us to keep the default value conservative (e.g., 4) to
> avoid unnecessary memory overhead, while giving users the flexibility
> to tune the emergency reserves based on their specific hardware and
> workload requirements.
>
> The patch is attached below. Does this look like a reasonable
> compromise?
Guys, just stop. 4 is fine. Take a look at the default biosets and
what reserve amount they use. I'd recommend you do some testing and
check how often the reserves are _actually_ used, and once you do
that, then you'll see why this isn't necessary at all.
I thought the idea was to make some progress on getting this fixed.
Let's please do that and get it queued.
--
Jens Axboe
next prev parent reply other threads:[~2026-01-21 14:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260120023535.9109-1-zhangshida@kylinos.cn>
2026-01-20 2:39 ` Stephen Zhang
2026-01-20 2:48 ` Stephen Zhang
2026-01-20 6:53 ` Fwd: " Christoph Hellwig
2026-01-20 14:46 ` Coly Li
2026-01-20 15:01 ` Jens Axboe
2026-01-21 1:34 ` Coly Li
2026-01-21 11:55 ` Stephen Zhang
2026-01-21 14:50 ` Jens Axboe [this message]
2026-01-22 3:39 ` Coly Li
2026-01-21 22:48 ` Fwd: " Kent Overstreet
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=9a928d95-f027-4f0d-b34b-ca028ad36046@kernel.dk \
--to=axboe@kernel.dk \
--cc=colyli@fnnas.com \
--cc=hch@infradead.org \
--cc=kent.overstreet@linux.dev \
--cc=linux-bcache@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sashal@kernel.org \
--cc=starzhangzsd@gmail.com \
--cc=zhangshida@kylinos.cn \
/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®