From: "Sun YangKai" <sunyangkai@fnnas.com>
To: <dsterba@suse.cz>
Cc: "Rosen Penev" <rosenp@gmail.com>, <linux-btrfs@vger.kernel.org>,
"Chris Mason" <clm@fb.com>, "David Sterba" <dsterba@suse.com>,
"open list" <linux-kernel@vger.kernel.org>,
<sunk67188@gmail.com>
Subject: Re: [PATCH] btrfs: compression: allocate buckets with workspace
Date: Tue, 30 Jun 2026 09:51:11 +0800 [thread overview]
Message-ID: <d12006e8-538a-4890-b52d-43dc12704ec4@fnnas.com> (raw)
In-Reply-To: <20260629230908.GB2398896@twin.jikos.cz>
On 2026/6/30 07:09, David Sterba wrote:
> On Mon, Jun 29, 2026 at 09:54:11AM +0800, Sun YangKai wrote:
>>> - ws = kzalloc_obj(*ws);
>>> + ws = kzalloc(struct_size(ws, bucket, BUCKET_SIZE * 2), GFP_KERNEL);
>>
>> It seems that size is fixed and known at compile time, and since we want
>> to inline the buckets in the struct, I think we can have something like
>> this to save one pointer:
>>
>> struct heuristic_ws {
>> ...
>> struct bucket_item bucket[BUCKET_SIZE];
>> struct bucket_item bucket_b[BUCKET_SIZE];
>
> I like this idea, given that we know the size at compile time.
>
>> }
>>
>> However, each bucket array takes exactly 1024B memory. Currently we have
>> a 48B allocation for the struct it self, 2 * 1024B allocation for bucket
>> array, and 8192B allocation for sample. With these 2 arrays inlined, the
>> struct will need 32 + 2048B allocation if my calculation is correct,
>> which will goes into kmalloc-4k. Seems not good.
>
> SLUB merges same/similar sized structures for the named caches, I'm not
> sure if this also works for the generic slabs. We can add the kmem cache
> and so we can utilize the merging.
Oh, I've missed that. Then things seems good for me.
> The sharing can be seen in /sys/kernel/slab, "ls -l | grep <SIZE>". The
> size is rounded up to hw cacheline, so for the heuristic workspace it'll
> end up in size 2112. I see at least one existing named slab on my
> system, 'dmaengine-unmap-256'. This may not matter, but a named cache
> can fix the slack space in the 4k slab.
And I have
❯ sudo grep 2112 /proc/slabinfo
sighand_cache 593 1335 2112 15 8
on my system :)
Thanks,
Sun YangKai
next prev parent reply other threads:[~2026-06-30 1:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-29 0:25 Rosen Penev
2026-06-29 1:54 ` Sun YangKai
2026-06-29 23:09 ` David Sterba
2026-06-30 1:51 ` Sun YangKai [this message]
2026-06-29 10:14 ` Qu Wenruo
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=d12006e8-538a-4890-b52d-43dc12704ec4@fnnas.com \
--to=sunyangkai@fnnas.com \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rosenp@gmail.com \
--cc=sunk67188@gmail.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
all inboxes | Powered by JetHome®