Linux-XFS Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 0/4] Get rid of pointless wrappers
@ 2019-11-14 20:09 Carlos Maiolino
  2019-11-14 20:09 ` [PATCH 1/4] xfs: Remove slab init wrappers Carlos Maiolino
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Carlos Maiolino @ 2019-11-14 20:09 UTC (permalink / raw)
  To: linux-xfs

As agreed on the first version of the series to cleanup kmem_* wrappers and KM_*
flags, we've decided to split the whole work into 3 parts.

This is the first one, containing the removal of wrappers which are pointless,
requiring no logic change and no flag change, just replacing the kmem_* callers
by the proper generic memory allocation helpers.

All first 3 patches already have the reviewed-by, the last one is a new patch,
removing kmem_free() and converting their users to use kfree() directly, or
kvfree(), for those users which memory have been allocated by kmem_alloc_io() or
kmem_alloc_large().

Cheers

Carlos Maiolino (4):
  xfs: Remove slab init wrappers
  xfs: Remove kmem_zone_destroy() wrapper
  xfs: Remove kmem_zone_free() wrapper
  xfs: Remove kmem_free()

 fs/xfs/kmem.h                  |  35 -------
 fs/xfs/libxfs/xfs_attr.c       |   2 +-
 fs/xfs/libxfs/xfs_attr_leaf.c  |   8 +-
 fs/xfs/libxfs/xfs_btree.c      |   2 +-
 fs/xfs/libxfs/xfs_da_btree.c   |  12 +--
 fs/xfs/libxfs/xfs_defer.c      |   4 +-
 fs/xfs/libxfs/xfs_dir2.c       |  18 ++--
 fs/xfs/libxfs/xfs_dir2_block.c |   4 +-
 fs/xfs/libxfs/xfs_dir2_sf.c    |   8 +-
 fs/xfs/libxfs/xfs_iext_tree.c  |   8 +-
 fs/xfs/libxfs/xfs_inode_fork.c |  16 +--
 fs/xfs/libxfs/xfs_refcount.c   |   4 +-
 fs/xfs/scrub/agheader.c        |   2 +-
 fs/xfs/scrub/agheader_repair.c |   2 +-
 fs/xfs/scrub/attr.c            |   2 +-
 fs/xfs/scrub/bitmap.c          |   4 +-
 fs/xfs/scrub/btree.c           |   2 +-
 fs/xfs/scrub/refcount.c        |   8 +-
 fs/xfs/scrub/scrub.c           |   2 +-
 fs/xfs/xfs_acl.c               |   4 +-
 fs/xfs/xfs_attr_inactive.c     |   2 +-
 fs/xfs/xfs_attr_list.c         |   4 +-
 fs/xfs/xfs_bmap_item.c         |   8 +-
 fs/xfs/xfs_buf.c               |  25 ++---
 fs/xfs/xfs_buf_item.c          |   8 +-
 fs/xfs/xfs_dquot.c             |  20 ++--
 fs/xfs/xfs_dquot_item.c        |   8 +-
 fs/xfs/xfs_error.c             |   2 +-
 fs/xfs/xfs_extent_busy.c       |   2 +-
 fs/xfs/xfs_extfree_item.c      |  18 ++--
 fs/xfs/xfs_filestream.c        |   4 +-
 fs/xfs/xfs_icache.c            |   4 +-
 fs/xfs/xfs_icreate_item.c      |   2 +-
 fs/xfs/xfs_inode.c             |  12 +--
 fs/xfs/xfs_inode_item.c        |   4 +-
 fs/xfs/xfs_ioctl.c             |   6 +-
 fs/xfs/xfs_ioctl32.c           |   2 +-
 fs/xfs/xfs_iops.c              |   2 +-
 fs/xfs/xfs_itable.c            |   4 +-
 fs/xfs/xfs_iwalk.c             |   4 +-
 fs/xfs/xfs_log.c               |  14 +--
 fs/xfs/xfs_log_cil.c           |  16 +--
 fs/xfs/xfs_log_recover.c       |  50 +++++-----
 fs/xfs/xfs_mount.c             |   8 +-
 fs/xfs/xfs_mru_cache.c         |   8 +-
 fs/xfs/xfs_qm.c                |   6 +-
 fs/xfs/xfs_refcount_item.c     |  10 +-
 fs/xfs/xfs_rmap_item.c         |  10 +-
 fs/xfs/xfs_rtalloc.c           |   8 +-
 fs/xfs/xfs_super.c             | 171 ++++++++++++++++++---------------
 fs/xfs/xfs_trans.c             |   2 +-
 fs/xfs/xfs_trans_ail.c         |   4 +-
 fs/xfs/xfs_trans_dquot.c       |   2 +-
 53 files changed, 292 insertions(+), 305 deletions(-)

-- 
2.23.0


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/4] xfs: Remove slab init wrappers
  2019-11-14 20:09 [PATCH 0/4] Get rid of pointless wrappers Carlos Maiolino
@ 2019-11-14 20:09 ` Carlos Maiolino
  2019-11-14 20:09 ` [PATCH 2/4] xfs: Remove kmem_zone_destroy() wrapper Carlos Maiolino
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 14+ messages in thread
From: Carlos Maiolino @ 2019-11-14 20:09 UTC (permalink / raw)
  To: linux-xfs

Remove kmem_zone_init() and kmem_zone_init_flags() together with their
specific KM_* to SLAB_* flag wrappers.

Use kmem_cache_create() directly.

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
---
 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


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 2/4] xfs: Remove kmem_zone_destroy() wrapper
  2019-11-14 20:09 [PATCH 0/4] Get rid of pointless wrappers Carlos Maiolino
  2019-11-14 20:09 ` [PATCH 1/4] xfs: Remove slab init wrappers Carlos Maiolino
