From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Carlos Maiolino <cmaiolino@redhat.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 01/11] xfs: Remove slab init wrappers
Date: Wed, 13 Nov 2019 09:06:18 -0800 [thread overview]
Message-ID: <20191113170618.GX6219@magnolia> (raw)
In-Reply-To: <20191113142335.1045631-2-cmaiolino@redhat.com>
On Wed, Nov 13, 2019 at 03:23:25PM +0100, Carlos Maiolino wrote:
> Remove kmem_zone_init() and kmem_zone_init_flags() together with their
> specific KM_* to SLAB_* flag wrappers.
>
> Use kmem_cache_create() directly.
>
> Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
--D
> ---
> fs/xfs/kmem.h | 18 ---------
> fs/xfs/xfs_buf.c | 5 ++-
> fs/xfs/xfs_dquot.c | 10 +++--
> fs/xfs/xfs_super.c | 99 +++++++++++++++++++++++++++-------------------
> 4 files changed, 68 insertions(+), 64 deletions(-)
>
> diff --git a/fs/xfs/kmem.h b/fs/xfs/kmem.h
> index 8170d95cf930..15c5800128b3 100644
> --- a/fs/xfs/kmem.h
> +++ b/fs/xfs/kmem.h
> @@ -78,27 +78,9 @@ kmem_zalloc_large(size_t size, xfs_km_flags_t flags)
> * Zone interfaces
> */
>
> -#define KM_ZONE_HWALIGN SLAB_HWCACHE_ALIGN
> -#define KM_ZONE_RECLAIM SLAB_RECLAIM_ACCOUNT
> -#define KM_ZONE_SPREAD SLAB_MEM_SPREAD
> -#define KM_ZONE_ACCOUNT SLAB_ACCOUNT
> -
> #define kmem_zone kmem_cache
> #define kmem_zone_t struct kmem_cache
>
> -static inline kmem_zone_t *
> -kmem_zone_init(int size, char *zone_name)
> -{
> - return kmem_cache_create(zone_name, size, 0, 0, NULL);
> -}
> -
> -static inline kmem_zone_t *
> -kmem_zone_init_flags(int size, char *zone_name, slab_flags_t flags,
> - void (*construct)(void *))
> -{
> - return kmem_cache_create(zone_name, size, 0, flags, construct);
> -}
> -
> static inline void
> kmem_zone_free(kmem_zone_t *zone, void *ptr)
> {
> diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
> index 2ed3c65c602f..3741f5b369de 100644
> --- a/fs/xfs/xfs_buf.c
> +++ b/fs/xfs/xfs_buf.c
> @@ -2060,8 +2060,9 @@ xfs_buf_delwri_pushbuf(
> int __init
> xfs_buf_init(void)
> {
> - xfs_buf_zone = kmem_zone_init_flags(sizeof(xfs_buf_t), "xfs_buf",
> - KM_ZONE_HWALIGN, NULL);
> + xfs_buf_zone = kmem_cache_create("xfs_buf",
> + sizeof(struct xfs_buf), 0,
> + SLAB_HWCACHE_ALIGN, NULL);
> if (!xfs_buf_zone)
> goto out;
>
> diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
> index bcd4247b5014..90dd1623de5a 100644
> --- a/fs/xfs/xfs_dquot.c
> +++ b/fs/xfs/xfs_dquot.c
> @@ -1211,13 +1211,15 @@ xfs_dqlock2(
> int __init
> xfs_qm_init(void)
> {
> - xfs_qm_dqzone =
> - kmem_zone_init(sizeof(struct xfs_dquot), "xfs_dquot");
> + xfs_qm_dqzone = kmem_cache_create("xfs_dquot",
> + sizeof(struct xfs_dquot),
> + 0, 0, NULL);
> if (!xfs_qm_dqzone)
> goto out;
>
> - xfs_qm_dqtrxzone =
> - kmem_zone_init(sizeof(struct xfs_dquot_acct), "xfs_dqtrx");
> + xfs_qm_dqtrxzone = kmem_cache_create("xfs_dqtrx",
> + sizeof(struct xfs_dquot_acct),
> + 0, 0, NULL);
> if (!xfs_qm_dqtrxzone)
> goto out_free_dqzone;
>
> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> index 7f1fc76376f5..d3c3f7b5bdcf 100644
> --- a/fs/xfs/xfs_super.c
> +++ b/fs/xfs/xfs_super.c
> @@ -1797,32 +1797,39 @@ MODULE_ALIAS_FS("xfs");
> STATIC int __init
> xfs_init_zones(void)
> {
> - xfs_log_ticket_zone = kmem_zone_init(sizeof(xlog_ticket_t),
> - "xfs_log_ticket");
> + xfs_log_ticket_zone = kmem_cache_create("xfs_log_ticket",
> + sizeof(struct xlog_ticket),
> + 0, 0, NULL);
> if (!xfs_log_ticket_zone)
> goto out;
>
> - xfs_bmap_free_item_zone = kmem_zone_init(
> - sizeof(struct xfs_extent_free_item),
> - "xfs_bmap_free_item");
> + xfs_bmap_free_item_zone = kmem_cache_create("xfs_bmap_free_item",
> + sizeof(struct xfs_extent_free_item),
> + 0, 0, NULL);
> if (!xfs_bmap_free_item_zone)
> goto out_destroy_log_ticket_zone;
>
> - xfs_btree_cur_zone = kmem_zone_init(sizeof(xfs_btree_cur_t),
> - "xfs_btree_cur");
> + xfs_btree_cur_zone = kmem_cache_create("xfs_btree_cur",
> + sizeof(struct xfs_btree_cur),
> + 0, 0, NULL);
> if (!xfs_btree_cur_zone)
> goto out_destroy_bmap_free_item_zone;
>
> - xfs_da_state_zone = kmem_zone_init(sizeof(xfs_da_state_t),
> - "xfs_da_state");
> + xfs_da_state_zone = kmem_cache_create("xfs_da_state",
> + sizeof(struct xfs_da_state),
> + 0, 0, NULL);
> if (!xfs_da_state_zone)
> goto out_destroy_btree_cur_zone;
>
> - xfs_ifork_zone = kmem_zone_init(sizeof(struct xfs_ifork), "xfs_ifork");
> + xfs_ifork_zone = kmem_cache_create("xfs_ifork",
> + sizeof(struct xfs_ifork),
> + 0, 0, NULL);
> if (!xfs_ifork_zone)
> goto out_destroy_da_state_zone;
>
> - xfs_trans_zone = kmem_zone_init(sizeof(xfs_trans_t), "xfs_trans");
> + xfs_trans_zone = kmem_cache_create("xf_trans",
> + sizeof(struct xfs_trans),
> + 0, 0, NULL);
> if (!xfs_trans_zone)
> goto out_destroy_ifork_zone;
>
> @@ -1832,70 +1839,82 @@ xfs_init_zones(void)
> * size possible under XFS. This wastes a little bit of memory,
> * but it is much faster.
> */
> - xfs_buf_item_zone = kmem_zone_init(sizeof(struct xfs_buf_log_item),
> - "xfs_buf_item");
> + xfs_buf_item_zone = kmem_cache_create("xfs_buf_item",
> + sizeof(struct xfs_buf_log_item),
> + 0, 0, NULL);
> if (!xfs_buf_item_zone)
> goto out_destroy_trans_zone;
>
> - xfs_efd_zone = kmem_zone_init((sizeof(xfs_efd_log_item_t) +
> - ((XFS_EFD_MAX_FAST_EXTENTS - 1) *
> - sizeof(xfs_extent_t))), "xfs_efd_item");
> + xfs_efd_zone = kmem_cache_create("xfs_efd_item",
> + (sizeof(struct xfs_efd_log_item) +
> + (XFS_EFD_MAX_FAST_EXTENTS - 1) *
> + sizeof(struct xfs_extent)),
> + 0, 0, NULL);
> if (!xfs_efd_zone)
> goto out_destroy_buf_item_zone;
>
> - xfs_efi_zone = kmem_zone_init((sizeof(xfs_efi_log_item_t) +
> - ((XFS_EFI_MAX_FAST_EXTENTS - 1) *
> - sizeof(xfs_extent_t))), "xfs_efi_item");
> + xfs_efi_zone = kmem_cache_create("xfs_efi_item",
> + (sizeof(struct xfs_efi_log_item) +
> + (XFS_EFI_MAX_FAST_EXTENTS - 1) *
> + sizeof(struct xfs_extent)),
> + 0, 0, NULL);
> if (!xfs_efi_zone)
> goto out_destroy_efd_zone;
>
> - xfs_inode_zone =
> - kmem_zone_init_flags(sizeof(xfs_inode_t), "xfs_inode",
> - KM_ZONE_HWALIGN | KM_ZONE_RECLAIM | KM_ZONE_SPREAD |
> - KM_ZONE_ACCOUNT, xfs_fs_inode_init_once);
> + xfs_inode_zone = kmem_cache_create("xfs_inode",
> + sizeof(struct xfs_inode), 0,
> + (SLAB_HWCACHE_ALIGN |
> + SLAB_RECLAIM_ACCOUNT |
> + SLAB_MEM_SPREAD | SLAB_ACCOUNT),
> + xfs_fs_inode_init_once);
> if (!xfs_inode_zone)
> goto out_destroy_efi_zone;
>
> - xfs_ili_zone =
> - kmem_zone_init_flags(sizeof(xfs_inode_log_item_t), "xfs_ili",
> - KM_ZONE_SPREAD, NULL);
> + xfs_ili_zone = kmem_cache_create("xfs_ili",
> + sizeof(struct xfs_inode_log_item), 0,
> + SLAB_MEM_SPREAD, NULL);
> if (!xfs_ili_zone)
> goto out_destroy_inode_zone;
> - xfs_icreate_zone = kmem_zone_init(sizeof(struct xfs_icreate_item),
> - "xfs_icr");
> +
> + xfs_icreate_zone = kmem_cache_create("xfs_icr",
> + sizeof(struct xfs_icreate_item),
> + 0, 0, NULL);
> if (!xfs_icreate_zone)
> goto out_destroy_ili_zone;
>
> - xfs_rud_zone = kmem_zone_init(sizeof(struct xfs_rud_log_item),
> - "xfs_rud_item");
> + xfs_rud_zone = kmem_cache_create("xfs_rud_item",
> + sizeof(struct xfs_rud_log_item),
> + 0, 0, NULL);
> if (!xfs_rud_zone)
> goto out_destroy_icreate_zone;
>
> - xfs_rui_zone = kmem_zone_init(
> + xfs_rui_zone = kmem_cache_create("xfs_rui_item",
> xfs_rui_log_item_sizeof(XFS_RUI_MAX_FAST_EXTENTS),
> - "xfs_rui_item");
> + 0, 0, NULL);
> if (!xfs_rui_zone)
> goto out_destroy_rud_zone;
>
> - xfs_cud_zone = kmem_zone_init(sizeof(struct xfs_cud_log_item),
> - "xfs_cud_item");
> + xfs_cud_zone = kmem_cache_create("xfs_cud_item",
> + sizeof(struct xfs_cud_log_item),
> + 0, 0, NULL);
> if (!xfs_cud_zone)
> goto out_destroy_rui_zone;
>
> - xfs_cui_zone = kmem_zone_init(
> + xfs_cui_zone = kmem_cache_create("xfs_cui_item",
> xfs_cui_log_item_sizeof(XFS_CUI_MAX_FAST_EXTENTS),
> - "xfs_cui_item");
> + 0, 0, NULL);
> if (!xfs_cui_zone)
> goto out_destroy_cud_zone;
>
> - xfs_bud_zone = kmem_zone_init(sizeof(struct xfs_bud_log_item),
> - "xfs_bud_item");
> + xfs_bud_zone = kmem_cache_create("xfs_bud_item",
> + sizeof(struct xfs_bud_log_item),
> + 0, 0, NULL);
> if (!xfs_bud_zone)
> goto out_destroy_cui_zone;
>
> - xfs_bui_zone = kmem_zone_init(
> + xfs_bui_zone = kmem_cache_create("xfs_bui_item",
> xfs_bui_log_item_sizeof(XFS_BUI_MAX_FAST_EXTENTS),
> - "xfs_bui_item");
> + 0, 0, NULL);
> if (!xfs_bui_zone)
> goto out_destroy_bud_zone;
>
> --
> 2.23.0
>
next prev parent reply other threads:[~2019-11-13 17:08 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 [this message]
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
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=20191113170618.GX6219@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