Re: [PATCH] xfs: replace kvmalloc_array with kvzalloc_objs
From: Carlos Maiolino
Date: Fri Sep 18 2026 - 07:57:20 EST
On Fri, Sep 18, 2026 at 04:16:46AM -0700, Christoph Hellwig wrote:
> On Fri, Sep 18, 2026 at 07:16:32AM +0200, Carlos Maiolino wrote:
> > On Thu, Sep 17, 2026 at 08:08:35PM +0000, Lalit Shankar Chowdhury wrote:
> > > Replace kvmalloc_array() with the more concise kvzalloc_objs()
> > > implementation.
> > >
> > > Signed-off-by: Lalit Shankar Chowdhury <lalitshankarch@xxxxxxxxx>
> >
> > NAK...
> >
> > This is used to allocate composite objects managed through a
> > slab cache. This is not for fundamental basic data types....
>
> I don't think so. While the naming of the helper is a bit
> unfortunate, it is intended for allocating arrays.
>
> But this function really should not exist, instead bitmap_alloc/free
> should be switched to th kvmalloc family so that it will just work
> for large allocations and we can kill the wrappers in XFS.
>
You meant something like this? Leaving xfs_alloc_bucket_bitmap() looks
a bit better for me, to avoid overly long indentation.
I don't think there are free_bitmap_bucket though, buckets are straight
kvfree()'ed.
diff --git a/fs/xfs/xfs_zone_alloc.c b/fs/xfs/xfs_zone_alloc.c
index 28c1e48909fa..864020603dfb 100644
--- a/fs/xfs/xfs_zone_alloc.c
+++ b/fs/xfs/xfs_zone_alloc.c
@@ -1234,14 +1234,6 @@ xfs_calc_open_zones(
return 0;
}
-static unsigned long *
-xfs_alloc_bucket_bitmap(
- struct xfs_mount *mp)
-{
- return kvmalloc_array(BITS_TO_LONGS(mp->m_sb.sb_rgcount),
- sizeof(unsigned long), GFP_KERNEL | __GFP_ZERO);
-}
-
static struct xfs_zone_info *
xfs_alloc_zone_info(
struct xfs_mount *mp)
@@ -1260,7 +1252,10 @@ xfs_alloc_zone_info(
init_waitqueue_head(&zi->zi_zone_wait);
spin_lock_init(&zi->zi_used_buckets_lock);
for (i = 0; i < XFS_ZONE_USED_BUCKETS; i++) {
- zi->zi_used_bucket_bitmap[i] = xfs_alloc_bucket_bitmap(mp);
+ zi->zi_used_bucket_bitmap[i] =
+ kvmalloc_array(BITS_TO_LONGS(mp->m_sb.sb_rgcount),
+ sizeof(unsigned long),
+ GFP_KERNEL | GFP_ZERO);
if (!zi->zi_used_bucket_bitmap[i])
goto out_free_bitmaps;
}