@ 2019-11-14 20:09 ` Carlos Maiolino
  2019-11-14 20:09 ` [PATCH 3/4] xfs: Remove kmem_zone_free() wrapper Carlos Maiolino
  2019-11-14 20:09 ` [PATCH 4/4] xfs: Remove kmem_free() Carlos Maiolino
  3 siblings, 0 replies; 14+ messages in thread
From: Carlos Maiolino @ 2019-11-14 20:09 UTC (permalink / raw)
  To: linux-xfs

Use kmem_cache_destroy directly

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
---
 fs/xfs/kmem.h      |  6 ----
 fs/xfs/xfs_buf.c   |  2 +-
 fs/xfs/xfs_dquot.c |  6 ++--
 fs/xfs/xfs_super.c | 70 +++++++++++++++++++++++-----------------------
 4 files changed, 39 insertions(+), 45 deletions(-)

diff --git a/fs/xfs/kmem.h b/fs/xfs/kmem.h
index 15c5800128b3..70ed74c7f37e 100644
--- a/fs/xfs/kmem.h
+++ b/fs/xfs/kmem.h
@@ -87,12 +87,6 @@ kmem_zone_free(kmem_zone_t *zone, void *ptr)
 	kmem_cache_free(zone, ptr);
 }
 
-static inline void
-kmem_zone_destroy(kmem_zone_t *zone)
-{
-	kmem_cache_destroy(zone);
-}
-
 extern void *kmem_zone_alloc(kmem_zone_t *, xfs_km_flags_t);
 
 static inline void *
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 3741f5b369de..ccccfb792ff8 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -2075,7 +2075,7 @@ xfs_buf_init(void)
 void
 xfs_buf_terminate(void)
 {
-	kmem_zone_destroy(xfs_buf_zone);
+	kmem_cache_destroy(xfs_buf_zone);
 }
 
 void xfs_buf_set_ref(struct xfs_buf *bp, int lru_ref)
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index 90dd1623de5a..4f969d94fb74 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -1226,7 +1226,7 @@ xfs_qm_init(void)
 	return 0;
 
 out_free_dqzone:
-	kmem_zone_destroy(xfs_qm_dqzone);
+	kmem_cache_destroy(xfs_qm_dqzone);
 out:
 	return -ENOMEM;
 }
@@ -1234,8 +1234,8 @@ xfs_qm_init(void)
 void
 xfs_qm_exit(void)
 {
-	kmem_zone_destroy(xfs_qm_dqtrxzone);
-	kmem_zone_destroy(xfs_qm_dqzone);
+	kmem_cache_destroy(xfs_qm_dqtrxzone);
+	kmem_cache_destroy(xfs_qm_dqzone);
 }
 
 /*
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index d3c3f7b5bdcf..d9ae27ddf253 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1921,39 +1921,39 @@ xfs_init_zones(void)
 	return 0;
 
  out_destroy_bud_zone:
-	kmem_zone_destroy(xfs_bud_zone);
+	kmem_cache_destroy(xfs_bud_zone);
  out_destroy_cui_zone:
-	kmem_zone_destroy(xfs_cui_zone);
+	kmem_cache_destroy(xfs_cui_zone);
  out_destroy_cud_zone:
-	kmem_zone_destroy(xfs_cud_zone);
+	kmem_cache_destroy(xfs_cud_zone);
  out_destroy_rui_zone:
-	kmem_zone_destroy(xfs_rui_zone);
+	kmem_cache_destroy(xfs_rui_zone);
  out_destroy_rud_zone:
-	kmem_zone_destroy(xfs_rud_zone);
+	kmem_cache_destroy(xfs_rud_zone);
  out_destroy_icreate_zone:
-	kmem_zone_destroy(xfs_icreate_zone);
+	kmem_cache_destroy(xfs_icreate_zone);
  out_destroy_ili_zone:
-	kmem_zone_destroy(xfs_ili_zone);
+	kmem_cache_destroy(xfs_ili_zone);
  out_destroy_inode_zone:
-	kmem_zone_destroy(xfs_inode_zone);
+	kmem_cache_destroy(xfs_inode_zone);
  out_destroy_efi_zone:
-	kmem_zone_destroy(xfs_efi_zone);
+	kmem_cache_destroy(xfs_efi_zone);
  out_destroy_efd_zone:
-	kmem_zone_destroy(xfs_efd_zone);
+	kmem_cache_destroy(xfs_efd_zone);
  out_destroy_buf_item_zone:
-	kmem_zone_destroy(xfs_buf_item_zone);
+	kmem_cache_destroy(xfs_buf_item_zone);
  out_destroy_trans_zone:
-	kmem_zone_destroy(xfs_trans_zone);
+	kmem_cache_destroy(xfs_trans_zone);
  out_destroy_ifork_zone:
-	kmem_zone_destroy(xfs_ifork_zone);
+	kmem_cache_destroy(xfs_ifork_zone);
  out_destroy_da_state_zone:
-	kmem_zone_destroy(xfs_da_state_zone);
+	kmem_cache_destroy(xfs_da_state_zone);
  out_destroy_btree_cur_zone:
-	kmem_zone_destroy(xfs_btree_cur_zone);
+	kmem_cache_destroy(xfs_btree_cur_zone);
  out_destroy_bmap_free_item_zone:
-	kmem_zone_destroy(xfs_bmap_free_item_zone);
+	kmem_cache_destroy(xfs_bmap_free_item_zone);
  out_destroy_log_ticket_zone:
-	kmem_zone_destroy(xfs_log_ticket_zone);
+	kmem_cache_destroy(xfs_log_ticket_zone);
  out:
 	return -ENOMEM;
 }
@@ -1966,24 +1966,24 @@ xfs_destroy_zones(void)
 	 * destroy caches.
 	 */
 	rcu_barrier();
-	kmem_zone_destroy(xfs_bui_zone);
-	kmem_zone_destroy(xfs_bud_zone);
-	kmem_zone_destroy(xfs_cui_zone);
-	kmem_zone_destroy(xfs_cud_zone);
-	kmem_zone_destroy(xfs_rui_zone);
-	kmem_zone_destroy(xfs_rud_zone);
-	kmem_zone_destroy(xfs_icreate_zone);
-	kmem_zone_destroy(xfs_ili_zone);
-	kmem_zone_destroy(xfs_inode_zone);
-	kmem_zone_destroy(xfs_efi_zone);
-	kmem_zone_destroy(xfs_efd_zone);
-	kmem_zone_destroy(xfs_buf_item_zone);
-	kmem_zone_destroy(xfs_trans_zone);
-	kmem_zone_destroy(xfs_ifork_zone);
-	kmem_zone_destroy(xfs_da_state_zone);
-	kmem_zone_destroy(xfs_btree_cur_zone);
-	kmem_zone_destroy(xfs_bmap_free_item_zone);
-	kmem_zone_destroy(xfs_log_ticket_zone);
+	kmem_cache_destroy(xfs_bui_zone);
+	kmem_cache_destroy(xfs_bud_zone);
+	kmem_cache_destroy(xfs_cui_zone);
+	kmem_cache_destroy(xfs_cud_zone);
+	kmem_cache_destroy(xfs_rui_zone);
+	kmem_cache_destroy(xfs_rud_zone);
+	kmem_cache_destroy(xfs_icreate_zone);
+	kmem_cache_destroy(xfs_ili_zone);
+	kmem_cache_destroy(xfs_inode_zone);
+	kmem_cache_destroy(xfs_efi_zone);
+	kmem_cache_destroy(xfs_efd_zone);
+	kmem_cache_destroy(xfs_buf_item_zone);
+	kmem_cache_destroy(xfs_trans_zone);
+	kmem_cache_destroy(xfs_ifork_zone);
+	kmem_cache_destroy(xfs_da_state_zone);
+	kmem_cache_destroy(xfs_btree_cur_zone);
+	kmem_cache_destroy(xfs_bmap_free_item_zone);
+	kmem_cache_destroy(xfs_log_ticket_zone);
 }
 
 STATIC int __init
-- 
2.23.0


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 3/4] xfs: Remove kmem_zone_free() wrapper
  2019-11-14 20:09 [PATCH 0/4] Get rid of pointless wrappers Carlos Maiolino
  2019-11-14 20:09 ` [PATCH 1/4] xfs: Remove slab init wrappers Carlos Maiolino
  2019-11-14 20:09 ` [PATCH 2/4] xfs: Remove kmem_zone_destroy() wrapper Carlos Maiolino
@ 2019-11-14 20:09 ` Carlos Maiolino
  2019-11-14 20:09 ` [PATCH 4/4] xfs: Remove kmem_free() Carlos Maiolino
  3 siblings, 0 replies; 14+ messages in thread
From: Carlos Maiolino @ 2019-11-14 20:09 UTC (permalink / raw)
  To: linux-xfs

We can remove it now, without needing to rework the KM_ flags.

Use kmem_cache_free() directly.

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
---
 fs/xfs/kmem.h                  | 6 ------
 fs/xfs/libxfs/xfs_btree.c      | 2 +-
 fs/xfs/libxfs/xfs_da_btree.c   | 2 +-
 fs/xfs/libxfs/xfs_inode_fork.c | 8 ++++----
 fs/xfs/xfs_bmap_item.c         | 4 ++--
 fs/xfs/xfs_buf.c               | 6 +++---
 fs/xfs/xfs_buf_item.c          | 4 ++--
 fs/xfs/xfs_dquot.c             | 2 +-
 fs/xfs/xfs_extfree_item.c      | 4 ++--
 fs/xfs/xfs_icache.c            | 4 ++--
 fs/xfs/xfs_icreate_item.c      | 2 +-
 fs/xfs/xfs_inode_item.c        | 2 +-
 fs/xfs/xfs_log.c               | 2 +-
 fs/xfs/xfs_refcount_item.c     | 4 ++--
 fs/xfs/xfs_rmap_item.c         | 4 ++--
 fs/xfs/xfs_trans.c             | 2 +-
 fs/xfs/xfs_trans_dquot.c       | 2 +-
 17 files changed, 27 insertions(+), 33 deletions(-)

diff --git a/fs/xfs/kmem.h b/fs/xfs/kmem.h
index 70ed74c7f37e..6143117770e9 100644
--- a/fs/xfs/kmem.h
+++ b/fs/xfs/kmem.h
@@ -81,12 +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
 
-static inline void
-kmem_zone_free(kmem_zone_t *zone, void *ptr)
-{
-	kmem_cache_free(zone, ptr);
-}
-
 extern void *kmem_zone_alloc(kmem_zone_t *, xfs_km_flags_t);
 
 static inline void *
diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
index 98843f1258b8..ac0b78ea417b 100644
--- a/fs/xfs/libxfs/xfs_btree.c
+++ b/fs/xfs/libxfs/xfs_btree.c
@@ -384,7 +384,7 @@ xfs_btree_del_cursor(
 	/*
 	 * Free the cursor.
 	 */
-	kmem_zone_free(xfs_btree_cur_zone, cur);
+	kmem_cache_free(xfs_btree_cur_zone, cur);
 }
 
 /*
diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index 46b1c3fb305c..c5c0b73febae 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -107,7 +107,7 @@ xfs_da_state_free(xfs_da_state_t *state)
 #ifdef DEBUG
 	memset((char *)state, 0, sizeof(*state));
 #endif /* DEBUG */
-	kmem_zone_free(xfs_da_state_zone, state);
+	kmem_cache_free(xfs_da_state_zone, state);
 }
 
 void
diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
index 15d6f947620f..ad2b9c313fd2 100644
--- a/fs/xfs/libxfs/xfs_inode_fork.c
+++ b/fs/xfs/libxfs/xfs_inode_fork.c
@@ -120,10 +120,10 @@ xfs_iformat_fork(
 		break;
 	}
 	if (error) {
-		kmem_zone_free(xfs_ifork_zone, ip->i_afp);
+		kmem_cache_free(xfs_ifork_zone, ip->i_afp);
 		ip->i_afp = NULL;
 		if (ip->i_cowfp)
-			kmem_zone_free(xfs_ifork_zone, ip->i_cowfp);
+			kmem_cache_free(xfs_ifork_zone, ip->i_cowfp);
 		ip->i_cowfp = NULL;
 		xfs_idestroy_fork(ip, XFS_DATA_FORK);
 	}
@@ -531,10 +531,10 @@ xfs_idestroy_fork(
 	}
 
 	if (whichfork == XFS_ATTR_FORK) {
-		kmem_zone_free(xfs_ifork_zone, ip->i_afp);
+		kmem_cache_free(xfs_ifork_zone, ip->i_afp);
 		ip->i_afp = NULL;
 	} else if (whichfork == XFS_COW_FORK) {
-		kmem_zone_free(xfs_ifork_zone, ip->i_cowfp);
+		kmem_cache_free(xfs_ifork_zone, ip->i_cowfp);
 		ip->i_cowfp = NULL;
 	}
 }
diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c
index 243e5e0f82a3..ee6f4229cebc 100644
--- a/fs/xfs/xfs_bmap_item.c
+++ b/fs/xfs/xfs_bmap_item.c
@@ -35,7 +35,7 @@ void
 xfs_bui_item_free(
 	struct xfs_bui_log_item	*buip)
 {
-	kmem_zone_free(xfs_bui_zone, buip);
+	kmem_cache_free(xfs_bui_zone, buip);
 }
 
 /*
@@ -201,7 +201,7 @@ xfs_bud_item_release(
 	struct xfs_bud_log_item	*budp = BUD_ITEM(lip);
 
 	xfs_bui_release(budp->bud_buip);
-	kmem_zone_free(xfs_bud_zone, budp);
+	kmem_cache_free(xfs_bud_zone, budp);
 }
 
 static const struct xfs_item_ops xfs_bud_item_ops = {
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index ccccfb792ff8..a0229c368e78 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -238,7 +238,7 @@ _xfs_buf_alloc(
 	 */
 	error = xfs_buf_get_maps(bp, nmaps);
 	if (error)  {
-		kmem_zone_free(xfs_buf_zone, bp);
+		kmem_cache_free(xfs_buf_zone, bp);
 		return NULL;
 	}
 
@@ -328,7 +328,7 @@ xfs_buf_free(
 		kmem_free(bp->b_addr);
 	_xfs_buf_free_pages(bp);
 	xfs_buf_free_maps(bp);
-	kmem_zone_free(xfs_buf_zone, bp);
+	kmem_cache_free(xfs_buf_zone, bp);
 }
 
 /*
@@ -949,7 +949,7 @@ xfs_buf_get_uncached(
 	_xfs_buf_free_pages(bp);
  fail_free_buf:
 	xfs_buf_free_maps(bp);
-	kmem_zone_free(xfs_buf_zone, bp);
+	kmem_cache_free(xfs_buf_zone, bp);
  fail:
 	return NULL;
 }
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index 6b69e6137b2b..3458a1264a3f 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -763,7 +763,7 @@ xfs_buf_item_init(
 	error = xfs_buf_item_get_format(bip, bp->b_map_count);
 	ASSERT(error == 0);
 	if (error) {	/* to stop gcc throwing set-but-unused warnings */
-		kmem_zone_free(xfs_buf_item_zone, bip);
+		kmem_cache_free(xfs_buf_item_zone, bip);
 		return error;
 	}
 
@@ -939,7 +939,7 @@ xfs_buf_item_free(
 {
 	xfs_buf_item_free_format(bip);
 	kmem_free(bip->bli_item.li_lv_shadow);
-	kmem_zone_free(xfs_buf_item_zone, bip);
+	kmem_cache_free(xfs_buf_item_zone, bip);
 }
 
 /*
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index 4f969d94fb74..153815bf18fc 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -56,7 +56,7 @@ xfs_qm_dqdestroy(
 	mutex_destroy(&dqp->q_qlock);
 
 	XFS_STATS_DEC(dqp->q_mount, xs_qm_dquot);
-	kmem_zone_free(xfs_qm_dqzone, dqp);
+	kmem_cache_free(xfs_qm_dqzone, dqp);
 }
 
 /*
diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
index a05a1074e8f8..6ea847f6e298 100644
--- a/fs/xfs/xfs_extfree_item.c
+++ b/fs/xfs/xfs_extfree_item.c
@@ -39,7 +39,7 @@ xfs_efi_item_free(
 	if (efip->efi_format.efi_nextents > XFS_EFI_MAX_FAST_EXTENTS)
 		kmem_free(efip);
 	else
-		kmem_zone_free(xfs_efi_zone, efip);
+		kmem_cache_free(xfs_efi_zone, efip);
 }
 
 /*
@@ -244,7 +244,7 @@ xfs_efd_item_free(struct xfs_efd_log_item *efdp)
 	if (efdp->efd_format.efd_nextents > XFS_EFD_MAX_FAST_EXTENTS)
 		kmem_free(efdp);
 	else
-		kmem_zone_free(xfs_efd_zone, efdp);
+		kmem_cache_free(xfs_efd_zone, efdp);
 }
 
 /*
diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
index 944add5ff8e0..950e8a51ec66 100644
--- a/fs/xfs/xfs_icache.c
+++ b/fs/xfs/xfs_icache.c
@@ -44,7 +44,7 @@ xfs_inode_alloc(
 	if (!ip)
 		return NULL;
 	if (inode_init_always(mp->m_super, VFS_I(ip))) {
-		kmem_zone_free(xfs_inode_zone, ip);
+		kmem_cache_free(xfs_inode_zone, ip);
 		return NULL;
 	}
 
@@ -104,7 +104,7 @@ xfs_inode_free_callback(
 		ip->i_itemp = NULL;
 	}
 
-	kmem_zone_free(xfs_inode_zone, ip);
+	kmem_cache_free(xfs_inode_zone, ip);
 }
 
 static void
diff --git a/fs/xfs/xfs_icreate_item.c b/fs/xfs/xfs_icreate_item.c
index 3ebd1b7f49d8..490fee22b878 100644
--- a/fs/xfs/xfs_icreate_item.c
+++ b/fs/xfs/xfs_icreate_item.c
@@ -55,7 +55,7 @@ STATIC void
 xfs_icreate_item_release(
 	struct xfs_log_item	*lip)
 {
-	kmem_zone_free(xfs_icreate_zone, ICR_ITEM(lip));
+	kmem_cache_free(xfs_icreate_zone, ICR_ITEM(lip));
 }
 
 static const struct xfs_item_ops xfs_icreate_item_ops = {
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index 726aa3bfd6e8..3a62976291a1 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -667,7 +667,7 @@ xfs_inode_item_destroy(
 	xfs_inode_t	*ip)
 {
 	kmem_free(ip->i_itemp->ili_item.li_lv_shadow);
-	kmem_zone_free(xfs_ili_zone, ip->i_itemp);
+	kmem_cache_free(xfs_ili_zone, ip->i_itemp);
 }
 
 
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 3806674090ed..6a147c63a8a6 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -3468,7 +3468,7 @@ xfs_log_ticket_put(
 {
 	ASSERT(atomic_read(&ticket->t_ref) > 0);
 	if (atomic_dec_and_test(&ticket->t_ref))
-		kmem_zone_free(xfs_log_ticket_zone, ticket);
+		kmem_cache_free(xfs_log_ticket_zone, ticket);
 }
 
 xlog_ticket_t *
diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c
index d5708d40ad87..8eeed73928cd 100644
--- a/fs/xfs/xfs_refcount_item.c
+++ b/fs/xfs/xfs_refcount_item.c
@@ -34,7 +34,7 @@ xfs_cui_item_free(
 	if (cuip->cui_format.cui_nextents > XFS_CUI_MAX_FAST_EXTENTS)
 		kmem_free(cuip);
 	else
-		kmem_zone_free(xfs_cui_zone, cuip);
+		kmem_cache_free(xfs_cui_zone, cuip);
 }
 
 /*
@@ -206,7 +206,7 @@ xfs_cud_item_release(
 	struct xfs_cud_log_item	*cudp = CUD_ITEM(lip);
 
 	xfs_cui_release(cudp->cud_cuip);
-	kmem_zone_free(xfs_cud_zone, cudp);
+	kmem_cache_free(xfs_cud_zone, cudp);
 }
 
 static const struct xfs_item_ops xfs_cud_item_ops = {
diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c
index 02f84d9a511c..4911b68f95dd 100644
--- a/fs/xfs/xfs_rmap_item.c
+++ b/fs/xfs/xfs_rmap_item.c
@@ -34,7 +34,7 @@ xfs_rui_item_free(
 	if (ruip->rui_format.rui_nextents > XFS_RUI_MAX_FAST_EXTENTS)
 		kmem_free(ruip);
 	else
-		kmem_zone_free(xfs_rui_zone, ruip);
+		kmem_cache_free(xfs_rui_zone, ruip);
 }
 
 /*
@@ -229,7 +229,7 @@ xfs_rud_item_release(
 	struct xfs_rud_log_item	*rudp = RUD_ITEM(lip);
 
 	xfs_rui_release(rudp->rud_ruip);
-	kmem_zone_free(xfs_rud_zone, rudp);
+	kmem_cache_free(xfs_rud_zone, rudp);
 }
 
 static const struct xfs_item_ops xfs_rud_item_ops = {
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
index f4795fdb7389..3b208f9a865c 100644
--- a/fs/xfs/xfs_trans.c
+++ b/fs/xfs/xfs_trans.c
@@ -71,7 +71,7 @@ xfs_trans_free(
 	if (!(tp->t_flags & XFS_TRANS_NO_WRITECOUNT))
 		sb_end_intwrite(tp->t_mountp->m_super);
 	xfs_trans_free_dqinfo(tp);
-	kmem_zone_free(xfs_trans_zone, tp);
+	kmem_cache_free(xfs_trans_zone, tp);
 }
 
 /*
diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c
index 16457465833b..ff1c326826d3 100644
--- a/fs/xfs/xfs_trans_dquot.c
+++ b/fs/xfs/xfs_trans_dquot.c
@@ -872,6 +872,6 @@ xfs_trans_free_dqinfo(
 {
 	if (!tp->t_dqinfo)
 		return;
-	kmem_zone_free(xfs_qm_dqtrxzone, tp->t_dqinfo);
+	kmem_cache_free(xfs_qm_dqtrxzone, tp->t_dqinfo);
 	tp->t_dqinfo = NULL;
 }
-- 
2.23.0


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 4/4] xfs: Remove kmem_free()
  2019-11-14 20:09 [PATCH 0/4] Get rid of pointless wrappers Carlos Maiolino
                   ` (2 preceding siblings ...)
  2019-11-14 20:09 ` [PATCH 3/4] xfs: Remove kmem_zone_free() wrapper Carlos Maiolino
@ 2019-11-14 20:09 ` Carlos Maiolino
  2019-11-14 21:00   ` Darrick J. Wong
  3 siblings, 1 reply; 14+ messages in thread
From: Carlos Maiolino @ 2019-11-14 20:09 UTC (permalink / raw)
  To: linux-xfs

This can be replaced by direct calls to kfree() or kvfree() (whenever
allocation is done via kmem_alloc_io() or kmem_alloc_large().

This patch has been partially scripted. I used the following sed to
replace all kmem_free() calls by kfree()

 # find fs/xfs/ -type f -name '*.c' -o -name '*.h' | xargs sed -i \
   's/kmem_free/kfree/g'

And manually inspected kmem_alloc_io() and kmem_alloc_large() uses to
use kvfree() instead.

Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
---
 fs/xfs/kmem.h                  |  5 ----
 fs/xfs/libxfs/xfs_attr.c       |  2 +-
 fs/xfs/libxfs/xfs_attr_leaf.c  |  8 +++---
 fs/xfs/libxfs/xfs_da_btree.c   | 10 +++----
 fs/xfs/libxfs/xfs_defer.c      |  4 +--
 fs/xfs/libxfs/xfs_dir2.c       | 18 ++++++------
 fs/xfs/libxfs/xfs_dir2_block.c |  4 +--
 fs/xfs/libxfs/xfs_dir2_sf.c    |  8 +++---
 fs/xfs/libxfs/xfs_iext_tree.c  |  8 +++---
 fs/xfs/libxfs/xfs_inode_fork.c |  8 +++---
 fs/xfs/libxfs/xfs_refcount.c   |  4 +--
 fs/xfs/scrub/agheader.c        |  2 +-
 fs/xfs/scrub/agheader_repair.c |  2 +-
 fs/xfs/scrub/attr.c            |  2 +-
 fs/xfs/scrub/bitmap.c          |  4 +--
 fs/xfs/scrub/btree.c           |  2 +-
 fs/xfs/scrub/refcount.c        |  8 +++---
 fs/xfs/scrub/scrub.c           |  2 +-
 fs/xfs/xfs_acl.c               |  4 +--
 fs/xfs/xfs_attr_inactive.c     |  2 +-
 fs/xfs/xfs_attr_list.c         |  4 +--
 fs/xfs/xfs_bmap_item.c         |  4 +--
 fs/xfs/xfs_buf.c               | 12 ++++----
 fs/xfs/xfs_buf_item.c          |  4 +--
 fs/xfs/xfs_dquot.c             |  2 +-
 fs/xfs/xfs_dquot_item.c        |  8 +++---
 fs/xfs/xfs_error.c             |  2 +-
 fs/xfs/xfs_extent_busy.c       |  2 +-
 fs/xfs/xfs_extfree_item.c      | 14 +++++-----
 fs/xfs/xfs_filestream.c        |  4 +--
 fs/xfs/xfs_inode.c             | 12 ++++----
 fs/xfs/xfs_inode_item.c        |  2 +-
 fs/xfs/xfs_ioctl.c             |  6 ++--
 fs/xfs/xfs_ioctl32.c           |  2 +-
 fs/xfs/xfs_iops.c              |  2 +-
 fs/xfs/xfs_itable.c            |  4 +--
 fs/xfs/xfs_iwalk.c             |  4 +--
 fs/xfs/xfs_log.c               | 12 ++++----
 fs/xfs/xfs_log_cil.c           | 16 +++++------
 fs/xfs/xfs_log_recover.c       | 50 +++++++++++++++++-----------------
 fs/xfs/xfs_mount.c             |  8 +++---
 fs/xfs/xfs_mru_cache.c         |  8 +++---
 fs/xfs/xfs_qm.c                |  6 ++--
 fs/xfs/xfs_refcount_item.c     |  6 ++--
 fs/xfs/xfs_rmap_item.c         |  6 ++--
 fs/xfs/xfs_rtalloc.c           |  8 +++---
 fs/xfs/xfs_super.c             |  2 +-
 fs/xfs/xfs_trans_ail.c         |  4 +--
 48 files changed, 158 insertions(+), 163 deletions(-)

diff --git a/fs/xfs/kmem.h b/fs/xfs/kmem.h
index 6143117770e9..ccdc72519339 100644
--- a/fs/xfs/kmem.h
+++ b/fs/xfs/kmem.h
@@ -56,11 +56,6 @@ 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);
-}
-
 
 static inline void *
 kmem_zalloc(size_t size, xfs_km_flags_t flags)
diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
index 510ca6974604..bc8ca09e71d0 100644
--- a/fs/xfs/libxfs/xfs_attr.c
+++ b/fs/xfs/libxfs/xfs_attr.c
@@ -174,7 +174,7 @@ xfs_attr_get(
 	/* on error, we have to clean up allocated value buffers */
 	if (error) {
 		if (flags & ATTR_ALLOC) {
-			kmem_free(args.value);
+			kvfree(args.value);
 			*value = NULL;
 		}
 		return error;
diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
index 85ec5945d29f..795b9b21b64d 100644
--- a/fs/xfs/libxfs/xfs_attr_leaf.c
+++ b/fs/xfs/libxfs/xfs_attr_leaf.c
@@ -931,7 +931,7 @@ xfs_attr_shortform_to_leaf(
 	error = 0;
 	*leaf_bp = bp;
 out:
-	kmem_free(tmpbuffer);
+	kfree(tmpbuffer);
 	return error;
 }
 
@@ -1131,7 +1131,7 @@ xfs_attr3_leaf_to_shortform(
 	error = 0;
 
 out:
-	kmem_free(tmpbuffer);
+	kfree(tmpbuffer);
 	return error;
 }
 
@@ -1572,7 +1572,7 @@ xfs_attr3_leaf_compact(
 	 */
 	xfs_trans_log_buf(trans, bp, 0, args->geo->blksize - 1);
 
-	kmem_free(tmpbuffer);
+	kfree(tmpbuffer);
 }
 
 /*
@@ -2293,7 +2293,7 @@ xfs_attr3_leaf_unbalance(
 		}
 		memcpy(save_leaf, tmp_leaf, state->args->geo->blksize);
 		savehdr = tmphdr; /* struct copy */
-		kmem_free(tmp_leaf);
+		kfree(tmp_leaf);
 	}
 
 	xfs_attr3_leaf_hdr_to_disk(state->args->geo, save_leaf, &savehdr);
diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index c5c0b73febae..7ae82d91f776 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -2189,7 +2189,7 @@ xfs_da_grow_inode_int(
 
 out_free_map:
 	if (mapp != &map)
-		kmem_free(mapp);
+		kfree(mapp);
 	return error;
 }
 
@@ -2639,7 +2639,7 @@ xfs_dabuf_map(
 	error = xfs_buf_map_from_irec(mp, map, nmaps, irecs, nirecs);
 out:
 	if (irecs != &irec)
-		kmem_free(irecs);
+		kfree(irecs);
 	return error;
 }
 
@@ -2686,7 +2686,7 @@ xfs_da_get_buf(
 
 out_free:
 	if (mapp != &map)
-		kmem_free(mapp);
+		kfree(mapp);
 
 	return error;
 }
@@ -2735,7 +2735,7 @@ xfs_da_read_buf(
 	*bpp = bp;
 out_free:
 	if (mapp != &map)
-		kmem_free(mapp);
+		kfree(mapp);
 
 	return error;
 }
@@ -2772,7 +2772,7 @@ xfs_da_reada_buf(
 
 out_free:
 	if (mapp != &map)
-		kmem_free(mapp);
+		kfree(mapp);
 
 	return error;
 }
diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c
index 22557527cfdb..27c3d150068a 100644
--- a/fs/xfs/libxfs/xfs_defer.c
+++ b/fs/xfs/libxfs/xfs_defer.c
@@ -341,7 +341,7 @@ xfs_defer_cancel_list(
 			ops->cancel_item(pwi);
 		}
 		ASSERT(dfp->dfp_count == 0);
-		kmem_free(dfp);
+		kfree(dfp);
 	}
 }
 
@@ -433,7 +433,7 @@ xfs_defer_finish_noroll(
 		} else {
 			/* Done with the dfp, free it. */
 			list_del(&dfp->dfp_list);
-			kmem_free(dfp);
+			kfree(dfp);
 		}
 
 		if (ops->finish_cleanup)
diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c
index 624c05e77ab4..efd7cec65259 100644
--- a/fs/xfs/libxfs/xfs_dir2.c
+++ b/fs/xfs/libxfs/xfs_dir2.c
@@ -109,8 +109,8 @@ xfs_da_mount(
 	mp->m_attr_geo = kmem_zalloc(sizeof(struct xfs_da_geometry),
 				     KM_MAYFAIL);
 	if (!mp->m_dir_geo || !mp->m_attr_geo) {
-		kmem_free(mp->m_dir_geo);
-		kmem_free(mp->m_attr_geo);
+		kfree(mp->m_dir_geo);
+		kfree(mp->m_attr_geo);
 		return -ENOMEM;
 	}
 
@@ -176,8 +176,8 @@ void
 xfs_da_unmount(
 	struct xfs_mount	*mp)
 {
-	kmem_free(mp->m_dir_geo);
-	kmem_free(mp->m_attr_geo);
+	kfree(mp->m_dir_geo);
+	kfree(mp->m_attr_geo);
 }
 
 /*
@@ -242,7 +242,7 @@ xfs_dir_init(
 	args->dp = dp;
 	args->trans = tp;
 	error = xfs_dir2_sf_create(args, pdp->i_ino);
-	kmem_free(args);
+	kfree(args);
 	return error;
 }
 
@@ -311,7 +311,7 @@ xfs_dir_createname(
 		rval = xfs_dir2_node_addname(args);
 
 out_free:
-	kmem_free(args);
+	kfree(args);
 	return rval;
 }
 
@@ -417,7 +417,7 @@ xfs_dir_lookup(
 	}
 out_free:
 	xfs_iunlock(dp, lock_mode);
-	kmem_free(args);
+	kfree(args);
 	return rval;
 }
 
@@ -475,7 +475,7 @@ xfs_dir_removename(
 	else
 		rval = xfs_dir2_node_removename(args);
 out_free:
-	kmem_free(args);
+	kfree(args);
 	return rval;
 }
 
@@ -536,7 +536,7 @@ xfs_dir_replace(
 	else
 		rval = xfs_dir2_node_replace(args);
 out_free:
-	kmem_free(args);
+	kfree(args);
 	return rval;
 }
 
diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c
index 358151ddfa75..766f282b706a 100644
--- a/fs/xfs/libxfs/xfs_dir2_block.c
+++ b/fs/xfs/libxfs/xfs_dir2_block.c
@@ -1229,7 +1229,7 @@ xfs_dir2_sf_to_block(
 			sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep);
 	}
 	/* Done with the temporary buffer */
-	kmem_free(sfp);
+	kfree(sfp);
 	/*
 	 * Sort the leaf entries by hash value.
 	 */
@@ -1244,6 +1244,6 @@ xfs_dir2_sf_to_block(
 	xfs_dir3_data_check(dp, bp);
 	return 0;
 out_free:
-	kmem_free(sfp);
+	kfree(sfp);
 	return error;
 }
diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c
index db1a82972d9e..f4de4e7b10ef 100644
--- a/fs/xfs/libxfs/xfs_dir2_sf.c
+++ b/fs/xfs/libxfs/xfs_dir2_sf.c
@@ -350,7 +350,7 @@ xfs_dir2_block_to_sf(
 	xfs_dir2_sf_check(args);
 out:
 	xfs_trans_log_inode(args->trans, dp, logflags);
-	kmem_free(sfp);
+	kfree(sfp);
 	return error;
 }
 
@@ -585,7 +585,7 @@ xfs_dir2_sf_addname_hard(
 		sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep);
 		memcpy(sfep, oldsfep, old_isize - nbytes);
 	}
-	kmem_free(buf);
+	kfree(buf);
 	dp->i_d.di_size = new_isize;
 	xfs_dir2_sf_check(args);
 }
@@ -1202,7 +1202,7 @@ xfs_dir2_sf_toino4(
 	/*
 	 * Clean up the inode.
 	 */
-	kmem_free(buf);
+	kfree(buf);
 	dp->i_d.di_size = newsize;
 	xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA);
 }
@@ -1275,7 +1275,7 @@ xfs_dir2_sf_toino8(
 	/*
 	 * Clean up the inode.
 	 */
-	kmem_free(buf);
+	kfree(buf);
 	dp->i_d.di_size = newsize;
 	xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA);
 }
diff --git a/fs/xfs/libxfs/xfs_iext_tree.c b/fs/xfs/libxfs/xfs_iext_tree.c
index 52451809c478..a7ba30cd81da 100644
--- a/fs/xfs/libxfs/xfs_iext_tree.c
+++ b/fs/xfs/libxfs/xfs_iext_tree.c
@@ -734,7 +734,7 @@ xfs_iext_remove_node(
 again:
 	ASSERT(node->ptrs[pos]);
 	ASSERT(node->ptrs[pos] == victim);
-	kmem_free(victim);
+	kfree(victim);
 
 	nr_entries = xfs_iext_node_nr_entries(node, pos) - 1;
 	offset = node->keys[0];
@@ -780,7 +780,7 @@ xfs_iext_remove_node(
 		ASSERT(node == ifp->if_u1.if_root);
 		ifp->if_u1.if_root = node->ptrs[0];
 		ifp->if_height--;
-		kmem_free(node);
+		kfree(node);
 	}
 }
 
@@ -854,7 +854,7 @@ xfs_iext_free_last_leaf(
 	struct xfs_ifork	*ifp)
 {
 	ifp->if_height--;
-	kmem_free(ifp->if_u1.if_root);
+	kfree(ifp->if_u1.if_root);
 	ifp->if_u1.if_root = NULL;
 }
 
@@ -1035,7 +1035,7 @@ xfs_iext_destroy_node(
 		}
 	}
 
-	kmem_free(node);
+	kfree(node);
 }
 
 void
diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
index ad2b9c313fd2..296677958212 100644
--- a/fs/xfs/libxfs/xfs_inode_fork.c
+++ b/fs/xfs/libxfs/xfs_inode_fork.c
@@ -445,7 +445,7 @@ xfs_iroot_realloc(
 						     (int)new_size);
 		memcpy(np, op, new_max * (uint)sizeof(xfs_fsblock_t));
 	}
-	kmem_free(ifp->if_broot);
+	kfree(ifp->if_broot);
 	ifp->if_broot = new_broot;
 	ifp->if_broot_bytes = (int)new_size;
 	if (ifp->if_broot)
@@ -486,7 +486,7 @@ xfs_idata_realloc(
 		return;
 
 	if (new_size == 0) {
-		kmem_free(ifp->if_u1.if_data);
+		kfree(ifp->if_u1.if_data);
 		ifp->if_u1.if_data = NULL;
 		ifp->if_bytes = 0;
 		return;
@@ -511,7 +511,7 @@ xfs_idestroy_fork(
 
 	ifp = XFS_IFORK_PTR(ip, whichfork);
 	if (ifp->if_broot != NULL) {
-		kmem_free(ifp->if_broot);
+		kfree(ifp->if_broot);
 		ifp->if_broot = NULL;
 	}
 
@@ -523,7 +523,7 @@ xfs_idestroy_fork(
 	 */
 	if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL) {
 		if (ifp->if_u1.if_data != NULL) {
-			kmem_free(ifp->if_u1.if_data);
+			kfree(ifp->if_u1.if_data);
 			ifp->if_u1.if_data = NULL;
 		}
 	} else if ((ifp->if_flags & XFS_IFEXTENTS) && ifp->if_height) {
diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c
index 78236bd6c64f..07894c53e753 100644
--- a/fs/xfs/libxfs/xfs_refcount.c
+++ b/fs/xfs/libxfs/xfs_refcount.c
@@ -1684,7 +1684,7 @@ xfs_refcount_recover_cow_leftovers(
 			goto out_free;
 
 		list_del(&rr->rr_list);
-		kmem_free(rr);
+		kfree(rr);
 	}
 
 	return error;
@@ -1694,7 +1694,7 @@ xfs_refcount_recover_cow_leftovers(
 	/* Free the leftover list */
 	list_for_each_entry_safe(rr, n, &debris, rr_list) {
 		list_del(&rr->rr_list);
-		kmem_free(rr);
+		kfree(rr);
 	}
 	return error;
 }
diff --git a/fs/xfs/scrub/agheader.c b/fs/xfs/scrub/agheader.c
index ba0f747c82e8..6f7126f6d25c 100644
--- a/fs/xfs/scrub/agheader.c
+++ b/fs/xfs/scrub/agheader.c
@@ -753,7 +753,7 @@ xchk_agfl(
 	}
 
 out_free:
-	kmem_free(sai.entries);
+	kfree(sai.entries);
 out:
 	return error;
 }
diff --git a/fs/xfs/scrub/agheader_repair.c b/fs/xfs/scrub/agheader_repair.c
index 7a1a38b636a9..15fabf020d1b 100644
--- a/fs/xfs/scrub/agheader_repair.c
+++ b/fs/xfs/scrub/agheader_repair.c
@@ -624,7 +624,7 @@ xrep_agfl_init_header(
 		if (br->len)
 			break;
 		list_del(&br->list);
-		kmem_free(br);
+		kfree(br);
 	}
 
 	/* Write new AGFL to disk. */
diff --git a/fs/xfs/scrub/attr.c b/fs/xfs/scrub/attr.c
index d9f0dd444b80..7a2a240febc1 100644
--- a/fs/xfs/scrub/attr.c
+++ b/fs/xfs/scrub/attr.c
@@ -49,7 +49,7 @@ xchk_setup_xattr_buf(
 	if (ab) {
 		if (sz <= ab->sz)
 			return 0;
-		kmem_free(ab);
+		kvfree(ab);
 		sc->buf = NULL;
 	}
 
diff --git a/fs/xfs/scrub/bitmap.c b/fs/xfs/scrub/bitmap.c
index 18a684e18a69..cabde1c4c235 100644
--- a/fs/xfs/scrub/bitmap.c
+++ b/fs/xfs/scrub/bitmap.c
@@ -47,7 +47,7 @@ xfs_bitmap_destroy(
 
 	for_each_xfs_bitmap_extent(bmr, n, bitmap) {
 		list_del(&bmr->list);
-		kmem_free(bmr);
+		kfree(bmr);
 	}
 }
 
@@ -174,7 +174,7 @@ xfs_bitmap_disunion(
 			/* Total overlap, just delete ex. */
 			lp = lp->next;
 			list_del(&br->list);
-			kmem_free(br);
+			kfree(br);
 			break;
 		case 0:
 			/*
diff --git a/fs/xfs/scrub/btree.c b/fs/xfs/scrub/btree.c
index f52a7b8256f9..bed40b605076 100644
--- a/fs/xfs/scrub/btree.c
+++ b/fs/xfs/scrub/btree.c
@@ -698,7 +698,7 @@ xchk_btree(
 			error = xchk_btree_check_block_owner(&bs,
 					co->level, co->daddr);
 		list_del(&co->list);
-		kmem_free(co);
+		kfree(co);
 	}
 
 	return error;
diff --git a/fs/xfs/scrub/refcount.c b/fs/xfs/scrub/refcount.c
index 0cab11a5d390..985724e81ebf 100644
--- a/fs/xfs/scrub/refcount.c
+++ b/fs/xfs/scrub/refcount.c
@@ -215,7 +215,7 @@ xchk_refcountbt_process_rmap_fragments(
 				continue;
 			}
 			list_del(&frag->list);
-			kmem_free(frag);
+			kfree(frag);
 			nr++;
 		}
 
@@ -257,11 +257,11 @@ xchk_refcountbt_process_rmap_fragments(
 	/* Delete fragments and work list. */
 	list_for_each_entry_safe(frag, n, &worklist, list) {
 		list_del(&frag->list);
-		kmem_free(frag);
+		kfree(frag);
 	}
 	list_for_each_entry_safe(frag, n, &refchk->fragments, list) {
 		list_del(&frag->list);
-		kmem_free(frag);
+		kfree(frag);
 	}
 }
 
@@ -308,7 +308,7 @@ xchk_refcountbt_xref_rmap(
 out_free:
 	list_for_each_entry_safe(frag, n, &refchk.fragments, list) {
 		list_del(&frag->list);
-		kmem_free(frag);
+		kfree(frag);
 	}
 }
 
diff --git a/fs/xfs/scrub/scrub.c b/fs/xfs/scrub/scrub.c
index f1775bb19313..7c63cdf13946 100644
--- a/fs/xfs/scrub/scrub.c
+++ b/fs/xfs/scrub/scrub.c
@@ -175,7 +175,7 @@ xchk_teardown(
 		sc->flags &= ~XCHK_HAS_QUOTAOFFLOCK;
 	}
 	if (sc->buf) {
-		kmem_free(sc->buf);
+		kvfree(sc->buf);
 		sc->buf = NULL;
 	}
 	return error;
diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c
index 91693fce34a8..81b2c989242e 100644
--- a/fs/xfs/xfs_acl.c
+++ b/fs/xfs/xfs_acl.c
@@ -157,7 +157,7 @@ xfs_get_acl(struct inode *inode, int type)
 	} else  {
 		acl = xfs_acl_from_disk(ip->i_mount, xfs_acl, len,
 					XFS_ACL_MAX_ENTRIES(ip->i_mount));
-		kmem_free(xfs_acl);
+		kvfree(xfs_acl);
 	}
 	return acl;
 }
@@ -199,7 +199,7 @@ __xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
 		error = xfs_attr_set(ip, ea_name, (unsigned char *)xfs_acl,
 				len, ATTR_ROOT);
 
-		kmem_free(xfs_acl);
+		kvfree(xfs_acl);
 	} else {
 		/*
 		 * A NULL ACL argument means we want to remove the ACL.
diff --git a/fs/xfs/xfs_attr_inactive.c b/fs/xfs/xfs_attr_inactive.c
index a78c501f6fb1..8351b3b611ac 100644
--- a/fs/xfs/xfs_attr_inactive.c
+++ b/fs/xfs/xfs_attr_inactive.c
@@ -181,7 +181,7 @@ xfs_attr3_leaf_inactive(
 			error = tmp;	/* save only the 1st errno */
 	}
 
-	kmem_free(list);
+	kfree(list);
 	return error;
 }
 
diff --git a/fs/xfs/xfs_attr_list.c b/fs/xfs/xfs_attr_list.c
index 0ec6606149a2..e1d1c4eb9e69 100644
--- a/fs/xfs/xfs_attr_list.c
+++ b/fs/xfs/xfs_attr_list.c
@@ -131,7 +131,7 @@ xfs_attr_shortform_list(
 					     XFS_ERRLEVEL_LOW,
 					     context->dp->i_mount, sfe,
 					     sizeof(*sfe));
-			kmem_free(sbuf);
+			kfree(sbuf);
 			return -EFSCORRUPTED;
 		}
 
@@ -195,7 +195,7 @@ xfs_attr_shortform_list(
 		cursor->offset++;
 	}
 out:
-	kmem_free(sbuf);
+	kfree(sbuf);
 	return error;
 }
 
diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c
index ee6f4229cebc..a89e10519f05 100644
--- a/fs/xfs/xfs_bmap_item.c
+++ b/fs/xfs/xfs_bmap_item.c
@@ -391,7 +391,7 @@ xfs_bmap_update_finish_item(
 		bmap->bi_bmap.br_blockcount = count;
 		return -EAGAIN;
 	}
-	kmem_free(bmap);
+	kfree(bmap);
 	return error;
 }
 
@@ -411,7 +411,7 @@ xfs_bmap_update_cancel_item(
 	struct xfs_bmap_intent		*bmap;
 
 	bmap = container_of(item, struct xfs_bmap_intent, bi_list);
-	kmem_free(bmap);
+	kfree(bmap);
 }
 
 const struct xfs_defer_op_type xfs_bmap_update_defer_type = {
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index a0229c368e78..80ef2fc8bb77 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -193,7 +193,7 @@ xfs_buf_free_maps(
 	struct xfs_buf	*bp)
 {
 	if (bp->b_maps != &bp->__b_map) {
-		kmem_free(bp->b_maps);
+		kfree(bp->b_maps);
 		bp->b_maps = NULL;
 	}
 }
@@ -292,7 +292,7 @@ _xfs_buf_free_pages(
 	xfs_buf_t	*bp)
 {
 	if (bp->b_pages != bp->b_page_array) {
-		kmem_free(bp->b_pages);
+		kfree(bp->b_pages);
 		bp->b_pages = NULL;
 	}
 }
@@ -325,7 +325,7 @@ xfs_buf_free(
 			__free_page(page);
 		}
 	} else if (bp->b_flags & _XBF_KMEM)
-		kmem_free(bp->b_addr);
+		kvfree(bp->b_addr);
 	_xfs_buf_free_pages(bp);
 	xfs_buf_free_maps(bp);
 	kmem_cache_free(xfs_buf_zone, bp);
@@ -373,7 +373,7 @@ xfs_buf_allocate_memory(
 		if (((unsigned long)(bp->b_addr + size - 1) & PAGE_MASK) !=
 		    ((unsigned long)bp->b_addr & PAGE_MASK)) {
 			/* b_addr spans two pages - use alloc_page instead */
-			kmem_free(bp->b_addr);
+			kvfree(bp->b_addr);
 			bp->b_addr = NULL;
 			goto use_alloc_page;
 		}
@@ -1702,7 +1702,7 @@ xfs_free_buftarg(
 
 	xfs_blkdev_issue_flush(btp);
 
-	kmem_free(btp);
+	kfree(btp);
 }
 
 int
@@ -1778,7 +1778,7 @@ xfs_alloc_buftarg(
 error_lru:
 	list_lru_destroy(&btp->bt_lru);
 error_free:
-	kmem_free(btp);
+	kfree(btp);
 	return NULL;
 }
 
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index 3458a1264a3f..8dc3330f1797 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -713,7 +713,7 @@ xfs_buf_item_free_format(
 	struct xfs_buf_log_item	*bip)
 {
 	if (bip->bli_formats != &bip->__bli_format) {
-		kmem_free(bip->bli_formats);
+		kfree(bip->bli_formats);
 		bip->bli_formats = NULL;
 	}
 }
@@ -938,7 +938,7 @@ xfs_buf_item_free(
 	struct xfs_buf_log_item	*bip)
 {
 	xfs_buf_item_free_format(bip);
-	kmem_free(bip->bli_item.li_lv_shadow);
+	kfree(bip->bli_item.li_lv_shadow);
 	kmem_cache_free(xfs_buf_item_zone, bip);
 }
 
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index 153815bf18fc..a073281c3bd7 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -52,7 +52,7 @@ xfs_qm_dqdestroy(
 {
 	ASSERT(list_empty(&dqp->q_lru));
 
-	kmem_free(dqp->q_logitem.qli_item.li_lv_shadow);
+	kfree(dqp->q_logitem.qli_item.li_lv_shadow);
 	mutex_destroy(&dqp->q_qlock);
 
 	XFS_STATS_DEC(dqp->q_mount, xs_qm_dquot);
diff --git a/fs/xfs/xfs_dquot_item.c b/fs/xfs/xfs_dquot_item.c
index d60647d7197b..1b5e68ccef60 100644
--- a/fs/xfs/xfs_dquot_item.c
+++ b/fs/xfs/xfs_dquot_item.c
@@ -316,10 +316,10 @@ xfs_qm_qoffend_logitem_committed(
 	spin_lock(&ailp->ail_lock);
 	xfs_trans_ail_delete(ailp, &qfs->qql_item, SHUTDOWN_LOG_IO_ERROR);
 
-	kmem_free(qfs->qql_item.li_lv_shadow);
-	kmem_free(lip->li_lv_shadow);
-	kmem_free(qfs);
-	kmem_free(qfe);
+	kfree(qfs->qql_item.li_lv_shadow);
+	kfree(lip->li_lv_shadow);
+	kfree(qfs);
+	kfree(qfe);
 	return (xfs_lsn_t)-1;
 }
 
diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
index 51dd1f43d12f..4c0883380d7c 100644
--- a/fs/xfs/xfs_error.c
+++ b/fs/xfs/xfs_error.c
@@ -226,7 +226,7 @@ xfs_errortag_del(
 	struct xfs_mount	*mp)
 {
 	xfs_sysfs_del(&mp->m_errortag_kobj);
-	kmem_free(mp->m_errortag);
+	kfree(mp->m_errortag);
 }
 
 bool
diff --git a/fs/xfs/xfs_extent_busy.c b/fs/xfs/xfs_extent_busy.c
index 3991e59cfd18..9f0b99c7b34a 100644
--- a/fs/xfs/xfs_extent_busy.c
+++ b/fs/xfs/xfs_extent_busy.c
@@ -532,7 +532,7 @@ xfs_extent_busy_clear_one(
 	}
 
 	list_del_init(&busyp->list);
-	kmem_free(busyp);
+	kfree(busyp);
 }
 
 static void
diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
index 6ea847f6e298..29b3a90aee91 100644
--- a/fs/xfs/xfs_extfree_item.c
+++ b/fs/xfs/xfs_extfree_item.c
@@ -35,9 +35,9 @@ void
 xfs_efi_item_free(
 	struct xfs_efi_log_item	*efip)
 {
-	kmem_free(efip->efi_item.li_lv_shadow);
+	kfree(efip->efi_item.li_lv_shadow);
 	if (efip->efi_format.efi_nextents > XFS_EFI_MAX_FAST_EXTENTS)
-		kmem_free(efip);
+		kfree(efip);
 	else
 		kmem_cache_free(xfs_efi_zone, efip);
 }
@@ -240,9 +240,9 @@ static inline struct xfs_efd_log_item *EFD_ITEM(struct xfs_log_item *lip)
 STATIC void
 xfs_efd_item_free(struct xfs_efd_log_item *efdp)
 {
-	kmem_free(efdp->efd_item.li_lv_shadow);
+	kfree(efdp->efd_item.li_lv_shadow);
 	if (efdp->efd_format.efd_nextents > XFS_EFD_MAX_FAST_EXTENTS)
-		kmem_free(efdp);
+		kfree(efdp);
 	else
 		kmem_cache_free(xfs_efd_zone, efdp);
 }
@@ -488,7 +488,7 @@ xfs_extent_free_finish_item(
 			free->xefi_startblock,
 			free->xefi_blockcount,
 			&free->xefi_oinfo, free->xefi_skip_discard);
-	kmem_free(free);
+	kfree(free);
 	return error;
 }
 
@@ -508,7 +508,7 @@ xfs_extent_free_cancel_item(
 	struct xfs_extent_free_item	*free;
 
 	free = container_of(item, struct xfs_extent_free_item, xefi_list);
-	kmem_free(free);
+	kfree(free);
 }
 
 const struct xfs_defer_op_type xfs_extent_free_defer_type = {
@@ -572,7 +572,7 @@ xfs_agfl_free_finish_item(
 	extp->ext_len = free->xefi_blockcount;
 	efdp->efd_next_extent++;
 
-	kmem_free(free);
+	kfree(free);
 	return error;
 }
 
diff --git a/fs/xfs/xfs_filestream.c b/fs/xfs/xfs_filestream.c
index 2ae356775f63..9778e4e69e07 100644
--- a/fs/xfs/xfs_filestream.c
+++ b/fs/xfs/xfs_filestream.c
@@ -118,7 +118,7 @@ xfs_fstrm_free_func(
 	xfs_filestream_put_ag(mp, item->ag);
 	trace_xfs_filestream_free(mp, mru->key, item->ag);
 
-	kmem_free(item);
+	kfree(item);
 }
 
 /*
@@ -263,7 +263,7 @@ xfs_filestream_pick_ag(
 	return 0;
 
 out_free_item:
-	kmem_free(item);
+	kfree(item);
 out_put_ag:
 	xfs_filestream_put_ag(mp, *agp);
 	return err;
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index a92d4521748d..e1121ed7cbb5 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -708,7 +708,7 @@ xfs_lookup(
 
 out_free_name:
 	if (ci_name)
-		kmem_free(ci_name->name);
+		kfree(ci_name->name);
 out_unlock:
 	*ipp = NULL;
 	return error;
@@ -2001,7 +2001,7 @@ xfs_iunlink_insert_backref(
 	 */
 	if (error) {
 		WARN(error != -ENOMEM, "iunlink cache insert error %d", error);
-		kmem_free(iu);
+		kfree(iu);
 	}
 	/*
 	 * Absorb any runtime errors that aren't a result of corruption because
@@ -2066,7 +2066,7 @@ xfs_iunlink_change_backref(
 
 	/* If there is no new next entry just free our item and return. */
 	if (next_unlinked == NULLAGINO) {
-		kmem_free(iu);
+		kfree(iu);
 		return 0;
 	}
 
@@ -2094,7 +2094,7 @@ xfs_iunlink_free_item(
 	bool			*freed_anything = arg;
 
 	*freed_anything = true;
-	kmem_free(iu);
+	kfree(iu);
 }
 
 void
@@ -3598,7 +3598,7 @@ xfs_iflush_cluster(
 
 out_free:
 	rcu_read_unlock();
-	kmem_free(cilist);
+	kfree(cilist);
 out_put:
 	xfs_perag_put(pag);
 	return 0;
@@ -3629,7 +3629,7 @@ xfs_iflush_cluster(
 
 	/* abort the corrupt inode, as it was not attached to the buffer */
 	xfs_iflush_abort(cip, false);
-	kmem_free(cilist);
+	kfree(cilist);
 	xfs_perag_put(pag);
 	return -EFSCORRUPTED;
 }
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index 3a62976291a1..c8461a5515f1 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -666,7 +666,7 @@ void
 xfs_inode_item_destroy(
 	xfs_inode_t	*ip)
 {
-	kmem_free(ip->i_itemp->ili_item.li_lv_shadow);
+	kfree(ip->i_itemp->ili_item.li_lv_shadow);
 	kmem_cache_free(xfs_ili_zone, ip->i_itemp);
 }
 
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 364961c23cd0..f86dde7c9ea6 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -417,7 +417,7 @@ xfs_attrlist_by_handle(
 		error = -EFAULT;
 
 out_kfree:
-	kmem_free(kbuf);
+	kvfree(kbuf);
 out_dput:
 	dput(dentry);
 	return error;
@@ -448,7 +448,7 @@ xfs_attrmulti_attr_get(
 		error = -EFAULT;
 
 out_kfree:
-	kmem_free(kbuf);
+	kvfree(kbuf);
 	return error;
 }
 
@@ -1777,7 +1777,7 @@ xfs_ioc_getbmap(
 
 	error = 0;
 out_free_buf:
-	kmem_free(buf);
+	kvfree(buf);
 	return error;
 }
 
diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c
index 3c0d518e1039..de472fcd2f67 100644
--- a/fs/xfs/xfs_ioctl32.c
+++ b/fs/xfs/xfs_ioctl32.c
@@ -400,7 +400,7 @@ xfs_compat_attrlist_by_handle(
 		error = -EFAULT;
 
 out_kfree:
-	kmem_free(kbuf);
+	kvfree(kbuf);
 out_dput:
 	dput(dentry);
 	return error;
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 57e6e44123a9..e532db27d0dc 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -303,7 +303,7 @@ xfs_vn_ci_lookup(
 	dname.name = ci_name.name;
 	dname.len = ci_name.len;
 	dentry = d_add_ci(dentry, VFS_I(ip), &dname);
-	kmem_free(ci_name.name);
+	kfree(ci_name.name);
 	return dentry;
 }
 
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
index 884950adbd16..36bf47f11117 100644
--- a/fs/xfs/xfs_itable.c
+++ b/fs/xfs/xfs_itable.c
@@ -175,7 +175,7 @@ xfs_bulkstat_one(
 
 	error = xfs_bulkstat_one_int(breq->mp, NULL, breq->startino, &bc);
 
-	kmem_free(bc.buf);
+	kfree(bc.buf);
 
 	/*
 	 * If we reported one inode to userspace then we abort because we hit
@@ -250,7 +250,7 @@ xfs_bulkstat(
 	error = xfs_iwalk(breq->mp, NULL, breq->startino, breq->flags,
 			xfs_bulkstat_iwalk, breq->icount, &bc);
 
-	kmem_free(bc.buf);
+	kfree(bc.buf);
 
 	/*
 	 * We found some inodes, so clear the error status and return them.
diff --git a/fs/xfs/xfs_iwalk.c b/fs/xfs/xfs_iwalk.c
index aa375cf53021..67e98f9023d2 100644
--- a/fs/xfs/xfs_iwalk.c
+++ b/fs/xfs/xfs_iwalk.c
@@ -164,7 +164,7 @@ STATIC void
 xfs_iwalk_free(
 	struct xfs_iwalk_ag	*iwag)
 {
-	kmem_free(iwag->recs);
+	kfree(iwag->recs);
 	iwag->recs = NULL;
 }
 
@@ -578,7 +578,7 @@ xfs_iwalk_ag_work(
 	error = xfs_iwalk_ag(iwag);
 	xfs_iwalk_free(iwag);
 out:
-	kmem_free(iwag);
+	kfree(iwag);
 	return error;
 }
 
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 6a147c63a8a6..e8349b0d7c51 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -1540,11 +1540,11 @@ xlog_alloc_log(
 out_free_iclog:
 	for (iclog = log->l_iclog; iclog; iclog = prev_iclog) {
 		prev_iclog = iclog->ic_next;
-		kmem_free(iclog->ic_data);
-		kmem_free(iclog);
+		kvfree(iclog->ic_data);
+		kfree(iclog);
 	}
 out_free_log:
-	kmem_free(log);
+	kfree(log);
 out:
 	return ERR_PTR(error);
 }	/* xlog_alloc_log */
@@ -2001,14 +2001,14 @@ xlog_dealloc_log(
 	iclog = log->l_iclog;
 	for (i = 0; i < log->l_iclog_bufs; i++) {
 		next_iclog = iclog->ic_next;
-		kmem_free(iclog->ic_data);
-		kmem_free(iclog);
+		kvfree(iclog->ic_data);
+		kfree(iclog);
 		iclog = next_iclog;
 	}
 
 	log->l_mp->m_log = NULL;
 	destroy_workqueue(log->l_ioend_workqueue);
-	kmem_free(log);
+	kfree(log);
 }	/* xlog_dealloc_log */
 
 /*
diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
index 48435cf2aa16..23d70836a2b7 100644
--- a/fs/xfs/xfs_log_cil.c
+++ b/fs/xfs/xfs_log_cil.c
@@ -184,7 +184,7 @@ xlog_cil_alloc_shadow_bufs(
 			 * the buffer, only the log vector header and the iovec
 			 * storage.
 			 */
-			kmem_free(lip->li_lv_shadow);
+			kfree(lip->li_lv_shadow);
 
 			lv = kmem_alloc_large(buf_size, KM_NOFS);
 			memset(lv, 0, xlog_cil_iovec_space(niovecs));
@@ -492,7 +492,7 @@ xlog_cil_free_logvec(
 
 	for (lv = log_vector; lv; ) {
 		struct xfs_log_vec *next = lv->lv_next;
-		kmem_free(lv);
+		kvfree(lv);
 		lv = next;
 	}
 }
@@ -506,7 +506,7 @@ xlog_discard_endio_work(
 	struct xfs_mount	*mp = ctx->cil->xc_log->l_mp;
 
 	xfs_extent_busy_clear(mp, &ctx->busy_extents, false);
-	kmem_free(ctx);
+	kfree(ctx);
 }
 
 /*
@@ -608,7 +608,7 @@ xlog_cil_committed(
 	if (!list_empty(&ctx->busy_extents))
 		xlog_discard_busy_extents(mp, ctx);
 	else
-		kmem_free(ctx);
+		kfree(ctx);
 }
 
 void
@@ -872,7 +872,7 @@ xlog_cil_push(
 out_skip:
 	up_write(&cil->xc_ctx_lock);
 	xfs_log_ticket_put(new_ctx->ticket);
-	kmem_free(new_ctx);
+	kfree(new_ctx);
 	return 0;
 
 out_abort_free_ticket:
@@ -1185,7 +1185,7 @@ xlog_cil_init(
 
 	ctx = kmem_zalloc(sizeof(*ctx), KM_MAYFAIL);
 	if (!ctx) {
-		kmem_free(cil);
+		kfree(cil);
 		return -ENOMEM;
 	}
 
@@ -1216,10 +1216,10 @@ xlog_cil_destroy(
 	if (log->l_cilp->xc_ctx) {
 		if (log->l_cilp->xc_ctx->ticket)
 			xfs_log_ticket_put(log->l_cilp->xc_ctx->ticket);
-		kmem_free(log->l_cilp->xc_ctx);
+		kfree(log->l_cilp->xc_ctx);
 	}
 
 	ASSERT(list_empty(&log->l_cilp->xc_cil));
-	kmem_free(log->l_cilp);
+	kfree(log->l_cilp);
 }
 
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 02f2147952b3..4167e1326f62 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -418,7 +418,7 @@ xlog_find_verify_cycle(
 	*new_blk = -1;
 
 out:
-	kmem_free(buffer);
+	kvfree(buffer);
 	return error;
 }
 
@@ -529,7 +529,7 @@ xlog_find_verify_log_record(
 		*last_blk = i;
 
 out:
-	kmem_free(buffer);
+	kvfree(buffer);
 	return error;
 }
 
@@ -783,7 +783,7 @@ xlog_find_head(
 			goto out_free_buffer;
 	}
 
-	kmem_free(buffer);
+	kvfree(buffer);
 	if (head_blk == log_bbnum)
 		*return_head_blk = 0;
 	else
@@ -797,7 +797,7 @@ xlog_find_head(
 	return 0;
 
 out_free_buffer:
-	kmem_free(buffer);
+	kvfree(buffer);
 	if (error)
 		xfs_warn(log->l_mp, "failed to find log head");
 	return error;
@@ -1051,7 +1051,7 @@ xlog_verify_tail(
 		"Tail block (0x%llx) overwrite detected. Updated to 0x%llx",
 			 orig_tail, *tail_blk);
 out:
-	kmem_free(buffer);
+	kvfree(buffer);
 	return error;
 }
 
@@ -1098,7 +1098,7 @@ xlog_verify_head(
 	error = xlog_rseek_logrec_hdr(log, *head_blk, *tail_blk,
 				      XLOG_MAX_ICLOGS, tmp_buffer,
 				      &tmp_rhead_blk, &tmp_rhead, &tmp_wrapped);
-	kmem_free(tmp_buffer);
+	kvfree(tmp_buffer);
 	if (error < 0)
 		return error;
 
@@ -1431,7 +1431,7 @@ xlog_find_tail(
 		error = xlog_clear_stale_blocks(log, tail_lsn);
 
 done:
-	kmem_free(buffer);
+	kvfree(buffer);
 
 	if (error)
 		xfs_warn(log->l_mp, "failed to locate log tail");
@@ -1479,7 +1479,7 @@ xlog_find_zeroed(
 	first_cycle = xlog_get_cycle(offset);
 	if (first_cycle == 0) {		/* completely zeroed log */
 		*blk_no = 0;
-		kmem_free(buffer);
+		kvfree(buffer);
 		return 1;
 	}
 
@@ -1490,7 +1490,7 @@ xlog_find_zeroed(
 
 	last_cycle = xlog_get_cycle(offset);
 	if (last_cycle != 0) {		/* log completely written to */
-		kmem_free(buffer);
+		kvfree(buffer);
 		return 0;
 	}
 
@@ -1537,7 +1537,7 @@ xlog_find_zeroed(
 
 	*blk_no = last_blk;
 out_free_buffer:
-	kmem_free(buffer);
+	kvfree(buffer);
 	if (error)
 		return error;
 	return 1;
@@ -1649,7 +1649,7 @@ xlog_write_log_records(
 	}
 
 out_free_buffer:
-	kmem_free(buffer);
+	kvfree(buffer);
 	return error;
 }
 
@@ -2039,7 +2039,7 @@ xlog_check_buffer_cancelled(
 	if (flags & XFS_BLF_CANCEL) {
 		if (--bcp->bc_refcount == 0) {
 			list_del(&bcp->bc_list);
-			kmem_free(bcp);
+			kfree(bcp);
 		}
 	}
 	return 1;
@@ -3188,7 +3188,7 @@ xlog_recover_inode_pass2(
 	xfs_buf_relse(bp);
 error:
 	if (need_free)
-		kmem_free(in_f);
+		kfree(in_f);
 	return error;
 }
 
@@ -4292,7 +4292,7 @@ xlog_recover_add_to_trans(
 		"bad number of regions (%d) in inode log format",
 				  in_f->ilf_size);
 			ASSERT(0);
-			kmem_free(ptr);
+			kfree(ptr);
 			return -EFSCORRUPTED;
 		}
 
@@ -4307,7 +4307,7 @@ xlog_recover_add_to_trans(
 	"log item region count (%d) overflowed size (%d)",
 				item->ri_cnt, item->ri_total);
 		ASSERT(0);
-		kmem_free(ptr);
+		kfree(ptr);
 		return -EFSCORRUPTED;
 	}
 
@@ -4337,13 +4337,13 @@ xlog_recover_free_trans(
 		/* Free the regions in the item. */
 		list_del(&item->ri_list);
 		for (i = 0; i < item->ri_cnt; i++)
-			kmem_free(item->ri_buf[i].i_addr);
+			kfree(item->ri_buf[i].i_addr);
 		/* Free the item itself */
-		kmem_free(item->ri_buf);
-		kmem_free(item);
+		kfree(item->ri_buf);
+		kfree(item);
 	}
 	/* Free the transaction recover structure */
-	kmem_free(trans);
+	kfree(trans);
 }
 
 /*
@@ -5327,7 +5327,7 @@ xlog_do_recovery_pass(
 			hblks = h_size / XLOG_HEADER_CYCLE_SIZE;
 			if (h_size % XLOG_HEADER_CYCLE_SIZE)
 				hblks++;
-			kmem_free(hbp);
+			kvfree(hbp);
 			hbp = xlog_alloc_buffer(log, hblks);
 		} else {
 			hblks = 1;
@@ -5343,7 +5343,7 @@ xlog_do_recovery_pass(
 		return -ENOMEM;
 	dbp = xlog_alloc_buffer(log, BTOBB(h_size));
 	if (!dbp) {
-		kmem_free(hbp);
+		kvfree(hbp);
 		return -ENOMEM;
 	}
 
@@ -5504,9 +5504,9 @@ xlog_do_recovery_pass(
 	}
 
  bread_err2:
-	kmem_free(dbp);
+	kvfree(dbp);
  bread_err1:
-	kmem_free(hbp);
+	kvfree(hbp);
 
 	/*
 	 * Submit buffers that have been added from the last record processed,
@@ -5570,7 +5570,7 @@ xlog_do_log_recovery(
 	error = xlog_do_recovery_pass(log, head_blk, tail_blk,
 				      XLOG_RECOVER_PASS1, NULL);
 	if (error != 0) {
-		kmem_free(log->l_buf_cancel_table);
+		kfree(log->l_buf_cancel_table);
 		log->l_buf_cancel_table = NULL;
 		return error;
 	}
@@ -5589,7 +5589,7 @@ xlog_do_log_recovery(
 	}
 #endif	/* DEBUG */
 
-	kmem_free(log->l_buf_cancel_table);
+	kfree(log->l_buf_cancel_table);
 	log->l_buf_cancel_table = NULL;
 
 	return error;
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 5ea95247a37f..53ddb058b11a 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -42,7 +42,7 @@ xfs_uuid_table_free(void)
 {
 	if (xfs_uuid_table_size == 0)
 		return;
-	kmem_free(xfs_uuid_table);
+	kfree(xfs_uuid_table);
 	xfs_uuid_table = NULL;
 	xfs_uuid_table_size = 0;
 }
@@ -127,7 +127,7 @@ __xfs_free_perag(
 	struct xfs_perag *pag = container_of(head, struct xfs_perag, rcu_head);
 
 	ASSERT(atomic_read(&pag->pag_ref) == 0);
-	kmem_free(pag);
+	kfree(pag);
 }
 
 /*
@@ -243,7 +243,7 @@ xfs_initialize_perag(
 	xfs_buf_hash_destroy(pag);
 out_free_pag:
 	mutex_destroy(&pag->pag_ici_reclaim_lock);
-	kmem_free(pag);
+	kfree(pag);
 out_unwind_new_pags:
 	/* unwind any prior newly initialized pags */
 	for (index = first_initialised; index < agcount; index++) {
@@ -253,7 +253,7 @@ xfs_initialize_perag(
 		xfs_buf_hash_destroy(pag);
 		xfs_iunlink_destroy(pag);
 		mutex_destroy(&pag->pag_ici_reclaim_lock);
-		kmem_free(pag);
+		kfree(pag);
 	}
 	return error;
 }
diff --git a/fs/xfs/xfs_mru_cache.c b/fs/xfs/xfs_mru_cache.c
index a06661dac5be..6ef0a71d7681 100644
--- a/fs/xfs/xfs_mru_cache.c
+++ b/fs/xfs/xfs_mru_cache.c
@@ -364,9 +364,9 @@ xfs_mru_cache_create(
 
 exit:
 	if (err && mru && mru->lists)
-		kmem_free(mru->lists);
+		kfree(mru->lists);
 	if (err && mru)
-		kmem_free(mru);
+		kfree(mru);
 
 	return err;
 }
@@ -406,8 +406,8 @@ xfs_mru_cache_destroy(
 
 	xfs_mru_cache_flush(mru);
 
-	kmem_free(mru->lists);
-	kmem_free(mru);
+	kfree(mru->lists);
+	kfree(mru);
 }
 
 /*
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index 66ea8e4fca86..06c92dc61a03 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -698,7 +698,7 @@ xfs_qm_init_quotainfo(
 out_free_lru:
 	list_lru_destroy(&qinf->qi_lru);
 out_free_qinf:
-	kmem_free(qinf);
+	kfree(qinf);
 	mp->m_quotainfo = NULL;
 	return error;
 }
@@ -722,7 +722,7 @@ xfs_qm_destroy_quotainfo(
 	xfs_qm_destroy_quotainos(qi);
 	mutex_destroy(&qi->qi_tree_lock);
 	mutex_destroy(&qi->qi_quotaofflock);
-	kmem_free(qi);
+	kfree(qi);
 	mp->m_quotainfo = NULL;
 }
 
@@ -1049,7 +1049,7 @@ xfs_qm_reset_dqcounts_buf(
 	} while (nmaps > 0);
 
 out:
-	kmem_free(map);
+	kfree(map);
 	return error;
 }
 
diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c
index 8eeed73928cd..0ac598f55339 100644
--- a/fs/xfs/xfs_refcount_item.c
+++ b/fs/xfs/xfs_refcount_item.c
@@ -32,7 +32,7 @@ xfs_cui_item_free(
 	struct xfs_cui_log_item	*cuip)
 {
 	if (cuip->cui_format.cui_nextents > XFS_CUI_MAX_FAST_EXTENTS)
-		kmem_free(cuip);
+		kfree(cuip);
 	else
 		kmem_cache_free(xfs_cui_zone, cuip);
 }
@@ -392,7 +392,7 @@ xfs_refcount_update_finish_item(
 		refc->ri_blockcount = new_aglen;
 		return -EAGAIN;
 	}
-	kmem_free(refc);
+	kfree(refc);
 	return error;
 }
 
@@ -424,7 +424,7 @@ xfs_refcount_update_cancel_item(
 	struct xfs_refcount_intent	*refc;
 
 	refc = container_of(item, struct xfs_refcount_intent, ri_list);
-	kmem_free(refc);
+	kfree(refc);
 }
 
 const struct xfs_defer_op_type xfs_refcount_update_defer_type = {
diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c
index 4911b68f95dd..a0a02d862ddd 100644
--- a/fs/xfs/xfs_rmap_item.c
+++ b/fs/xfs/xfs_rmap_item.c
@@ -32,7 +32,7 @@ xfs_rui_item_free(
 	struct xfs_rui_log_item	*ruip)
 {
 	if (ruip->rui_format.rui_nextents > XFS_RUI_MAX_FAST_EXTENTS)
-		kmem_free(ruip);
+		kfree(ruip);
 	else
 		kmem_cache_free(xfs_rui_zone, ruip);
 }
@@ -436,7 +436,7 @@ xfs_rmap_update_finish_item(
 			rmap->ri_bmap.br_blockcount,
 			rmap->ri_bmap.br_state,
 			(struct xfs_btree_cur **)state);
-	kmem_free(rmap);
+	kfree(rmap);
 	return error;
 }
 
@@ -468,7 +468,7 @@ xfs_rmap_update_cancel_item(
 	struct xfs_rmap_intent		*rmap;
 
 	rmap = container_of(item, struct xfs_rmap_intent, ri_list);
-	kmem_free(rmap);
+	kfree(rmap);
 }
 
 const struct xfs_defer_op_type xfs_rmap_update_defer_type = {
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index d42b5a2047e0..7f03b4ab3452 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -1082,7 +1082,7 @@ xfs_growfs_rt(
 	/*
 	 * Free the fake mp structure.
 	 */
-	kmem_free(nmp);
+	kfree(nmp);
 
 	/*
 	 * If we had to allocate a new rsum_cache, we either need to free the
@@ -1091,10 +1091,10 @@ xfs_growfs_rt(
 	 */
 	if (rsum_cache != mp->m_rsum_cache) {
 		if (error) {
-			kmem_free(mp->m_rsum_cache);
+			kvfree(mp->m_rsum_cache);
 			mp->m_rsum_cache = rsum_cache;
 		} else {
-			kmem_free(rsum_cache);
+			kvfree(rsum_cache);
 		}
 	}
 
@@ -1253,7 +1253,7 @@ void
 xfs_rtunmount_inodes(
 	struct xfs_mount	*mp)
 {
-	kmem_free(mp->m_rsum_cache);
+	kvfree(mp->m_rsum_cache);
 	if (mp->m_rbmip)
 		xfs_irele(mp->m_rbmip);
 	if (mp->m_rsumip)
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index d9ae27ddf253..cc1933dc652f 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -725,7 +725,7 @@ xfs_mount_free(
 {
 	kfree(mp->m_rtname);
 	kfree(mp->m_logname);
-	kmem_free(mp);
+	kfree(mp);
 }
 
 STATIC int
diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c
index 00cc5b8734be..589918d11041 100644
--- a/fs/xfs/xfs_trans_ail.c
+++ b/fs/xfs/xfs_trans_ail.c
@@ -844,7 +844,7 @@ xfs_trans_ail_init(
 	return 0;
 
 out_free_ailp:
-	kmem_free(ailp);
+	kfree(ailp);
 	return -ENOMEM;
 }
 
@@ -855,5 +855,5 @@ xfs_trans_ail_destroy(
 	struct xfs_ail	*ailp = mp->m_ail;
 
 	kthread_stop(ailp->ail_task);
-	kmem_free(ailp);
+	kfree(ailp);
 }
-- 
2.23.0


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/4] xfs: Remove kmem_free()
  2019-11-14 20:09 ` [PATCH 4/4] xfs: Remove kmem_free() Carlos Maiolino
