* [PATCH] xfs: replace kvmalloc_array with kvzalloc_objs
@ 2026-09-17 20:08 Lalit Shankar Chowdhury
2026-09-18 5:16 ` Carlos Maiolino
0 siblings, 1 reply; 6+ messages in thread
From: Lalit Shankar Chowdhury @ 2026-09-17 20:08 UTC (permalink / raw)
To: Carlos Maiolino, open list:XFS FILESYSTEM, open list
Cc: Lalit Shankar Chowdhury
Replace kvmalloc_array() with the more concise kvzalloc_objs()
implementation.
Signed-off-by: Lalit Shankar Chowdhury <lalitshankarch@gmail.com>
---
fs/xfs/xfs_zone_alloc.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/xfs/xfs_zone_alloc.c b/fs/xfs/xfs_zone_alloc.c
index 28c1e48909fa..82615045aa4c 100644
--- a/fs/xfs/xfs_zone_alloc.c
+++ b/fs/xfs/xfs_zone_alloc.c
@@ -1238,8 +1238,7 @@ 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);
+ return kvzalloc_objs(unsigned long, BITS_TO_LONGS(mp->m_sb.sb_rgcount));
}
static struct xfs_zone_info *
--
2.53.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] xfs: replace kvmalloc_array with kvzalloc_objs
2026-09-17 20:08 [PATCH] xfs: replace kvmalloc_array with kvzalloc_objs Lalit Shankar Chowdhury
@ 2026-09-18 5:16 ` Carlos Maiolino
2026-09-18 11:16 ` Christoph Hellwig
0 siblings, 1 reply; 6+ messages in thread
From: Carlos Maiolino @ 2026-09-18 5:16 UTC (permalink / raw)
To: Lalit Shankar Chowdhury; +Cc: open list:XFS FILESYSTEM, open list
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@gmail.com>
NAK...
This is used to allocate composite objects managed through a
slab cache. This is not for fundamental basic data types....
> ---
> fs/xfs/xfs_zone_alloc.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/fs/xfs/xfs_zone_alloc.c b/fs/xfs/xfs_zone_alloc.c
> index 28c1e48909fa..82615045aa4c 100644
> --- a/fs/xfs/xfs_zone_alloc.c
> +++ b/fs/xfs/xfs_zone_alloc.c
> @@ -1238,8 +1238,7 @@ 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);
> + return kvzalloc_objs(unsigned long, BITS_TO_LONGS(mp->m_sb.sb_rgcount));
> }
>
> static struct xfs_zone_info *
> --
> 2.53.0
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] xfs: replace kvmalloc_array with kvzalloc_objs
2026-09-18 5:16 ` Carlos Maiolino
@ 2026-09-18 11:16 ` Christoph Hellwig
2026-09-18 11:32 ` Carlos Maiolino
2026-09-18 11:44 ` Carlos Maiolino
0 siblings, 2 replies; 6+ messages in thread
From: Christoph Hellwig @ 2026-09-18 11:16 UTC (permalink / raw)
To: Carlos Maiolino
Cc: Lalit Shankar Chowdhury, open list:XFS FILESYSTEM, open list
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@gmail.com>
>
> 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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] xfs: replace kvmalloc_array with kvzalloc_objs
2026-09-18 11:16 ` Christoph Hellwig
@ 2026-09-18 11:32 ` Carlos Maiolino
2026-09-18 11:44 ` Carlos Maiolino
1 sibling, 0 replies; 6+ messages in thread
From: Carlos Maiolino @ 2026-09-18 11:32 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Lalit Shankar Chowdhury, open list:XFS FILESYSTEM, open list
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@gmail.com>
> >
> > 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.
I see your point, but what kv(z)alloc_objs() do is essentially
kmalloc(sizeof(object type) * count, GFP)...
While I see why it's useful for composite types, I don't see the much
the point of doing kvzalloc_objs(int, count)..
And still kvmalloc_array() looks a better fit in this case IMO than
kvmalloc_objs().
>
> 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.
>
+1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] xfs: replace kvmalloc_array with kvzalloc_objs
2026-09-18 11:16 ` Christoph Hellwig
2026-09-18 11:32 ` Carlos Maiolino
@ 2026-09-18 11:44 ` Carlos Maiolino
2026-09-18 13:51 ` Christoph Hellwig
1 sibling, 1 reply; 6+ messages in thread
From: Carlos Maiolino @ 2026-09-18 11:44 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Lalit Shankar Chowdhury, open list:XFS FILESYSTEM, open list
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@gmail.com>
> >
> > 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;
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] xfs: replace kvmalloc_array with kvzalloc_objs
2026-09-18 11:44 ` Carlos Maiolino
@ 2026-09-18 13:51 ` Christoph Hellwig
0 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2026-09-18 13:51 UTC (permalink / raw)
To: Carlos Maiolino
Cc: Christoph Hellwig, Lalit Shankar Chowdhury,
open list:XFS FILESYSTEM, open list
On Fri, Sep 18, 2026 at 01:44:12PM +0200, Carlos Maiolino wrote:
> 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.
No, I mean changing bitmap_*alloc* and bitmap_Free in lib/bitmap.c.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-09-18 13:51 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-17 20:08 [PATCH] xfs: replace kvmalloc_array with kvzalloc_objs Lalit Shankar Chowdhury
2026-09-18 5:16 ` Carlos Maiolino
2026-09-18 11:16 ` Christoph Hellwig
2026-09-18 11:32 ` Carlos Maiolino
2026-09-18 11:44 ` Carlos Maiolino
2026-09-18 13:51 ` Christoph Hellwig
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®