Get rid of kmem_realloc()
cover Get rid of kmem_realloc()
Hi folks.
This is just to give continuity to the kmem cleanup. This series get rid of kmem_realloc() and its users.
Patches have been tested with xfstests, no issues reported so far.
Cheers
Carlos Maiolino (2):
xfs: remove kmem_realloc() users
xfs: remove kmem_realloc()
fs/xfs/kmem.c | 22 ---------------------- fs/xfs/kmem.h | 1 - fs/xfs/libxfs/xfs_iext_tree.c | 2 +- fs/xfs/libxfs/xfs_inode_fork.c | 8 ++++---- fs/xfs/xfs_log_recover.c | 2 +- fs/xfs/xfs_mount.c | 4 ++-- fs/xfs/xfs_trace.h | 1 - 7 files changed, 8 insertions(+), 32 deletions(-)
Signature · 1 line
2.26.2
PATCH 1/2 xfs: remove kmem_realloc() users
As a part of the memory cleanup, this patch remove all users of kmem_realloc(). Next patch will remove the function.
--- fs/xfs/libxfs/xfs_iext_tree.c | 2 +- fs/xfs/libxfs/xfs_inode_fork.c | 8 ++++---- fs/xfs/xfs_log_recover.c | 2 +- fs/xfs/xfs_mount.c | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-)
fs/xfs/libxfs/xfs_iext_tree.c +1 -1
@@ -603,7 +603,7 @@ xfs_iext_realloc_root(if (new_size /sizeof (struct xfs_iext_rec ) ==RECS_PER_LEAF ) new_size =NODE_SIZE ; - new =kmem_realloc (ifp->if_u1.if_root, new_size,KM_NOFS ); + new =krealloc (ifp->if_u1.if_root, new_size,GFP_NOFS | __GFP_NOFAIL);memset (new + ifp->if_bytes,0 , new_size - ifp->if_bytes); ifp->if_u1.if_root = new; cur->leaf = new;
fs/xfs/libxfs/xfs_inode_fork.c +4 -4
@@ -386,8 +386,8 @@ xfs_iroot_realloc( cur_max =xfs_bmbt_maxrecs (mp, ifp->if_broot_bytes,0 ); new_max = cur_max + rec_diff; new_size =XFS_BMAP_BROOT_SPACE_CALC (mp, new_max); - ifp->if_broot =kmem_realloc (ifp->if_broot, new_size, -KM_NOFS ); + ifp->if_broot =krealloc (ifp->if_broot, new_size, +GFP_NOFS | __GFP_NOFAIL); op = (char *)XFS_BMAP_BROOT_PTR_ADDR (mp, ifp->if_broot,1 , ifp->if_broot_bytes); np = (char *)XFS_BMAP_BROOT_PTR_ADDR(mp, ifp->if_broot, 1,
@@ -496,8 +496,8 @@ xfs_idata_realloc(* in size so that it can be logged and stay on word boundaries. * We enforce that here. */ - ifp->if_u1.if_data =kmem_realloc (ifp->if_u1.if_data, -roundup (new_size,4 ),KM_NOFS ); + ifp->if_u1.if_data =krealloc (ifp->if_u1.if_data,roundup (new_size,4 ), +GFP_NOFS | __GFP_NOFAIL); ifp->if_bytes = new_size; }
fs/xfs/xfs_log_recover.c +1 -1
@@ -2097,7 +2097,7 @@ xlog_recover_add_to_cont_trans( old_ptr = item->ri_buf[item->ri_cnt-1 ].i_addr; old_len = item->ri_buf[item->ri_cnt-1 ].i_len; - ptr =kmem_realloc (old_ptr, len + old_len,0 ); + ptr =krealloc (old_ptr, len + old_len,GFP_KERNEL | __GFP_NOFAIL);memcpy (&ptr[old_len], dp, len); item->ri_buf[item->ri_cnt-1 ].i_len += len; item->ri_buf[item->ri_cnt-1 ].i_addr = ptr;
fs/xfs/xfs_mount.c +2 -2
@@ -80,9 +80,9 @@ xfs_uuid_mount( }if (hole <0 ) { - xfs_uuid_table =kmem_realloc (xfs_uuid_table, + xfs_uuid_table =krealloc (xfs_uuid_table, (xfs_uuid_table_size +1 ) *sizeof (*xfs_uuid_table), -0 ); +GFP_KERNEL | __GFP_NOFAIL); hole = xfs_uuid_table_size++; } xfs_uuid_table[hole] = *uuid;
Signature · 1 line
2.26.2
PATCH 2/2 xfs: remove kmem_realloc()
In reply to Carlos MaiolinoAll its users are now using MM API directly, so, there is no more need for this function and its tracepoint to be around
--- fs/xfs/kmem.c | 22 ---------------------- fs/xfs/kmem.h | 1 - fs/xfs/xfs_trace.h | 1 - 3 files changed, 24 deletions(-)
fs/xfs/kmem.c +0 -22
@@ -93,25 +93,3 @@ kmem_alloc_large(size_t size, xfs_km_flags_t flags)return ptr;return __kmem_vmalloc (size, flags); } - -void * -kmem_realloc (const void *old,size_t newsize,xfs_km_flags_t flags) -{ -int retries =0 ; -gfp_t lflags =kmem_flags_convert (flags); -void *ptr; - -trace_kmem_realloc (newsize, flags, _RET_IP_); - -do { - ptr =krealloc (old, newsize, lflags); -if (ptr || (flags &KM_MAYFAIL )) -return ptr; -if (!(++retries %100 )) -xfs_err (NULL , -"%s(%u) possible memory allocation deadlock size %zu in %s (mode:0x%x)" , - current->comm, current->pid, - newsize, __func__, lflags); -congestion_wait (BLK_RW_ASYNC ,HZ /50 ); - }while (1 ); -}
fs/xfs/kmem.h +0 -1
@@ -59,7 +59,6 @@ kmem_flags_convert(xfs_km_flags_t flags)extern void *kmem_alloc (size_t ,xfs_km_flags_t );extern void *kmem_alloc_io (size_t size,int align_mask,xfs_km_flags_t flags);extern void *kmem_alloc_large (size_t size,xfs_km_flags_t ); -extern void *kmem_realloc (const void *,size_t ,xfs_km_flags_t );static inline void kmem_free (const void *ptr) {kvfree (ptr);
fs/xfs/xfs_trace.h +0 -1
@@ -3676,7 +3676,6 @@ DEFINE_EVENT(xfs_kmem_class, name, \DEFINE_KMEM_EVENT (kmem_alloc);DEFINE_KMEM_EVENT (kmem_alloc_io);DEFINE_KMEM_EVENT (kmem_alloc_large); -DEFINE_KMEM_EVENT (kmem_realloc); TRACE_EVENT(xfs_check_new_dalign, TP_PROTO(struct xfs_mount *mp, int new_dalign, xfs_ino_t calc_rootino),
Signature · 1 line
2.26.2
Both patches looks good:
although personally I would have simply sent them as a single patch.
Quoted 5 lines · Christoph Hellwig
Both patches looks good:
Reviewed-by Christoph Hellwig <[email protected]>although personally I would have simply sent them as a single patch.
Thanks Christoph. I have no preference, I just submitted the patches according to what I was doing, 'remove users, nothing broke? Remove functions', but I particularly have no preference, Darrick, if the patches need to be merged just give me a heads up.
Cheers.
Quoted 1 line
Signature · 1 line
Carlos
Quoted 11 lines · Carlos Maiolino
Quoted 5 lines · Christoph Hellwig
Both patches looks good:
Reviewed-by Christoph Hellwig <[email protected]>although personally I would have simply sent them as a single patch.
Thanks Christoph. I have no preference, I just submitted the patches according to what I was doing, 'remove users, nothing broke? Remove functions', but I particularly have no preference, Darrick, if the patches need to be merged just give me a heads up.
Yes, the two patches are simple enough that they ought to be merged.
--D
Quoted 7 lines
Cheers.
Quoted 1 line
Signature · 1 line
Carlos
Quoted 6 lines · Darrick J. Wong
Quoted 5 lines · Carlos Maiolino
Quoted 4 lines · Christoph Hellwig
Both patches looks good:
Reviewed-by Christoph Hellwig <[email protected]>
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
although personally I would have simply sent them as a single patch.
Thanks Christoph. I have no preference, I just submitted the patches according to what I was doing, 'remove users, nothing broke? Remove functions', but I particularly have no preference, Darrick, if the patches need to be merged just give me a heads up.
Yes, the two patches are simple enough that they ought to be merged.
Ok, you want me to resend or it's just a heads up for the next time?
Signature · 1 line
Carlos
Quoted 9 lines · Carlos Maiolino
Quoted 8 lines · Darrick J. Wong
Quoted 7 lines · Carlos Maiolino
Quoted 5 lines · Christoph Hellwig
Both patches looks good:
Reviewed-by Christoph Hellwig <[email protected]>although personally I would have simply sent them as a single patch.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Thanks Christoph. I have no preference, I just submitted the patches according to what I was doing, 'remove users, nothing broke? Remove functions', but I particularly have no preference, Darrick, if the patches need to be merged just give me a heads up.
Yes, the two patches are simple enough that they ought to be merged.
Ok, you want me to resend or it's just a heads up for the next time?
Yes please. You've got plenty of time. :)
(FWIW I'll probably put this in for-next after -rc6, though I guess it mostly depends on whether or not anyone tries to land any huge patchsets this cycle that would clash with this...)
--D
Quoted 5 lines
Signature · 2 lines
-- Carlos