@ 2019-11-14 21:00   ` Darrick J. Wong
  2019-11-15 14:20     ` Carlos Maiolino
  0 siblings, 1 reply; 14+ messages in thread
From: Darrick J. Wong @ 2019-11-14 21:00 UTC (permalink / raw)
  To: Carlos Maiolino; +Cc: linux-xfs

On Thu, Nov 14, 2019 at 09:09:55PM +0100, Carlos Maiolino wrote:
> This can be replaced by direct calls to kfree() or kvfree() (whenever
> allocation is done via kmem_alloc_io() or kmem_alloc_large().
> 
> This patch has been partially scripted. I used the following sed to
> replace all kmem_free() calls by kfree()
> 
>  # find fs/xfs/ -type f -name '*.c' -o -name '*.h' | xargs sed -i \
>    's/kmem_free/kfree/g'

Coccinelle? ;)

> And manually inspected kmem_alloc_io() and kmem_alloc_large() uses to
> use kvfree() instead.

Why not just use kvfree everywhere?  Is there a significant performance
penalty for the is_vmalloc_addr() check in kvfree vs. having to keep
track of kfree vs. kvfree?

--D

> Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
> ---
>  fs/xfs/kmem.h                  |  5 ----
>  fs/xfs/libxfs/xfs_attr.c       |  2 +-
>  fs/xfs/libxfs/xfs_attr_leaf.c  |  8 +++---
>  fs/xfs/libxfs/xfs_da_btree.c   | 10 +++----
>  fs/xfs/libxfs/xfs_defer.c      |  4 +--
>  fs/xfs/libxfs/xfs_dir2.c       | 18 ++++++------
>  fs/xfs/libxfs/xfs_dir2_block.c |  4 +--
>  fs/xfs/libxfs/xfs_dir2_sf.c    |  8 +++---
>  fs/xfs/libxfs/xfs_iext_tree.c  |  8 +++---
>  fs/xfs/libxfs/xfs_inode_fork.c |  8 +++---
>  fs/xfs/libxfs/xfs_refcount.c   |  4 +--
>  fs/xfs/scrub/agheader.c        |  2 +-
>  fs/xfs/scrub/agheader_repair.c |  2 +-
>  fs/xfs/scrub/attr.c            |  2 +-
>  fs/xfs/scrub/bitmap.c          |  4 +--
>  fs/xfs/scrub/btree.c           |  2 +-
>  fs/xfs/scrub/refcount.c        |  8 +++---
>  fs/xfs/scrub/scrub.c           |  2 +-
>  fs/xfs/xfs_acl.c               |  4 +--
>  fs/xfs/xfs_attr_inactive.c     |  2 +-
>  fs/xfs/xfs_attr_list.c         |  4 +--
>  fs/xfs/xfs_bmap_item.c         |  4 +--
>  fs/xfs/xfs_buf.c               | 12 ++++----
>  fs/xfs/xfs_buf_item.c          |  4 +--
>  fs/xfs/xfs_dquot.c             |  2 +-
>  fs/xfs/xfs_dquot_item.c        |  8 +++---
>  fs/xfs/xfs_error.c             |  2 +-
>  fs/xfs/xfs_extent_busy.c       |  2 +-
>  fs/xfs/xfs_extfree_item.c      | 14 +++++-----
>  fs/xfs/xfs_filestream.c        |  4 +--
>  fs/xfs/xfs_inode.c             | 12 ++++----
>  fs/xfs/xfs_inode_item.c        |  2 +-
>  fs/xfs/xfs_ioctl.c             |  6 ++--
>  fs/xfs/xfs_ioctl32.c           |  2 +-
>  fs/xfs/xfs_iops.c              |  2 +-
>  fs/xfs/xfs_itable.c            |  4 +--
>  fs/xfs/xfs_iwalk.c             |  4 +--
>  fs/xfs/xfs_log.c               | 12 ++++----
>  fs/xfs/xfs_log_cil.c           | 16 +++++------
>  fs/xfs/xfs_log_recover.c       | 50 +++++++++++++++++-----------------
>  fs/xfs/xfs_mount.c             |  8 +++---
>  fs/xfs/xfs_mru_cache.c         |  8 +++---
>  fs/xfs/xfs_qm.c                |  6 ++--
>  fs/xfs/xfs_refcount_item.c     |  6 ++--
>  fs/xfs/xfs_rmap_item.c         |  6 ++--
>  fs/xfs/xfs_rtalloc.c           |  8 +++---
>  fs/xfs/xfs_super.c             |  2 +-
>  fs/xfs/xfs_trans_ail.c         |  4 +--
>  48 files changed, 158 insertions(+), 163 deletions(-)
> 
> diff --git a/fs/xfs/kmem.h b/fs/xfs/kmem.h
> index 6143117770e9..ccdc72519339 100644
> --- a/fs/xfs/kmem.h
> +++ b/fs/xfs/kmem.h
> @@ -56,11 +56,6 @@ 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);
> -}
> -
>  
>  static inline void *
>  kmem_zalloc(size_t size, xfs_km_flags_t flags)
> diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
> index 510ca6974604..bc8ca09e71d0 100644
> --- a/fs/xfs/libxfs/xfs_attr.c
> +++ b/fs/xfs/libxfs/xfs_attr.c
> @@ -174,7 +174,7 @@ xfs_attr_get(
>  	/* on error, we have to clean up allocated value buffers */
>  	if (error) {
>  		if (flags & ATTR_ALLOC) {
> -			kmem_free(args.value);
> +			kvfree(args.value);
>  			*value = NULL;
>  		}
>  		return error;
> diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
> index 85ec5945d29f..795b9b21b64d 100644
> --- a/fs/xfs/libxfs/xfs_attr_leaf.c
> +++ b/fs/xfs/libxfs/xfs_attr_leaf.c
> @@ -931,7 +931,7 @@ xfs_attr_shortform_to_leaf(
>  	error = 0;
>  	*leaf_bp = bp;
>  out:
> -	kmem_free(tmpbuffer);
> +	kfree(tmpbuffer);
>  	return error;
>  }
>  
> @@ -1131,7 +1131,7 @@ xfs_attr3_leaf_to_shortform(
>  	error = 0;
>  
>  out:
> -	kmem_free(tmpbuffer);
> +	kfree(tmpbuffer);
>  	return error;
>  }
>  
> @@ -1572,7 +1572,7 @@ xfs_attr3_leaf_compact(
>  	 */
>  	xfs_trans_log_buf(trans, bp, 0, args->geo->blksize - 1);
>  
> -	kmem_free(tmpbuffer);
> +	kfree(tmpbuffer);
>  }
>  
>  /*
> @@ -2293,7 +2293,7 @@ xfs_attr3_leaf_unbalance(
>  		}
>  		memcpy(save_leaf, tmp_leaf, state->args->geo->blksize);
>  		savehdr = tmphdr; /* struct copy */
> -		kmem_free(tmp_leaf);
> +		kfree(tmp_leaf);
>  	}
>  
>  	xfs_attr3_leaf_hdr_to_disk(state->args->geo, save_leaf, &savehdr);
> diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
> index c5c0b73febae..7ae82d91f776 100644
> --- a/fs/xfs/libxfs/xfs_da_btree.c
> +++ b/fs/xfs/libxfs/xfs_da_btree.c
> @@ -2189,7 +2189,7 @@ xfs_da_grow_inode_int(
>  
>  out_free_map:
>  	if (mapp != &map)
> -		kmem_free(mapp);
> +		kfree(mapp);
>  	return error;
>  }
>  
> @@ -2639,7 +2639,7 @@ xfs_dabuf_map(
>  	error = xfs_buf_map_from_irec(mp, map, nmaps, irecs, nirecs);
>  out:
>  	if (irecs != &irec)
> -		kmem_free(irecs);
> +		kfree(irecs);
>  	return error;
>  }
>  
> @@ -2686,7 +2686,7 @@ xfs_da_get_buf(
>  
>  out_free:
>  	if (mapp != &map)
> -		kmem_free(mapp);
> +		kfree(mapp);
>  
>  	return error;
>  }
> @@ -2735,7 +2735,7 @@ xfs_da_read_buf(
>  	*bpp = bp;
>  out_free:
>  	if (mapp != &map)
> -		kmem_free(mapp);
> +		kfree(mapp);
>  
>  	return error;
>  }
> @@ -2772,7 +2772,7 @@ xfs_da_reada_buf(
>  
>  out_free:
>  	if (mapp != &map)
> -		kmem_free(mapp);
> +		kfree(mapp);
>  
>  	return error;
>  }
> diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c
> index 22557527cfdb..27c3d150068a 100644
> --- a/fs/xfs/libxfs/xfs_defer.c
> +++ b/fs/xfs/libxfs/xfs_defer.c
> @@ -341,7 +341,7 @@ xfs_defer_cancel_list(
>  			ops->cancel_item(pwi);
>  		}
>  		ASSERT(dfp->dfp_count == 0);
> -		kmem_free(dfp);
> +		kfree(dfp);
>  	}
>  }
>  
> @@ -433,7 +433,7 @@ xfs_defer_finish_noroll(
>  		} else {
>  			/* Done with the dfp, free it. */
>  			list_del(&dfp->dfp_list);
> -			kmem_free(dfp);
> +			kfree(dfp);
>  		}
>  
>  		if (ops->finish_cleanup)
> diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c
> index 624c05e77ab4..efd7cec65259 100644
> --- a/fs/xfs/libxfs/xfs_dir2.c
> +++ b/fs/xfs/libxfs/xfs_dir2.c
> @@ -109,8 +109,8 @@ xfs_da_mount(
>  	mp->m_attr_geo = kmem_zalloc(sizeof(struct xfs_da_geometry),
>  				     KM_MAYFAIL);
>  	if (!mp->m_dir_geo || !mp->m_attr_geo) {
> -		kmem_free(mp->m_dir_geo);
> -		kmem_free(mp->m_attr_geo);
> +		kfree(mp->m_dir_geo);
> +		kfree(mp->m_attr_geo);
>  		return -ENOMEM;
>  	}
>  
> @@ -176,8 +176,8 @@ void
>  xfs_da_unmount(
>  	struct xfs_mount	*mp)
>  {
> -	kmem_free(mp->m_dir_geo);
> -	kmem_free(mp->m_attr_geo);
> +	kfree(mp->m_dir_geo);
> +	kfree(mp->m_attr_geo);
>  }
>  
>  /*
> @@ -242,7 +242,7 @@ xfs_dir_init(
>  	args->dp = dp;
>  	args->trans = tp;
>  	error = xfs_dir2_sf_create(args, pdp->i_ino);
> -	kmem_free(args);
> +	kfree(args);
>  	return error;
>  }
>  
> @@ -311,7 +311,7 @@ xfs_dir_createname(
>  		rval = xfs_dir2_node_addname(args);
>  
>  out_free:
> -	kmem_free(args);
> +	kfree(args);
>  	return rval;
>  }
>  
> @@ -417,7 +417,7 @@ xfs_dir_lookup(
>  	}
>  out_free:
>  	xfs_iunlock(dp, lock_mode);
> -	kmem_free(args);
> +	kfree(args);
>  	return rval;
>  }
>  
> @@ -475,7 +475,7 @@ xfs_dir_removename(
>  	else
>  		rval = xfs_dir2_node_removename(args);
>  out_free:
> -	kmem_free(args);
> +	kfree(args);
>  	return rval;
>  }
>  
> @@ -536,7 +536,7 @@ xfs_dir_replace(
>  	else
>  		rval = xfs_dir2_node_replace(args);
>  out_free:
> -	kmem_free(args);
> +	kfree(args);
>  	return rval;
>  }
>  
> diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c
> index 358151ddfa75..766f282b706a 100644
> --- a/fs/xfs/libxfs/xfs_dir2_block.c
> +++ b/fs/xfs/libxfs/xfs_dir2_block.c
> @@ -1229,7 +1229,7 @@ xfs_dir2_sf_to_block(
>  			sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep);
>  	}
>  	/* Done with the temporary buffer */
> -	kmem_free(sfp);
> +	kfree(sfp);
>  	/*
>  	 * Sort the leaf entries by hash value.
>  	 */
> @@ -1244,6 +1244,6 @@ xfs_dir2_sf_to_block(
>  	xfs_dir3_data_check(dp, bp);
>  	return 0;
>  out_free:
> -	kmem_free(sfp);
> +	kfree(sfp);
>  	return error;
>  }
> diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c
> index db1a82972d9e..f4de4e7b10ef 100644
> --- a/fs/xfs/libxfs/xfs_dir2_sf.c
> +++ b/fs/xfs/libxfs/xfs_dir2_sf.c
> @@ -350,7 +350,7 @@ xfs_dir2_block_to_sf(
>  	xfs_dir2_sf_check(args);
>  out:
>  	xfs_trans_log_inode(args->trans, dp, logflags);
> -	kmem_free(sfp);
> +	kfree(sfp);
>  	return error;
>  }
>  
> @@ -585,7 +585,7 @@ xfs_dir2_sf_addname_hard(
>  		sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep);
>  		memcpy(sfep, oldsfep, old_isize - nbytes);
>  	}
> -	kmem_free(buf);
> +	kfree(buf);
>  	dp->i_d.di_size = new_isize;
>  	xfs_dir2_sf_check(args);
>  }
> @@ -1202,7 +1202,7 @@ xfs_dir2_sf_toino4(
>  	/*
>  	 * Clean up the inode.
>  	 */
> -	kmem_free(buf);
> +	kfree(buf);
>  	dp->i_d.di_size = newsize;
>  	xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA);
>  }
> @@ -1275,7 +1275,7 @@ xfs_dir2_sf_toino8(
>  	/*
>  	 * Clean up the inode.
>  	 */
> -	kmem_free(buf);
> +	kfree(buf);
>  	dp->i_d.di_size = newsize;
>  	xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA);
>  }
> diff --git a/fs/xfs/libxfs/xfs_iext_tree.c b/fs/xfs/libxfs/xfs_iext_tree.c
> index 52451809c478..a7ba30cd81da 100644
> --- a/fs/xfs/libxfs/xfs_iext_tree.c
> +++ b/fs/xfs/libxfs/xfs_iext_tree.c
> @@ -734,7 +734,7 @@ xfs_iext_remove_node(
>  again:
>  	ASSERT(node->ptrs[pos]);
>  	ASSERT(node->ptrs[pos] == victim);
> -	kmem_free(victim);
> +	kfree(victim);
>  
>  	nr_entries = xfs_iext_node_nr_entries(node, pos) - 1;
>  	offset = node->keys[0];
> @@ -780,7 +780,7 @@ xfs_iext_remove_node(
>  		ASSERT(node == ifp->if_u1.if_root);
>  		ifp->if_u1.if_root = node->ptrs[0];
>  		ifp->if_height--;
> -		kmem_free(node);
> +		kfree(node);
>  	}
>  }
>  
> @@ -854,7 +854,7 @@ xfs_iext_free_last_leaf(
>  	struct xfs_ifork	*ifp)
>  {
>  	ifp->if_height--;
> -	kmem_free(ifp->if_u1.if_root);
> +	kfree(ifp->if_u1.if_root);
>  	ifp->if_u1.if_root = NULL;
>  }
>  
> @@ -1035,7 +1035,7 @@ xfs_iext_destroy_node(
>  		}
>  	}
>  
> -	kmem_free(node);
> +	kfree(node);
>  }
>  
>  void
> diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
> index ad2b9c313fd2..296677958212 100644
> --- a/fs/xfs/libxfs/xfs_inode_fork.c
> +++ b/fs/xfs/libxfs/xfs_inode_fork.c
> @@ -445,7 +445,7 @@ xfs_iroot_realloc(
>  						     (int)new_size);
>  		memcpy(np, op, new_max * (uint)sizeof(xfs_fsblock_t));
>  	}
> -	kmem_free(ifp->if_broot);
> +	kfree(ifp->if_broot);
>  	ifp->if_broot = new_broot;
>  	ifp->if_broot_bytes = (int)new_size;
>  	if (ifp->if_broot)
> @@ -486,7 +486,7 @@ xfs_idata_realloc(
>  		return;
>  
>  	if (new_size == 0) {
> -		kmem_free(ifp->if_u1.if_data);
> +		kfree(ifp->if_u1.if_data);
>  		ifp->if_u1.if_data = NULL;
>  		ifp->if_bytes = 0;
>  		return;
> @@ -511,7 +511,7 @@ xfs_idestroy_fork(
>  
>  	ifp = XFS_IFORK_PTR(ip, whichfork);
>  	if (ifp->if_broot != NULL) {
> -		kmem_free(ifp->if_broot);
> +		kfree(ifp->if_broot);
>  		ifp->if_broot = NULL;
>  	}
>  
> @@ -523,7 +523,7 @@ xfs_idestroy_fork(
>  	 */
>  	if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL) {
>  		if (ifp->if_u1.if_data != NULL) {
> -			kmem_free(ifp->if_u1.if_data);
> +			kfree(ifp->if_u1.if_data);
>  			ifp->if_u1.if_data = NULL;
>  		}
>  	} else if ((ifp->if_flags & XFS_IFEXTENTS) && ifp->if_height) {
> diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c
> index 78236bd6c64f..07894c53e753 100644
> --- a/fs/xfs/libxfs/xfs_refcount.c
> +++ b/fs/xfs/libxfs/xfs_refcount.c
> @@ -1684,7 +1684,7 @@ xfs_refcount_recover_cow_leftovers(
>  			goto out_free;
>  
>  		list_del(&rr->rr_list);
> -		kmem_free(rr);
> +		kfree(rr);
>  	}
>  
>  	return error;
> @@ -1694,7 +1694,7 @@ xfs_refcount_recover_cow_leftovers(
>  	/* Free the leftover list */
>  	list_for_each_entry_safe(rr, n, &debris, rr_list) {
>  		list_del(&rr->rr_list);
> -		kmem_free(rr);
> +		kfree(rr);
>  	}
>  	return error;
>  }
> diff --git a/fs/xfs/scrub/agheader.c b/fs/xfs/scrub/agheader.c
> index ba0f747c82e8..6f7126f6d25c 100644
> --- a/fs/xfs/scrub/agheader.c
> +++ b/fs/xfs/scrub/agheader.c
> @@ -753,7 +753,7 @@ xchk_agfl(
>  	}
>  
>  out_free:
> -	kmem_free(sai.entries);
> +	kfree(sai.entries);
>  out:
>  	return error;
>  }
> diff --git a/fs/xfs/scrub/agheader_repair.c b/fs/xfs/scrub/agheader_repair.c
> index 7a1a38b636a9..15fabf020d1b 100644
> --- a/fs/xfs/scrub/agheader_repair.c
> +++ b/fs/xfs/scrub/agheader_repair.c
> @@ -624,7 +624,7 @@ xrep_agfl_init_header(
>  		if (br->len)
>  			break;
>  		list_del(&br->list);
> -		kmem_free(br);
> +		kfree(br);
>  	}
>  
>  	/* Write new AGFL to disk. */
> diff --git a/fs/xfs/scrub/attr.c b/fs/xfs/scrub/attr.c
> index d9f0dd444b80..7a2a240febc1 100644
> --- a/fs/xfs/scrub/attr.c
> +++ b/fs/xfs/scrub/attr.c
> @@ -49,7 +49,7 @@ xchk_setup_xattr_buf(
>  	if (ab) {
>  		if (sz <= ab->sz)
>  			return 0;
> -		kmem_free(ab);
> +		kvfree(ab);
>  		sc->buf = NULL;
>  	}
>  
> diff --git a/fs/xfs/scrub/bitmap.c b/fs/xfs/scrub/bitmap.c
> index 18a684e18a69..cabde1c4c235 100644
> --- a/fs/xfs/scrub/bitmap.c
> +++ b/fs/xfs/scrub/bitmap.c
> @@ -47,7 +47,7 @@ xfs_bitmap_destroy(
>  
>  	for_each_xfs_bitmap_extent(bmr, n, bitmap) {
>  		list_del(&bmr->list);
> -		kmem_free(bmr);
> +		kfree(bmr);
>  	}
>  }
>  
> @@ -174,7 +174,7 @@ xfs_bitmap_disunion(
>  			/* Total overlap, just delete ex. */
>  			lp = lp->next;
>  			list_del(&br->list);
> -			kmem_free(br);
> +			kfree(br);
>  			break;
>  		case 0:
>  			/*
> diff --git a/fs/xfs/scrub/btree.c b/fs/xfs/scrub/btree.c
> index f52a7b8256f9..bed40b605076 100644
> --- a/fs/xfs/scrub/btree.c
> +++ b/fs/xfs/scrub/btree.c
> @@ -698,7 +698,7 @@ xchk_btree(
>  			error = xchk_btree_check_block_owner(&bs,
>  					co->level, co->daddr);
>  		list_del(&co->list);
> -		kmem_free(co);
> +		kfree(co);
>  	}
>  
>  	return error;
> diff --git a/fs/xfs/scrub/refcount.c b/fs/xfs/scrub/refcount.c
> index 0cab11a5d390..985724e81ebf 100644
> --- a/fs/xfs/scrub/refcount.c
> +++ b/fs/xfs/scrub/refcount.c
> @@ -215,7 +215,7 @@ xchk_refcountbt_process_rmap_fragments(
>  				continue;
>  			}
>  			list_del(&frag->list);
> -			kmem_free(frag);
> +			kfree(frag);
>  			nr++;
>  		}
>  
> @@ -257,11 +257,11 @@ xchk_refcountbt_process_rmap_fragments(
>  	/* Delete fragments and work list. */
>  	list_for_each_entry_safe(frag, n, &worklist, list) {
>  		list_del(&frag->list);
> -		kmem_free(frag);
> +		kfree(frag);
>  	}
>  	list_for_each_entry_safe(frag, n, &refchk->fragments, list) {
>  		list_del(&frag->list);
> -		kmem_free(frag);
> +		kfree(frag);
>  	}
>  }
>  
> @@ -308,7 +308,7 @@ xchk_refcountbt_xref_rmap(
>  out_free:
>  	list_for_each_entry_safe(frag, n, &refchk.fragments, list) {
>  		list_del(&frag->list);
> -		kmem_free(frag);
> +		kfree(frag);
>  	}
>  }
>  
> diff --git a/fs/xfs/scrub/scrub.c b/fs/xfs/scrub/scrub.c
> index f1775bb19313..7c63cdf13946 100644
> --- a/fs/xfs/scrub/scrub.c
> +++ b/fs/xfs/scrub/scrub.c
> @@ -175,7 +175,7 @@ xchk_teardown(
>  		sc->flags &= ~XCHK_HAS_QUOTAOFFLOCK;
>  	}
>  	if (sc->buf) {
> -		kmem_free(sc->buf);
> +		kvfree(sc->buf);
>  		sc->buf = NULL;
>  	}
>  	return error;
> diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c
> index 91693fce34a8..81b2c989242e 100644
> --- a/fs/xfs/xfs_acl.c
> +++ b/fs/xfs/xfs_acl.c
> @@ -157,7 +157,7 @@ xfs_get_acl(struct inode *inode, int type)
>  	} else  {
>  		acl = xfs_acl_from_disk(ip->i_mount, xfs_acl, len,
>  					XFS_ACL_MAX_ENTRIES(ip->i_mount));
> -		kmem_free(xfs_acl);
> +		kvfree(xfs_acl);
>  	}
>  	return acl;
>  }
> @@ -199,7 +199,7 @@ __xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
>  		error = xfs_attr_set(ip, ea_name, (unsigned char *)xfs_acl,
>  				len, ATTR_ROOT);
>  
> -		kmem_free(xfs_acl);
> +		kvfree(xfs_acl);
>  	} else {
>  		/*
>  		 * A NULL ACL argument means we want to remove the ACL.
> diff --git a/fs/xfs/xfs_attr_inactive.c b/fs/xfs/xfs_attr_inactive.c
> index a78c501f6fb1..8351b3b611ac 100644
> --- a/fs/xfs/xfs_attr_inactive.c
> +++ b/fs/xfs/xfs_attr_inactive.c
> @@ -181,7 +181,7 @@ xfs_attr3_leaf_inactive(
>  			error = tmp;	/* save only the 1st errno */
>  	}
>  
> -	kmem_free(list);
> +	kfree(list);
>  	return error;
>  }
>  
> diff --git a/fs/xfs/xfs_attr_list.c b/fs/xfs/xfs_attr_list.c
> index 0ec6606149a2..e1d1c4eb9e69 100644
> --- a/fs/xfs/xfs_attr_list.c
> +++ b/fs/xfs/xfs_attr_list.c
> @@ -131,7 +131,7 @@ xfs_attr_shortform_list(
>  					     XFS_ERRLEVEL_LOW,
>  					     context->dp->i_mount, sfe,
>  					     sizeof(*sfe));
> -			kmem_free(sbuf);
> +			kfree(sbuf);
>  			return -EFSCORRUPTED;
>  		}
>  
> @@ -195,7 +195,7 @@ xfs_attr_shortform_list(
>  		cursor->offset++;
>  	}
>  out:
> -	kmem_free(sbuf);
> +	kfree(sbuf);
>  	return error;
>  }
>  
> diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c
> index ee6f4229cebc..a89e10519f05 100644
> --- a/fs/xfs/xfs_bmap_item.c
> +++ b/fs/xfs/xfs_bmap_item.c
> @@ -391,7 +391,7 @@ xfs_bmap_update_finish_item(
>  		bmap->bi_bmap.br_blockcount = count;
>  		return -EAGAIN;
>  	}
> -	kmem_free(bmap);
> +	kfree(bmap);
>  	return error;
>  }
>  
> @@ -411,7 +411,7 @@ xfs_bmap_update_cancel_item(
>  	struct xfs_bmap_intent		*bmap;
>  
>  	bmap = container_of(item, struct xfs_bmap_intent, bi_list);
> -	kmem_free(bmap);
> +	kfree(bmap);
>  }
>  
>  const struct xfs_defer_op_type xfs_bmap_update_defer_type = {
> diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
> index a0229c368e78..80ef2fc8bb77 100644
> --- a/fs/xfs/xfs_buf.c
> +++ b/fs/xfs/xfs_buf.c
> @@ -193,7 +193,7 @@ xfs_buf_free_maps(
>  	struct xfs_buf	*bp)
>  {
>  	if (bp->b_maps != &bp->__b_map) {
> -		kmem_free(bp->b_maps);
> +		kfree(bp->b_maps);
>  		bp->b_maps = NULL;
>  	}
>  }
> @@ -292,7 +292,7 @@ _xfs_buf_free_pages(
>  	xfs_buf_t	*bp)
>  {
>  	if (bp->b_pages != bp->b_page_array) {
> -		kmem_free(bp->b_pages);
> +		kfree(bp->b_pages);
>  		bp->b_pages = NULL;
>  	}
>  }
> @@ -325,7 +325,7 @@ xfs_buf_free(
>  			__free_page(page);
>  		}
>  	} else if (bp->b_flags & _XBF_KMEM)
> -		kmem_free(bp->b_addr);
> +		kvfree(bp->b_addr);
>  	_xfs_buf_free_pages(bp);
>  	xfs_buf_free_maps(bp);
>  	kmem_cache_free(xfs_buf_zone, bp);
> @@ -373,7 +373,7 @@ xfs_buf_allocate_memory(
>  		if (((unsigned long)(bp->b_addr + size - 1) & PAGE_MASK) !=
>  		    ((unsigned long)bp->b_addr & PAGE_MASK)) {
>  			/* b_addr spans two pages - use alloc_page instead */
> -			kmem_free(bp->b_addr);
> +			kvfree(bp->b_addr);
>  			bp->b_addr = NULL;
>  			goto use_alloc_page;
>  		}
> @@ -1702,7 +1702,7 @@ xfs_free_buftarg(
>  
>  	xfs_blkdev_issue_flush(btp);
>  
> -	kmem_free(btp);
> +	kfree(btp);
>  }
>  
>  int
> @@ -1778,7 +1778,7 @@ xfs_alloc_buftarg(
>  error_lru:
>  	list_lru_destroy(&btp->bt_lru);
>  error_free:
> -	kmem_free(btp);
> +	kfree(btp);
>  	return NULL;
>  }
>  
> diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
> index 3458a1264a3f..8dc3330f1797 100644
> --- a/fs/xfs/xfs_buf_item.c
> +++ b/fs/xfs/xfs_buf_item.c
> @@ -713,7 +713,7 @@ xfs_buf_item_free_format(
>  	struct xfs_buf_log_item	*bip)
>  {
>  	if (bip->bli_formats != &bip->__bli_format) {
> -		kmem_free(bip->bli_formats);
> +		kfree(bip->bli_formats);
>  		bip->bli_formats = NULL;
>  	}
>  }
> @@ -938,7 +938,7 @@ xfs_buf_item_free(
>  	struct xfs_buf_log_item	*bip)
>  {
>  	xfs_buf_item_free_format(bip);
> -	kmem_free(bip->bli_item.li_lv_shadow);
> +	kfree(bip->bli_item.li_lv_shadow);
>  	kmem_cache_free(xfs_buf_item_zone, bip);
>  }
>  
> diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
> index 153815bf18fc..a073281c3bd7 100644
> --- a/fs/xfs/xfs_dquot.c
> +++ b/fs/xfs/xfs_dquot.c
> @@ -52,7 +52,7 @@ xfs_qm_dqdestroy(
>  {
>  	ASSERT(list_empty(&dqp->q_lru));
>  
> -	kmem_free(dqp->q_logitem.qli_item.li_lv_shadow);
> +	kfree(dqp->q_logitem.qli_item.li_lv_shadow);
>  	mutex_destroy(&dqp->q_qlock);
>  
>  	XFS_STATS_DEC(dqp->q_mount, xs_qm_dquot);
> diff --git a/fs/xfs/xfs_dquot_item.c b/fs/xfs/xfs_dquot_item.c
> index d60647d7197b..1b5e68ccef60 100644
> --- a/fs/xfs/xfs_dquot_item.c
> +++ b/fs/xfs/xfs_dquot_item.c
> @@ -316,10 +316,10 @@ xfs_qm_qoffend_logitem_committed(
>  	spin_lock(&ailp->ail_lock);
>  	xfs_trans_ail_delete(ailp, &qfs->qql_item, SHUTDOWN_LOG_IO_ERROR);
>  
> -	kmem_free(qfs->qql_item.li_lv_shadow);
> -	kmem_free(lip->li_lv_shadow);
> -	kmem_free(qfs);
> -	kmem_free(qfe);
> +	kfree(qfs->qql_item.li_lv_shadow);
> +	kfree(lip->li_lv_shadow);
> +	kfree(qfs);
> +	kfree(qfe);
>  	return (xfs_lsn_t)-1;
>  }
>  
> diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
> index 51dd1f43d12f..4c0883380d7c 100644
> --- a/fs/xfs/xfs_error.c
> +++ b/fs/xfs/xfs_error.c
> @@ -226,7 +226,7 @@ xfs_errortag_del(
>  	struct xfs_mount	*mp)
>  {
>  	xfs_sysfs_del(&mp->m_errortag_kobj);
> -	kmem_free(mp->m_errortag);
> +	kfree(mp->m_errortag);
>  }
>  
>  bool
> diff --git a/fs/xfs/xfs_extent_busy.c b/fs/xfs/xfs_extent_busy.c
> index 3991e59cfd18..9f0b99c7b34a 100644
> --- a/fs/xfs/xfs_extent_busy.c
> +++ b/fs/xfs/xfs_extent_busy.c
> @@ -532,7 +532,7 @@ xfs_extent_busy_clear_one(
>  	}
>  
>  	list_del_init(&busyp->list);
> -	kmem_free(busyp);
> +	kfree(busyp);
>  }
>  
>  static void
> diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
> index 6ea847f6e298..29b3a90aee91 100644
> --- a/fs/xfs/xfs_extfree_item.c
> +++ b/fs/xfs/xfs_extfree_item.c
> @@ -35,9 +35,9 @@ void
>  xfs_efi_item_free(
>  	struct xfs_efi_log_item	*efip)
>  {
> -	kmem_free(efip->efi_item.li_lv_shadow);
> +	kfree(efip->efi_item.li_lv_shadow);
>  	if (efip->efi_format.efi_nextents > XFS_EFI_MAX_FAST_EXTENTS)
> -		kmem_free(efip);
> +		kfree(efip);
>  	else
>  		kmem_cache_free(xfs_efi_zone, efip);
>  }
> @@ -240,9 +240,9 @@ static inline struct xfs_efd_log_item *EFD_ITEM(struct xfs_log_item *lip)
>  STATIC void
>  xfs_efd_item_free(struct xfs_efd_log_item *efdp)
>  {
> -	kmem_free(efdp->efd_item.li_lv_shadow);
> +	kfree(efdp->efd_item.li_lv_shadow);
>  	if (efdp->efd_format.efd_nextents > XFS_EFD_MAX_FAST_EXTENTS)
> -		kmem_free(efdp);
> +		kfree(efdp);
>  	else
>  		kmem_cache_free(xfs_efd_zone, efdp);
>  }
> @@ -488,7 +488,7 @@ xfs_extent_free_finish_item(
>  			free->xefi_startblock,
>  			free->xefi_blockcount,
>  			&free->xefi_oinfo, free->xefi_skip_discard);
> -	kmem_free(free);
> +	kfree(free);
>  	return error;
>  }
>  
> @@ -508,7 +508,7 @@ xfs_extent_free_cancel_item(
>  	struct xfs_extent_free_item	*free;
>  
>  	free = container_of(item, struct xfs_extent_free_item, xefi_list);
> -	kmem_free(free);
> +	kfree(free);
>  }
>  
>  const struct xfs_defer_op_type xfs_extent_free_defer_type = {
> @@ -572,7 +572,7 @@ xfs_agfl_free_finish_item(
>  	extp->ext_len = free->xefi_blockcount;
>  	efdp->efd_next_extent++;
>  
> -	kmem_free(free);
> +	kfree(free);
>  	return error;
>  }
>  
> diff --git a/fs/xfs/xfs_filestream.c b/fs/xfs/xfs_filestream.c
> index 2ae356775f63..9778e4e69e07 100644
> --- a/fs/xfs/xfs_filestream.c
> +++ b/fs/xfs/xfs_filestream.c
> @@ -118,7 +118,7 @@ xfs_fstrm_free_func(
>  	xfs_filestream_put_ag(mp, item->ag);
>  	trace_xfs_filestream_free(mp, mru->key, item->ag);
>  
> -	kmem_free(item);
> +	kfree(item);
>  }
>  
>  /*
> @@ -263,7 +263,7 @@ xfs_filestream_pick_ag(
>  	return 0;
>  
>  out_free_item:
> -	kmem_free(item);
> +	kfree(item);
>  out_put_ag:
>  	xfs_filestream_put_ag(mp, *agp);
>  	return err;
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index a92d4521748d..e1121ed7cbb5 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -708,7 +708,7 @@ xfs_lookup(
>  
>  out_free_name:
>  	if (ci_name)
> -		kmem_free(ci_name->name);
> +		kfree(ci_name->name);
>  out_unlock:
>  	*ipp = NULL;
>  	return error;
> @@ -2001,7 +2001,7 @@ xfs_iunlink_insert_backref(
>  	 */
>  	if (error) {
>  		WARN(error != -ENOMEM, "iunlink cache insert error %d", error);
> -		kmem_free(iu);
> +		kfree(iu);
>  	}
>  	/*
>  	 * Absorb any runtime errors that aren't a result of corruption because
> @@ -2066,7 +2066,7 @@ xfs_iunlink_change_backref(
>  
>  	/* If there is no new next entry just free our item and return. */
>  	if (next_unlinked == NULLAGINO) {
> -		kmem_free(iu);
> +		kfree(iu);
>  		return 0;
>  	}
>  
> @@ -2094,7 +2094,7 @@ xfs_iunlink_free_item(
>  	bool			*freed_anything = arg;
>  
>  	*freed_anything = true;
> -	kmem_free(iu);
> +	kfree(iu);
>  }
>  
>  void
> @@ -3598,7 +3598,7 @@ xfs_iflush_cluster(
>  
>  out_free:
>  	rcu_read_unlock();
> -	kmem_free(cilist);
> +	kfree(cilist);
>  out_put:
>  	xfs_perag_put(pag);
>  	return 0;
> @@ -3629,7 +3629,7 @@ xfs_iflush_cluster(
>  
>  	/* abort the corrupt inode, as it was not attached to the buffer */
>  	xfs_iflush_abort(cip, false);
> -	kmem_free(cilist);
> +	kfree(cilist);
>  	xfs_perag_put(pag);
>  	return -EFSCORRUPTED;
>  }
> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> index 3a62976291a1..c8461a5515f1 100644
> --- a/fs/xfs/xfs_inode_item.c
> +++ b/fs/xfs/xfs_inode_item.c
> @@ -666,7 +666,7 @@ void
>  xfs_inode_item_destroy(
>  	xfs_inode_t	*ip)
>  {
> -	kmem_free(ip->i_itemp->ili_item.li_lv_shadow);
> +	kfree(ip->i_itemp->ili_item.li_lv_shadow);
>  	kmem_cache_free(xfs_ili_zone, ip->i_itemp);
>  }
>  
> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> index 364961c23cd0..f86dde7c9ea6 100644
> --- a/fs/xfs/xfs_ioctl.c
> +++ b/fs/xfs/xfs_ioctl.c
> @@ -417,7 +417,7 @@ xfs_attrlist_by_handle(
>  		error = -EFAULT;
>  
>  out_kfree:
> -	kmem_free(kbuf);
> +	kvfree(kbuf);
>  out_dput:
>  	dput(dentry);
>  	return error;
> @@ -448,7 +448,7 @@ xfs_attrmulti_attr_get(
>  		error = -EFAULT;
>  
>  out_kfree:
> -	kmem_free(kbuf);
> +	kvfree(kbuf);
>  	return error;
>  }
>  
> @@ -1777,7 +1777,7 @@ xfs_ioc_getbmap(
>  
>  	error = 0;
>  out_free_buf:
> -	kmem_free(buf);
> +	kvfree(buf);
>  	return error;
>  }
>  
> diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c
> index 3c0d518e1039..de472fcd2f67 100644
> --- a/fs/xfs/xfs_ioctl32.c
> +++ b/fs/xfs/xfs_ioctl32.c
> @@ -400,7 +400,7 @@ xfs_compat_attrlist_by_handle(
>  		error = -EFAULT;
>  
>  out_kfree:
> -	kmem_free(kbuf);
> +	kvfree(kbuf);
>  out_dput:
>  	dput(dentry);
>  	return error;
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index 57e6e44123a9..e532db27d0dc 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -303,7 +303,7 @@ xfs_vn_ci_lookup(
>  	dname.name = ci_name.name;
>  	dname.len = ci_name.len;
>  	dentry = d_add_ci(dentry, VFS_I(ip), &dname);
> -	kmem_free(ci_name.name);
> +	kfree(ci_name.name);
>  	return dentry;
>  }
>  
> diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
> index 884950adbd16..36bf47f11117 100644
> --- a/fs/xfs/xfs_itable.c
> +++ b/fs/xfs/xfs_itable.c
> @@ -175,7 +175,7 @@ xfs_bulkstat_one(
>  
>  	error = xfs_bulkstat_one_int(breq->mp, NULL, breq->startino, &bc);
>  
> -	kmem_free(bc.buf);
> +	kfree(bc.buf);
>  
>  	/*
>  	 * If we reported one inode to userspace then we abort because we hit
> @@ -250,7 +250,7 @@ xfs_bulkstat(
>  	error = xfs_iwalk(breq->mp, NULL, breq->startino, breq->flags,
>  			xfs_bulkstat_iwalk, breq->icount, &bc);
>  
> -	kmem_free(bc.buf);
> +	kfree(bc.buf);
>  
>  	/*
>  	 * We found some inodes, so clear the error status and return them.
> diff --git a/fs/xfs/xfs_iwalk.c b/fs/xfs/xfs_iwalk.c
> index aa375cf53021..67e98f9023d2 100644
> --- a/fs/xfs/xfs_iwalk.c
> +++ b/fs/xfs/xfs_iwalk.c
> @@ -164,7 +164,7 @@ STATIC void
>  xfs_iwalk_free(
>  	struct xfs_iwalk_ag	*iwag)
>  {
> -	kmem_free(iwag->recs);
> +	kfree(iwag->recs);
>  	iwag->recs = NULL;
>  }
>  
> @@ -578,7 +578,7 @@ xfs_iwalk_ag_work(
>  	error = xfs_iwalk_ag(iwag);
>  	xfs_iwalk_free(iwag);
>  out:
> -	kmem_free(iwag);
> +	kfree(iwag);
>  	return error;
>  }
>  
> diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
> index 6a147c63a8a6..e8349b0d7c51 100644
> --- a/fs/xfs/xfs_log.c
> +++ b/fs/xfs/xfs_log.c
> @@ -1540,11 +1540,11 @@ xlog_alloc_log(
>  out_free_iclog:
>  	for (iclog = log->l_iclog; iclog; iclog = prev_iclog) {
>  		prev_iclog = iclog->ic_next;
> -		kmem_free(iclog->ic_data);
> -		kmem_free(iclog);
> +		kvfree(iclog->ic_data);
> +		kfree(iclog);
>  	}
>  out_free_log:
> -	kmem_free(log);
> +	kfree(log);
>  out:
>  	return ERR_PTR(error);
>  }	/* xlog_alloc_log */
> @@ -2001,14 +2001,14 @@ xlog_dealloc_log(
>  	iclog = log->l_iclog;
>  	for (i = 0; i < log->l_iclog_bufs; i++) {
>  		next_iclog = iclog->ic_next;
> -		kmem_free(iclog->ic_data);
> -		kmem_free(iclog);
> +		kvfree(iclog->ic_data);
> +		kfree(iclog);
>  		iclog = next_iclog;
>  	}
>  
>  	log->l_mp->m_log = NULL;
>  	destroy_workqueue(log->l_ioend_workqueue);
> -	kmem_free(log);
> +	kfree(log);
>  }	/* xlog_dealloc_log */
>  
>  /*
> diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
> index 48435cf2aa16..23d70836a2b7 100644
> --- a/fs/xfs/xfs_log_cil.c
> +++ b/fs/xfs/xfs_log_cil.c
> @@ -184,7 +184,7 @@ xlog_cil_alloc_shadow_bufs(
>  			 * the buffer, only the log vector header and the iovec
>  			 * storage.
>  			 */
> -			kmem_free(lip->li_lv_shadow);
> +			kfree(lip->li_lv_shadow);
>  
>  			lv = kmem_alloc_large(buf_size, KM_NOFS);
>  			memset(lv, 0, xlog_cil_iovec_space(niovecs));
> @@ -492,7 +492,7 @@ xlog_cil_free_logvec(
>  
>  	for (lv = log_vector; lv; ) {
>  		struct xfs_log_vec *next = lv->lv_next;
> -		kmem_free(lv);
> +		kvfree(lv);
>  		lv = next;
>  	}
>  }
> @@ -506,7 +506,7 @@ xlog_discard_endio_work(
>  	struct xfs_mount	*mp = ctx->cil->xc_log->l_mp;
>  
>  	xfs_extent_busy_clear(mp, &ctx->busy_extents, false);
> -	kmem_free(ctx);
> +	kfree(ctx);
>  }
>  
>  /*
> @@ -608,7 +608,7 @@ xlog_cil_committed(
>  	if (!list_empty(&ctx->busy_extents))
>  		xlog_discard_busy_extents(mp, ctx);
>  	else
> -		kmem_free(ctx);
> +		kfree(ctx);
>  }
>  
>  void
> @@ -872,7 +872,7 @@ xlog_cil_push(
>  out_skip:
>  	up_write(&cil->xc_ctx_lock);
>  	xfs_log_ticket_put(new_ctx->ticket);
> -	kmem_free(new_ctx);
> +	kfree(new_ctx);
>  	return 0;
>  
>  out_abort_free_ticket:
> @@ -1185,7 +1185,7 @@ xlog_cil_init(
>  
>  	ctx = kmem_zalloc(sizeof(*ctx), KM_MAYFAIL);
>  	if (!ctx) {
> -		kmem_free(cil);
> +		kfree(cil);
>  		return -ENOMEM;
>  	}
>  
> @@ -1216,10 +1216,10 @@ xlog_cil_destroy(
>  	if (log->l_cilp->xc_ctx) {
>  		if (log->l_cilp->xc_ctx->ticket)
>  			xfs_log_ticket_put(log->l_cilp->xc_ctx->ticket);
> -		kmem_free(log->l_cilp->xc_ctx);
> +		kfree(log->l_cilp->xc_ctx);
>  	}
>  
>  	ASSERT(list_empty(&log->l_cilp->xc_cil));
> -	kmem_free(log->l_cilp);
> +	kfree(log->l_cilp);
>  }
>  
> diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
> index 02f2147952b3..4167e1326f62 100644
> --- a/fs/xfs/xfs_log_recover.c
> +++ b/fs/xfs/xfs_log_recover.c
> @@ -418,7 +418,7 @@ xlog_find_verify_cycle(
>  	*new_blk = -1;
>  
>  out:
> -	kmem_free(buffer);
> +	kvfree(buffer);
>  	return error;
>  }
>  
> @@ -529,7 +529,7 @@ xlog_find_verify_log_record(
>  		*last_blk = i;
>  
>  out:
> -	kmem_free(buffer);
> +	kvfree(buffer);
>  	return error;
>  }
>  
> @@ -783,7 +783,7 @@ xlog_find_head(
>  			goto out_free_buffer;
>  	}
>  
> -	kmem_free(buffer);
> +	kvfree(buffer);
>  	if (head_blk == log_bbnum)
>  		*return_head_blk = 0;
>  	else
> @@ -797,7 +797,7 @@ xlog_find_head(
>  	return 0;
>  
>  out_free_buffer:
> -	kmem_free(buffer);
> +	kvfree(buffer);
>  	if (error)
>  		xfs_warn(log->l_mp, "failed to find log head");
>  	return error;
> @@ -1051,7 +1051,7 @@ xlog_verify_tail(
>  		"Tail block (0x%llx) overwrite detected. Updated to 0x%llx",
>  			 orig_tail, *tail_blk);
>  out:
> -	kmem_free(buffer);
> +	kvfree(buffer);
>  	return error;
>  }
>  
> @@ -1098,7 +1098,7 @@ xlog_verify_head(
>  	error = xlog_rseek_logrec_hdr(log, *head_blk, *tail_blk,
>  				      XLOG_MAX_ICLOGS, tmp_buffer,
>  				      &tmp_rhead_blk, &tmp_rhead, &tmp_wrapped);
> -	kmem_free(tmp_buffer);
> +	kvfree(tmp_buffer);
>  	if (error < 0)
>  		return error;
>  
> @@ -1431,7 +1431,7 @@ xlog_find_tail(
>  		error = xlog_clear_stale_blocks(log, tail_lsn);
>  
>  done:
> -	kmem_free(buffer);
> +	kvfree(buffer);
>  
>  	if (error)
>  		xfs_warn(log->l_mp, "failed to locate log tail");
> @@ -1479,7 +1479,7 @@ xlog_find_zeroed(
>  	first_cycle = xlog_get_cycle(offset);
>  	if (first_cycle == 0) {		/* completely zeroed log */
>  		*blk_no = 0;
> -		kmem_free(buffer);
> +		kvfree(buffer);
>  		return 1;
>  	}
>  
> @@ -1490,7 +1490,7 @@ xlog_find_zeroed(
>  
>  	last_cycle = xlog_get_cycle(offset);
>  	if (last_cycle != 0) {		/* log completely written to */
> -		kmem_free(buffer);
> +		kvfree(buffer);
>  		return 0;
>  	}
>  
> @@ -1537,7 +1537,7 @@ xlog_find_zeroed(
>  
>  	*blk_no = last_blk;
>  out_free_buffer:
> -	kmem_free(buffer);
> +	kvfree(buffer);
>  	if (error)
>  		return error;
>  	return 1;
> @@ -1649,7 +1649,7 @@ xlog_write_log_records(
>  	}
>  
>  out_free_buffer:
> -	kmem_free(buffer);
> +	kvfree(buffer);
>  	return error;
>  }
>  
> @@ -2039,7 +2039,7 @@ xlog_check_buffer_cancelled(
>  	if (flags & XFS_BLF_CANCEL) {
>  		if (--bcp->bc_refcount == 0) {
>  			list_del(&bcp->bc_list);
> -			kmem_free(bcp);
> +			kfree(bcp);
>  		}
>  	}
>  	return 1;
> @@ -3188,7 +3188,7 @@ xlog_recover_inode_pass2(
>  	xfs_buf_relse(bp);
>  error:
>  	if (need_free)
> -		kmem_free(in_f);
> +		kfree(in_f);
>  	return error;
>  }
>  
> @@ -4292,7 +4292,7 @@ xlog_recover_add_to_trans(
>  		"bad number of regions (%d) in inode log format",
>  				  in_f->ilf_size);
>  			ASSERT(0);
> -			kmem_free(ptr);
> +			kfree(ptr);
>  			return -EFSCORRUPTED;
>  		}
>  
> @@ -4307,7 +4307,7 @@ xlog_recover_add_to_trans(
>  	"log item region count (%d) overflowed size (%d)",
>  				item->ri_cnt, item->ri_total);
>  		ASSERT(0);
> -		kmem_free(ptr);
> +		kfree(ptr);
>  		return -EFSCORRUPTED;
>  	}
>  
> @@ -4337,13 +4337,13 @@ xlog_recover_free_trans(
>  		/* Free the regions in the item. */
>  		list_del(&item->ri_list);
>  		for (i = 0; i < item->ri_cnt; i++)
> -			kmem_free(item->ri_buf[i].i_addr);
> +			kfree(item->ri_buf[i].i_addr);
>  		/* Free the item itself */
> -		kmem_free(item->ri_buf);
> -		kmem_free(item);
> +		kfree(item->ri_buf);
> +		kfree(item);
>  	}
>  	/* Free the transaction recover structure */
> -	kmem_free(trans);
> +	kfree(trans);
>  }
>  
>  /*
> @@ -5327,7 +5327,7 @@ xlog_do_recovery_pass(
>  			hblks = h_size / XLOG_HEADER_CYCLE_SIZE;
>  			if (h_size % XLOG_HEADER_CYCLE_SIZE)
>  				hblks++;
> -			kmem_free(hbp);
> +			kvfree(hbp);
>  			hbp = xlog_alloc_buffer(log, hblks);
>  		} else {
>  			hblks = 1;
> @@ -5343,7 +5343,7 @@ xlog_do_recovery_pass(
>  		return -ENOMEM;
>  	dbp = xlog_alloc_buffer(log, BTOBB(h_size));
>  	if (!dbp) {
> -		kmem_free(hbp);
> +		kvfree(hbp);
>  		return -ENOMEM;
>  	}
>  
> @@ -5504,9 +5504,9 @@ xlog_do_recovery_pass(
>  	}
>  
>   bread_err2:
> -	kmem_free(dbp);
> +	kvfree(dbp);
>   bread_err1:
> -	kmem_free(hbp);
> +	kvfree(hbp);
>  
>  	/*
>  	 * Submit buffers that have been added from the last record processed,
> @@ -5570,7 +5570,7 @@ xlog_do_log_recovery(
>  	error = xlog_do_recovery_pass(log, head_blk, tail_blk,
>  				      XLOG_RECOVER_PASS1, NULL);
>  	if (error != 0) {
> -		kmem_free(log->l_buf_cancel_table);
> +		kfree(log->l_buf_cancel_table);
>  		log->l_buf_cancel_table = NULL;
>  		return error;
>  	}
> @@ -5589,7 +5589,7 @@ xlog_do_log_recovery(
>  	}
>  #endif	/* DEBUG */
>  
> -	kmem_free(log->l_buf_cancel_table);
> +	kfree(log->l_buf_cancel_table);
>  	log->l_buf_cancel_table = NULL;
>  
>  	return error;
> diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
> index 5ea95247a37f..53ddb058b11a 100644
> --- a/fs/xfs/xfs_mount.c
> +++ b/fs/xfs/xfs_mount.c
> @@ -42,7 +42,7 @@ xfs_uuid_table_free(void)
>  {
>  	if (xfs_uuid_table_size == 0)
>  		return;
> -	kmem_free(xfs_uuid_table);
> +	kfree(xfs_uuid_table);
>  	xfs_uuid_table = NULL;
>  	xfs_uuid_table_size = 0;
>  }
> @@ -127,7 +127,7 @@ __xfs_free_perag(
>  	struct xfs_perag *pag = container_of(head, struct xfs_perag, rcu_head);
>  
>  	ASSERT(atomic_read(&pag->pag_ref) == 0);
> -	kmem_free(pag);
> +	kfree(pag);
>  }
>  
>  /*
> @@ -243,7 +243,7 @@ xfs_initialize_perag(
>  	xfs_buf_hash_destroy(pag);
>  out_free_pag:
>  	mutex_destroy(&pag->pag_ici_reclaim_lock);
> -	kmem_free(pag);
> +	kfree(pag);
>  out_unwind_new_pags:
>  	/* unwind any prior newly initialized pags */
>  	for (index = first_initialised; index < agcount; index++) {
> @@ -253,7 +253,7 @@ xfs_initialize_perag(
>  		xfs_buf_hash_destroy(pag);
>  		xfs_iunlink_destroy(pag);
>  		mutex_destroy(&pag->pag_ici_reclaim_lock);
> -		kmem_free(pag);
> +		kfree(pag);
>  	}
>  	return error;
>  }
> diff --git a/fs/xfs/xfs_mru_cache.c b/fs/xfs/xfs_mru_cache.c
> index a06661dac5be..6ef0a71d7681 100644
> --- a/fs/xfs/xfs_mru_cache.c
> +++ b/fs/xfs/xfs_mru_cache.c
> @@ -364,9 +364,9 @@ xfs_mru_cache_create(
>  
>  exit:
>  	if (err && mru && mru->lists)
> -		kmem_free(mru->lists);
> +		kfree(mru->lists);
>  	if (err && mru)
> -		kmem_free(mru);
> +		kfree(mru);
>  
>  	return err;
>  }
> @@ -406,8 +406,8 @@ xfs_mru_cache_destroy(
>  
>  	xfs_mru_cache_flush(mru);
>  
> -	kmem_free(mru->lists);
> -	kmem_free(mru);
> +	kfree(mru->lists);
> +	kfree(mru);
>  }
>  
>  /*
> diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
> index 66ea8e4fca86..06c92dc61a03 100644
> --- a/fs/xfs/xfs_qm.c
> +++ b/fs/xfs/xfs_qm.c
> @@ -698,7 +698,7 @@ xfs_qm_init_quotainfo(
>  out_free_lru:
>  	list_lru_destroy(&qinf->qi_lru);
>  out_free_qinf:
> -	kmem_free(qinf);
> +	kfree(qinf);
>  	mp->m_quotainfo = NULL;
>  	return error;
>  }
> @@ -722,7 +722,7 @@ xfs_qm_destroy_quotainfo(
>  	xfs_qm_destroy_quotainos(qi);
>  	mutex_destroy(&qi->qi_tree_lock);
>  	mutex_destroy(&qi->qi_quotaofflock);
> -	kmem_free(qi);
> +	kfree(qi);
>  	mp->m_quotainfo = NULL;
>  }
>  
> @@ -1049,7 +1049,7 @@ xfs_qm_reset_dqcounts_buf(
>  	} while (nmaps > 0);
>  
>  out:
> -	kmem_free(map);
> +	kfree(map);
>  	return error;
>  }
>  
> diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c
> index 8eeed73928cd..0ac598f55339 100644
> --- a/fs/xfs/xfs_refcount_item.c
> +++ b/fs/xfs/xfs_refcount_item.c
> @@ -32,7 +32,7 @@ xfs_cui_item_free(
>  	struct xfs_cui_log_item	*cuip)
>  {
>  	if (cuip->cui_format.cui_nextents > XFS_CUI_MAX_FAST_EXTENTS)
> -		kmem_free(cuip);
> +		kfree(cuip);
>  	else
>  		kmem_cache_free(xfs_cui_zone, cuip);
>  }
> @@ -392,7 +392,7 @@ xfs_refcount_update_finish_item(
>  		refc->ri_blockcount = new_aglen;
>  		return -EAGAIN;
>  	}
> -	kmem_free(refc);
> +	kfree(refc);
>  	return error;
>  }
>  
> @@ -424,7 +424,7 @@ xfs_refcount_update_cancel_item(
>  	struct xfs_refcount_intent	*refc;
>  
>  	refc = container_of(item, struct xfs_refcount_intent, ri_list);
> -	kmem_free(refc);
> +	kfree(refc);
>  }
>  
>  const struct xfs_defer_op_type xfs_refcount_update_defer_type = {
> diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c
> index 4911b68f95dd..a0a02d862ddd 100644
> --- a/fs/xfs/xfs_rmap_item.c
> +++ b/fs/xfs/xfs_rmap_item.c
> @@ -32,7 +32,7 @@ xfs_rui_item_free(
>  	struct xfs_rui_log_item	*ruip)
>  {
>  	if (ruip->rui_format.rui_nextents > XFS_RUI_MAX_FAST_EXTENTS)
> -		kmem_free(ruip);
> +		kfree(ruip);
>  	else
>  		kmem_cache_free(xfs_rui_zone, ruip);
>  }
> @@ -436,7 +436,7 @@ xfs_rmap_update_finish_item(
>  			rmap->ri_bmap.br_blockcount,
>  			rmap->ri_bmap.br_state,
>  			(struct xfs_btree_cur **)state);
> -	kmem_free(rmap);
> +	kfree(rmap);
>  	return error;
>  }
>  
> @@ -468,7 +468,7 @@ xfs_rmap_update_cancel_item(
>  	struct xfs_rmap_intent		*rmap;
>  
>  	rmap = container_of(item, struct xfs_rmap_intent, ri_list);
> -	kmem_free(rmap);
> +	kfree(rmap);
>  }
>  
>  const struct xfs_defer_op_type xfs_rmap_update_defer_type = {
> diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
> index d42b5a2047e0..7f03b4ab3452 100644
> --- a/fs/xfs/xfs_rtalloc.c
> +++ b/fs/xfs/xfs_rtalloc.c
> @@ -1082,7 +1082,7 @@ xfs_growfs_rt(
>  	/*
>  	 * Free the fake mp structure.
>  	 */
> -	kmem_free(nmp);
> +	kfree(nmp);
>  
>  	/*
>  	 * If we had to allocate a new rsum_cache, we either need to free the
> @@ -1091,10 +1091,10 @@ xfs_growfs_rt(
>  	 */
>  	if (rsum_cache != mp->m_rsum_cache) {
>  		if (error) {
> -			kmem_free(mp->m_rsum_cache);
> +			kvfree(mp->m_rsum_cache);
>  			mp->m_rsum_cache = rsum_cache;
>  		} else {
> -			kmem_free(rsum_cache);
> +			kvfree(rsum_cache);
>  		}
>  	}
>  
> @@ -1253,7 +1253,7 @@ void
>  xfs_rtunmount_inodes(
>  	struct xfs_mount	*mp)
>  {
> -	kmem_free(mp->m_rsum_cache);
> +	kvfree(mp->m_rsum_cache);
>  	if (mp->m_rbmip)
>  		xfs_irele(mp->m_rbmip);
>  	if (mp->m_rsumip)
> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> index d9ae27ddf253..cc1933dc652f 100644
> --- a/fs/xfs/xfs_super.c
> +++ b/fs/xfs/xfs_super.c
> @@ -725,7 +725,7 @@ xfs_mount_free(
>  {
>  	kfree(mp->m_rtname);
>  	kfree(mp->m_logname);
> -	kmem_free(mp);
> +	kfree(mp);
>  }
>  
>  STATIC int
> diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c
> index 00cc5b8734be..589918d11041 100644
> --- a/fs/xfs/xfs_trans_ail.c
> +++ b/fs/xfs/xfs_trans_ail.c
> @@ -844,7 +844,7 @@ xfs_trans_ail_init(
>  	return 0;
>  
>  out_free_ailp:
> -	kmem_free(ailp);
> +	kfree(ailp);
>  	return -ENOMEM;
>  }
>  
> @@ -855,5 +855,5 @@ xfs_trans_ail_destroy(
>  	struct xfs_ail	*ailp = mp->m_ail;
>  
>  	kthread_stop(ailp->ail_task);
> -	kmem_free(ailp);
> +	kfree(ailp);
>  }
> -- 
> 2.23.0
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/4] xfs: Remove kmem_free()
  2019-11-14 21:00   ` Darrick J. Wong
@ 2019-11-15 14:20     ` Carlos Maiolino
  2019-11-15 17:23       ` Darrick J. Wong
  0 siblings, 1 reply; 14+ messages in thread
From: Carlos Maiolino @ 2019-11-15 14:20 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-xfs, dchinner

On Thu, Nov 14, 2019 at 01:00:00PM -0800, Darrick J. Wong wrote:
> On Thu, Nov 14, 2019 at 09:09:55PM +0100, Carlos Maiolino wrote:
> > This can be replaced by direct calls to kfree() or kvfree() (whenever
> > allocation is done via kmem_alloc_io() or kmem_alloc_large().
> > 
> > This patch has been partially scripted. I used the following sed to
> > replace all kmem_free() calls by kfree()
> > 
> >  # find fs/xfs/ -type f -name '*.c' -o -name '*.h' | xargs sed -i \
> >    's/kmem_free/kfree/g'
> 
> Coccinelle? ;)

/me Doesn't understand the reference but thinks Darrick is talking about
Coccinelle fancy brand :P

/me is adept to conference-wear :D

> 
> > And manually inspected kmem_alloc_io() and kmem_alloc_large() uses to
> > use kvfree() instead.
> 
> Why not just use kvfree everywhere?  Is there a significant performance
> penalty for the is_vmalloc_addr() check in kvfree vs. having to keep
> track of kfree vs. kvfree?

I honestly didn't see a big difference between both. Although, I didn't test
much, other than some perf measurements while exercising some paths like for
example xfs_dir_lookup().

I can't really say we will have any benefits in segmenting it by using kvfree()
only where kmem_alloc_{large, io} is used, so I just relied on the comments
above kvfree(), and well, we have an extra function call and a few extra
instructions using kvfree(). So, even though it might be 'slightly' faster, this
might build up on hot paths when handling millions of kfree().

But, at the end, I'd be lying if I say I spotted any significant difference.


Btw, Dave mentioned in a not so far future, kmalloc() requests will be
guaranteed to be aligned, so, I wonder if we will be able to replace both
kmem_alloc_large() and kmem_alloc_io() by simple calls to kvmalloc() which does
the job of falling back to vmalloc() if kmalloc() fails?!

Not related to this patch itself, but to the whole talks about these helpers, I
just thought worth to mention.

> 
> --D
> 
> > Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
> > ---
> >  fs/xfs/kmem.h                  |  5 ----
> >  fs/xfs/libxfs/xfs_attr.c       |  2 +-
> >  fs/xfs/libxfs/xfs_attr_leaf.c  |  8 +++---
> >  fs/xfs/libxfs/xfs_da_btree.c   | 10 +++----
> >  fs/xfs/libxfs/xfs_defer.c      |  4 +--
> >  fs/xfs/libxfs/xfs_dir2.c       | 18 ++++++------
> >  fs/xfs/libxfs/xfs_dir2_block.c |  4 +--
> >  fs/xfs/libxfs/xfs_dir2_sf.c    |  8 +++---
> >  fs/xfs/libxfs/xfs_iext_tree.c  |  8 +++---
> >  fs/xfs/libxfs/xfs_inode_fork.c |  8 +++---
> >  fs/xfs/libxfs/xfs_refcount.c   |  4 +--
> >  fs/xfs/scrub/agheader.c        |  2 +-
> >  fs/xfs/scrub/agheader_repair.c |  2 +-
> >  fs/xfs/scrub/attr.c            |  2 +-
> >  fs/xfs/scrub/bitmap.c          |  4 +--
> >  fs/xfs/scrub/btree.c           |  2 +-
> >  fs/xfs/scrub/refcount.c        |  8 +++---
> >  fs/xfs/scrub/scrub.c           |  2 +-
> >  fs/xfs/xfs_acl.c               |  4 +--
> >  fs/xfs/xfs_attr_inactive.c     |  2 +-
> >  fs/xfs/xfs_attr_list.c         |  4 +--
> >  fs/xfs/xfs_bmap_item.c         |  4 +--
> >  fs/xfs/xfs_buf.c               | 12 ++++----
> >  fs/xfs/xfs_buf_item.c          |  4 +--
> >  fs/xfs/xfs_dquot.c             |  2 +-
> >  fs/xfs/xfs_dquot_item.c        |  8 +++---
> >  fs/xfs/xfs_error.c             |  2 +-
> >  fs/xfs/xfs_extent_busy.c       |  2 +-
> >  fs/xfs/xfs_extfree_item.c      | 14 +++++-----
> >  fs/xfs/xfs_filestream.c        |  4 +--
> >  fs/xfs/xfs_inode.c             | 12 ++++----
> >  fs/xfs/xfs_inode_item.c        |  2 +-
> >  fs/xfs/xfs_ioctl.c             |  6 ++--
> >  fs/xfs/xfs_ioctl32.c           |  2 +-
> >  fs/xfs/xfs_iops.c              |  2 +-
> >  fs/xfs/xfs_itable.c            |  4 +--
> >  fs/xfs/xfs_iwalk.c             |  4 +--
> >  fs/xfs/xfs_log.c               | 12 ++++----
> >  fs/xfs/xfs_log_cil.c           | 16 +++++------
> >  fs/xfs/xfs_log_recover.c       | 50 +++++++++++++++++-----------------
> >  fs/xfs/xfs_mount.c             |  8 +++---
> >  fs/xfs/xfs_mru_cache.c         |  8 +++---
> >  fs/xfs/xfs_qm.c                |  6 ++--
> >  fs/xfs/xfs_refcount_item.c     |  6 ++--
> >  fs/xfs/xfs_rmap_item.c         |  6 ++--
> >  fs/xfs/xfs_rtalloc.c           |  8 +++---
> >  fs/xfs/xfs_super.c             |  2 +-
> >  fs/xfs/xfs_trans_ail.c         |  4 +--
> >  48 files changed, 158 insertions(+), 163 deletions(-)
> > 
> > diff --git a/fs/xfs/kmem.h b/fs/xfs/kmem.h
> > index 6143117770e9..ccdc72519339 100644
> > --- a/fs/xfs/kmem.h
> > +++ b/fs/xfs/kmem.h
> > @@ -56,11 +56,6 @@ 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);
> > -}
> > -
> >  
> >  static inline void *
> >  kmem_zalloc(size_t size, xfs_km_flags_t flags)
> > diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
> > index 510ca6974604..bc8ca09e71d0 100644
> > --- a/fs/xfs/libxfs/xfs_attr.c
> > +++ b/fs/xfs/libxfs/xfs_attr.c
> > @@ -174,7 +174,7 @@ xfs_attr_get(
> >  	/* on error, we have to clean up allocated value buffers */
> >  	if (error) {
> >  		if (flags & ATTR_ALLOC) {
> > -			kmem_free(args.value);
> > +			kvfree(args.value);
> >  			*value = NULL;
> >  		}
> >  		return error;
> > diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
> > index 85ec5945d29f..795b9b21b64d 100644
> > --- a/fs/xfs/libxfs/xfs_attr_leaf.c
> > +++ b/fs/xfs/libxfs/xfs_attr_leaf.c
> > @@ -931,7 +931,7 @@ xfs_attr_shortform_to_leaf(
> >  	error = 0;
> >  	*leaf_bp = bp;
> >  out:
> > -	kmem_free(tmpbuffer);
> > +	kfree(tmpbuffer);
> >  	return error;
> >  }
> >  
> > @@ -1131,7 +1131,7 @@ xfs_attr3_leaf_to_shortform(
> >  	error = 0;
> >  
> >  out:
> > -	kmem_free(tmpbuffer);
> > +	kfree(tmpbuffer);
> >  	return error;
> >  }
> >  
> > @@ -1572,7 +1572,7 @@ xfs_attr3_leaf_compact(
> >  	 */
> >  	xfs_trans_log_buf(trans, bp, 0, args->geo->blksize - 1);
> >  
> > -	kmem_free(tmpbuffer);
> > +	kfree(tmpbuffer);
> >  }
> >  
> >  /*
> > @@ -2293,7 +2293,7 @@ xfs_attr3_leaf_unbalance(
> >  		}
> >  		memcpy(save_leaf, tmp_leaf, state->args->geo->blksize);
> >  		savehdr = tmphdr; /* struct copy */
> > -		kmem_free(tmp_leaf);
> > +		kfree(tmp_leaf);
> >  	}
> >  
> >  	xfs_attr3_leaf_hdr_to_disk(state->args->geo, save_leaf, &savehdr);
> > diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
> > index c5c0b73febae..7ae82d91f776 100644
> > --- a/fs/xfs/libxfs/xfs_da_btree.c
> > +++ b/fs/xfs/libxfs/xfs_da_btree.c
> > @@ -2189,7 +2189,7 @@ xfs_da_grow_inode_int(
> >  
> >  out_free_map:
> >  	if (mapp != &map)
> > -		kmem_free(mapp);
> > +		kfree(mapp);
> >  	return error;
> >  }
> >  
> > @@ -2639,7 +2639,7 @@ xfs_dabuf_map(
> >  	error = xfs_buf_map_from_irec(mp, map, nmaps, irecs, nirecs);
> >  out:
> >  	if (irecs != &irec)
> > -		kmem_free(irecs);
> > +		kfree(irecs);
> >  	return error;
> >  }
> >  
> > @@ -2686,7 +2686,7 @@ xfs_da_get_buf(
> >  
> >  out_free:
> >  	if (mapp != &map)
> > -		kmem_free(mapp);
> > +		kfree(mapp);
> >  
> >  	return error;
> >  }
> > @@ -2735,7 +2735,7 @@ xfs_da_read_buf(
> >  	*bpp = bp;
> >  out_free:
> >  	if (mapp != &map)
> > -		kmem_free(mapp);
> > +		kfree(mapp);
> >  
> >  	return error;
> >  }
> > @@ -2772,7 +2772,7 @@ xfs_da_reada_buf(
> >  
> >  out_free:
> >  	if (mapp != &map)
> > -		kmem_free(mapp);
> > +		kfree(mapp);
> >  
> >  	return error;
> >  }
> > diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c
> > index 22557527cfdb..27c3d150068a 100644
> > --- a/fs/xfs/libxfs/xfs_defer.c
> > +++ b/fs/xfs/libxfs/xfs_defer.c
> > @@ -341,7 +341,7 @@ xfs_defer_cancel_list(
> >  			ops->cancel_item(pwi);
> >  		}
> >  		ASSERT(dfp->dfp_count == 0);
> > -		kmem_free(dfp);
> > +		kfree(dfp);
> >  	}
> >  }
> >  
> > @@ -433,7 +433,7 @@ xfs_defer_finish_noroll(
> >  		} else {
> >  			/* Done with the dfp, free it. */
> >  			list_del(&dfp->dfp_list);
> > -			kmem_free(dfp);
> > +			kfree(dfp);
> >  		}
> >  
> >  		if (ops->finish_cleanup)
> > diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c
> > index 624c05e77ab4..efd7cec65259 100644
> > --- a/fs/xfs/libxfs/xfs_dir2.c
> > +++ b/fs/xfs/libxfs/xfs_dir2.c
> > @@ -109,8 +109,8 @@ xfs_da_mount(
> >  	mp->m_attr_geo = kmem_zalloc(sizeof(struct xfs_da_geometry),
> >  				     KM_MAYFAIL);
> >  	if (!mp->m_dir_geo || !mp->m_attr_geo) {
> > -		kmem_free(mp->m_dir_geo);
> > -		kmem_free(mp->m_attr_geo);
> > +		kfree(mp->m_dir_geo);
> > +		kfree(mp->m_attr_geo);
> >  		return -ENOMEM;
> >  	}
> >  
> > @@ -176,8 +176,8 @@ void
> >  xfs_da_unmount(
> >  	struct xfs_mount	*mp)
> >  {
> > -	kmem_free(mp->m_dir_geo);
> > -	kmem_free(mp->m_attr_geo);
> > +	kfree(mp->m_dir_geo);
> > +	kfree(mp->m_attr_geo);
> >  }
> >  
> >  /*
> > @@ -242,7 +242,7 @@ xfs_dir_init(
> >  	args->dp = dp;
> >  	args->trans = tp;
> >  	error = xfs_dir2_sf_create(args, pdp->i_ino);
> > -	kmem_free(args);
> > +	kfree(args);
> >  	return error;
> >  }
> >  
> > @@ -311,7 +311,7 @@ xfs_dir_createname(
> >  		rval = xfs_dir2_node_addname(args);
> >  
> >  out_free:
> > -	kmem_free(args);
> > +	kfree(args);
> >  	return rval;
> >  }
> >  
> > @@ -417,7 +417,7 @@ xfs_dir_lookup(
> >  	}
> >  out_free:
> >  	xfs_iunlock(dp, lock_mode);
> > -	kmem_free(args);
> > +	kfree(args);
> >  	return rval;
> >  }
> >  
> > @@ -475,7 +475,7 @@ xfs_dir_removename(
> >  	else
> >  		rval = xfs_dir2_node_removename(args);
> >  out_free:
> > -	kmem_free(args);
> > +	kfree(args);
> >  	return rval;
> >  }
> >  
> > @@ -536,7 +536,7 @@ xfs_dir_replace(
> >  	else
> >  		rval = xfs_dir2_node_replace(args);
> >  out_free:
> > -	kmem_free(args);
> > +	kfree(args);
> >  	return rval;
> >  }
> >  
> > diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c
> > index 358151ddfa75..766f282b706a 100644
> > --- a/fs/xfs/libxfs/xfs_dir2_block.c
> > +++ b/fs/xfs/libxfs/xfs_dir2_block.c
> > @@ -1229,7 +1229,7 @@ xfs_dir2_sf_to_block(
> >  			sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep);
> >  	}
> >  	/* Done with the temporary buffer */
> > -	kmem_free(sfp);
> > +	kfree(sfp);
> >  	/*
> >  	 * Sort the leaf entries by hash value.
> >  	 */
> > @@ -1244,6 +1244,6 @@ xfs_dir2_sf_to_block(
> >  	xfs_dir3_data_check(dp, bp);
> >  	return 0;
> >  out_free:
> > -	kmem_free(sfp);
> > +	kfree(sfp);
> >  	return error;
> >  }
> > diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c
> > index db1a82972d9e..f4de4e7b10ef 100644
> > --- a/fs/xfs/libxfs/xfs_dir2_sf.c
> > +++ b/fs/xfs/libxfs/xfs_dir2_sf.c
> > @@ -350,7 +350,7 @@ xfs_dir2_block_to_sf(
> >  	xfs_dir2_sf_check(args);
> >  out:
> >  	xfs_trans_log_inode(args->trans, dp, logflags);
> > -	kmem_free(sfp);
> > +	kfree(sfp);
> >  	return error;
> >  }
> >  
> > @@ -585,7 +585,7 @@ xfs_dir2_sf_addname_hard(
> >  		sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep);
> >  		memcpy(sfep, oldsfep, old_isize - nbytes);
> >  	}
> > -	kmem_free(buf);
> > +	kfree(buf);
> >  	dp->i_d.di_size = new_isize;
> >  	xfs_dir2_sf_check(args);
> >  }
> > @@ -1202,7 +1202,7 @@ xfs_dir2_sf_toino4(
> >  	/*
> >  	 * Clean up the inode.
> >  	 */
> > -	kmem_free(buf);
> > +	kfree(buf);
> >  	dp->i_d.di_size = newsize;
> >  	xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA);
> >  }
> > @@ -1275,7 +1275,7 @@ xfs_dir2_sf_toino8(
> >  	/*
> >  	 * Clean up the inode.
> >  	 */
> > -	kmem_free(buf);
> > +	kfree(buf);
> >  	dp->i_d.di_size = newsize;
> >  	xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA);
> >  }
> > diff --git a/fs/xfs/libxfs/xfs_iext_tree.c b/fs/xfs/libxfs/xfs_iext_tree.c
> > index 52451809c478..a7ba30cd81da 100644
> > --- a/fs/xfs/libxfs/xfs_iext_tree.c
> > +++ b/fs/xfs/libxfs/xfs_iext_tree.c
> > @@ -734,7 +734,7 @@ xfs_iext_remove_node(
> >  again:
> >  	ASSERT(node->ptrs[pos]);
> >  	ASSERT(node->ptrs[pos] == victim);
> > -	kmem_free(victim);
> > +	kfree(victim);
> >  
> >  	nr_entries = xfs_iext_node_nr_entries(node, pos) - 1;
> >  	offset = node->keys[0];
> > @@ -780,7 +780,7 @@ xfs_iext_remove_node(
> >  		ASSERT(node == ifp->if_u1.if_root);
> >  		ifp->if_u1.if_root = node->ptrs[0];
> >  		ifp->if_height--;
> > -		kmem_free(node);
> > +		kfree(node);
> >  	}
> >  }
> >  
> > @@ -854,7 +854,7 @@ xfs_iext_free_last_leaf(
> >  	struct xfs_ifork	*ifp)
> >  {
> >  	ifp->if_height--;
> > -	kmem_free(ifp->if_u1.if_root);
> > +	kfree(ifp->if_u1.if_root);
> >  	ifp->if_u1.if_root = NULL;
> >  }
> >  
> > @@ -1035,7 +1035,7 @@ xfs_iext_destroy_node(
> >  		}
> >  	}
> >  
> > -	kmem_free(node);
> > +	kfree(node);
> >  }
> >  
> >  void
> > diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
> > index ad2b9c313fd2..296677958212 100644
> > --- a/fs/xfs/libxfs/xfs_inode_fork.c
> > +++ b/fs/xfs/libxfs/xfs_inode_fork.c
> > @@ -445,7 +445,7 @@ xfs_iroot_realloc(
> >  						     (int)new_size);
> >  		memcpy(np, op, new_max * (uint)sizeof(xfs_fsblock_t));
> >  	}
> > -	kmem_free(ifp->if_broot);
> > +	kfree(ifp->if_broot);
> >  	ifp->if_broot = new_broot;
> >  	ifp->if_broot_bytes = (int)new_size;
> >  	if (ifp->if_broot)
> > @@ -486,7 +486,7 @@ xfs_idata_realloc(
> >  		return;
> >  
> >  	if (new_size == 0) {
> > -		kmem_free(ifp->if_u1.if_data);
> > +		kfree(ifp->if_u1.if_data);
> >  		ifp->if_u1.if_data = NULL;
> >  		ifp->if_bytes = 0;
> >  		return;
> > @@ -511,7 +511,7 @@ xfs_idestroy_fork(
> >  
> >  	ifp = XFS_IFORK_PTR(ip, whichfork);
> >  	if (ifp->if_broot != NULL) {
> > -		kmem_free(ifp->if_broot);
> > +		kfree(ifp->if_broot);
> >  		ifp->if_broot = NULL;
> >  	}
> >  
> > @@ -523,7 +523,7 @@ xfs_idestroy_fork(
> >  	 */
> >  	if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL) {
> >  		if (ifp->if_u1.if_data != NULL) {
> > -			kmem_free(ifp->if_u1.if_data);
> > +			kfree(ifp->if_u1.if_data);
> >  			ifp->if_u1.if_data = NULL;
> >  		}
> >  	} else if ((ifp->if_flags & XFS_IFEXTENTS) && ifp->if_height) {
> > diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c
> > index 78236bd6c64f..07894c53e753 100644
> > --- a/fs/xfs/libxfs/xfs_refcount.c
> > +++ b/fs/xfs/libxfs/xfs_refcount.c
> > @@ -1684,7 +1684,7 @@ xfs_refcount_recover_cow_leftovers(
> >  			goto out_free;
> >  
> >  		list_del(&rr->rr_list);
> > -		kmem_free(rr);
> > +		kfree(rr);
> >  	}
> >  
> >  	return error;
> > @@ -1694,7 +1694,7 @@ xfs_refcount_recover_cow_leftovers(
> >  	/* Free the leftover list */
> >  	list_for_each_entry_safe(rr, n, &debris, rr_list) {
> >  		list_del(&rr->rr_list);
> > -		kmem_free(rr);
> > +		kfree(rr);
> >  	}
> >  	return error;
> >  }
> > diff --git a/fs/xfs/scrub/agheader.c b/fs/xfs/scrub/agheader.c
> > index ba0f747c82e8..6f7126f6d25c 100644
> > --- a/fs/xfs/scrub/agheader.c
> > +++ b/fs/xfs/scrub/agheader.c
> > @@ -753,7 +753,7 @@ xchk_agfl(
> >  	}
> >  
> >  out_free:
> > -	kmem_free(sai.entries);
> > +	kfree(sai.entries);
> >  out:
> >  	return error;
> >  }
> > diff --git a/fs/xfs/scrub/agheader_repair.c b/fs/xfs/scrub/agheader_repair.c
> > index 7a1a38b636a9..15fabf020d1b 100644
> > --- a/fs/xfs/scrub/agheader_repair.c
> > +++ b/fs/xfs/scrub/agheader_repair.c
> > @@ -624,7 +624,7 @@ xrep_agfl_init_header(
> >  		if (br->len)
> >  			break;
> >  		list_del(&br->list);
> > -		kmem_free(br);
> > +		kfree(br);
> >  	}
> >  
> >  	/* Write new AGFL to disk. */
> > diff --git a/fs/xfs/scrub/attr.c b/fs/xfs/scrub/attr.c
> > index d9f0dd444b80..7a2a240febc1 100644
> > --- a/fs/xfs/scrub/attr.c
> > +++ b/fs/xfs/scrub/attr.c
> > @@ -49,7 +49,7 @@ xchk_setup_xattr_buf(
> >  	if (ab) {
> >  		if (sz <= ab->sz)
> >  			return 0;
> > -		kmem_free(ab);
> > +		kvfree(ab);
> >  		sc->buf = NULL;
> >  	}
> >  
> > diff --git a/fs/xfs/scrub/bitmap.c b/fs/xfs/scrub/bitmap.c
> > index 18a684e18a69..cabde1c4c235 100644
> > --- a/fs/xfs/scrub/bitmap.c
> > +++ b/fs/xfs/scrub/bitmap.c
> > @@ -47,7 +47,7 @@ xfs_bitmap_destroy(
> >  
> >  	for_each_xfs_bitmap_extent(bmr, n, bitmap) {
> >  		list_del(&bmr->list);
> > -		kmem_free(bmr);
> > +		kfree(bmr);
> >  	}
> >  }
> >  
> > @@ -174,7 +174,7 @@ xfs_bitmap_disunion(
> >  			/* Total overlap, just delete ex. */
> >  			lp = lp->next;
> >  			list_del(&br->list);
> > -			kmem_free(br);
> > +			kfree(br);
> >  			break;
> >  		case 0:
> >  			/*
> > diff --git a/fs/xfs/scrub/btree.c b/fs/xfs/scrub/btree.c
> > index f52a7b8256f9..bed40b605076 100644
> > --- a/fs/xfs/scrub/btree.c
> > +++ b/fs/xfs/scrub/btree.c
> > @@ -698,7 +698,7 @@ xchk_btree(
> >  			error = xchk_btree_check_block_owner(&bs,
> >  					co->level, co->daddr);
> >  		list_del(&co->list);
> > -		kmem_free(co);
> > +		kfree(co);
> >  	}
> >  
> >  	return error;
> > diff --git a/fs/xfs/scrub/refcount.c b/fs/xfs/scrub/refcount.c
> > index 0cab11a5d390..985724e81ebf 100644
> > --- a/fs/xfs/scrub/refcount.c
> > +++ b/fs/xfs/scrub/refcount.c
> > @@ -215,7 +215,7 @@ xchk_refcountbt_process_rmap_fragments(
> >  				continue;
> >  			}
> >  			list_del(&frag->list);
> > -			kmem_free(frag);
> > +			kfree(frag);
> >  			nr++;
> >  		}
> >  
> > @@ -257,11 +257,11 @@ xchk_refcountbt_process_rmap_fragments(
> >  	/* Delete fragments and work list. */
> >  	list_for_each_entry_safe(frag, n, &worklist, list) {
> >  		list_del(&frag->list);
> > -		kmem_free(frag);
> > +		kfree(frag);
> >  	}
> >  	list_for_each_entry_safe(frag, n, &refchk->fragments, list) {
> >  		list_del(&frag->list);
> > -		kmem_free(frag);
> > +		kfree(frag);
> >  	}
> >  }
> >  
> > @@ -308,7 +308,7 @@ xchk_refcountbt_xref_rmap(
> >  out_free:
> >  	list_for_each_entry_safe(frag, n, &refchk.fragments, list) {
> >  		list_del(&frag->list);
> > -		kmem_free(frag);
> > +		kfree(frag);
> >  	}
> >  }
> >  
> > diff --git a/fs/xfs/scrub/scrub.c b/fs/xfs/scrub/scrub.c
> > index f1775bb19313..7c63cdf13946 100644
> > --- a/fs/xfs/scrub/scrub.c
> > +++ b/fs/xfs/scrub/scrub.c
> > @@ -175,7 +175,7 @@ xchk_teardown(
> >  		sc->flags &= ~XCHK_HAS_QUOTAOFFLOCK;
> >  	}
> >  	if (sc->buf) {
> > -		kmem_free(sc->buf);
> > +		kvfree(sc->buf);
> >  		sc->buf = NULL;
> >  	}
> >  	return error;
> > diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c
> > index 91693fce34a8..81b2c989242e 100644
> > --- a/fs/xfs/xfs_acl.c
> > +++ b/fs/xfs/xfs_acl.c
> > @@ -157,7 +157,7 @@ xfs_get_acl(struct inode *inode, int type)
> >  	} else  {
> >  		acl = xfs_acl_from_disk(ip->i_mount, xfs_acl, len,
> >  					XFS_ACL_MAX_ENTRIES(ip->i_mount));
> > -		kmem_free(xfs_acl);
> > +		kvfree(xfs_acl);
> >  	}
> >  	return acl;
> >  }
> > @@ -199,7 +199,7 @@ __xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
> >  		error = xfs_attr_set(ip, ea_name, (unsigned char *)xfs_acl,
> >  				len, ATTR_ROOT);
> >  
> > -		kmem_free(xfs_acl);
> > +		kvfree(xfs_acl);
> >  	} else {
> >  		/*
> >  		 * A NULL ACL argument means we want to remove the ACL.
> > diff --git a/fs/xfs/xfs_attr_inactive.c b/fs/xfs/xfs_attr_inactive.c
> > index a78c501f6fb1..8351b3b611ac 100644
> > --- a/fs/xfs/xfs_attr_inactive.c
> > +++ b/fs/xfs/xfs_attr_inactive.c
> > @@ -181,7 +181,7 @@ xfs_attr3_leaf_inactive(
> >  			error = tmp;	/* save only the 1st errno */
> >  	}
> >  
> > -	kmem_free(list);
> > +	kfree(list);
> >  	return error;
> >  }
> >  
> > diff --git a/fs/xfs/xfs_attr_list.c b/fs/xfs/xfs_attr_list.c
> > index 0ec6606149a2..e1d1c4eb9e69 100644
> > --- a/fs/xfs/xfs_attr_list.c
> > +++ b/fs/xfs/xfs_attr_list.c
> > @@ -131,7 +131,7 @@ xfs_attr_shortform_list(
> >  					     XFS_ERRLEVEL_LOW,
> >  					     context->dp->i_mount, sfe,
> >  					     sizeof(*sfe));
> > -			kmem_free(sbuf);
> > +			kfree(sbuf);
> >  			return -EFSCORRUPTED;
> >  		}
> >  
> > @@ -195,7 +195,7 @@ xfs_attr_shortform_list(
> >  		cursor->offset++;
> >  	}
> >  out:
> > -	kmem_free(sbuf);
> > +	kfree(sbuf);
> >  	return error;
> >  }
> >  
> > diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c
> > index ee6f4229cebc..a89e10519f05 100644
> > --- a/fs/xfs/xfs_bmap_item.c
> > +++ b/fs/xfs/xfs_bmap_item.c
> > @@ -391,7 +391,7 @@ xfs_bmap_update_finish_item(
> >  		bmap->bi_bmap.br_blockcount = count;
> >  		return -EAGAIN;
> >  	}
> > -	kmem_free(bmap);
> > +	kfree(bmap);
> >  	return error;
> >  }
> >  
> > @@ -411,7 +411,7 @@ xfs_bmap_update_cancel_item(
> >  	struct xfs_bmap_intent		*bmap;
> >  
> >  	bmap = container_of(item, struct xfs_bmap_intent, bi_list);
> > -	kmem_free(bmap);
> > +	kfree(bmap);
> >  }
> >  
> >  const struct xfs_defer_op_type xfs_bmap_update_defer_type = {
> > diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
> > index a0229c368e78..80ef2fc8bb77 100644
> > --- a/fs/xfs/xfs_buf.c
> > +++ b/fs/xfs/xfs_buf.c
> > @@ -193,7 +193,7 @@ xfs_buf_free_maps(
> >  	struct xfs_buf	*bp)
> >  {
> >  	if (bp->b_maps != &bp->__b_map) {
> > -		kmem_free(bp->b_maps);
> > +		kfree(bp->b_maps);
> >  		bp->b_maps = NULL;
> >  	}
> >  }
> > @@ -292,7 +292,7 @@ _xfs_buf_free_pages(
> >  	xfs_buf_t	*bp)
> >  {
> >  	if (bp->b_pages != bp->b_page_array) {
> > -		kmem_free(bp->b_pages);
> > +		kfree(bp->b_pages);
> >  		bp->b_pages = NULL;
> >  	}
> >  }
> > @@ -325,7 +325,7 @@ xfs_buf_free(
> >  			__free_page(page);
> >  		}
> >  	} else if (bp->b_flags & _XBF_KMEM)
> > -		kmem_free(bp->b_addr);
> > +		kvfree(bp->b_addr);
> >  	_xfs_buf_free_pages(bp);
> >  	xfs_buf_free_maps(bp);
> >  	kmem_cache_free(xfs_buf_zone, bp);
> > @@ -373,7 +373,7 @@ xfs_buf_allocate_memory(
> >  		if (((unsigned long)(bp->b_addr + size - 1) & PAGE_MASK) !=
> >  		    ((unsigned long)bp->b_addr & PAGE_MASK)) {
> >  			/* b_addr spans two pages - use alloc_page instead */
> > -			kmem_free(bp->b_addr);
> > +			kvfree(bp->b_addr);
> >  			bp->b_addr = NULL;
> >  			goto use_alloc_page;
> >  		}
> > @@ -1702,7 +1702,7 @@ xfs_free_buftarg(
> >  
> >  	xfs_blkdev_issue_flush(btp);
> >  
> > -	kmem_free(btp);
> > +	kfree(btp);
> >  }
> >  
> >  int
> > @@ -1778,7 +1778,7 @@ xfs_alloc_buftarg(
> >  error_lru:
> >  	list_lru_destroy(&btp->bt_lru);
> >  error_free:
> > -	kmem_free(btp);
> > +	kfree(btp);
> >  	return NULL;
> >  }
> >  
> > diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
> > index 3458a1264a3f..8dc3330f1797 100644
> > --- a/fs/xfs/xfs_buf_item.c
> > +++ b/fs/xfs/xfs_buf_item.c
> > @@ -713,7 +713,7 @@ xfs_buf_item_free_format(
> >  	struct xfs_buf_log_item	*bip)
> >  {
> >  	if (bip->bli_formats != &bip->__bli_format) {
> > -		kmem_free(bip->bli_formats);
> > +		kfree(bip->bli_formats);
> >  		bip->bli_formats = NULL;
> >  	}
> >  }
> > @@ -938,7 +938,7 @@ xfs_buf_item_free(
> >  	struct xfs_buf_log_item	*bip)
> >  {
> >  	xfs_buf_item_free_format(bip);
> > -	kmem_free(bip->bli_item.li_lv_shadow);
> > +	kfree(bip->bli_item.li_lv_shadow);
> >  	kmem_cache_free(xfs_buf_item_zone, bip);
> >  }
> >  
> > diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
> > index 153815bf18fc..a073281c3bd7 100644
> > --- a/fs/xfs/xfs_dquot.c
> > +++ b/fs/xfs/xfs_dquot.c
> > @@ -52,7 +52,7 @@ xfs_qm_dqdestroy(
> >  {
> >  	ASSERT(list_empty(&dqp->q_lru));
> >  
> > -	kmem_free(dqp->q_logitem.qli_item.li_lv_shadow);
> > +	kfree(dqp->q_logitem.qli_item.li_lv_shadow);
> >  	mutex_destroy(&dqp->q_qlock);
> >  
> >  	XFS_STATS_DEC(dqp->q_mount, xs_qm_dquot);
> > diff --git a/fs/xfs/xfs_dquot_item.c b/fs/xfs/xfs_dquot_item.c
> > index d60647d7197b..1b5e68ccef60 100644
> > --- a/fs/xfs/xfs_dquot_item.c
> > +++ b/fs/xfs/xfs_dquot_item.c
> > @@ -316,10 +316,10 @@ xfs_qm_qoffend_logitem_committed(
> >  	spin_lock(&ailp->ail_lock);
> >  	xfs_trans_ail_delete(ailp, &qfs->qql_item, SHUTDOWN_LOG_IO_ERROR);
> >  
> > -	kmem_free(qfs->qql_item.li_lv_shadow);
> > -	kmem_free(lip->li_lv_shadow);
> > -	kmem_free(qfs);
> > -	kmem_free(qfe);
> > +	kfree(qfs->qql_item.li_lv_shadow);
> > +	kfree(lip->li_lv_shadow);
> > +	kfree(qfs);
> > +	kfree(qfe);
> >  	return (xfs_lsn_t)-1;
> >  }
> >  
> > diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
> > index 51dd1f43d12f..4c0883380d7c 100644
> > --- a/fs/xfs/xfs_error.c
> > +++ b/fs/xfs/xfs_error.c
> > @@ -226,7 +226,7 @@ xfs_errortag_del(
> >  	struct xfs_mount	*mp)
> >  {
> >  	xfs_sysfs_del(&mp->m_errortag_kobj);
> > -	kmem_free(mp->m_errortag);
> > +	kfree(mp->m_errortag);
> >  }
> >  
> >  bool
> > diff --git a/fs/xfs/xfs_extent_busy.c b/fs/xfs/xfs_extent_busy.c
> > index 3991e59cfd18..9f0b99c7b34a 100644
> > --- a/fs/xfs/xfs_extent_busy.c
> > +++ b/fs/xfs/xfs_extent_busy.c
> > @@ -532,7 +532,7 @@ xfs_extent_busy_clear_one(
> >  	}
> >  
> >  	list_del_init(&busyp->list);
> > -	kmem_free(busyp);
> > +	kfree(busyp);
> >  }
> >  
> >  static void
> > diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
> > index 6ea847f6e298..29b3a90aee91 100644
> > --- a/fs/xfs/xfs_extfree_item.c
> > +++ b/fs/xfs/xfs_extfree_item.c
> > @@ -35,9 +35,9 @@ void
> >  xfs_efi_item_free(
> >  	struct xfs_efi_log_item	*efip)
> >  {
> > -	kmem_free(efip->efi_item.li_lv_shadow);
> > +	kfree(efip->efi_item.li_lv_shadow);
> >  	if (efip->efi_format.efi_nextents > XFS_EFI_MAX_FAST_EXTENTS)
> > -		kmem_free(efip);
> > +		kfree(efip);
> >  	else
> >  		kmem_cache_free(xfs_efi_zone, efip);
> >  }
> > @@ -240,9 +240,9 @@ static inline struct xfs_efd_log_item *EFD_ITEM(struct xfs_log_item *lip)
> >  STATIC void
> >  xfs_efd_item_free(struct xfs_efd_log_item *efdp)
> >  {
> > -	kmem_free(efdp->efd_item.li_lv_shadow);
> > +	kfree(efdp->efd_item.li_lv_shadow);
> >  	if (efdp->efd_format.efd_nextents > XFS_EFD_MAX_FAST_EXTENTS)
> > -		kmem_free(efdp);
> > +		kfree(efdp);
> >  	else
> >  		kmem_cache_free(xfs_efd_zone, efdp);
> >  }
> > @@ -488,7 +488,7 @@ xfs_extent_free_finish_item(
> >  			free->xefi_startblock,
> >  			free->xefi_blockcount,
> >  			&free->xefi_oinfo, free->xefi_skip_discard);
> > -	kmem_free(free);
> > +	kfree(free);
> >  	return error;
> >  }
> >  
> > @@ -508,7 +508,7 @@ xfs_extent_free_cancel_item(
> >  	struct xfs_extent_free_item	*free;
> >  
> >  	free = container_of(item, struct xfs_extent_free_item, xefi_list);
> > -	kmem_free(free);
> > +	kfree(free);
> >  }
> >  
> >  const struct xfs_defer_op_type xfs_extent_free_defer_type = {
> > @@ -572,7 +572,7 @@ xfs_agfl_free_finish_item(
> >  	extp->ext_len = free->xefi_blockcount;
> >  	efdp->efd_next_extent++;
> >  
> > -	kmem_free(free);
> > +	kfree(free);
> >  	return error;
> >  }
> >  
> > diff --git a/fs/xfs/xfs_filestream.c b/fs/xfs/xfs_filestream.c
> > index 2ae356775f63..9778e4e69e07 100644
> > --- a/fs/xfs/xfs_filestream.c
> > +++ b/fs/xfs/xfs_filestream.c
> > @@ -118,7 +118,7 @@ xfs_fstrm_free_func(
> >  	xfs_filestream_put_ag(mp, item->ag);
> >  	trace_xfs_filestream_free(mp, mru->key, item->ag);
> >  
> > -	kmem_free(item);
> > +	kfree(item);
> >  }
> >  
> >  /*
> > @@ -263,7 +263,7 @@ xfs_filestream_pick_ag(
> >  	return 0;
> >  
> >  out_free_item:
> > -	kmem_free(item);
> > +	kfree(item);
> >  out_put_ag:
> >  	xfs_filestream_put_ag(mp, *agp);
> >  	return err;
> > diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> > index a92d4521748d..e1121ed7cbb5 100644
> > --- a/fs/xfs/xfs_inode.c
> > +++ b/fs/xfs/xfs_inode.c
> > @@ -708,7 +708,7 @@ xfs_lookup(
> >  
> >  out_free_name:
> >  	if (ci_name)
> > -		kmem_free(ci_name->name);
> > +		kfree(ci_name->name);
> >  out_unlock:
> >  	*ipp = NULL;
> >  	return error;
> > @@ -2001,7 +2001,7 @@ xfs_iunlink_insert_backref(
> >  	 */
> >  	if (error) {
> >  		WARN(error != -ENOMEM, "iunlink cache insert error %d", error);
> > -		kmem_free(iu);
> > +		kfree(iu);
> >  	}
> >  	/*
> >  	 * Absorb any runtime errors that aren't a result of corruption because
> > @@ -2066,7 +2066,7 @@ xfs_iunlink_change_backref(
> >  
> >  	/* If there is no new next entry just free our item and return. */
> >  	if (next_unlinked == NULLAGINO) {
> > -		kmem_free(iu);
> > +		kfree(iu);
> >  		return 0;
> >  	}
> >  
> > @@ -2094,7 +2094,7 @@ xfs_iunlink_free_item(
> >  	bool			*freed_anything = arg;
> >  
> >  	*freed_anything = true;
> > -	kmem_free(iu);
> > +	kfree(iu);
> >  }
> >  
> >  void
> > @@ -3598,7 +3598,7 @@ xfs_iflush_cluster(
> >  
> >  out_free:
> >  	rcu_read_unlock();
> > -	kmem_free(cilist);
> > +	kfree(cilist);
> >  out_put:
> >  	xfs_perag_put(pag);
> >  	return 0;
> > @@ -3629,7 +3629,7 @@ xfs_iflush_cluster(
> >  
> >  	/* abort the corrupt inode, as it was not attached to the buffer */
> >  	xfs_iflush_abort(cip, false);
> > -	kmem_free(cilist);
> > +	kfree(cilist);
> >  	xfs_perag_put(pag);
> >  	return -EFSCORRUPTED;
> >  }
> > diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> > index 3a62976291a1..c8461a5515f1 100644
> > --- a/fs/xfs/xfs_inode_item.c
> > +++ b/fs/xfs/xfs_inode_item.c
> > @@ -666,7 +666,7 @@ void
> >  xfs_inode_item_destroy(
> >  	xfs_inode_t	*ip)
> >  {
> > -	kmem_free(ip->i_itemp->ili_item.li_lv_shadow);
> > +	kfree(ip->i_itemp->ili_item.li_lv_shadow);
> >  	kmem_cache_free(xfs_ili_zone, ip->i_itemp);
> >  }
> >  
> > diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> > index 364961c23cd0..f86dde7c9ea6 100644
> > --- a/fs/xfs/xfs_ioctl.c
> > +++ b/fs/xfs/xfs_ioctl.c
> > @@ -417,7 +417,7 @@ xfs_attrlist_by_handle(
> >  		error = -EFAULT;
> >  
> >  out_kfree:
> > -	kmem_free(kbuf);
> > +	kvfree(kbuf);
> >  out_dput:
> >  	dput(dentry);
> >  	return error;
> > @@ -448,7 +448,7 @@ xfs_attrmulti_attr_get(
> >  		error = -EFAULT;
> >  
> >  out_kfree:
> > -	kmem_free(kbuf);
> > +	kvfree(kbuf);
> >  	return error;
> >  }
> >  
> > @@ -1777,7 +1777,7 @@ xfs_ioc_getbmap(
> >  
> >  	error = 0;
> >  out_free_buf:
> > -	kmem_free(buf);
> > +	kvfree(buf);
> >  	return error;
> >  }
> >  
> > diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c
> > index 3c0d518e1039..de472fcd2f67 100644
> > --- a/fs/xfs/xfs_ioctl32.c
> > +++ b/fs/xfs/xfs_ioctl32.c
> > @@ -400,7 +400,7 @@ xfs_compat_attrlist_by_handle(
> >  		error = -EFAULT;
> >  
> >  out_kfree:
> > -	kmem_free(kbuf);
> > +	kvfree(kbuf);
> >  out_dput:
> >  	dput(dentry);
> >  	return error;
> > diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> > index 57e6e44123a9..e532db27d0dc 100644
> > --- a/fs/xfs/xfs_iops.c
> > +++ b/fs/xfs/xfs_iops.c
> > @@ -303,7 +303,7 @@ xfs_vn_ci_lookup(
> >  	dname.name = ci_name.name;
> >  	dname.len = ci_name.len;
> >  	dentry = d_add_ci(dentry, VFS_I(ip), &dname);
> > -	kmem_free(ci_name.name);
> > +	kfree(ci_name.name);
> >  	return dentry;
> >  }
> >  
> > diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
> > index 884950adbd16..36bf47f11117 100644
> > --- a/fs/xfs/xfs_itable.c
> > +++ b/fs/xfs/xfs_itable.c
> > @@ -175,7 +175,7 @@ xfs_bulkstat_one(
> >  
> >  	error = xfs_bulkstat_one_int(breq->mp, NULL, breq->startino, &bc);
> >  
> > -	kmem_free(bc.buf);
> > +	kfree(bc.buf);
> >  
> >  	/*
> >  	 * If we reported one inode to userspace then we abort because we hit
> > @@ -250,7 +250,7 @@ xfs_bulkstat(
> >  	error = xfs_iwalk(breq->mp, NULL, breq->startino, breq->flags,
> >  			xfs_bulkstat_iwalk, breq->icount, &bc);
> >  
> > -	kmem_free(bc.buf);
> > +	kfree(bc.buf);
> >  
> >  	/*
> >  	 * We found some inodes, so clear the error status and return them.
> > diff --git a/fs/xfs/xfs_iwalk.c b/fs/xfs/xfs_iwalk.c
> > index aa375cf53021..67e98f9023d2 100644
> > --- a/fs/xfs/xfs_iwalk.c
> > +++ b/fs/xfs/xfs_iwalk.c
> > @@ -164,7 +164,7 @@ STATIC void
> >  xfs_iwalk_free(
> >  	struct xfs_iwalk_ag	*iwag)
> >  {
> > -	kmem_free(iwag->recs);
> > +	kfree(iwag->recs);
> >  	iwag->recs = NULL;
> >  }
> >  
> > @@ -578,7 +578,7 @@ xfs_iwalk_ag_work(
> >  	error = xfs_iwalk_ag(iwag);
> >  	xfs_iwalk_free(iwag);
> >  out:
> > -	kmem_free(iwag);
> > +	kfree(iwag);
> >  	return error;
> >  }
> >  
> > diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
> > index 6a147c63a8a6..e8349b0d7c51 100644
> > --- a/fs/xfs/xfs_log.c
> > +++ b/fs/xfs/xfs_log.c
> > @@ -1540,11 +1540,11 @@ xlog_alloc_log(
> >  out_free_iclog:
> >  	for (iclog = log->l_iclog; iclog; iclog = prev_iclog) {
> >  		prev_iclog = iclog->ic_next;
> > -		kmem_free(iclog->ic_data);
> > -		kmem_free(iclog);
> > +		kvfree(iclog->ic_data);
> > +		kfree(iclog);
> >  	}
> >  out_free_log:
> > -	kmem_free(log);
> > +	kfree(log);
> >  out:
> >  	return ERR_PTR(error);
> >  }	/* xlog_alloc_log */
> > @@ -2001,14 +2001,14 @@ xlog_dealloc_log(
> >  	iclog = log->l_iclog;
> >  	for (i = 0; i < log->l_iclog_bufs; i++) {
> >  		next_iclog = iclog->ic_next;
> > -		kmem_free(iclog->ic_data);
> > -		kmem_free(iclog);
> > +		kvfree(iclog->ic_data);
> > +		kfree(iclog);
> >  		iclog = next_iclog;
> >  	}
> >  
> >  	log->l_mp->m_log = NULL;
> >  	destroy_workqueue(log->l_ioend_workqueue);
> > -	kmem_free(log);
> > +	kfree(log);
> >  }	/* xlog_dealloc_log */
> >  
> >  /*
> > diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
> > index 48435cf2aa16..23d70836a2b7 100644
> > --- a/fs/xfs/xfs_log_cil.c
> > +++ b/fs/xfs/xfs_log_cil.c
> > @@ -184,7 +184,7 @@ xlog_cil_alloc_shadow_bufs(
> >  			 * the buffer, only the log vector header and the iovec
> >  			 * storage.
> >  			 */
> > -			kmem_free(lip->li_lv_shadow);
> > +			kfree(lip->li_lv_shadow);
> >  
> >  			lv = kmem_alloc_large(buf_size, KM_NOFS);
> >  			memset(lv, 0, xlog_cil_iovec_space(niovecs));
> > @@ -492,7 +492,7 @@ xlog_cil_free_logvec(
> >  
> >  	for (lv = log_vector; lv; ) {
> >  		struct xfs_log_vec *next = lv->lv_next;
> > -		kmem_free(lv);
> > +		kvfree(lv);
> >  		lv = next;
> >  	}
> >  }
> > @@ -506,7 +506,7 @@ xlog_discard_endio_work(
> >  	struct xfs_mount	*mp = ctx->cil->xc_log->l_mp;
> >  
> >  	xfs_extent_busy_clear(mp, &ctx->busy_extents, false);
> > -	kmem_free(ctx);
> > +	kfree(ctx);
> >  }
> >  
> >  /*
> > @@ -608,7 +608,7 @@ xlog_cil_committed(
> >  	if (!list_empty(&ctx->busy_extents))
> >  		xlog_discard_busy_extents(mp, ctx);
> >  	else
> > -		kmem_free(ctx);
> > +		kfree(ctx);
> >  }
> >  
> >  void
> > @@ -872,7 +872,7 @@ xlog_cil_push(
> >  out_skip:
> >  	up_write(&cil->xc_ctx_lock);
> >  	xfs_log_ticket_put(new_ctx->ticket);
> > -	kmem_free(new_ctx);
> > +	kfree(new_ctx);
> >  	return 0;
> >  
> >  out_abort_free_ticket:
> > @@ -1185,7 +1185,7 @@ xlog_cil_init(
> >  
> >  	ctx = kmem_zalloc(sizeof(*ctx), KM_MAYFAIL);
> >  	if (!ctx) {
> > -		kmem_free(cil);
> > +		kfree(cil);
> >  		return -ENOMEM;
> >  	}
> >  
> > @@ -1216,10 +1216,10 @@ xlog_cil_destroy(
> >  	if (log->l_cilp->xc_ctx) {
> >  		if (log->l_cilp->xc_ctx->ticket)
> >  			xfs_log_ticket_put(log->l_cilp->xc_ctx->ticket);
> > -		kmem_free(log->l_cilp->xc_ctx);
> > +		kfree(log->l_cilp->xc_ctx);
> >  	}
> >  
> >  	ASSERT(list_empty(&log->l_cilp->xc_cil));
> > -	kmem_free(log->l_cilp);
> > +	kfree(log->l_cilp);
> >  }
> >  
> > diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
> > index 02f2147952b3..4167e1326f62 100644
> > --- a/fs/xfs/xfs_log_recover.c
> > +++ b/fs/xfs/xfs_log_recover.c
> > @@ -418,7 +418,7 @@ xlog_find_verify_cycle(
> >  	*new_blk = -1;
> >  
> >  out:
> > -	kmem_free(buffer);
> > +	kvfree(buffer);
> >  	return error;
> >  }
> >  
> > @@ -529,7 +529,7 @@ xlog_find_verify_log_record(
> >  		*last_blk = i;
> >  
> >  out:
> > -	kmem_free(buffer);
> > +	kvfree(buffer);
> >  	return error;
> >  }
> >  
> > @@ -783,7 +783,7 @@ xlog_find_head(
> >  			goto out_free_buffer;
> >  	}
> >  
> > -	kmem_free(buffer);
> > +	kvfree(buffer);
> >  	if (head_blk == log_bbnum)
> >  		*return_head_blk = 0;
> >  	else
> > @@ -797,7 +797,7 @@ xlog_find_head(
> >  	return 0;
> >  
> >  out_free_buffer:
> > -	kmem_free(buffer);
> > +	kvfree(buffer);
> >  	if (error)
> >  		xfs_warn(log->l_mp, "failed to find log head");
> >  	return error;
> > @@ -1051,7 +1051,7 @@ xlog_verify_tail(
> >  		"Tail block (0x%llx) overwrite detected. Updated to 0x%llx",
> >  			 orig_tail, *tail_blk);
> >  out:
> > -	kmem_free(buffer);
> > +	kvfree(buffer);
> >  	return error;
> >  }
> >  
> > @@ -1098,7 +1098,7 @@ xlog_verify_head(
> >  	error = xlog_rseek_logrec_hdr(log, *head_blk, *tail_blk,
> >  				      XLOG_MAX_ICLOGS, tmp_buffer,
> >  				      &tmp_rhead_blk, &tmp_rhead, &tmp_wrapped);
> > -	kmem_free(tmp_buffer);
> > +	kvfree(tmp_buffer);
> >  	if (error < 0)
> >  		return error;
> >  
> > @@ -1431,7 +1431,7 @@ xlog_find_tail(
> >  		error = xlog_clear_stale_blocks(log, tail_lsn);
> >  
> >  done:
> > -	kmem_free(buffer);
> > +	kvfree(buffer);
> >  
> >  	if (error)
> >  		xfs_warn(log->l_mp, "failed to locate log tail");
> > @@ -1479,7 +1479,7 @@ xlog_find_zeroed(
> >  	first_cycle = xlog_get_cycle(offset);
> >  	if (first_cycle == 0) {		/* completely zeroed log */
> >  		*blk_no = 0;
> > -		kmem_free(buffer);
> > +		kvfree(buffer);
> >  		return 1;
> >  	}
> >  
> > @@ -1490,7 +1490,7 @@ xlog_find_zeroed(
> >  
> >  	last_cycle = xlog_get_cycle(offset);
> >  	if (last_cycle != 0) {		/* log completely written to */
> > -		kmem_free(buffer);
> > +		kvfree(buffer);
> >  		return 0;
> >  	}
> >  
> > @@ -1537,7 +1537,7 @@ xlog_find_zeroed(
> >  
> >  	*blk_no = last_blk;
> >  out_free_buffer:
> > -	kmem_free(buffer);
> > +	kvfree(buffer);
> >  	if (error)
> >  		return error;
> >  	return 1;
> > @@ -1649,7 +1649,7 @@ xlog_write_log_records(
> >  	}
> >  
> >  out_free_buffer:
> > -	kmem_free(buffer);
> > +	kvfree(buffer);
> >  	return error;
> >  }
> >  
> > @@ -2039,7 +2039,7 @@ xlog_check_buffer_cancelled(
> >  	if (flags & XFS_BLF_CANCEL) {
> >  		if (--bcp->bc_refcount == 0) {
> >  			list_del(&bcp->bc_list);
> > -			kmem_free(bcp);
> > +			kfree(bcp);
> >  		}
> >  	}
> >  	return 1;
> > @@ -3188,7 +3188,7 @@ xlog_recover_inode_pass2(
> >  	xfs_buf_relse(bp);
> >  error:
> >  	if (need_free)
> > -		kmem_free(in_f);
> > +		kfree(in_f);
> >  	return error;
> >  }
> >  
> > @@ -4292,7 +4292,7 @@ xlog_recover_add_to_trans(
> >  		"bad number of regions (%d) in inode log format",
> >  				  in_f->ilf_size);
> >  			ASSERT(0);
> > -			kmem_free(ptr);
> > +			kfree(ptr);
> >  			return -EFSCORRUPTED;
> >  		}
> >  
> > @@ -4307,7 +4307,7 @@ xlog_recover_add_to_trans(
> >  	"log item region count (%d) overflowed size (%d)",
> >  				item->ri_cnt, item->ri_total);
> >  		ASSERT(0);
> > -		kmem_free(ptr);
> > +		kfree(ptr);
> >  		return -EFSCORRUPTED;
> >  	}
> >  
> > @@ -4337,13 +4337,13 @@ xlog_recover_free_trans(
> >  		/* Free the regions in the item. */
> >  		list_del(&item->ri_list);
> >  		for (i = 0; i < item->ri_cnt; i++)
> > -			kmem_free(item->ri_buf[i].i_addr);
> > +			kfree(item->ri_buf[i].i_addr);
> >  		/* Free the item itself */
> > -		kmem_free(item->ri_buf);
> > -		kmem_free(item);
> > +		kfree(item->ri_buf);
> > +		kfree(item);
> >  	}
> >  	/* Free the transaction recover structure */
> > -	kmem_free(trans);
> > +	kfree(trans);
> >  }
> >  
> >  /*
> > @@ -5327,7 +5327,7 @@ xlog_do_recovery_pass(
> >  			hblks = h_size / XLOG_HEADER_CYCLE_SIZE;
> >  			if (h_size % XLOG_HEADER_CYCLE_SIZE)
> >  				hblks++;
> > -			kmem_free(hbp);
> > +			kvfree(hbp);
> >  			hbp = xlog_alloc_buffer(log, hblks);
> >  		} else {
> >  			hblks = 1;
> > @@ -5343,7 +5343,7 @@ xlog_do_recovery_pass(
> >  		return -ENOMEM;
> >  	dbp = xlog_alloc_buffer(log, BTOBB(h_size));
> >  	if (!dbp) {
> > -		kmem_free(hbp);
> > +		kvfree(hbp);
> >  		return -ENOMEM;
> >  	}
> >  
> > @@ -5504,9 +5504,9 @@ xlog_do_recovery_pass(
> >  	}
> >  
> >   bread_err2:
> > -	kmem_free(dbp);
> > +	kvfree(dbp);
> >   bread_err1:
> > -	kmem_free(hbp);
> > +	kvfree(hbp);
> >  
> >  	/*
> >  	 * Submit buffers that have been added from the last record processed,
> > @@ -5570,7 +5570,7 @@ xlog_do_log_recovery(
> >  	error = xlog_do_recovery_pass(log, head_blk, tail_blk,
> >  				      XLOG_RECOVER_PASS1, NULL);
> >  	if (error != 0) {
> > -		kmem_free(log->l_buf_cancel_table);
> > +		kfree(log->l_buf_cancel_table);
> >  		log->l_buf_cancel_table = NULL;
> >  		return error;
> >  	}
> > @@ -5589,7 +5589,7 @@ xlog_do_log_recovery(
> >  	}
> >  #endif	/* DEBUG */
> >  
> > -	kmem_free(log->l_buf_cancel_table);
> > +	kfree(log->l_buf_cancel_table);
> >  	log->l_buf_cancel_table = NULL;
> >  
> >  	return error;
> > diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
> > index 5ea95247a37f..53ddb058b11a 100644
> > --- a/fs/xfs/xfs_mount.c
> > +++ b/fs/xfs/xfs_mount.c
> > @@ -42,7 +42,7 @@ xfs_uuid_table_free(void)
> >  {
> >  	if (xfs_uuid_table_size == 0)
> >  		return;
> > -	kmem_free(xfs_uuid_table);
> > +	kfree(xfs_uuid_table);
> >  	xfs_uuid_table = NULL;
> >  	xfs_uuid_table_size = 0;
> >  }
> > @@ -127,7 +127,7 @@ __xfs_free_perag(
> >  	struct xfs_perag *pag = container_of(head, struct xfs_perag, rcu_head);
> >  
> >  	ASSERT(atomic_read(&pag->pag_ref) == 0);
> > -	kmem_free(pag);
> > +	kfree(pag);
> >  }
> >  
> >  /*
> > @@ -243,7 +243,7 @@ xfs_initialize_perag(
> >  	xfs_buf_hash_destroy(pag);
> >  out_free_pag:
> >  	mutex_destroy(&pag->pag_ici_reclaim_lock);
> > -	kmem_free(pag);
> > +	kfree(pag);
> >  out_unwind_new_pags:
> >  	/* unwind any prior newly initialized pags */
> >  	for (index = first_initialised; index < agcount; index++) {
> > @@ -253,7 +253,7 @@ xfs_initialize_perag(
> >  		xfs_buf_hash_destroy(pag);
> >  		xfs_iunlink_destroy(pag);
> >  		mutex_destroy(&pag->pag_ici_reclaim_lock);
> > -		kmem_free(pag);
> > +		kfree(pag);
> >  	}
> >  	return error;
> >  }
> > diff --git a/fs/xfs/xfs_mru_cache.c b/fs/xfs/xfs_mru_cache.c
> > index a06661dac5be..6ef0a71d7681 100644
> > --- a/fs/xfs/xfs_mru_cache.c
> > +++ b/fs/xfs/xfs_mru_cache.c
> > @@ -364,9 +364,9 @@ xfs_mru_cache_create(
> >  
> >  exit:
> >  	if (err && mru && mru->lists)
> > -		kmem_free(mru->lists);
> > +		kfree(mru->lists);
> >  	if (err && mru)
> > -		kmem_free(mru);
> > +		kfree(mru);
> >  
> >  	return err;
> >  }
> > @@ -406,8 +406,8 @@ xfs_mru_cache_destroy(
> >  
> >  	xfs_mru_cache_flush(mru);
> >  
> > -	kmem_free(mru->lists);
> > -	kmem_free(mru);
> > +	kfree(mru->lists);
> > +	kfree(mru);
> >  }
> >  
> >  /*
> > diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
> > index 66ea8e4fca86..06c92dc61a03 100644
> > --- a/fs/xfs/xfs_qm.c
> > +++ b/fs/xfs/xfs_qm.c
> > @@ -698,7 +698,7 @@ xfs_qm_init_quotainfo(
> >  out_free_lru:
> >  	list_lru_destroy(&qinf->qi_lru);
> >  out_free_qinf:
> > -	kmem_free(qinf);
> > +	kfree(qinf);
> >  	mp->m_quotainfo = NULL;
> >  	return error;
> >  }
> > @@ -722,7 +722,7 @@ xfs_qm_destroy_quotainfo(
> >  	xfs_qm_destroy_quotainos(qi);
> >  	mutex_destroy(&qi->qi_tree_lock);
> >  	mutex_destroy(&qi->qi_quotaofflock);
> > -	kmem_free(qi);
> > +	kfree(qi);
> >  	mp->m_quotainfo = NULL;
> >  }
> >  
> > @@ -1049,7 +1049,7 @@ xfs_qm_reset_dqcounts_buf(
> >  	} while (nmaps > 0);
> >  
> >  out:
> > -	kmem_free(map);
> > +	kfree(map);
> >  	return error;
> >  }
> >  
> > diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c
> > index 8eeed73928cd..0ac598f55339 100644
> > --- a/fs/xfs/xfs_refcount_item.c
> > +++ b/fs/xfs/xfs_refcount_item.c
> > @@ -32,7 +32,7 @@ xfs_cui_item_free(
> >  	struct xfs_cui_log_item	*cuip)
> >  {
> >  	if (cuip->cui_format.cui_nextents > XFS_CUI_MAX_FAST_EXTENTS)
> > -		kmem_free(cuip);
> > +		kfree(cuip);
> >  	else
> >  		kmem_cache_free(xfs_cui_zone, cuip);
> >  }
> > @@ -392,7 +392,7 @@ xfs_refcount_update_finish_item(
> >  		refc->ri_blockcount = new_aglen;
> >  		return -EAGAIN;
> >  	}
> > -	kmem_free(refc);
> > +	kfree(refc);
> >  	return error;
> >  }
> >  
> > @@ -424,7 +424,7 @@ xfs_refcount_update_cancel_item(
> >  	struct xfs_refcount_intent	*refc;
> >  
> >  	refc = container_of(item, struct xfs_refcount_intent, ri_list);
> > -	kmem_free(refc);
> > +	kfree(refc);
> >  }
> >  
> >  const struct xfs_defer_op_type xfs_refcount_update_defer_type = {
> > diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c
> > index 4911b68f95dd..a0a02d862ddd 100644
> > --- a/fs/xfs/xfs_rmap_item.c
> > +++ b/fs/xfs/xfs_rmap_item.c
> > @@ -32,7 +32,7 @@ xfs_rui_item_free(
> >  	struct xfs_rui_log_item	*ruip)
> >  {
> >  	if (ruip->rui_format.rui_nextents > XFS_RUI_MAX_FAST_EXTENTS)
> > -		kmem_free(ruip);
> > +		kfree(ruip);
> >  	else
> >  		kmem_cache_free(xfs_rui_zone, ruip);
> >  }
> > @@ -436,7 +436,7 @@ xfs_rmap_update_finish_item(
> >  			rmap->ri_bmap.br_blockcount,
> >  			rmap->ri_bmap.br_state,
> >  			(struct xfs_btree_cur **)state);
> > -	kmem_free(rmap);
> > +	kfree(rmap);
> >  	return error;
> >  }
> >  
> > @@ -468,7 +468,7 @@ xfs_rmap_update_cancel_item(
> >  	struct xfs_rmap_intent		*rmap;
> >  
> >  	rmap = container_of(item, struct xfs_rmap_intent, ri_list);
> > -	kmem_free(rmap);
> > +	kfree(rmap);
> >  }
> >  
> >  const struct xfs_defer_op_type xfs_rmap_update_defer_type = {
> > diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
> > index d42b5a2047e0..7f03b4ab3452 100644
> > --- a/fs/xfs/xfs_rtalloc.c
> > +++ b/fs/xfs/xfs_rtalloc.c
> > @@ -1082,7 +1082,7 @@ xfs_growfs_rt(
> >  	/*
> >  	 * Free the fake mp structure.
> >  	 */
> > -	kmem_free(nmp);
> > +	kfree(nmp);
> >  
> >  	/*
> >  	 * If we had to allocate a new rsum_cache, we either need to free the
> > @@ -1091,10 +1091,10 @@ xfs_growfs_rt(
> >  	 */
> >  	if (rsum_cache != mp->m_rsum_cache) {
> >  		if (error) {
> > -			kmem_free(mp->m_rsum_cache);
> > +			kvfree(mp->m_rsum_cache);
> >  			mp->m_rsum_cache = rsum_cache;
> >  		} else {
> > -			kmem_free(rsum_cache);
> > +			kvfree(rsum_cache);
> >  		}
> >  	}
> >  
> > @@ -1253,7 +1253,7 @@ void
> >  xfs_rtunmount_inodes(
> >  	struct xfs_mount	*mp)
> >  {
> > -	kmem_free(mp->m_rsum_cache);
> > +	kvfree(mp->m_rsum_cache);
> >  	if (mp->m_rbmip)
> >  		xfs_irele(mp->m_rbmip);
> >  	if (mp->m_rsumip)
> > diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> > index d9ae27ddf253..cc1933dc652f 100644
> > --- a/fs/xfs/xfs_super.c
> > +++ b/fs/xfs/xfs_super.c
> > @@ -725,7 +725,7 @@ xfs_mount_free(
> >  {
> >  	kfree(mp->m_rtname);
> >  	kfree(mp->m_logname);
> > -	kmem_free(mp);
> > +	kfree(mp);
> >  }
> >  
> >  STATIC int
> > diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c
> > index 00cc5b8734be..589918d11041 100644
> > --- a/fs/xfs/xfs_trans_ail.c
> > +++ b/fs/xfs/xfs_trans_ail.c
> > @@ -844,7 +844,7 @@ xfs_trans_ail_init(
> >  	return 0;
> >  
> >  out_free_ailp:
> > -	kmem_free(ailp);
> > +	kfree(ailp);
> >  	return -ENOMEM;
> >  }
> >  
> > @@ -855,5 +855,5 @@ xfs_trans_ail_destroy(
> >  	struct xfs_ail	*ailp = mp->m_ail;
> >  
> >  	kthread_stop(ailp->ail_task);
> > -	kmem_free(ailp);
> > +	kfree(ailp);
> >  }
> > -- 
> > 2.23.0
> > 
> 

-- 
Carlos


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/4] xfs: Remove kmem_free()
  2019-11-15 14:20     ` Carlos Maiolino
@ 2019-11-15 17:23       ` Darrick J. Wong
  2019-11-18  0:39         ` Dave Chinner
  2019-11-18  8:30         ` Carlos Maiolino
  0 siblings, 2 replies; 14+ messages in thread
From: Darrick J. Wong @ 2019-11-15 17:23 UTC (permalink / raw)
  To: linux-xfs, dchinner

On Fri, Nov 15, 2019 at 03:20:55PM +0100, Carlos Maiolino wrote:
> On Thu, Nov 14, 2019 at 01:00:00PM -0800, Darrick J. Wong wrote:
> > On Thu, Nov 14, 2019 at 09:09:55PM +0100, Carlos Maiolino wrote:
> > > This can be replaced by direct calls to kfree() or kvfree() (whenever
> > > allocation is done via kmem_alloc_io() or kmem_alloc_large().
> > > 
> > > This patch has been partially scripted. I used the following sed to
> > > replace all kmem_free() calls by kfree()
> > > 
> > >  # find fs/xfs/ -type f -name '*.c' -o -name '*.h' | xargs sed -i \
> > >    's/kmem_free/kfree/g'
> > 
> > Coccinelle? ;)
> 
> /me Doesn't understand the reference but thinks Darrick is talking about
> Coccinelle fancy brand :P
> 
> /me is adept to conference-wear :D

http://coccinelle.lip6.fr/

The semantic patch thing, because understanding the weird spatch
language is slightly less infuriating than making tons of minor code
changes by hand. :P

> > 
> > > And manually inspected kmem_alloc_io() and kmem_alloc_large() uses to
> > > use kvfree() instead.
> > 
> > Why not just use kvfree everywhere?  Is there a significant performance
> > penalty for the is_vmalloc_addr() check in kvfree vs. having to keep
> > track of kfree vs. kvfree?
> 
> I honestly didn't see a big difference between both. Although, I didn't test
> much, other than some perf measurements while exercising some paths like for
> example xfs_dir_lookup().
> 
> I can't really say we will have any benefits in segmenting it by using kvfree()
> only where kmem_alloc_{large, io} is used, so I just relied on the comments
> above kvfree(), and well, we have an extra function call and a few extra
> instructions using kvfree(). So, even though it might be 'slightly' faster, this
> might build up on hot paths when handling millions of kfree().
> 
> But, at the end, I'd be lying if I say I spotted any significant difference.

<nod> Though the way I see it, kfree vs. kvfree is another bookkeepping
detail that xfs developers will have to keep straight.  But maybe that's
fine for the dozen or so specialized users of _io and _large?  What do
others think?

> Btw, Dave mentioned in a not so far future, kmalloc() requests will be
> guaranteed to be aligned, so, I wonder if we will be able to replace both
> kmem_alloc_large() and kmem_alloc_io() by simple calls to kvmalloc() which does
> the job of falling back to vmalloc() if kmalloc() fails?!

Sure, but I'll believe that when I see it.  And given that Christoph
Lameter seems totally opposed to the idea, I think we should keep our
silly wrapper for a while to see if they don't accidentally revert it or
something.

--D

> Not related to this patch itself, but to the whole talks about these helpers, I
> just thought worth to mention.
> 
> > 
> > --D
> > 
> > > Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
> > > ---
> > >  fs/xfs/kmem.h                  |  5 ----
> > >  fs/xfs/libxfs/xfs_attr.c       |  2 +-
> > >  fs/xfs/libxfs/xfs_attr_leaf.c  |  8 +++---
> > >  fs/xfs/libxfs/xfs_da_btree.c   | 10 +++----
> > >  fs/xfs/libxfs/xfs_defer.c      |  4 +--
> > >  fs/xfs/libxfs/xfs_dir2.c       | 18 ++++++------
> > >  fs/xfs/libxfs/xfs_dir2_block.c |  4 +--
> > >  fs/xfs/libxfs/xfs_dir2_sf.c    |  8 +++---
> > >  fs/xfs/libxfs/xfs_iext_tree.c  |  8 +++---
> > >  fs/xfs/libxfs/xfs_inode_fork.c |  8 +++---
> > >  fs/xfs/libxfs/xfs_refcount.c   |  4 +--
> > >  fs/xfs/scrub/agheader.c        |  2 +-
> > >  fs/xfs/scrub/agheader_repair.c |  2 +-
> > >  fs/xfs/scrub/attr.c            |  2 +-
> > >  fs/xfs/scrub/bitmap.c          |  4 +--
> > >  fs/xfs/scrub/btree.c           |  2 +-
> > >  fs/xfs/scrub/refcount.c        |  8 +++---
> > >  fs/xfs/scrub/scrub.c           |  2 +-
> > >  fs/xfs/xfs_acl.c               |  4 +--
> > >  fs/xfs/xfs_attr_inactive.c     |  2 +-
> > >  fs/xfs/xfs_attr_list.c         |  4 +--
> > >  fs/xfs/xfs_bmap_item.c         |  4 +--
> > >  fs/xfs/xfs_buf.c               | 12 ++++----
> > >  fs/xfs/xfs_buf_item.c          |  4 +--
> > >  fs/xfs/xfs_dquot.c             |  2 +-
> > >  fs/xfs/xfs_dquot_item.c        |  8 +++---
> > >  fs/xfs/xfs_error.c             |  2 +-
> > >  fs/xfs/xfs_extent_busy.c       |  2 +-
> > >  fs/xfs/xfs_extfree_item.c      | 14 +++++-----
> > >  fs/xfs/xfs_filestream.c        |  4 +--
> > >  fs/xfs/xfs_inode.c             | 12 ++++----
> > >  fs/xfs/xfs_inode_item.c        |  2 +-
> > >  fs/xfs/xfs_ioctl.c             |  6 ++--
> > >  fs/xfs/xfs_ioctl32.c           |  2 +-
> > >  fs/xfs/xfs_iops.c              |  2 +-
> > >  fs/xfs/xfs_itable.c            |  4 +--
> > >  fs/xfs/xfs_iwalk.c             |  4 +--
> > >  fs/xfs/xfs_log.c               | 12 ++++----
> > >  fs/xfs/xfs_log_cil.c           | 16 +++++------
> > >  fs/xfs/xfs_log_recover.c       | 50 +++++++++++++++++-----------------
> > >  fs/xfs/xfs_mount.c             |  8 +++---
> > >  fs/xfs/xfs_mru_cache.c         |  8 +++---
> > >  fs/xfs/xfs_qm.c                |  6 ++--
> > >  fs/xfs/xfs_refcount_item.c     |  6 ++--
> > >  fs/xfs/xfs_rmap_item.c         |  6 ++--
> > >  fs/xfs/xfs_rtalloc.c           |  8 +++---
> > >  fs/xfs/xfs_super.c             |  2 +-
> > >  fs/xfs/xfs_trans_ail.c         |  4 +--
> > >  48 files changed, 158 insertions(+), 163 deletions(-)
> > > 
> > > diff --git a/fs/xfs/kmem.h b/fs/xfs/kmem.h
> > > index 6143117770e9..ccdc72519339 100644
> > > --- a/fs/xfs/kmem.h
> > > +++ b/fs/xfs/kmem.h
> > > @@ -56,11 +56,6 @@ 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);
> > > -}
> > > -
> > >  
> > >  static inline void *
> > >  kmem_zalloc(size_t size, xfs_km_flags_t flags)
> > > diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
> > > index 510ca6974604..bc8ca09e71d0 100644
> > > --- a/fs/xfs/libxfs/xfs_attr.c
> > > +++ b/fs/xfs/libxfs/xfs_attr.c
> > > @@ -174,7 +174,7 @@ xfs_attr_get(
> > >  	/* on error, we have to clean up allocated value buffers */
> > >  	if (error) {
> > >  		if (flags & ATTR_ALLOC) {
> > > -			kmem_free(args.value);
> > > +			kvfree(args.value);
> > >  			*value = NULL;
> > >  		}
> > >  		return error;
> > > diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
> > > index 85ec5945d29f..795b9b21b64d 100644
> > > --- a/fs/xfs/libxfs/xfs_attr_leaf.c
> > > +++ b/fs/xfs/libxfs/xfs_attr_leaf.c
> > > @@ -931,7 +931,7 @@ xfs_attr_shortform_to_leaf(
> > >  	error = 0;
> > >  	*leaf_bp = bp;
> > >  out:
> > > -	kmem_free(tmpbuffer);
> > > +	kfree(tmpbuffer);
> > >  	return error;
> > >  }
> > >  
> > > @@ -1131,7 +1131,7 @@ xfs_attr3_leaf_to_shortform(
> > >  	error = 0;
> > >  
> > >  out:
> > > -	kmem_free(tmpbuffer);
> > > +	kfree(tmpbuffer);
> > >  	return error;
> > >  }
> > >  
> > > @@ -1572,7 +1572,7 @@ xfs_attr3_leaf_compact(
> > >  	 */
> > >  	xfs_trans_log_buf(trans, bp, 0, args->geo->blksize - 1);
> > >  
> > > -	kmem_free(tmpbuffer);
> > > +	kfree(tmpbuffer);
> > >  }
> > >  
> > >  /*
> > > @@ -2293,7 +2293,7 @@ xfs_attr3_leaf_unbalance(
> > >  		}
> > >  		memcpy(save_leaf, tmp_leaf, state->args->geo->blksize);
> > >  		savehdr = tmphdr; /* struct copy */
> > > -		kmem_free(tmp_leaf);
> > > +		kfree(tmp_leaf);
> > >  	}
> > >  
> > >  	xfs_attr3_leaf_hdr_to_disk(state->args->geo, save_leaf, &savehdr);
> > > diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
> > > index c5c0b73febae..7ae82d91f776 100644
> > > --- a/fs/xfs/libxfs/xfs_da_btree.c
> > > +++ b/fs/xfs/libxfs/xfs_da_btree.c
> > > @@ -2189,7 +2189,7 @@ xfs_da_grow_inode_int(
> > >  
> > >  out_free_map:
> > >  	if (mapp != &map)
> > > -		kmem_free(mapp);
> > > +		kfree(mapp);
> > >  	return error;
> > >  }
> > >  
> > > @@ -2639,7 +2639,7 @@ xfs_dabuf_map(
> > >  	error = xfs_buf_map_from_irec(mp, map, nmaps, irecs, nirecs);
> > >  out:
> > >  	if (irecs != &irec)
> > > -		kmem_free(irecs);
> > > +		kfree(irecs);
> > >  	return error;
> > >  }
> > >  
> > > @@ -2686,7 +2686,7 @@ xfs_da_get_buf(
> > >  
> > >  out_free:
> > >  	if (mapp != &map)
> > > -		kmem_free(mapp);
> > > +		kfree(mapp);
> > >  
> > >  	return error;
> > >  }
> > > @@ -2735,7 +2735,7 @@ xfs_da_read_buf(
> > >  	*bpp = bp;
> > >  out_free:
> > >  	if (mapp != &map)
> > > -		kmem_free(mapp);
> > > +		kfree(mapp);
> > >  
> > >  	return error;
> > >  }
> > > @@ -2772,7 +2772,7 @@ xfs_da_reada_buf(
> > >  
> > >  out_free:
> > >  	if (mapp != &map)
> > > -		kmem_free(mapp);
> > > +		kfree(mapp);
> > >  
> > >  	return error;
> > >  }
> > > diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c
> > > index 22557527cfdb..27c3d150068a 100644
> > > --- a/fs/xfs/libxfs/xfs_defer.c
> > > +++ b/fs/xfs/libxfs/xfs_defer.c
> > > @@ -341,7 +341,7 @@ xfs_defer_cancel_list(
> > >  			ops->cancel_item(pwi);
> > >  		}
> > >  		ASSERT(dfp->dfp_count == 0);
> > > -		kmem_free(dfp);
> > > +		kfree(dfp);
> > >  	}
> > >  }
> > >  
> > > @@ -433,7 +433,7 @@ xfs_defer_finish_noroll(
> > >  		} else {
> > >  			/* Done with the dfp, free it. */
> > >  			list_del(&dfp->dfp_list);
> > > -			kmem_free(dfp);
> > > +			kfree(dfp);
> > >  		}
> > >  
> > >  		if (ops->finish_cleanup)
> > > diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c
> > > index 624c05e77ab4..efd7cec65259 100644
> > > --- a/fs/xfs/libxfs/xfs_dir2.c
> > > +++ b/fs/xfs/libxfs/xfs_dir2.c
> > > @@ -109,8 +109,8 @@ xfs_da_mount(
> > >  	mp->m_attr_geo = kmem_zalloc(sizeof(struct xfs_da_geometry),
> > >  				     KM_MAYFAIL);
> > >  	if (!mp->m_dir_geo || !mp->m_attr_geo) {
> > > -		kmem_free(mp->m_dir_geo);
> > > -		kmem_free(mp->m_attr_geo);
> > > +		kfree(mp->m_dir_geo);
> > > +		kfree(mp->m_attr_geo);
> > >  		return -ENOMEM;
> > >  	}
> > >  
> > > @@ -176,8 +176,8 @@ void
> > >  xfs_da_unmount(
> > >  	struct xfs_mount	*mp)
> > >  {
> > > -	kmem_free(mp->m_dir_geo);
> > > -	kmem_free(mp->m_attr_geo);
> > > +	kfree(mp->m_dir_geo);
> > > +	kfree(mp->m_attr_geo);
> > >  }
> > >  
> > >  /*
> > > @@ -242,7 +242,7 @@ xfs_dir_init(
> > >  	args->dp = dp;
> > >  	args->trans = tp;
> > >  	error = xfs_dir2_sf_create(args, pdp->i_ino);
> > > -	kmem_free(args);
> > > +	kfree(args);
> > >  	return error;
> > >  }
> > >  
> > > @@ -311,7 +311,7 @@ xfs_dir_createname(
> > >  		rval = xfs_dir2_node_addname(args);
> > >  
> > >  out_free:
> > > -	kmem_free(args);
> > > +	kfree(args);
> > >  	return rval;
> > >  }
> > >  
> > > @@ -417,7 +417,7 @@ xfs_dir_lookup(
> > >  	}
> > >  out_free:
> > >  	xfs_iunlock(dp, lock_mode);
> > > -	kmem_free(args);
> > > +	kfree(args);
> > >  	return rval;
> > >  }
> > >  
> > > @@ -475,7 +475,7 @@ xfs_dir_removename(
> > >  	else
> > >  		rval = xfs_dir2_node_removename(args);
> > >  out_free:
> > > -	kmem_free(args);
> > > +	kfree(args);
> > >  	return rval;
> > >  }
> > >  
> > > @@ -536,7 +536,7 @@ xfs_dir_replace(
> > >  	else
> > >  		rval = xfs_dir2_node_replace(args);
> > >  out_free:
> > > -	kmem_free(args);
> > > +	kfree(args);
> > >  	return rval;
> > >  }
> > >  
> > > diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c
> > > index 358151ddfa75..766f282b706a 100644
> > > --- a/fs/xfs/libxfs/xfs_dir2_block.c
> > > +++ b/fs/xfs/libxfs/xfs_dir2_block.c
> > > @@ -1229,7 +1229,7 @@ xfs_dir2_sf_to_block(
> > >  			sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep);
> > >  	}
> > >  	/* Done with the temporary buffer */
> > > -	kmem_free(sfp);
> > > +	kfree(sfp);
> > >  	/*
> > >  	 * Sort the leaf entries by hash value.
> > >  	 */
> > > @@ -1244,6 +1244,6 @@ xfs_dir2_sf_to_block(
> > >  	xfs_dir3_data_check(dp, bp);
> > >  	return 0;
> > >  out_free:
> > > -	kmem_free(sfp);
> > > +	kfree(sfp);
> > >  	return error;
> > >  }
> > > diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c
> > > index db1a82972d9e..f4de4e7b10ef 100644
> > > --- a/fs/xfs/libxfs/xfs_dir2_sf.c
> > > +++ b/fs/xfs/libxfs/xfs_dir2_sf.c
> > > @@ -350,7 +350,7 @@ xfs_dir2_block_to_sf(
> > >  	xfs_dir2_sf_check(args);
> > >  out:
> > >  	xfs_trans_log_inode(args->trans, dp, logflags);
> > > -	kmem_free(sfp);
> > > +	kfree(sfp);
> > >  	return error;
> > >  }
> > >  
> > > @@ -585,7 +585,7 @@ xfs_dir2_sf_addname_hard(
> > >  		sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep);
> > >  		memcpy(sfep, oldsfep, old_isize - nbytes);
> > >  	}
> > > -	kmem_free(buf);
> > > +	kfree(buf);
> > >  	dp->i_d.di_size = new_isize;
> > >  	xfs_dir2_sf_check(args);
> > >  }
> > > @@ -1202,7 +1202,7 @@ xfs_dir2_sf_toino4(
> > >  	/*
> > >  	 * Clean up the inode.
> > >  	 */
> > > -	kmem_free(buf);
> > > +	kfree(buf);
> > >  	dp->i_d.di_size = newsize;
> > >  	xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA);
> > >  }
> > > @@ -1275,7 +1275,7 @@ xfs_dir2_sf_toino8(
> > >  	/*
> > >  	 * Clean up the inode.
> > >  	 */
> > > -	kmem_free(buf);
> > > +	kfree(buf);
> > >  	dp->i_d.di_size = newsize;
> > >  	xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA);
> > >  }
> > > diff --git a/fs/xfs/libxfs/xfs_iext_tree.c b/fs/xfs/libxfs/xfs_iext_tree.c
> > > index 52451809c478..a7ba30cd81da 100644
> > > --- a/fs/xfs/libxfs/xfs_iext_tree.c
> > > +++ b/fs/xfs/libxfs/xfs_iext_tree.c
> > > @@ -734,7 +734,7 @@ xfs_iext_remove_node(
> > >  again:
> > >  	ASSERT(node->ptrs[pos]);
> > >  	ASSERT(node->ptrs[pos] == victim);
> > > -	kmem_free(victim);
> > > +	kfree(victim);
> > >  
> > >  	nr_entries = xfs_iext_node_nr_entries(node, pos) - 1;
> > >  	offset = node->keys[0];
> > > @@ -780,7 +780,7 @@ xfs_iext_remove_node(
> > >  		ASSERT(node == ifp->if_u1.if_root);
> > >  		ifp->if_u1.if_root = node->ptrs[0];
> > >  		ifp->if_height--;
> > > -		kmem_free(node);
> > > +		kfree(node);
> > >  	}
> > >  }
> > >  
> > > @@ -854,7 +854,7 @@ xfs_iext_free_last_leaf(
> > >  	struct xfs_ifork	*ifp)
> > >  {
> > >  	ifp->if_height--;
> > > -	kmem_free(ifp->if_u1.if_root);
> > > +	kfree(ifp->if_u1.if_root);
> > >  	ifp->if_u1.if_root = NULL;
> > >  }
> > >  
> > > @@ -1035,7 +1035,7 @@ xfs_iext_destroy_node(
> > >  		}
> > >  	}
> > >  
> > > -	kmem_free(node);
> > > +	kfree(node);
> > >  }
> > >  
> > >  void
> > > diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
> > > index ad2b9c313fd2..296677958212 100644
> > > --- a/fs/xfs/libxfs/xfs_inode_fork.c
> > > +++ b/fs/xfs/libxfs/xfs_inode_fork.c
> > > @@ -445,7 +445,7 @@ xfs_iroot_realloc(
> > >  						     (int)new_size);
> > >  		memcpy(np, op, new_max * (uint)sizeof(xfs_fsblock_t));
> > >  	}
> > > -	kmem_free(ifp->if_broot);
> > > +	kfree(ifp->if_broot);
> > >  	ifp->if_broot = new_broot;
> > >  	ifp->if_broot_bytes = (int)new_size;
> > >  	if (ifp->if_broot)
> > > @@ -486,7 +486,7 @@ xfs_idata_realloc(
> > >  		return;
> > >  
> > >  	if (new_size == 0) {
> > > -		kmem_free(ifp->if_u1.if_data);
> > > +		kfree(ifp->if_u1.if_data);
> > >  		ifp->if_u1.if_data = NULL;
> > >  		ifp->if_bytes = 0;
> > >  		return;
> > > @@ -511,7 +511,7 @@ xfs_idestroy_fork(
> > >  
> > >  	ifp = XFS_IFORK_PTR(ip, whichfork);
> > >  	if (ifp->if_broot != NULL) {
> > > -		kmem_free(ifp->if_broot);
> > > +		kfree(ifp->if_broot);
> > >  		ifp->if_broot = NULL;
> > >  	}
> > >  
> > > @@ -523,7 +523,7 @@ xfs_idestroy_fork(
> > >  	 */
> > >  	if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL) {
> > >  		if (ifp->if_u1.if_data != NULL) {
> > > -			kmem_free(ifp->if_u1.if_data);
> > > +			kfree(ifp->if_u1.if_data);
> > >  			ifp->if_u1.if_data = NULL;
> > >  		}
> > >  	} else if ((ifp->if_flags & XFS_IFEXTENTS) && ifp->if_height) {
> > > diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c
> > > index 78236bd6c64f..07894c53e753 100644
> > > --- a/fs/xfs/libxfs/xfs_refcount.c
> > > +++ b/fs/xfs/libxfs/xfs_refcount.c
> > > @@ -1684,7 +1684,7 @@ xfs_refcount_recover_cow_leftovers(
> > >  			goto out_free;
> > >  
> > >  		list_del(&rr->rr_list);
> > > -		kmem_free(rr);
> > > +		kfree(rr);
> > >  	}
> > >  
> > >  	return error;
> > > @@ -1694,7 +1694,7 @@ xfs_refcount_recover_cow_leftovers(
> > >  	/* Free the leftover list */
> > >  	list_for_each_entry_safe(rr, n, &debris, rr_list) {
> > >  		list_del(&rr->rr_list);
> > > -		kmem_free(rr);
> > > +		kfree(rr);
> > >  	}
> > >  	return error;
> > >  }
> > > diff --git a/fs/xfs/scrub/agheader.c b/fs/xfs/scrub/agheader.c
> > > index ba0f747c82e8..6f7126f6d25c 100644
> > > --- a/fs/xfs/scrub/agheader.c
> > > +++ b/fs/xfs/scrub/agheader.c
> > > @@ -753,7 +753,7 @@ xchk_agfl(
> > >  	}
> > >  
> > >  out_free:
> > > -	kmem_free(sai.entries);
> > > +	kfree(sai.entries);
> > >  out:
> > >  	return error;
> > >  }
> > > diff --git a/fs/xfs/scrub/agheader_repair.c b/fs/xfs/scrub/agheader_repair.c
> > > index 7a1a38b636a9..15fabf020d1b 100644
> > > --- a/fs/xfs/scrub/agheader_repair.c
> > > +++ b/fs/xfs/scrub/agheader_repair.c
> > > @@ -624,7 +624,7 @@ xrep_agfl_init_header(
> > >  		if (br->len)
> > >  			break;
> > >  		list_del(&br->list);
> > > -		kmem_free(br);
> > > +		kfree(br);
> > >  	}
> > >  
> > >  	/* Write new AGFL to disk. */
> > > diff --git a/fs/xfs/scrub/attr.c b/fs/xfs/scrub/attr.c
> > > index d9f0dd444b80..7a2a240febc1 100644
> > > --- a/fs/xfs/scrub/attr.c
> > > +++ b/fs/xfs/scrub/attr.c
> > > @@ -49,7 +49,7 @@ xchk_setup_xattr_buf(
> > >  	if (ab) {
> > >  		if (sz <= ab->sz)
> > >  			return 0;
> > > -		kmem_free(ab);
> > > +		kvfree(ab);
> > >  		sc->buf = NULL;
> > >  	}
> > >  
> > > diff --git a/fs/xfs/scrub/bitmap.c b/fs/xfs/scrub/bitmap.c
> > > index 18a684e18a69..cabde1c4c235 100644
> > > --- a/fs/xfs/scrub/bitmap.c
> > > +++ b/fs/xfs/scrub/bitmap.c
> > > @@ -47,7 +47,7 @@ xfs_bitmap_destroy(
> > >  
> > >  	for_each_xfs_bitmap_extent(bmr, n, bitmap) {
> > >  		list_del(&bmr->list);
> > > -		kmem_free(bmr);
> > > +		kfree(bmr);
> > >  	}
> > >  }
> > >  
> > > @@ -174,7 +174,7 @@ xfs_bitmap_disunion(
> > >  			/* Total overlap, just delete ex. */
> > >  			lp = lp->next;
> > >  			list_del(&br->list);
> > > -			kmem_free(br);
> > > +			kfree(br);
> > >  			break;
> > >  		case 0:
> > >  			/*
> > > diff --git a/fs/xfs/scrub/btree.c b/fs/xfs/scrub/btree.c
> > > index f52a7b8256f9..bed40b605076 100644
> > > --- a/fs/xfs/scrub/btree.c
> > > +++ b/fs/xfs/scrub/btree.c
> > > @@ -698,7 +698,7 @@ xchk_btree(
> > >  			error = xchk_btree_check_block_owner(&bs,
> > >  					co->level, co->daddr);
> > >  		list_del(&co->list);
> > > -		kmem_free(co);
> > > +		kfree(co);
> > >  	}
> > >  
> > >  	return error;
> > > diff --git a/fs/xfs/scrub/refcount.c b/fs/xfs/scrub/refcount.c
> > > index 0cab11a5d390..985724e81ebf 100644
> > > --- a/fs/xfs/scrub/refcount.c
> > > +++ b/fs/xfs/scrub/refcount.c
> > > @@ -215,7 +215,7 @@ xchk_refcountbt_process_rmap_fragments(
> > >  				continue;
> > >  			}
> > >  			list_del(&frag->list);
> > > -			kmem_free(frag);
> > > +			kfree(frag);
> > >  			nr++;
> > >  		}
> > >  
> > > @@ -257,11 +257,11 @@ xchk_refcountbt_process_rmap_fragments(
> > >  	/* Delete fragments and work list. */
> > >  	list_for_each_entry_safe(frag, n, &worklist, list) {
> > >  		list_del(&frag->list);
> > > -		kmem_free(frag);
> > > +		kfree(frag);
> > >  	}
> > >  	list_for_each_entry_safe(frag, n, &refchk->fragments, list) {
> > >  		list_del(&frag->list);
> > > -		kmem_free(frag);
> > > +		kfree(frag);
> > >  	}
> > >  }
> > >  
> > > @@ -308,7 +308,7 @@ xchk_refcountbt_xref_rmap(
> > >  out_free:
> > >  	list_for_each_entry_safe(frag, n, &refchk.fragments, list) {
> > >  		list_del(&frag->list);
> > > -		kmem_free(frag);
> > > +		kfree(frag);
> > >  	}
> > >  }
> > >  
> > > diff --git a/fs/xfs/scrub/scrub.c b/fs/xfs/scrub/scrub.c
> > > index f1775bb19313..7c63cdf13946 100644
> > > --- a/fs/xfs/scrub/scrub.c
> > > +++ b/fs/xfs/scrub/scrub.c
> > > @@ -175,7 +175,7 @@ xchk_teardown(
> > >  		sc->flags &= ~XCHK_HAS_QUOTAOFFLOCK;
> > >  	}
> > >  	if (sc->buf) {
> > > -		kmem_free(sc->buf);
> > > +		kvfree(sc->buf);
> > >  		sc->buf = NULL;
> > >  	}
> > >  	return error;
> > > diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c
> > > index 91693fce34a8..81b2c989242e 100644
> > > --- a/fs/xfs/xfs_acl.c
> > > +++ b/fs/xfs/xfs_acl.c
> > > @@ -157,7 +157,7 @@ xfs_get_acl(struct inode *inode, int type)
> > >  	} else  {
> > >  		acl = xfs_acl_from_disk(ip->i_mount, xfs_acl, len,
> > >  					XFS_ACL_MAX_ENTRIES(ip->i_mount));
> > > -		kmem_free(xfs_acl);
> > > +		kvfree(xfs_acl);
> > >  	}
> > >  	return acl;
> > >  }
> > > @@ -199,7 +199,7 @@ __xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
> > >  		error = xfs_attr_set(ip, ea_name, (unsigned char *)xfs_acl,
> > >  				len, ATTR_ROOT);
> > >  
> > > -		kmem_free(xfs_acl);
> > > +		kvfree(xfs_acl);
> > >  	} else {
> > >  		/*
> > >  		 * A NULL ACL argument means we want to remove the ACL.
> > > diff --git a/fs/xfs/xfs_attr_inactive.c b/fs/xfs/xfs_attr_inactive.c
> > > index a78c501f6fb1..8351b3b611ac 100644
> > > --- a/fs/xfs/xfs_attr_inactive.c
> > > +++ b/fs/xfs/xfs_attr_inactive.c
> > > @@ -181,7 +181,7 @@ xfs_attr3_leaf_inactive(
> > >  			error = tmp;	/* save only the 1st errno */
> > >  	}
> > >  
> > > -	kmem_free(list);
> > > +	kfree(list);
> > >  	return error;
> > >  }
> > >  
> > > diff --git a/fs/xfs/xfs_attr_list.c b/fs/xfs/xfs_attr_list.c
> > > index 0ec6606149a2..e1d1c4eb9e69 100644
> > > --- a/fs/xfs/xfs_attr_list.c
> > > +++ b/fs/xfs/xfs_attr_list.c
> > > @@ -131,7 +131,7 @@ xfs_attr_shortform_list(
> > >  					     XFS_ERRLEVEL_LOW,
> > >  					     context->dp->i_mount, sfe,
> > >  					     sizeof(*sfe));
> > > -			kmem_free(sbuf);
> > > +			kfree(sbuf);
> > >  			return -EFSCORRUPTED;
> > >  		}
> > >  
> > > @@ -195,7 +195,7 @@ xfs_attr_shortform_list(
> > >  		cursor->offset++;
> > >  	}
> > >  out:
> > > -	kmem_free(sbuf);
> > > +	kfree(sbuf);
> > >  	return error;
> > >  }
> > >  
> > > diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c
> > > index ee6f4229cebc..a89e10519f05 100644
> > > --- a/fs/xfs/xfs_bmap_item.c
> > > +++ b/fs/xfs/xfs_bmap_item.c
> > > @@ -391,7 +391,7 @@ xfs_bmap_update_finish_item(
> > >  		bmap->bi_bmap.br_blockcount = count;
> > >  		return -EAGAIN;
> > >  	}
> > > -	kmem_free(bmap);
> > > +	kfree(bmap);
> > >  	return error;
> > >  }
> > >  
> > > @@ -411,7 +411,7 @@ xfs_bmap_update_cancel_item(
> > >  	struct xfs_bmap_intent		*bmap;
> > >  
> > >  	bmap = container_of(item, struct xfs_bmap_intent, bi_list);
> > > -	kmem_free(bmap);
> > > +	kfree(bmap);
> > >  }
> > >  
> > >  const struct xfs_defer_op_type xfs_bmap_update_defer_type = {
> > > diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
> > > index a0229c368e78..80ef2fc8bb77 100644
> > > --- a/fs/xfs/xfs_buf.c
> > > +++ b/fs/xfs/xfs_buf.c
> > > @@ -193,7 +193,7 @@ xfs_buf_free_maps(
> > >  	struct xfs_buf	*bp)
> > >  {
> > >  	if (bp->b_maps != &bp->__b_map) {
> > > -		kmem_free(bp->b_maps);
> > > +		kfree(bp->b_maps);
> > >  		bp->b_maps = NULL;
> > >  	}
> > >  }
> > > @@ -292,7 +292,7 @@ _xfs_buf_free_pages(
> > >  	xfs_buf_t	*bp)
> > >  {
> > >  	if (bp->b_pages != bp->b_page_array) {
> > > -		kmem_free(bp->b_pages);
> > > +		kfree(bp->b_pages);
> > >  		bp->b_pages = NULL;
> > >  	}
> > >  }
> > > @@ -325,7 +325,7 @@ xfs_buf_free(
> > >  			__free_page(page);
> > >  		}
> > >  	} else if (bp->b_flags & _XBF_KMEM)
> > > -		kmem_free(bp->b_addr);
> > > +		kvfree(bp->b_addr);
> > >  	_xfs_buf_free_pages(bp);
> > >  	xfs_buf_free_maps(bp);
> > >  	kmem_cache_free(xfs_buf_zone, bp);
> > > @@ -373,7 +373,7 @@ xfs_buf_allocate_memory(
> > >  		if (((unsigned long)(bp->b_addr + size - 1) & PAGE_MASK) !=
> > >  		    ((unsigned long)bp->b_addr & PAGE_MASK)) {
> > >  			/* b_addr spans two pages - use alloc_page instead */
> > > -			kmem_free(bp->b_addr);
> > > +			kvfree(bp->b_addr);
> > >  			bp->b_addr = NULL;
> > >  			goto use_alloc_page;
> > >  		}
> > > @@ -1702,7 +1702,7 @@ xfs_free_buftarg(
> > >  
> > >  	xfs_blkdev_issue_flush(btp);
> > >  
> > > -	kmem_free(btp);
> > > +	kfree(btp);
> > >  }
> > >  
> > >  int
> > > @@ -1778,7 +1778,7 @@ xfs_alloc_buftarg(
> > >  error_lru:
> > >  	list_lru_destroy(&btp->bt_lru);
> > >  error_free:
> > > -	kmem_free(btp);
> > > +	kfree(btp);
> > >  	return NULL;
> > >  }
> > >  
> > > diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
> > > index 3458a1264a3f..8dc3330f1797 100644
> > > --- a/fs/xfs/xfs_buf_item.c
> > > +++ b/fs/xfs/xfs_buf_item.c
> > > @@ -713,7 +713,7 @@ xfs_buf_item_free_format(
> > >  	struct xfs_buf_log_item	*bip)
> > >  {
> > >  	if (bip->bli_formats != &bip->__bli_format) {
> > > -		kmem_free(bip->bli_formats);
> > > +		kfree(bip->bli_formats);
> > >  		bip->bli_formats = NULL;
> > >  	}
> > >  }
> > > @@ -938,7 +938,7 @@ xfs_buf_item_free(
> > >  	struct xfs_buf_log_item	*bip)
> > >  {
> > >  	xfs_buf_item_free_format(bip);
> > > -	kmem_free(bip->bli_item.li_lv_shadow);
> > > +	kfree(bip->bli_item.li_lv_shadow);
> > >  	kmem_cache_free(xfs_buf_item_zone, bip);
> > >  }
> > >  
> > > diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
> > > index 153815bf18fc..a073281c3bd7 100644
> > > --- a/fs/xfs/xfs_dquot.c
> > > +++ b/fs/xfs/xfs_dquot.c
> > > @@ -52,7 +52,7 @@ xfs_qm_dqdestroy(
> > >  {
> > >  	ASSERT(list_empty(&dqp->q_lru));
> > >  
> > > -	kmem_free(dqp->q_logitem.qli_item.li_lv_shadow);
> > > +	kfree(dqp->q_logitem.qli_item.li_lv_shadow);
> > >  	mutex_destroy(&dqp->q_qlock);
> > >  
> > >  	XFS_STATS_DEC(dqp->q_mount, xs_qm_dquot);
> > > diff --git a/fs/xfs/xfs_dquot_item.c b/fs/xfs/xfs_dquot_item.c
> > > index d60647d7197b..1b5e68ccef60 100644
> > > --- a/fs/xfs/xfs_dquot_item.c
> > > +++ b/fs/xfs/xfs_dquot_item.c
> > > @@ -316,10 +316,10 @@ xfs_qm_qoffend_logitem_committed(
> > >  	spin_lock(&ailp->ail_lock);
> > >  	xfs_trans_ail_delete(ailp, &qfs->qql_item, SHUTDOWN_LOG_IO_ERROR);
> > >  
> > > -	kmem_free(qfs->qql_item.li_lv_shadow);
> > > -	kmem_free(lip->li_lv_shadow);
> > > -	kmem_free(qfs);
> > > -	kmem_free(qfe);
> > > +	kfree(qfs->qql_item.li_lv_shadow);
> > > +	kfree(lip->li_lv_shadow);
> > > +	kfree(qfs);
> > > +	kfree(qfe);
> > >  	return (xfs_lsn_t)-1;
> > >  }
> > >  
> > > diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
> > > index 51dd1f43d12f..4c0883380d7c 100644
> > > --- a/fs/xfs/xfs_error.c
> > > +++ b/fs/xfs/xfs_error.c
> > > @@ -226,7 +226,7 @@ xfs_errortag_del(
> > >  	struct xfs_mount	*mp)
> > >  {
> > >  	xfs_sysfs_del(&mp->m_errortag_kobj);
> > > -	kmem_free(mp->m_errortag);
> > > +	kfree(mp->m_errortag);
> > >  }
> > >  
> > >  bool
> > > diff --git a/fs/xfs/xfs_extent_busy.c b/fs/xfs/xfs_extent_busy.c
> > > index 3991e59cfd18..9f0b99c7b34a 100644
> > > --- a/fs/xfs/xfs_extent_busy.c
> > > +++ b/fs/xfs/xfs_extent_busy.c
> > > @@ -532,7 +532,7 @@ xfs_extent_busy_clear_one(
> > >  	}
> > >  
> > >  	list_del_init(&busyp->list);
> > > -	kmem_free(busyp);
> > > +	kfree(busyp);
> > >  }
> > >  
> > >  static void
> > > diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
> > > index 6ea847f6e298..29b3a90aee91 100644
> > > --- a/fs/xfs/xfs_extfree_item.c
> > > +++ b/fs/xfs/xfs_extfree_item.c
> > > @@ -35,9 +35,9 @@ void
> > >  xfs_efi_item_free(
> > >  	struct xfs_efi_log_item	*efip)
> > >  {
> > > -	kmem_free(efip->efi_item.li_lv_shadow);
> > > +	kfree(efip->efi_item.li_lv_shadow);
> > >  	if (efip->efi_format.efi_nextents > XFS_EFI_MAX_FAST_EXTENTS)
> > > -		kmem_free(efip);
> > > +		kfree(efip);
> > >  	else
> > >  		kmem_cache_free(xfs_efi_zone, efip);
> > >  }
> > > @@ -240,9 +240,9 @@ static inline struct xfs_efd_log_item *EFD_ITEM(struct xfs_log_item *lip)
> > >  STATIC void
> > >  xfs_efd_item_free(struct xfs_efd_log_item *efdp)
> > >  {
> > > -	kmem_free(efdp->efd_item.li_lv_shadow);
> > > +	kfree(efdp->efd_item.li_lv_shadow);
> > >  	if (efdp->efd_format.efd_nextents > XFS_EFD_MAX_FAST_EXTENTS)
> > > -		kmem_free(efdp);
> > > +		kfree(efdp);
> > >  	else
> > >  		kmem_cache_free(xfs_efd_zone, efdp);
> > >  }
> > > @@ -488,7 +488,7 @@ xfs_extent_free_finish_item(
> > >  			free->xefi_startblock,
> > >  			free->xefi_blockcount,
> > >  			&free->xefi_oinfo, free->xefi_skip_discard);
> > > -	kmem_free(free);
> > > +	kfree(free);
> > >  	return error;
> > >  }
> > >  
> > > @@ -508,7 +508,7 @@ xfs_extent_free_cancel_item(
> > >  	struct xfs_extent_free_item	*free;
> > >  
> > >  	free = container_of(item, struct xfs_extent_free_item, xefi_list);
> > > -	kmem_free(free);
> > > +	kfree(free);
> > >  }
> > >  
> > >  const struct xfs_defer_op_type xfs_extent_free_defer_type = {
> > > @@ -572,7 +572,7 @@ xfs_agfl_free_finish_item(
> > >  	extp->ext_len = free->xefi_blockcount;
> > >  	efdp->efd_next_extent++;
> > >  
> > > -	kmem_free(free);
> > > +	kfree(free);
> > >  	return error;
> > >  }
> > >  
> > > diff --git a/fs/xfs/xfs_filestream.c b/fs/xfs/xfs_filestream.c
> > > index 2ae356775f63..9778e4e69e07 100644
> > > --- a/fs/xfs/xfs_filestream.c
> > > +++ b/fs/xfs/xfs_filestream.c
> > > @@ -118,7 +118,7 @@ xfs_fstrm_free_func(
> > >  	xfs_filestream_put_ag(mp, item->ag);
> > >  	trace_xfs_filestream_free(mp, mru->key, item->ag);
> > >  
> > > -	kmem_free(item);
> > > +	kfree(item);
> > >  }
> > >  
> > >  /*
> > > @@ -263,7 +263,7 @@ xfs_filestream_pick_ag(
> > >  	return 0;
> > >  
> > >  out_free_item:
> > > -	kmem_free(item);
> > > +	kfree(item);
> > >  out_put_ag:
> > >  	xfs_filestream_put_ag(mp, *agp);
> > >  	return err;
> > > diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> > > index a92d4521748d..e1121ed7cbb5 100644
> > > --- a/fs/xfs/xfs_inode.c
> > > +++ b/fs/xfs/xfs_inode.c
> > > @@ -708,7 +708,7 @@ xfs_lookup(
> > >  
> > >  out_free_name:
> > >  	if (ci_name)
> > > -		kmem_free(ci_name->name);
> > > +		kfree(ci_name->name);
> > >  out_unlock:
> > >  	*ipp = NULL;
> > >  	return error;
> > > @@ -2001,7 +2001,7 @@ xfs_iunlink_insert_backref(
> > >  	 */
> > >  	if (error) {
> > >  		WARN(error != -ENOMEM, "iunlink cache insert error %d", error);
> > > -		kmem_free(iu);
> > > +		kfree(iu);
> > >  	}
> > >  	/*
> > >  	 * Absorb any runtime errors that aren't a result of corruption because
> > > @@ -2066,7 +2066,7 @@ xfs_iunlink_change_backref(
> > >  
> > >  	/* If there is no new next entry just free our item and return. */
> > >  	if (next_unlinked == NULLAGINO) {
> > > -		kmem_free(iu);
> > > +		kfree(iu);
> > >  		return 0;
> > >  	}
> > >  
> > > @@ -2094,7 +2094,7 @@ xfs_iunlink_free_item(
> > >  	bool			*freed_anything = arg;
> > >  
> > >  	*freed_anything = true;
> > > -	kmem_free(iu);
> > > +	kfree(iu);
> > >  }
> > >  
> > >  void
> > > @@ -3598,7 +3598,7 @@ xfs_iflush_cluster(
> > >  
> > >  out_free:
> > >  	rcu_read_unlock();
> > > -	kmem_free(cilist);
> > > +	kfree(cilist);
> > >  out_put:
> > >  	xfs_perag_put(pag);
> > >  	return 0;
> > > @@ -3629,7 +3629,7 @@ xfs_iflush_cluster(
> > >  
> > >  	/* abort the corrupt inode, as it was not attached to the buffer */
> > >  	xfs_iflush_abort(cip, false);
> > > -	kmem_free(cilist);
> > > +	kfree(cilist);
> > >  	xfs_perag_put(pag);
> > >  	return -EFSCORRUPTED;
> > >  }
> > > diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> > > index 3a62976291a1..c8461a5515f1 100644
> > > --- a/fs/xfs/xfs_inode_item.c
> > > +++ b/fs/xfs/xfs_inode_item.c
> > > @@ -666,7 +666,7 @@ void
> > >  xfs_inode_item_destroy(
> > >  	xfs_inode_t	*ip)
> > >  {
> > > -	kmem_free(ip->i_itemp->ili_item.li_lv_shadow);
> > > +	kfree(ip->i_itemp->ili_item.li_lv_shadow);
> > >  	kmem_cache_free(xfs_ili_zone, ip->i_itemp);
> > >  }
> > >  
> > > diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> > > index 364961c23cd0..f86dde7c9ea6 100644
> > > --- a/fs/xfs/xfs_ioctl.c
> > > +++ b/fs/xfs/xfs_ioctl.c
> > > @@ -417,7 +417,7 @@ xfs_attrlist_by_handle(
> > >  		error = -EFAULT;
> > >  
> > >  out_kfree:
> > > -	kmem_free(kbuf);
> > > +	kvfree(kbuf);
> > >  out_dput:
> > >  	dput(dentry);
> > >  	return error;
> > > @@ -448,7 +448,7 @@ xfs_attrmulti_attr_get(
> > >  		error = -EFAULT;
> > >  
> > >  out_kfree:
> > > -	kmem_free(kbuf);
> > > +	kvfree(kbuf);
> > >  	return error;
> > >  }
> > >  
> > > @@ -1777,7 +1777,7 @@ xfs_ioc_getbmap(
> > >  
> > >  	error = 0;
> > >  out_free_buf:
> > > -	kmem_free(buf);
> > > +	kvfree(buf);
> > >  	return error;
> > >  }
> > >  
> > > diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c
> > > index 3c0d518e1039..de472fcd2f67 100644
> > > --- a/fs/xfs/xfs_ioctl32.c
> > > +++ b/fs/xfs/xfs_ioctl32.c
> > > @@ -400,7 +400,7 @@ xfs_compat_attrlist_by_handle(
> > >  		error = -EFAULT;
> > >  
> > >  out_kfree:
> > > -	kmem_free(kbuf);
> > > +	kvfree(kbuf);
> > >  out_dput:
> > >  	dput(dentry);
> > >  	return error;
> > > diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> > > index 57e6e44123a9..e532db27d0dc 100644
> > > --- a/fs/xfs/xfs_iops.c
> > > +++ b/fs/xfs/xfs_iops.c
> > > @@ -303,7 +303,7 @@ xfs_vn_ci_lookup(
> > >  	dname.name = ci_name.name;
> > >  	dname.len = ci_name.len;
> > >  	dentry = d_add_ci(dentry, VFS_I(ip), &dname);
> > > -	kmem_free(ci_name.name);
> > > +	kfree(ci_name.name);
> > >  	return dentry;
> > >  }
> > >  
> > > diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
> > > index 884950adbd16..36bf47f11117 100644
> > > --- a/fs/xfs/xfs_itable.c
> > > +++ b/fs/xfs/xfs_itable.c
> > > @@ -175,7 +175,7 @@ xfs_bulkstat_one(
> > >  
> > >  	error = xfs_bulkstat_one_int(breq->mp, NULL, breq->startino, &bc);
> > >  
> > > -	kmem_free(bc.buf);
> > > +	kfree(bc.buf);
> > >  
> > >  	/*
> > >  	 * If we reported one inode to userspace then we abort because we hit
> > > @@ -250,7 +250,7 @@ xfs_bulkstat(
> > >  	error = xfs_iwalk(breq->mp, NULL, breq->startino, breq->flags,
> > >  			xfs_bulkstat_iwalk, breq->icount, &bc);
> > >  
> > > -	kmem_free(bc.buf);
> > > +	kfree(bc.buf);
> > >  
> > >  	/*
> > >  	 * We found some inodes, so clear the error status and return them.
> > > diff --git a/fs/xfs/xfs_iwalk.c b/fs/xfs/xfs_iwalk.c
> > > index aa375cf53021..67e98f9023d2 100644
> > > --- a/fs/xfs/xfs_iwalk.c
> > > +++ b/fs/xfs/xfs_iwalk.c
> > > @@ -164,7 +164,7 @@ STATIC void
> > >  xfs_iwalk_free(
> > >  	struct xfs_iwalk_ag	*iwag)
> > >  {
> > > -	kmem_free(iwag->recs);
> > > +	kfree(iwag->recs);
> > >  	iwag->recs = NULL;
> > >  }
> > >  
> > > @@ -578,7 +578,7 @@ xfs_iwalk_ag_work(
> > >  	error = xfs_iwalk_ag(iwag);
> > >  	xfs_iwalk_free(iwag);
> > >  out:
> > > -	kmem_free(iwag);
> > > +	kfree(iwag);
> > >  	return error;
> > >  }
> > >  
> > > diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
> > > index 6a147c63a8a6..e8349b0d7c51 100644
> > > --- a/fs/xfs/xfs_log.c
> > > +++ b/fs/xfs/xfs_log.c
> > > @@ -1540,11 +1540,11 @@ xlog_alloc_log(
> > >  out_free_iclog:
> > >  	for (iclog = log->l_iclog; iclog; iclog = prev_iclog) {
> > >  		prev_iclog = iclog->ic_next;
> > > -		kmem_free(iclog->ic_data);
> > > -		kmem_free(iclog);
> > > +		kvfree(iclog->ic_data);
> > > +		kfree(iclog);
> > >  	}
> > >  out_free_log:
> > > -	kmem_free(log);
> > > +	kfree(log);
> > >  out:
> > >  	return ERR_PTR(error);
> > >  }	/* xlog_alloc_log */
> > > @@ -2001,14 +2001,14 @@ xlog_dealloc_log(
> > >  	iclog = log->l_iclog;
> > >  	for (i = 0; i < log->l_iclog_bufs; i++) {
> > >  		next_iclog = iclog->ic_next;
> > > -		kmem_free(iclog->ic_data);
> > > -		kmem_free(iclog);
> > > +		kvfree(iclog->ic_data);
> > > +		kfree(iclog);
> > >  		iclog = next_iclog;
> > >  	}
> > >  
> > >  	log->l_mp->m_log = NULL;
> > >  	destroy_workqueue(log->l_ioend_workqueue);
> > > -	kmem_free(log);
> > > +	kfree(log);
> > >  }	/* xlog_dealloc_log */
> > >  
> > >  /*
> > > diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
> > > index 48435cf2aa16..23d70836a2b7 100644
> > > --- a/fs/xfs/xfs_log_cil.c
> > > +++ b/fs/xfs/xfs_log_cil.c
> > > @@ -184,7 +184,7 @@ xlog_cil_alloc_shadow_bufs(
> > >  			 * the buffer, only the log vector header and the iovec
> > >  			 * storage.
> > >  			 */
> > > -			kmem_free(lip->li_lv_shadow);
> > > +			kfree(lip->li_lv_shadow);
> > >  
> > >  			lv = kmem_alloc_large(buf_size, KM_NOFS);
> > >  			memset(lv, 0, xlog_cil_iovec_space(niovecs));
> > > @@ -492,7 +492,7 @@ xlog_cil_free_logvec(
> > >  
> > >  	for (lv = log_vector; lv; ) {
> > >  		struct xfs_log_vec *next = lv->lv_next;
> > > -		kmem_free(lv);
> > > +		kvfree(lv);
> > >  		lv = next;
> > >  	}
> > >  }
> > > @@ -506,7 +506,7 @@ xlog_discard_endio_work(
> > >  	struct xfs_mount	*mp = ctx->cil->xc_log->l_mp;
> > >  
> > >  	xfs_extent_busy_clear(mp, &ctx->busy_extents, false);
> > > -	kmem_free(ctx);
> > > +	kfree(ctx);
> > >  }
> > >  
> > >  /*
> > > @@ -608,7 +608,7 @@ xlog_cil_committed(
> > >  	if (!list_empty(&ctx->busy_extents))
> > >  		xlog_discard_busy_extents(mp, ctx);
> > >  	else
> > > -		kmem_free(ctx);
> > > +		kfree(ctx);
> > >  }
> > >  
> > >  void
> > > @@ -872,7 +872,7 @@ xlog_cil_push(
> > >  out_skip:
> > >  	up_write(&cil->xc_ctx_lock);
> > >  	xfs_log_ticket_put(new_ctx->ticket);
> > > -	kmem_free(new_ctx);
> > > +	kfree(new_ctx);
> > >  	return 0;
> > >  
> > >  out_abort_free_ticket:
> > > @@ -1185,7 +1185,7 @@ xlog_cil_init(
> > >  
> > >  	ctx = kmem_zalloc(sizeof(*ctx), KM_MAYFAIL);
> > >  	if (!ctx) {
> > > -		kmem_free(cil);
> > > +		kfree(cil);
> > >  		return -ENOMEM;
> > >  	}
> > >  
> > > @@ -1216,10 +1216,10 @@ xlog_cil_destroy(
> > >  	if (log->l_cilp->xc_ctx) {
> > >  		if (log->l_cilp->xc_ctx->ticket)
> > >  			xfs_log_ticket_put(log->l_cilp->xc_ctx->ticket);
> > > -		kmem_free(log->l_cilp->xc_ctx);
> > > +		kfree(log->l_cilp->xc_ctx);
> > >  	}
> > >  
> > >  	ASSERT(list_empty(&log->l_cilp->xc_cil));
> > > -	kmem_free(log->l_cilp);
> > > +	kfree(log->l_cilp);
> > >  }
> > >  
> > > diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
> > > index 02f2147952b3..4167e1326f62 100644
> > > --- a/fs/xfs/xfs_log_recover.c
> > > +++ b/fs/xfs/xfs_log_recover.c
> > > @@ -418,7 +418,7 @@ xlog_find_verify_cycle(
> > >  	*new_blk = -1;
> > >  
> > >  out:
> > > -	kmem_free(buffer);
> > > +	kvfree(buffer);
> > >  	return error;
> > >  }
> > >  
> > > @@ -529,7 +529,7 @@ xlog_find_verify_log_record(
> > >  		*last_blk = i;
> > >  
> > >  out:
> > > -	kmem_free(buffer);
> > > +	kvfree(buffer);
> > >  	return error;
> > >  }
> > >  
> > > @@ -783,7 +783,7 @@ xlog_find_head(
> > >  			goto out_free_buffer;
> > >  	}
> > >  
> > > -	kmem_free(buffer);
> > > +	kvfree(buffer);
> > >  	if (head_blk == log_bbnum)
> > >  		*return_head_blk = 0;
> > >  	else
> > > @@ -797,7 +797,7 @@ xlog_find_head(
> > >  	return 0;
> > >  
> > >  out_free_buffer:
> > > -	kmem_free(buffer);
> > > +	kvfree(buffer);
> > >  	if (error)
> > >  		xfs_warn(log->l_mp, "failed to find log head");
> > >  	return error;
> > > @@ -1051,7 +1051,7 @@ xlog_verify_tail(
> > >  		"Tail block (0x%llx) overwrite detected. Updated to 0x%llx",
> > >  			 orig_tail, *tail_blk);
> > >  out:
> > > -	kmem_free(buffer);
> > > +	kvfree(buffer);
> > >  	return error;
> > >  }
> > >  
> > > @@ -1098,7 +1098,7 @@ xlog_verify_head(
> > >  	error = xlog_rseek_logrec_hdr(log, *head_blk, *tail_blk,
> > >  				      XLOG_MAX_ICLOGS, tmp_buffer,
> > >  				      &tmp_rhead_blk, &tmp_rhead, &tmp_wrapped);
> > > -	kmem_free(tmp_buffer);
> > > +	kvfree(tmp_buffer);
> > >  	if (error < 0)
> > >  		return error;
> > >  
> > > @@ -1431,7 +1431,7 @@ xlog_find_tail(
> > >  		error = xlog_clear_stale_blocks(log, tail_lsn);
> > >  
> > >  done:
> > > -	kmem_free(buffer);
> > > +	kvfree(buffer);
> > >  
> > >  	if (error)
> > >  		xfs_warn(log->l_mp, "failed to locate log tail");
> > > @@ -1479,7 +1479,7 @@ xlog_find_zeroed(
> > >  	first_cycle = xlog_get_cycle(offset);
> > >  	if (first_cycle == 0) {		/* completely zeroed log */
> > >  		*blk_no = 0;
> > > -		kmem_free(buffer);
> > > +		kvfree(buffer);
> > >  		return 1;
> > >  	}
> > >  
> > > @@ -1490,7 +1490,7 @@ xlog_find_zeroed(
> > >  
> > >  	last_cycle = xlog_get_cycle(offset);
> > >  	if (last_cycle != 0) {		/* log completely written to */
> > > -		kmem_free(buffer);
> > > +		kvfree(buffer);
> > >  		return 0;
> > >  	}
> > >  
> > > @@ -1537,7 +1537,7 @@ xlog_find_zeroed(
> > >  
> > >  	*blk_no = last_blk;
> > >  out_free_buffer:
> > > -	kmem_free(buffer);
> > > +	kvfree(buffer);
> > >  	if (error)
> > >  		return error;
> > >  	return 1;
> > > @@ -1649,7 +1649,7 @@ xlog_write_log_records(
> > >  	}
> > >  
> > >  out_free_buffer:
> > > -	kmem_free(buffer);
> > > +	kvfree(buffer);
> > >  	return error;
> > >  }
> > >  
> > > @@ -2039,7 +2039,7 @@ xlog_check_buffer_cancelled(
> > >  	if (flags & XFS_BLF_CANCEL) {
> > >  		if (--bcp->bc_refcount == 0) {
> > >  			list_del(&bcp->bc_list);
> > > -			kmem_free(bcp);
> > > +			kfree(bcp);
> > >  		}
> > >  	}
> > >  	return 1;
> > > @@ -3188,7 +3188,7 @@ xlog_recover_inode_pass2(
> > >  	xfs_buf_relse(bp);
> > >  error:
> > >  	if (need_free)
> > > -		kmem_free(in_f);
> > > +		kfree(in_f);
> > >  	return error;
> > >  }
> > >  
> > > @@ -4292,7 +4292,7 @@ xlog_recover_add_to_trans(
> > >  		"bad number of regions (%d) in inode log format",
> > >  				  in_f->ilf_size);
> > >  			ASSERT(0);
> > > -			kmem_free(ptr);
> > > +			kfree(ptr);
> > >  			return -EFSCORRUPTED;
> > >  		}
> > >  
> > > @@ -4307,7 +4307,7 @@ xlog_recover_add_to_trans(
> > >  	"log item region count (%d) overflowed size (%d)",
> > >  				item->ri_cnt, item->ri_total);
> > >  		ASSERT(0);
> > > -		kmem_free(ptr);
> > > +		kfree(ptr);
> > >  		return -EFSCORRUPTED;
> > >  	}
> > >  
> > > @@ -4337,13 +4337,13 @@ xlog_recover_free_trans(
> > >  		/* Free the regions in the item. */
> > >  		list_del(&item->ri_list);
> > >  		for (i = 0; i < item->ri_cnt; i++)
> > > -			kmem_free(item->ri_buf[i].i_addr);
> > > +			kfree(item->ri_buf[i].i_addr);
> > >  		/* Free the item itself */
> > > -		kmem_free(item->ri_buf);
> > > -		kmem_free(item);
> > > +		kfree(item->ri_buf);
> > > +		kfree(item);
> > >  	}
> > >  	/* Free the transaction recover structure */
> > > -	kmem_free(trans);
> > > +	kfree(trans);
> > >  }
> > >  
> > >  /*
> > > @@ -5327,7 +5327,7 @@ xlog_do_recovery_pass(
> > >  			hblks = h_size / XLOG_HEADER_CYCLE_SIZE;
> > >  			if (h_size % XLOG_HEADER_CYCLE_SIZE)
> > >  				hblks++;
> > > -			kmem_free(hbp);
> > > +			kvfree(hbp);
> > >  			hbp = xlog_alloc_buffer(log, hblks);
> > >  		} else {
> > >  			hblks = 1;
> > > @@ -5343,7 +5343,7 @@ xlog_do_recovery_pass(
> > >  		return -ENOMEM;
> > >  	dbp = xlog_alloc_buffer(log, BTOBB(h_size));
> > >  	if (!dbp) {
> > > -		kmem_free(hbp);
> > > +		kvfree(hbp);
> > >  		return -ENOMEM;
> > >  	}
> > >  
> > > @@ -5504,9 +5504,9 @@ xlog_do_recovery_pass(
> > >  	}
> > >  
> > >   bread_err2:
> > > -	kmem_free(dbp);
> > > +	kvfree(dbp);
> > >   bread_err1:
> > > -	kmem_free(hbp);
> > > +	kvfree(hbp);
> > >  
> > >  	/*
> > >  	 * Submit buffers that have been added from the last record processed,
> > > @@ -5570,7 +5570,7 @@ xlog_do_log_recovery(
> > >  	error = xlog_do_recovery_pass(log, head_blk, tail_blk,
> > >  				      XLOG_RECOVER_PASS1, NULL);
> > >  	if (error != 0) {
> > > -		kmem_free(log->l_buf_cancel_table);
> > > +		kfree(log->l_buf_cancel_table);
> > >  		log->l_buf_cancel_table = NULL;
> > >  		return error;
> > >  	}
> > > @@ -5589,7 +5589,7 @@ xlog_do_log_recovery(
> > >  	}
> > >  #endif	/* DEBUG */
> > >  
> > > -	kmem_free(log->l_buf_cancel_table);
> > > +	kfree(log->l_buf_cancel_table);
> > >  	log->l_buf_cancel_table = NULL;
> > >  
> > >  	return error;
> > > diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
> > > index 5ea95247a37f..53ddb058b11a 100644
> > > --- a/fs/xfs/xfs_mount.c
> > > +++ b/fs/xfs/xfs_mount.c
> > > @@ -42,7 +42,7 @@ xfs_uuid_table_free(void)
> > >  {
> > >  	if (xfs_uuid_table_size == 0)
> > >  		return;
> > > -	kmem_free(xfs_uuid_table);
> > > +	kfree(xfs_uuid_table);
> > >  	xfs_uuid_table = NULL;
> > >  	xfs_uuid_table_size = 0;
> > >  }
> > > @@ -127,7 +127,7 @@ __xfs_free_perag(
> > >  	struct xfs_perag *pag = container_of(head, struct xfs_perag, rcu_head);
> > >  
> > >  	ASSERT(atomic_read(&pag->pag_ref) == 0);
> > > -	kmem_free(pag);
> > > +	kfree(pag);
> > >  }
> > >  
> > >  /*
> > > @@ -243,7 +243,7 @@ xfs_initialize_perag(
> > >  	xfs_buf_hash_destroy(pag);
> > >  out_free_pag:
> > >  	mutex_destroy(&pag->pag_ici_reclaim_lock);
> > > -	kmem_free(pag);
> > > +	kfree(pag);
> > >  out_unwind_new_pags:
> > >  	/* unwind any prior newly initialized pags */
> > >  	for (index = first_initialised; index < agcount; index++) {
> > > @@ -253,7 +253,7 @@ xfs_initialize_perag(
> > >  		xfs_buf_hash_destroy(pag);
> > >  		xfs_iunlink_destroy(pag);
> > >  		mutex_destroy(&pag->pag_ici_reclaim_lock);
> > > -		kmem_free(pag);
> > > +		kfree(pag);
> > >  	}
> > >  	return error;
> > >  }
> > > diff --git a/fs/xfs/xfs_mru_cache.c b/fs/xfs/xfs_mru_cache.c
> > > index a06661dac5be..6ef0a71d7681 100644
> > > --- a/fs/xfs/xfs_mru_cache.c
> > > +++ b/fs/xfs/xfs_mru_cache.c
> > > @@ -364,9 +364,9 @@ xfs_mru_cache_create(
> > >  
> > >  exit:
> > >  	if (err && mru && mru->lists)
> > > -		kmem_free(mru->lists);
> > > +		kfree(mru->lists);
> > >  	if (err && mru)
> > > -		kmem_free(mru);
> > > +		kfree(mru);
> > >  
> > >  	return err;
> > >  }
> > > @@ -406,8 +406,8 @@ xfs_mru_cache_destroy(
> > >  
> > >  	xfs_mru_cache_flush(mru);
> > >  
> > > -	kmem_free(mru->lists);
> > > -	kmem_free(mru);
> > > +	kfree(mru->lists);
> > > +	kfree(mru);
> > >  }
> > >  
> > >  /*
> > > diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
> > > index 66ea8e4fca86..06c92dc61a03 100644
> > > --- a/fs/xfs/xfs_qm.c
> > > +++ b/fs/xfs/xfs_qm.c
> > > @@ -698,7 +698,7 @@ xfs_qm_init_quotainfo(
> > >  out_free_lru:
> > >  	list_lru_destroy(&qinf->qi_lru);
> > >  out_free_qinf:
> > > -	kmem_free(qinf);
> > > +	kfree(qinf);
> > >  	mp->m_quotainfo = NULL;
> > >  	return error;
> > >  }
> > > @@ -722,7 +722,7 @@ xfs_qm_destroy_quotainfo(
> > >  	xfs_qm_destroy_quotainos(qi);
> > >  	mutex_destroy(&qi->qi_tree_lock);
> > >  	mutex_destroy(&qi->qi_quotaofflock);
> > > -	kmem_free(qi);
> > > +	kfree(qi);
> > >  	mp->m_quotainfo = NULL;
> > >  }
> > >  
> > > @@ -1049,7 +1049,7 @@ xfs_qm_reset_dqcounts_buf(
> > >  	} while (nmaps > 0);
> > >  
> > >  out:
> > > -	kmem_free(map);
> > > +	kfree(map);
> > >  	return error;
> > >  }
> > >  
> > > diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c
> > > index 8eeed73928cd..0ac598f55339 100644
> > > --- a/fs/xfs/xfs_refcount_item.c
> > > +++ b/fs/xfs/xfs_refcount_item.c
> > > @@ -32,7 +32,7 @@ xfs_cui_item_free(
> > >  	struct xfs_cui_log_item	*cuip)
> > >  {
> > >  	if (cuip->cui_format.cui_nextents > XFS_CUI_MAX_FAST_EXTENTS)
> > > -		kmem_free(cuip);
> > > +		kfree(cuip);
> > >  	else
> > >  		kmem_cache_free(xfs_cui_zone, cuip);
> > >  }
> > > @@ -392,7 +392,7 @@ xfs_refcount_update_finish_item(
> > >  		refc->ri_blockcount = new_aglen;
> > >  		return -EAGAIN;
> > >  	}
> > > -	kmem_free(refc);
> > > +	kfree(refc);
> > >  	return error;
> > >  }
> > >  
> > > @@ -424,7 +424,7 @@ xfs_refcount_update_cancel_item(
> > >  	struct xfs_refcount_intent	*refc;
> > >  
> > >  	refc = container_of(item, struct xfs_refcount_intent, ri_list);
> > > -	kmem_free(refc);
> > > +	kfree(refc);
> > >  }
> > >  
> > >  const struct xfs_defer_op_type xfs_refcount_update_defer_type = {
> > > diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c
> > > index 4911b68f95dd..a0a02d862ddd 100644
> > > --- a/fs/xfs/xfs_rmap_item.c
> > > +++ b/fs/xfs/xfs_rmap_item.c
> > > @@ -32,7 +32,7 @@ xfs_rui_item_free(
> > >  	struct xfs_rui_log_item	*ruip)
> > >  {
> > >  	if (ruip->rui_format.rui_nextents > XFS_RUI_MAX_FAST_EXTENTS)
> > > -		kmem_free(ruip);
> > > +		kfree(ruip);
> > >  	else
> > >  		kmem_cache_free(xfs_rui_zone, ruip);
> > >  }
> > > @@ -436,7 +436,7 @@ xfs_rmap_update_finish_item(
> > >  			rmap->ri_bmap.br_blockcount,
> > >  			rmap->ri_bmap.br_state,
> > >  			(struct xfs_btree_cur **)state);
> > > -	kmem_free(rmap);
> > > +	kfree(rmap);
> > >  	return error;
> > >  }
> > >  
> > > @@ -468,7 +468,7 @@ xfs_rmap_update_cancel_item(
> > >  	struct xfs_rmap_intent		*rmap;
> > >  
> > >  	rmap = container_of(item, struct xfs_rmap_intent, ri_list);
> > > -	kmem_free(rmap);
> > > +	kfree(rmap);
> > >  }
> > >  
> > >  const struct xfs_defer_op_type xfs_rmap_update_defer_type = {
> > > diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
> > > index d42b5a2047e0..7f03b4ab3452 100644
> > > --- a/fs/xfs/xfs_rtalloc.c
> > > +++ b/fs/xfs/xfs_rtalloc.c
> > > @@ -1082,7 +1082,7 @@ xfs_growfs_rt(
> > >  	/*
> > >  	 * Free the fake mp structure.
> > >  	 */
> > > -	kmem_free(nmp);
> > > +	kfree(nmp);
> > >  
> > >  	/*
> > >  	 * If we had to allocate a new rsum_cache, we either need to free the
> > > @@ -1091,10 +1091,10 @@ xfs_growfs_rt(
> > >  	 */
> > >  	if (rsum_cache != mp->m_rsum_cache) {
> > >  		if (error) {
> > > -			kmem_free(mp->m_rsum_cache);
> > > +			kvfree(mp->m_rsum_cache);
> > >  			mp->m_rsum_cache = rsum_cache;
> > >  		} else {
> > > -			kmem_free(rsum_cache);
> > > +			kvfree(rsum_cache);
> > >  		}
> > >  	}
> > >  
> > > @@ -1253,7 +1253,7 @@ void
> > >  xfs_rtunmount_inodes(
> > >  	struct xfs_mount	*mp)
> > >  {
> > > -	kmem_free(mp->m_rsum_cache);
> > > +	kvfree(mp->m_rsum_cache);
> > >  	if (mp->m_rbmip)
> > >  		xfs_irele(mp->m_rbmip);
> > >  	if (mp->m_rsumip)
> > > diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> > > index d9ae27ddf253..cc1933dc652f 100644
> > > --- a/fs/xfs/xfs_super.c
> > > +++ b/fs/xfs/xfs_super.c
> > > @@ -725,7 +725,7 @@ xfs_mount_free(
> > >  {
> > >  	kfree(mp->m_rtname);
> > >  	kfree(mp->m_logname);
> > > -	kmem_free(mp);
> > > +	kfree(mp);
> > >  }
> > >  
> > >  STATIC int
> > > diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c
> > > index 00cc5b8734be..589918d11041 100644
> > > --- a/fs/xfs/xfs_trans_ail.c
> > > +++ b/fs/xfs/xfs_trans_ail.c
> > > @@ -844,7 +844,7 @@ xfs_trans_ail_init(
> > >  	return 0;
> > >  
> > >  out_free_ailp:
> > > -	kmem_free(ailp);
> > > +	kfree(ailp);
> > >  	return -ENOMEM;
> > >  }
> > >  
> > > @@ -855,5 +855,5 @@ xfs_trans_ail_destroy(
> > >  	struct xfs_ail	*ailp = mp->m_ail;
> > >  
> > >  	kthread_stop(ailp->ail_task);
> > > -	kmem_free(ailp);
> > > +	kfree(ailp);
> > >  }
> > > -- 
> > > 2.23.0
> > > 
> > 
> 
> -- 
> Carlos
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/4] xfs: Remove kmem_free()
  2019-11-15 17:23       ` Darrick J. Wong
@ 2019-11-18  0:39         ` Dave Chinner
  2019-11-18  8:30         ` Carlos Maiolino
  1 sibling, 0 replies; 14+ messages in thread
From: Dave Chinner @ 2019-11-18  0:39 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-xfs, dchinner

On Fri, Nov 15, 2019 at 09:23:22AM -0800, Darrick J. Wong wrote:
> On Fri, Nov 15, 2019 at 03:20:55PM +0100, Carlos Maiolino wrote:
> > Btw, Dave mentioned in a not so far future, kmalloc() requests will be
> > guaranteed to be aligned, so, I wonder if we will be able to replace both
> > kmem_alloc_large() and kmem_alloc_io() by simple calls to kvmalloc() which does
> > the job of falling back to vmalloc() if kmalloc() fails?!
> 
> Sure, but I'll believe that when I see it.  And given that Christoph
> Lameter seems totally opposed to the idea, I think we should keep our
> silly wrapper for a while to see if they don't accidentally revert it or
> something.

It's already been merged, see this commit 59bb47985c1d ("mm,
sl[aou]b: guarantee natural alignment for kmalloc(power-of-two)").

So in 5.6/5.7 if it's still there, we can remove kmem_alloc_io().

kmem_alloc_large() may need to remain because of the
memalloc_nofs_*() wrappers vmalloc requires in GFP_NOFS context.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/4] xfs: Remove kmem_free()
  2019-11-15 17:23       ` Darrick J. Wong
  2019-11-18  0:39         ` Dave Chinner
@ 2019-11-18  8:30         ` Carlos Maiolino
  2019-11-21  5:43           ` Darrick J. Wong
  1 sibling, 1 reply; 14+ messages in thread
From: Carlos Maiolino @ 2019-11-18  8:30 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-xfs, dchinner

On Fri, Nov 15, 2019 at 09:23:22AM -0800, Darrick J. Wong wrote:
> On Fri, Nov 15, 2019 at 03:20:55PM +0100, Carlos Maiolino wrote:
> > On Thu, Nov 14, 2019 at 01:00:00PM -0800, Darrick J. Wong wrote:
> > > On Thu, Nov 14, 2019 at 09:09:55PM +0100, Carlos Maiolino wrote:
> > > > This can be replaced by direct calls to kfree() or kvfree() (whenever
> > > > allocation is done via kmem_alloc_io() or kmem_alloc_large().
> > > > 
> > > > This patch has been partially scripted. I used the following sed to
> > > > replace all kmem_free() calls by kfree()
> > > > 
> > > >  # find fs/xfs/ -type f -name '*.c' -o -name '*.h' | xargs sed -i \
> > > >    's/kmem_free/kfree/g'
> > > 
> > > Coccinelle? ;)
> > 
> > /me Doesn't understand the reference but thinks Darrick is talking about
> > Coccinelle fancy brand :P
> > 
> > /me is adept to conference-wear :D
> 
> http://coccinelle.lip6.fr/
> 
> The semantic patch thing, because understanding the weird spatch
> language is slightly less infuriating than making tons of minor code
> changes by hand. :P

Oh, I didn't know about this. Thanks. The name could be something different
other than a fashion brand making googling for it easier :(

> > I can't really say we will have any benefits in segmenting it by using kvfree()
> > only where kmem_alloc_{large, io} is used, so I just relied on the comments
> > above kvfree(), and well, we have an extra function call and a few extra
> > instructions using kvfree(). So, even though it might be 'slightly' faster, this
> > might build up on hot paths when handling millions of kfree().
> > 
> > But, at the end, I'd be lying if I say I spotted any significant difference.
> 
> <nod> Though the way I see it, kfree vs. kvfree is another bookkeepping
> detail that xfs developers will have to keep straight.  But maybe that's
> fine for the dozen or so specialized users of _io and _large?  What do
> others think?

Ok, if we decide to move everything to kvfree() I'll just send a V2 of this
patch, which should apply cleanly on top of the other 3.

> 
> > Btw, Dave mentioned in a not so far future, kmalloc() requests will be
> > guaranteed to be aligned, so, I wonder if we will be able to replace both
> > kmem_alloc_large() and kmem_alloc_io() by simple calls to kvmalloc() which does
> > the job of falling back to vmalloc() if kmalloc() fails?!
> 
> Sure, but I'll believe that when I see it.  And given that Christoph
> Lameter seems totally opposed to the idea, I think we should keep our
> silly wrapper for a while to see if they don't accidentally revert it or
> something.
> 

Sure, I don't have any plans to do it now in this series or in a very near
future, I just used the email to share the idea :P

Thanks for the review.

-- 
Carlos


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/4] xfs: Remove kmem_free()
  2019-11-18  8:30         ` Carlos Maiolino
@ 2019-11-21  5:43           ` Darrick J. Wong
  2019-11-22  8:50             ` Carlos Maiolino
  0 siblings, 1 reply; 14+ messages in thread
From: Darrick J. Wong @ 2019-11-21  5:43 UTC (permalink / raw)
  To: linux-xfs, dchinner

On Mon, Nov 18, 2019 at 09:30:08AM +0100, Carlos Maiolino wrote:
> On Fri, Nov 15, 2019 at 09:23:22AM -0800, Darrick J. Wong wrote:
> > On Fri, Nov 15, 2019 at 03:20:55PM +0100, Carlos Maiolino wrote:
> > > On Thu, Nov 14, 2019 at 01:00:00PM -0800, Darrick J. Wong wrote:
> > > > On Thu, Nov 14, 2019 at 09:09:55PM +0100, Carlos Maiolino wrote:
> > > > > This can be replaced by direct calls to kfree() or kvfree() (whenever
> > > > > allocation is done via kmem_alloc_io() or kmem_alloc_large().
> > > > > 
> > > > > This patch has been partially scripted. I used the following sed to
> > > > > replace all kmem_free() calls by kfree()
> > > > > 
> > > > >  # find fs/xfs/ -type f -name '*.c' -o -name '*.h' | xargs sed -i \
> > > > >    's/kmem_free/kfree/g'
> > > > 
> > > > Coccinelle? ;)
> > > 
> > > /me Doesn't understand the reference but thinks Darrick is talking about
> > > Coccinelle fancy brand :P
> > > 
> > > /me is adept to conference-wear :D
> > 
> > http://coccinelle.lip6.fr/
> > 
> > The semantic patch thing, because understanding the weird spatch
> > language is slightly less infuriating than making tons of minor code
> > changes by hand. :P
> 
> Oh, I didn't know about this. Thanks. The name could be something different
> other than a fashion brand making googling for it easier :(
> 
> > > I can't really say we will have any benefits in segmenting it by using kvfree()
> > > only where kmem_alloc_{large, io} is used, so I just relied on the comments
> > > above kvfree(), and well, we have an extra function call and a few extra
> > > instructions using kvfree(). So, even though it might be 'slightly' faster, this
> > > might build up on hot paths when handling millions of kfree().
> > > 
> > > But, at the end, I'd be lying if I say I spotted any significant difference.
> > 
> > <nod> Though the way I see it, kfree vs. kvfree is another bookkeepping
> > detail that xfs developers will have to keep straight.  But maybe that's
> > fine for the dozen or so specialized users of _io and _large?  What do
> > others think?
> 
> Ok, if we decide to move everything to kvfree() I'll just send a V2 of this
> patch, which should apply cleanly on top of the other 3.
> 
> > 
> > > Btw, Dave mentioned in a not so far future, kmalloc() requests will be
> > > guaranteed to be aligned, so, I wonder if we will be able to replace both
> > > kmem_alloc_large() and kmem_alloc_io() by simple calls to kvmalloc() which does
> > > the job of falling back to vmalloc() if kmalloc() fails?!
> > 
> > Sure, but I'll believe that when I see it.  And given that Christoph
> > Lameter seems totally opposed to the idea, I think we should keep our
> > silly wrapper for a while to see if they don't accidentally revert it or
> > something.
> > 
> 
> Sure, I don't have any plans to do it now in this series or in a very near
> future, I just used the email to share the idea :P

Eh, well, FWIW I took a second look at all the kvfree/kfree and decided
that the usage was correct.  For future reference, please do the
straight change as one patch and straighten out the usages as a separate
patch.

In any case it seemed to test ok over the weekend (and still seems ok
with your series from today), so...
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> Thanks for the review.
> 
> -- 
> Carlos
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/4] xfs: Remove kmem_free()
  2019-11-21  5:43           ` Darrick J. Wong
@ 2019-11-22  8:50             ` Carlos Maiolino
  2019-11-22 16:11               ` Darrick J. Wong
  0 siblings, 1 reply; 14+ messages in thread
From: Carlos Maiolino @ 2019-11-22  8:50 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-xfs, dchinner

Hi Darrick.


> > > 
> > > Sure, but I'll believe that when I see it.  And given that Christoph
> > > Lameter seems totally opposed to the idea, I think we should keep our
> > > silly wrapper for a while to see if they don't accidentally revert it or
> > > something.
> > > 
> > 
> > Sure, I don't have any plans to do it now in this series or in a very near
> > future, I just used the email to share the idea :P
> 
> Eh, well, FWIW I took a second look at all the kvfree/kfree and decided
> that the usage was correct.  For future reference, please do the
> straight change as one patch and straighten out the usages as a separate
> patch.
> 

I'm not sure what you meant by 'straight change' and 'straighten out'.

Do you mean to do send a single patch with only the changes made by the
'find&replace' command, followed up by a kfree() -> kvfree() where appropriate?

Cheers.

> In any case it seemed to test ok over the weekend (and still seems ok
> with your series from today), so...
> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
> 

> --D
> 
> > Thanks for the review.
> > 
> > -- 
> > Carlos
> > 
> 

-- 
Carlos


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/4] xfs: Remove kmem_free()
  2019-11-22  8:50             ` Carlos Maiolino
@ 2019-11-22 16:11               ` Darrick J. Wong
  2019-11-25 14:10                 ` Carlos Maiolino
  0 siblings, 1 reply; 14+ messages in thread
From: Darrick J. Wong @ 2019-11-22 16:11 UTC (permalink / raw)
  To: linux-xfs, dchinner

On Fri, Nov 22, 2019 at 09:50:33AM +0100, Carlos Maiolino wrote:
> Hi Darrick.
> 
> 
> > > > 
> > > > Sure, but I'll believe that when I see it.  And given that Christoph
> > > > Lameter seems totally opposed to the idea, I think we should keep our
> > > > silly wrapper for a while to see if they don't accidentally revert it or
> > > > something.
> > > > 
> > > 
> > > Sure, I don't have any plans to do it now in this series or in a very near
> > > future, I just used the email to share the idea :P
> > 
> > Eh, well, FWIW I took a second look at all the kvfree/kfree and decided
> > that the usage was correct.  For future reference, please do the
> > straight change as one patch and straighten out the usages as a separate
> > patch.
> > 
> 
> I'm not sure what you meant by 'straight change' and 'straighten out'.
> 
> Do you mean to do send a single patch with only the changes made by the
> 'find&replace' command, followed up by a kfree() -> kvfree() where appropriate?

Er, the opposite in this case -- Patch 1 replaces all the kmem_free
calls with kvfree calls (because that's what kmem_free did).  Patch 2
then changes the kvfree calls to kfree calls, but only for the cases
where we kmalloc'd the memory.

--D

> Cheers.
> 
> > In any case it seemed to test ok over the weekend (and still seems ok
> > with your series from today), so...
> > Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> 
> > --D
> > 
> > > Thanks for the review.
> > > 
> > > -- 
> > > Carlos
> > > 
> > 
> 
> -- 
> Carlos
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/4] xfs: Remove kmem_free()
  2019-11-22 16:11               ` Darrick J. Wong
@ 2019-11-25 14:10                 ` Carlos Maiolino
  0 siblings, 0 replies; 14+ messages in thread
From: Carlos Maiolino @ 2019-11-25 14:10 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-xfs, dchinner

On Fri, Nov 22, 2019 at 08:11:11AM -0800, Darrick J. Wong wrote:
> On Fri, Nov 22, 2019 at 09:50:33AM +0100, Carlos Maiolino wrote:
> > Hi Darrick.
> > 
> > 
> > > > > 
> > > > > Sure, but I'll believe that when I see it.  And given that Christoph
> > > > > Lameter seems totally opposed to the idea, I think we should keep our
> > > > > silly wrapper for a while to see if they don't accidentally revert it or
> > > > > something.
> > > > > 
> > > > 
> > > > Sure, I don't have any plans to do it now in this series or in a very near
> > > > future, I just used the email to share the idea :P
> > > 
> > > Eh, well, FWIW I took a second look at all the kvfree/kfree and decided
> > > that the usage was correct.  For future reference, please do the
> > > straight change as one patch and straighten out the usages as a separate
> > > patch.
> > > 
> > 
> > I'm not sure what you meant by 'straight change' and 'straighten out'.
> > 
> > Do you mean to do send a single patch with only the changes made by the
> > 'find&replace' command, followed up by a kfree() -> kvfree() where appropriate?
> 
> Er, the opposite in this case -- Patch 1 replaces all the kmem_free
> calls with kvfree calls (because that's what kmem_free did).  Patch 2
> then changes the kvfree calls to kfree calls, but only for the cases
> where we kmalloc'd the memory.

Makes perfect sense. Thanks, I'll ensure to do that next time.

> 
> --D
> 
> > Cheers.
> > 
> > > In any case it seemed to test ok over the weekend (and still seems ok
> > > with your series from today), so...
> > > Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
> > > 
> > 
> > > --D
> > > 
> > > > Thanks for the review.
> > > > 
> > > > -- 
> > > > Carlos
> > > > 
> > > 
> > 
> > -- 
> > Carlos
> > 
> 

-- 
Carlos


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, back to index

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-14 20:09 [PATCH 0/4] Get rid of pointless wrappers Carlos Maiolino
2019-11-14 20:09 ` [PATCH 1/4] xfs: Remove slab init wrappers Carlos Maiolino
2019-11-14 20:09 ` [PATCH 2/4] xfs: Remove kmem_zone_destroy() wrapper Carlos Maiolino
2019-11-14 20:09 ` [PATCH 3/4] xfs: Remove kmem_zone_free() wrapper Carlos Maiolino
2019-11-14 20:09 ` [PATCH 4/4] xfs: Remove kmem_free() Carlos Maiolino
2019-11-14 21:00   ` Darrick J. Wong
2019-11-15 14:20     ` Carlos Maiolino
2019-11-15 17:23       ` Darrick J. Wong
2019-11-18  0:39         ` Dave Chinner
2019-11-18  8:30         ` Carlos Maiolino
2019-11-21  5:43           ` Darrick J. Wong
2019-11-22  8:50             ` Carlos Maiolino
2019-11-22 16:11               ` Darrick J. Wong
2019-11-25 14:10                 ` Carlos Maiolino

Linux-XFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-xfs/0 linux-xfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-xfs linux-xfs/ https://lore.kernel.org/linux-xfs \
		linux-xfs@vger.kernel.org
	public-inbox-index linux-xfs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-xfs


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git