Skip to contentSkip to conversation

xfs: Remove kmem_zalloc_large()

PATCH Superseded Carlos Maiolino 3 participants 3 messages Aug 26, 2020 XFS filesystem

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 xfs: Remove kmem_zalloc_large()

This patch aims to replace kmem_zalloc_large() with global kernel memory API. So, all its callers are now using kvzalloc() directly, so kmalloc() fallsback to vmalloc() automatically.

---

Changelog:

	V2:
		Remove __GFP_RETRY_MAYFAIL from the kvzalloc() calls
 fs/xfs/kmem.h          | 6 ------
 fs/xfs/scrub/symlink.c | 3 ++-
 fs/xfs/xfs_acl.c       | 2 +-
 fs/xfs/xfs_ioctl.c     | 4 ++--
 fs/xfs/xfs_rtalloc.c   | 2 +-
 5 files changed, 6 insertions(+), 11 deletions(-)
fs/xfs/kmem.h +0 -6
index fb1d066770723..38007117697ef 100644
@@ -71,12 +71,6 @@ kmem_zalloc(size_t size, xfs_km_flags_t flags)
 	return kmem_alloc(size, flags | KM_ZERO);
 }
 
-static inline void *
-kmem_zalloc_large(size_t size, xfs_km_flags_t flags)
-{
-	return kmem_alloc_large(size, flags | KM_ZERO);
-}
-
 /*
  * Zone interfaces
  */
fs/xfs/scrub/symlink.c +2 -1
index 5641ae512c9ef..5a721a9adea78 100644
@@ -22,11 +22,12 @@ xchk_setup_symlink(
 	struct xfs_inode	*ip)
 {
 	/* Allocate the buffer without the inode lock held. */
-	sc->buf = kmem_zalloc_large(XFS_SYMLINK_MAXLEN + 1, 0);
+	sc->buf = kvzalloc(XFS_SYMLINK_MAXLEN + 1, GFP_KERNEL);
 	if (!sc->buf)
 		return -ENOMEM;
 
 	return xchk_setup_inode_contents(sc, ip, 0);
+
 }
 
 /* Symbolic links. */
fs/xfs/xfs_acl.c +1 -1
index d4c687b5cd067..c544951a0c07f 100644
@@ -192,7 +192,7 @@ __xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
 
 	if (acl) {
 		args.valuelen = XFS_ACL_SIZE(acl->a_count);
-		args.value = kmem_zalloc_large(args.valuelen, 0);
+		args.value = kvzalloc(args.valuelen, GFP_KERNEL);
 		if (!args.value)
 			return -ENOMEM;
 		xfs_acl_to_disk(args.value, acl);
fs/xfs/xfs_ioctl.c +2 -2
index 6f22a66777cd0..4428b893f8372 100644
@@ -404,7 +404,7 @@ xfs_ioc_attr_list(
 	     context.cursor.offset))
 		return -EINVAL;
 
-	buffer = kmem_zalloc_large(bufsize, 0);
+	buffer = kvzalloc(bufsize, GFP_KERNEL);
 	if (!buffer)
 		return -ENOMEM;
 
@@ -1690,7 +1690,7 @@ xfs_ioc_getbmap(
 	if (bmx.bmv_count > ULONG_MAX / recsize)
 		return -ENOMEM;
 
-	buf = kmem_zalloc_large(bmx.bmv_count * sizeof(*buf), 0);
+	buf = kvzalloc(bmx.bmv_count * sizeof(*buf), GFP_KERNEL);
 	if (!buf)
 		return -ENOMEM;
 
fs/xfs/xfs_rtalloc.c +1 -1
index 6209e7b6b895b..0558f92ecdb83 100644
@@ -862,7 +862,7 @@ xfs_alloc_rsum_cache(
 	 * lower bound on the minimum level with any free extents. We can
 	 * continue without the cache if it couldn't be allocated.
 	 */
-	mp->m_rsum_cache = kmem_zalloc_large(rbmblocks, 0);
+	mp->m_rsum_cache = kvzalloc(rbmblocks, GFP_KERNEL);
 	if (!mp->m_rsum_cache)
 		xfs_warn(mp, "could not allocate realtime summary cache");
 }
Signature · 1 line
2.26.2
#1 lore raw
Quoted 41 lines · Carlos Maiolino

This patch aims to replace kmem_zalloc_large() with global kernel memory API. So, all its callers are now using kvzalloc() directly, so kmalloc() fallsback to vmalloc() automatically.

---

Changelog:

	V2:
		Remove __GFP_RETRY_MAYFAIL from the kvzalloc() calls
 fs/xfs/kmem.h          | 6 ------
 fs/xfs/scrub/symlink.c | 3 ++-
 fs/xfs/xfs_acl.c       | 2 +-
 fs/xfs/xfs_ioctl.c     | 4 ++--
 fs/xfs/xfs_rtalloc.c   | 2 +-
 5 files changed, 6 insertions(+), 11 deletions(-)
fs/xfs/kmem.h +0 -6
index fb1d066770723..38007117697ef 100644
@@ -71,12 +71,6 @@ kmem_zalloc(size_t size, xfs_km_flags_t flags)
 	return kmem_alloc(size, flags | KM_ZERO);
 }
 
-static inline void *
-kmem_zalloc_large(size_t size, xfs_km_flags_t flags)
-{
-	return kmem_alloc_large(size, flags | KM_ZERO);
-}
-
 /*
  * Zone interfaces
  */
