From: alexjlzheng@gmail.com
To: chandan.babu@oracle.com, djwong@kernel.org
Cc: david@fromorbit.com, hch@infradead.org,
linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org,
alexjlzheng@tencent.com
Subject: [PATCH v3 1/2] xfs: add xfs_log_vec_cache for separate xfs_log_vec/xfs_log_iovec
Date: Wed, 26 Jun 2024 12:49:08 +0800 [thread overview]
Message-ID: <20240626044909.15060-2-alexjlzheng@tencent.com> (raw)
In-Reply-To: <20240626044909.15060-1-alexjlzheng@tencent.com>
From: Jinliang Zheng <alexjlzheng@tencent.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@tencent.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
next prev parent reply other threads:[~2024-06-26 4:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-26 4:49 [PATCH v3 0/2] Separate xfs_log_vec/iovec to save memory alexjlzheng
2024-06-26 4:49 ` alexjlzheng [this message]
2024-06-26 4:49 ` [PATCH v3 2/2] xfs: make xfs_log_iovec independent from xfs_log_vec and free it early alexjlzheng
2024-07-01 0:51 ` Dave Chinner
2024-07-01 4:49 ` Christoph Hellwig
2024-07-02 23:44 ` Dave Chinner
2024-07-03 5:14 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240626044909.15060-2-alexjlzheng@tencent.com \
--to=alexjlzheng@gmail.com \
--cc=alexjlzheng@tencent.com \
--cc=chandan.babu@oracle.com \
--cc=david@fromorbit.com \
--cc=djwong@kernel.org \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).