On Wed, Nov 13, 2019 at 03:23:29PM +0100, Carlos Maiolino wrote: > Use kmem_cache_alloc() directly. > > Signed-off-by: Carlos Maiolino <cmaiolino@xxxxxxxxxx> > --- > fs/xfs/kmem.c | 21 --------------------- > fs/xfs/kmem.h | 2 -- > fs/xfs/libxfs/xfs_alloc.c | 3 ++- > fs/xfs/libxfs/xfs_bmap.c | 3 ++- > fs/xfs/xfs_icache.c | 2 +- > fs/xfs/xfs_trace.h | 1 - > 6 files changed, 5 insertions(+), 27 deletions(-) > > diff --git a/fs/xfs/kmem.c b/fs/xfs/kmem.c > index 1da94237a8cf..2644fdaa0549 100644 > --- a/fs/xfs/kmem.c > +++ b/fs/xfs/kmem.c > @@ -115,24 +115,3 @@ kmem_realloc(const void *old, size_t newsize, xfs_km_flags_t flags) > congestion_wait(BLK_RW_ASYNC, HZ/50); > } while (1); > } > - > -void * > -kmem_zone_alloc(kmem_zone_t *zone, xfs_km_flags_t flags) > -{ > - int retries = 0; > - gfp_t lflags = kmem_flags_convert(flags); > - void *ptr; > - > - trace_kmem_zone_alloc(kmem_cache_size(zone), flags, _RET_IP_); > - do { > - ptr = kmem_cache_alloc(zone, lflags); > - if (ptr || (flags & KM_MAYFAIL)) Heh, nobody was using KM_MAYFAIL here at all? :) Reviewed-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx> --D > - return ptr; > - if (!(++retries % 100)) > - xfs_err(NULL, > - "%s(%u) possible memory allocation deadlock in %s (mode:0x%x)", > - current->comm, current->pid, > - __func__, lflags); > - congestion_wait(BLK_RW_ASYNC, HZ/50); > - } while (1); > -} > diff --git a/fs/xfs/kmem.h b/fs/xfs/kmem.h > index c12ab170c396..33523a0b5801 100644 > --- a/fs/xfs/kmem.h > +++ b/fs/xfs/kmem.h > @@ -81,8 +81,6 @@ kmem_zalloc_large(size_t size, xfs_km_flags_t flags) > #define kmem_zone kmem_cache > #define kmem_zone_t struct kmem_cache > > -extern void *kmem_zone_alloc(kmem_zone_t *, xfs_km_flags_t); > - > static inline struct page * > kmem_to_page(void *addr) > { > diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c > index 675613c7bacb..42cae87bdd2d 100644 > --- a/fs/xfs/libxfs/xfs_alloc.c > +++ b/fs/xfs/libxfs/xfs_alloc.c > @@ -2351,7 +2351,8 @@ xfs_defer_agfl_block( > ASSERT(xfs_bmap_free_item_zone != NULL); > ASSERT(oinfo != NULL); > > - new = kmem_zone_alloc(xfs_bmap_free_item_zone, 0); > + new = kmem_cache_alloc(xfs_bmap_free_item_zone, > + GFP_KERNEL | __GFP_NOFAIL); > new->xefi_startblock = XFS_AGB_TO_FSB(mp, agno, agbno); > new->xefi_blockcount = 1; > new->xefi_oinfo = *oinfo; > diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c > index 9fbdca183465..37596e49b92e 100644 > --- a/fs/xfs/libxfs/xfs_bmap.c > +++ b/fs/xfs/libxfs/xfs_bmap.c > @@ -554,7 +554,8 @@ __xfs_bmap_add_free( > #endif > ASSERT(xfs_bmap_free_item_zone != NULL); > > - new = kmem_zone_alloc(xfs_bmap_free_item_zone, 0); > + new = kmem_cache_alloc(xfs_bmap_free_item_zone, > + GFP_KERNEL | __GFP_NOFAIL); > new->xefi_startblock = bno; > new->xefi_blockcount = (xfs_extlen_t)len; > if (oinfo) > diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c > index 950e8a51ec66..985f48e3795f 100644 > --- a/fs/xfs/xfs_icache.c > +++ b/fs/xfs/xfs_icache.c > @@ -40,7 +40,7 @@ xfs_inode_alloc( > * KM_MAYFAIL and return NULL here on ENOMEM. Set the Comment needs updating. How about: /* * If this didn't occur in transactions, we could omit * __GFP_NOFAIL and return NULL here on ENOMEM. Set the * code up to do this anyway. */ Looks ok other than that, though even with the full series applied I still see a few mentions of KM_* flags in comments. --D > * code up to do this anyway. > */ > - ip = kmem_zone_alloc(xfs_inode_zone, 0); > + ip = kmem_cache_alloc(xfs_inode_zone, GFP_KERNEL | __GFP_NOFAIL); > if (!ip) > return NULL; > if (inode_init_always(mp->m_super, VFS_I(ip))) { > diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h > index c13bb3655e48..192f499ccd7e 100644 > --- a/fs/xfs/xfs_trace.h > +++ b/fs/xfs/xfs_trace.h > @@ -3571,7 +3571,6 @@ DEFINE_KMEM_EVENT(kmem_alloc); > DEFINE_KMEM_EVENT(kmem_alloc_io); > DEFINE_KMEM_EVENT(kmem_alloc_large); > DEFINE_KMEM_EVENT(kmem_realloc); > -DEFINE_KMEM_EVENT(kmem_zone_alloc); > > #endif /* _TRACE_XFS_H */ > > -- > 2.23.0 >