* [PATCH v2] ceph: move to a dedicated slabcache for mds requests
@ 2020-02-18 15:35 Jeff Layton
2020-02-18 18:27 ` Ilya Dryomov
0 siblings, 1 reply; 2+ messages in thread
From: Jeff Layton @ 2020-02-18 15:35 UTC (permalink / raw)
To: ceph-devel; +Cc: idryomov, sage, zyan
On my machine (x86_64) this struct is 952 bytes, which gets rounded up
to 1024 by kmalloc. Move this to a dedicated slabcache, so we can
allocate them without the extra 72 bytes of overhead per.
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
fs/ceph/mds_client.c | 5 +++--
fs/ceph/super.c | 8 ++++++++
include/linux/ceph/libceph.h | 1 +
3 files changed, 12 insertions(+), 2 deletions(-)
v2: switch to kmem_cache_zalloc()
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index 2980e57ca7b9..fab9d6461a65 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -736,7 +736,7 @@ void ceph_mdsc_release_request(struct kref *kref)
put_request_session(req);
ceph_unreserve_caps(req->r_mdsc, &req->r_caps_reservation);
WARN_ON_ONCE(!list_empty(&req->r_wait));
- kfree(req);
+ kmem_cache_free(ceph_mds_request_cachep, req);
}
DEFINE_RB_FUNCS(request, struct ceph_mds_request, r_tid, r_node)
@@ -2094,8 +2094,9 @@ int ceph_alloc_readdir_reply_buffer(struct ceph_mds_request *req,
struct ceph_mds_request *
ceph_mdsc_create_request(struct ceph_mds_client *mdsc, int op, int mode)
{
- struct ceph_mds_request *req = kzalloc(sizeof(*req), GFP_NOFS);
+ struct ceph_mds_request *req;
+ req = kmem_cache_zalloc(ceph_mds_request_cachep, GFP_NOFS);
if (!req)
return ERR_PTR(-ENOMEM);
diff --git a/fs/ceph/super.c b/fs/ceph/super.c
index c7f150686a53..b1329cd5388a 100644
--- a/fs/ceph/super.c
+++ b/fs/ceph/super.c
@@ -729,6 +729,7 @@ struct kmem_cache *ceph_cap_flush_cachep;
struct kmem_cache *ceph_dentry_cachep;
struct kmem_cache *ceph_file_cachep;
struct kmem_cache *ceph_dir_file_cachep;
+struct kmem_cache *ceph_mds_request_cachep;
static void ceph_inode_init_once(void *foo)
{
@@ -769,6 +770,10 @@ static int __init init_caches(void)
if (!ceph_dir_file_cachep)
goto bad_dir_file;
+ ceph_mds_request_cachep = KMEM_CACHE(ceph_mds_request, SLAB_MEM_SPREAD);
+ if (!ceph_mds_request_cachep)
+ goto bad_mds_req;
+
error = ceph_fscache_register();
if (error)
goto bad_fscache;
@@ -776,6 +781,8 @@ static int __init init_caches(void)
return 0;
bad_fscache:
+ kmem_cache_destroy(ceph_mds_request_cachep);
+bad_mds_req:
kmem_cache_destroy(ceph_dir_file_cachep);
bad_dir_file:
kmem_cache_destroy(ceph_file_cachep);
@@ -804,6 +811,7 @@ static void destroy_caches(void)
kmem_cache_destroy(ceph_dentry_cachep);
kmem_cache_destroy(ceph_file_cachep);
kmem_cache_destroy(ceph_dir_file_cachep);
+ kmem_cache_destroy(ceph_mds_request_cachep);
ceph_fscache_unregister();
}
diff --git a/include/linux/ceph/libceph.h b/include/linux/ceph/libceph.h
index ec73ebc4827d..525b7c3f1c81 100644
--- a/include/linux/ceph/libceph.h
+++ b/include/linux/ceph/libceph.h
@@ -272,6 +272,7 @@ extern struct kmem_cache *ceph_cap_flush_cachep;
extern struct kmem_cache *ceph_dentry_cachep;
extern struct kmem_cache *ceph_file_cachep;
extern struct kmem_cache *ceph_dir_file_cachep;
+extern struct kmem_cache *ceph_mds_request_cachep;
/* ceph_common.c */
extern bool libceph_compatible(void *data);
--
2.24.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] ceph: move to a dedicated slabcache for mds requests
2020-02-18 15:35 [PATCH v2] ceph: move to a dedicated slabcache for mds requests Jeff Layton
@ 2020-02-18 18:27 ` Ilya Dryomov
0 siblings, 0 replies; 2+ messages in thread
From: Ilya Dryomov @ 2020-02-18 18:27 UTC (permalink / raw)
To: Jeff Layton; +Cc: Ceph Development, Sage Weil, Yan, Zheng
On Tue, Feb 18, 2020 at 4:35 PM Jeff Layton <jlayton@kernel.org> wrote:
>
> On my machine (x86_64) this struct is 952 bytes, which gets rounded up
> to 1024 by kmalloc. Move this to a dedicated slabcache, so we can
> allocate them without the extra 72 bytes of overhead per.
>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
> fs/ceph/mds_client.c | 5 +++--
> fs/ceph/super.c | 8 ++++++++
> include/linux/ceph/libceph.h | 1 +
> 3 files changed, 12 insertions(+), 2 deletions(-)
>
> v2: switch to kmem_cache_zalloc()
>
> diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
> index 2980e57ca7b9..fab9d6461a65 100644
> --- a/fs/ceph/mds_client.c
> +++ b/fs/ceph/mds_client.c
> @@ -736,7 +736,7 @@ void ceph_mdsc_release_request(struct kref *kref)
> put_request_session(req);
> ceph_unreserve_caps(req->r_mdsc, &req->r_caps_reservation);
> WARN_ON_ONCE(!list_empty(&req->r_wait));
> - kfree(req);
> + kmem_cache_free(ceph_mds_request_cachep, req);
> }
>
> DEFINE_RB_FUNCS(request, struct ceph_mds_request, r_tid, r_node)
> @@ -2094,8 +2094,9 @@ int ceph_alloc_readdir_reply_buffer(struct ceph_mds_request *req,
> struct ceph_mds_request *
> ceph_mdsc_create_request(struct ceph_mds_client *mdsc, int op, int mode)
> {
> - struct ceph_mds_request *req = kzalloc(sizeof(*req), GFP_NOFS);
> + struct ceph_mds_request *req;
>
> + req = kmem_cache_zalloc(ceph_mds_request_cachep, GFP_NOFS);
> if (!req)
> return ERR_PTR(-ENOMEM);
>
> diff --git a/fs/ceph/super.c b/fs/ceph/super.c
> index c7f150686a53..b1329cd5388a 100644
> --- a/fs/ceph/super.c
> +++ b/fs/ceph/super.c
> @@ -729,6 +729,7 @@ struct kmem_cache *ceph_cap_flush_cachep;
> struct kmem_cache *ceph_dentry_cachep;
> struct kmem_cache *ceph_file_cachep;
> struct kmem_cache *ceph_dir_file_cachep;
> +struct kmem_cache *ceph_mds_request_cachep;
>
> static void ceph_inode_init_once(void *foo)
> {
> @@ -769,6 +770,10 @@ static int __init init_caches(void)
> if (!ceph_dir_file_cachep)
> goto bad_dir_file;
>
> + ceph_mds_request_cachep = KMEM_CACHE(ceph_mds_request, SLAB_MEM_SPREAD);
> + if (!ceph_mds_request_cachep)
> + goto bad_mds_req;
> +
> error = ceph_fscache_register();
> if (error)
> goto bad_fscache;
> @@ -776,6 +781,8 @@ static int __init init_caches(void)
> return 0;
>
> bad_fscache:
> + kmem_cache_destroy(ceph_mds_request_cachep);
> +bad_mds_req:
> kmem_cache_destroy(ceph_dir_file_cachep);
> bad_dir_file:
> kmem_cache_destroy(ceph_file_cachep);
> @@ -804,6 +811,7 @@ static void destroy_caches(void)
> kmem_cache_destroy(ceph_dentry_cachep);
> kmem_cache_destroy(ceph_file_cachep);
> kmem_cache_destroy(ceph_dir_file_cachep);
> + kmem_cache_destroy(ceph_mds_request_cachep);
>
> ceph_fscache_unregister();
> }
> diff --git a/include/linux/ceph/libceph.h b/include/linux/ceph/libceph.h
> index ec73ebc4827d..525b7c3f1c81 100644
> --- a/include/linux/ceph/libceph.h
> +++ b/include/linux/ceph/libceph.h
> @@ -272,6 +272,7 @@ extern struct kmem_cache *ceph_cap_flush_cachep;
> extern struct kmem_cache *ceph_dentry_cachep;
> extern struct kmem_cache *ceph_file_cachep;
> extern struct kmem_cache *ceph_dir_file_cachep;
> +extern struct kmem_cache *ceph_mds_request_cachep;
>
> /* ceph_common.c */
> extern bool libceph_compatible(void *data);
Looks good, thanks for addressing my nit.
Ilya
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-02-18 18:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-18 15:35 [PATCH v2] ceph: move to a dedicated slabcache for mds requests Jeff Layton
2020-02-18 18:27 ` Ilya Dryomov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.