From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Carlos Maiolino <cmaiolino@redhat.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 05/11] xfs: Remove kmem_zone_alloc() wrapper
Date: Wed, 13 Nov 2019 10:12:18 -0800 [thread overview]
Message-ID: <20191113181218.GF6219@magnolia> (raw)
In-Reply-To: <20191113172820.GB6219@magnolia>
On Wed, Nov 13, 2019 at 09:28:20AM -0800, Darrick J. Wong wrote:
> On Wed, Nov 13, 2019 at 03:23:29PM +0100, Carlos Maiolino wrote:
> > Use kmem_cache_alloc() directly.
> >
> > Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
> > ---
> > 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@oracle.com>
Bah, I got the logic backwards. Why is it ok to remove this retry
loop?
/me hands himself another cup of coffee and says to see the reply to
patch #9.
--D
> --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
> >
next prev parent reply other threads:[~2019-11-13 18:12 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-13 14:23 [PATCH 00/11] Use generic memory API instead of a custom one Carlos Maiolino
2019-11-13 14:23 ` [PATCH 01/11] xfs: Remove slab init wrappers Carlos Maiolino
2019-11-13 17:06 ` Darrick J. Wong
2019-11-13 14:23 ` [PATCH 02/11] xfs: Remove kmem_zone_destroy() wrapper Carlos Maiolino
2019-11-13 17:06 ` Darrick J. Wong
2019-11-13 14:23 ` [PATCH 03/11] xfs: Remove kmem_zone_free() wrapper Carlos Maiolino
2019-11-13 17:08 ` Darrick J. Wong
2019-11-13 14:23 ` [PATCH 04/11] xfs: remove kmem_zone_zalloc() Carlos Maiolino
2019-11-13 17:18 ` Darrick J. Wong
2019-11-13 20:27 ` Carlos Maiolino
2019-11-13 14:23 ` [PATCH 05/11] xfs: Remove kmem_zone_alloc() wrapper Carlos Maiolino
2019-11-13 17:28 ` Darrick J. Wong
2019-11-13 18:12 ` Darrick J. Wong [this message]
2019-11-13 14:23 ` [PATCH 06/11] xfs: remove kmem_zalloc() wrapper Carlos Maiolino
2019-11-13 17:34 ` Darrick J. Wong
2019-11-13 14:23 ` [PATCH 07/11] xfs: Remove kmem_realloc Carlos Maiolino
2019-11-13 17:40 ` Darrick J. Wong
2019-11-13 18:10 ` Darrick J. Wong
2019-11-13 14:23 ` [PATCH 08/11] xfs: Convert kmem_alloc() users Carlos Maiolino
2019-11-13 17:49 ` Darrick J. Wong
2019-11-13 14:23 ` [PATCH 09/11] xfs: rework kmem_alloc_{io,large} to use GFP_* flags Carlos Maiolino
2019-11-13 18:08 ` Darrick J. Wong
2019-11-13 19:56 ` Dave Chinner
2019-11-14 9:40 ` Carlos Maiolino
2019-11-14 10:31 ` Carlos Maiolino
2019-11-13 14:23 ` [PATCH 10/11] xfs: Remove KM_* flags Carlos Maiolino
2019-11-13 18:14 ` Darrick J. Wong
2019-11-13 14:23 ` [PATCH 11/11] xfs: Remove kmem_alloc_{io, large} and kmem_zalloc_large Carlos Maiolino
2019-11-13 18:23 ` Darrick J. Wong
2019-11-13 20:06 ` Dave Chinner
2019-11-13 20:43 ` Eric Sandeen
2019-11-14 9:46 ` Carlos Maiolino
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191113181218.GF6219@magnolia \
--to=darrick.wong@oracle.com \
--cc=cmaiolino@redhat.com \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox