Re: [PATCH] btrfs: replace kcalloc() calls to kzalloc_objs()

From: Miquel Sabaté Solà

Date: Tue Feb 24 2026 - 01:46:45 EST


Johannes Thumshirn @ 2026-02-24 06:32 GMT:

> On 2/24/26 12:45 AM, Miquel Sabaté Solà wrote:
>> Commit 2932ba8d9c99 ("slab: Introduce kmalloc_obj() and family")
>> introduced, among many others, the kzalloc_objs() helper, which has some
>> benefits over kcalloc().
> Namely?

I didn't want to repeat the arguments from the quoted commit
2932ba8d9c99 ("slab: Introduce kmalloc_obj() and family"). Namely:

> Internal introspection of the allocated type now becomes possible,
> allowing for future alignment-aware choices to be made by the
> allocator and future hardening work that can be type sensitive.

Should I put this in the commit message as well, regardless of the
commit explaining this being quoted?

There's also the argument of dropping 'sizeof' to be more ergonomic. To
me, though, and considering how these helpers have been applied
tree-wide, I see this change more as aligning us with this recent
tree-wide move, which also affected btrfs (see commit 69050f8d6d07
"treewide: Replace kmalloc with kmalloc_obj for non-scalar types").

Attachment: signature.asc
Description: PGP signature