lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240626044909.15060-2-alexjlzheng@tencent.com>
Date: Wed, 26 Jun 2024 12:49:08 +0800
From: alexjlzheng@...il.com
To: chandan.babu@...cle.com,
	djwong@...nel.org
Cc: david@...morbit.com,
	hch@...radead.org,
	linux-kernel@...r.kernel.org,
	linux-xfs@...r.kernel.org,
	alexjlzheng@...cent.com
Subject: [PATCH v3 1/2] xfs: add xfs_log_vec_cache for separate xfs_log_vec/xfs_log_iovec

From: Jinliang Zheng <alexjlzheng@...cent.com>

This patch prepares for the next patch that separates xfs_log_iovec
from the xfs_log_vec/xfs_log_iovec combination.

Because xfs_log_vec itself is a very small object, there is no need
to fallback to vmalloc(). Use kmalloc() to allocate memory for
xfs_log_vec and use kmem_cache to speed it up.

Signed-off-by: Jinliang Zheng <alexjlzheng@...cent.com>
---
 fs/xfs/xfs_log.c   | 1 +
 fs/xfs/xfs_log.h   | 2 ++
 fs/xfs/xfs_super.c | 9 +++++++++
 3 files changed, 12 insertions(+)

diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 416c15494983..49e676061f2f 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -21,6 +21,7 @@
 #include "xfs_sb.h"
 #include "xfs_health.h"
 
+struct kmem_cache	*xfs_log_vec_cache;
 struct kmem_cache	*xfs_log_ticket_cache;
 
 /* Local miscellaneous function prototypes */
diff --git a/fs/xfs/xfs_log.h b/fs/xfs/xfs_log.h
index d69acf881153..9cc10acf7bcd 100644
--- a/fs/xfs/xfs_log.h
+++ b/fs/xfs/xfs_log.h
@@ -20,6 +20,8 @@ struct xfs_log_vec {
 	int			lv_size;	/* size of allocated lv */
 };
 
+extern struct kmem_cache *xfs_log_vec_cache;
+
 #define XFS_LOG_VEC_ORDERED	(-1)
 
 /*
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 27e9f749c4c7..7e94f9439a8f 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -2222,8 +2222,16 @@ xfs_init_caches(void)
 	if (!xfs_parent_args_cache)
 		goto out_destroy_xmi_cache;
 
+	xfs_log_vec_cache = kmem_cache_create("xfs_log_vec",
+						sizeof(struct xfs_log_vec),
+						0, 0, NULL);
+	if (!xfs_log_vec_cache)
+		goto out_destroy_args_cache;
+
 	return 0;
 
+ out_destroy_args_cache:
+	kmem_cache_destroy(xfs_parent_args_cache);
  out_destroy_xmi_cache:
 	kmem_cache_destroy(xfs_xmi_cache);
  out_destroy_xmd_cache:
@@ -2286,6 +2294,7 @@ xfs_destroy_caches(void)
 	 * destroy caches.
 	 */
 	rcu_barrier();
+	kmem_cache_destroy(xfs_log_vec_cache);
 	kmem_cache_destroy(xfs_parent_args_cache);
 	kmem_cache_destroy(xfs_xmd_cache);
 	kmem_cache_destroy(xfs_xmi_cache);
-- 
2.41.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