* [PATCHv2] btrfs: compression: allocate buckets with workspace
@ 2026-07-03 22:45 Rosen Penev
2026-07-21 12:09 ` David Sterba
0 siblings, 1 reply; 2+ messages in thread
From: Rosen Penev @ 2026-07-03 22:45 UTC (permalink / raw)
To: linux-btrfs; +Cc: Chris Mason, David Sterba, open list
Convert 3 allocations into one. Simplifies code slightly by removing
extra kfree calls.
SLUB merges same/similar sized structures for the named caches, so not
a huge size concern:
grep 2112 /proc/slabinfo
sighand_cache 593 1335 2112 15 8
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
v2: use normal arrays
fs/btrfs/compression.c | 14 ++------------
1 file changed, 2 insertions(+), 12 deletions(-)
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index ffb6b52863a7..c62b5148d5ac 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -651,9 +651,9 @@ struct heuristic_ws {
u8 *sample;
u32 sample_size;
/* Buckets store counters for each byte value */
- struct bucket_item *bucket;
+ struct bucket_item bucket[BUCKET_SIZE];
/* Sorting buffer */
- struct bucket_item *bucket_b;
+ struct bucket_item bucket_b[BUCKET_SIZE];
struct list_head list;
};
@@ -664,8 +664,6 @@ static void free_heuristic_ws(struct list_head *ws)
workspace = list_entry(ws, struct heuristic_ws, list);
kvfree(workspace->sample);
- kfree(workspace->bucket);
- kfree(workspace->bucket_b);
kfree(workspace);
}
@@ -681,14 +679,6 @@ static struct list_head *alloc_heuristic_ws(struct btrfs_fs_info *fs_info)
if (!ws->sample)
goto fail;
- ws->bucket = kzalloc_objs(*ws->bucket, BUCKET_SIZE);
- if (!ws->bucket)
- goto fail;
-
- ws->bucket_b = kzalloc_objs(*ws->bucket_b, BUCKET_SIZE);
- if (!ws->bucket_b)
- goto fail;
-
INIT_LIST_HEAD(&ws->list);
return &ws->list;
fail:
--
2.55.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCHv2] btrfs: compression: allocate buckets with workspace
2026-07-03 22:45 [PATCHv2] btrfs: compression: allocate buckets with workspace Rosen Penev
@ 2026-07-21 12:09 ` David Sterba
0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2026-07-21 12:09 UTC (permalink / raw)
To: Rosen Penev; +Cc: linux-btrfs, Chris Mason, David Sterba, open list
On Fri, Jul 03, 2026 at 03:45:57PM -0700, Rosen Penev wrote:
> Convert 3 allocations into one. Simplifies code slightly by removing
> extra kfree calls.
>
> SLUB merges same/similar sized structures for the named caches, so not
> a huge size concern:
>
> grep 2112 /proc/slabinfo
> sighand_cache 593 1335 2112 15 8
>
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
With slightly updated changelog merged to for-next, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-21 12:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-03 22:45 [PATCHv2] btrfs: compression: allocate buckets with workspace Rosen Penev
2026-07-21 12:09 ` David Sterba
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®