fs/xfs/scrub/symlink.c +0 -0
index 5641ae512c9ef..5a721a9adea78 100644

fs/xfs/scrub/symlink.c xchk_setup_symlink( · line 30

Quoted 10 lines
fs/xfs/scrub/symlink.c +2 -1
@@ -22,11 +22,12 @@ xchk_setup_symlink(
 	struct xfs_inode	*ip)
 {
 	/* Allocate the buffer without the inode lock held. */
-	sc->buf = kmem_zalloc_large(XFS_SYMLINK_MAXLEN + 1, 0);
+	sc->buf = kvzalloc(XFS_SYMLINK_MAXLEN + 1, GFP_KERNEL);
 	if (!sc->buf)
 		return -ENOMEM;
 
 	return xchk_setup_inode_contents(sc, ip, 0);
+

Nit: empty line added here.

Everything else looks fine to me.

--D

Quoted 54 lines
fs/xfs/scrub/symlink.c +0 -0
 }
 
 /* Symbolic links. */
fs/xfs/xfs_acl.c +1 -1
index d4c687b5cd067..c544951a0c07f 100644
@@ -192,7 +192,7 @@ __xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
 
 	if (acl) {
 		args.valuelen = XFS_ACL_SIZE(acl->a_count);
-		args.value = kmem_zalloc_large(args.valuelen, 0);
+		args.value = kvzalloc(args.valuelen, GFP_KERNEL);
 		if (!args.value)
 			return -ENOMEM;
 		xfs_acl_to_disk(args.value, acl);
fs/xfs/xfs_ioctl.c +2 -2
index 6f22a66777cd0..4428b893f8372 100644
@@ -404,7 +404,7 @@ xfs_ioc_attr_list(
 	     context.cursor.offset))
 		return -EINVAL;
 
-	buffer = kmem_zalloc_large(bufsize, 0);
+	buffer = kvzalloc(bufsize, GFP_KERNEL);
 	if (!buffer)
 		return -ENOMEM;
 
@@ -1690,7 +1690,7 @@ xfs_ioc_getbmap(
 	if (bmx.bmv_count > ULONG_MAX / recsize)
 		return -ENOMEM;
 
-	buf = kmem_zalloc_large(bmx.bmv_count * sizeof(*buf), 0);
+	buf = kvzalloc(bmx.bmv_count * sizeof(*buf), GFP_KERNEL);
 	if (!buf)
 		return -ENOMEM;
 
fs/xfs/xfs_rtalloc.c +1 -1
index 6209e7b6b895b..0558f92ecdb83 100644
@@ -862,7 +862,7 @@ xfs_alloc_rsum_cache(
 	 * lower bound on the minimum level with any free extents. We can
 	 * continue without the cache if it couldn't be allocated.
 	 */
-	mp->m_rsum_cache = kmem_zalloc_large(rbmblocks, 0);
+	mp->m_rsum_cache = kvzalloc(rbmblocks, GFP_KERNEL);
 	if (!mp->m_rsum_cache)
 		xfs_warn(mp, "could not allocate realtime summary cache");
 }
Signature · 1 line
2.26.2
Reviewed-by on v2 1/1
#2 lore raw
In reply to Carlos Maiolino
Quoted 42 lines · Carlos Maiolino

This patch aims to replace kmem_zalloc_large() with global kernel memory API. So, all its callers are now using kvzalloc() directly, so kmalloc() fallsback to vmalloc() automatically.

---

Changelog:

	V2:
		Remove __GFP_RETRY_MAYFAIL from the kvzalloc() calls
 fs/xfs/kmem.h          | 6 ------
 fs/xfs/scrub/symlink.c | 3 ++-
 fs/xfs/xfs_acl.c       | 2 +-
 fs/xfs/xfs_ioctl.c     | 4 ++--
 fs/xfs/xfs_rtalloc.c   | 2 +-
 5 files changed, 6 insertions(+), 11 deletions(-)
fs/xfs/kmem.h +0 -6
index fb1d066770723..38007117697ef 100644
@@ -71,12 +71,6 @@ kmem_zalloc(size_t size, xfs_km_flags_t flags)
 	return kmem_alloc(size, flags | KM_ZERO);
 }
 
-static inline void *
-kmem_zalloc_large(size_t size, xfs_km_flags_t flags)
-{
-	return kmem_alloc_large(size, flags | KM_ZERO);
-}
-
 /*
  * Zone interfaces
  */
fs/xfs/scrub/symlink.c +0 -0
index 5641ae512c9ef..5a721a9adea78 100644
@@ -22,11 +22,12 @@ xchk_setup_symlink(
 	struct xfs_inode	*ip)

fs/xfs/scrub/symlink.c xchk_setup_symlink( · line 31

Quoted 10 lines
fs/xfs/scrub/symlink.c +2 -1
 {
 	/* Allocate the buffer without the inode lock held. */
-	sc->buf = kmem_zalloc_large(XFS_SYMLINK_MAXLEN + 1, 0);
+	sc->buf = kvzalloc(XFS_SYMLINK_MAXLEN + 1, GFP_KERNEL);
 	if (!sc->buf)
 		return -ENOMEM;
 
 	return xchk_setup_inode_contents(sc, ip, 0);
+
 }

With the extra added line removed,

Signature · 2 lines
Dave Chinner
[email protected]