Linux CXL
 help / color / mirror / Atom feed
From: Mikulas Patocka <mpatocka@redhat.com>
To: Dongsheng Yang <dongsheng.yang@linux.dev>
Cc: agk@redhat.com, snitzer@kernel.org, axboe@kernel.dk, hch@lst.de,
	 dan.j.williams@intel.com, Jonathan.Cameron@Huawei.com,
	 linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	 linux-cxl@vger.kernel.org, nvdimm@lists.linux.dev,
	 dm-devel@lists.linux.dev
Subject: Re: [PATCH v2 00/11] dm-pcache – persistent-memory cache for block devices
Date: Mon, 7 Jul 2025 22:17:42 +0200 (CEST)	[thread overview]
Message-ID: <621900fd-1b17-cab3-5c4a-a12631440cd3@redhat.com> (raw)
In-Reply-To: <85b5cb31-b272-305f-8910-c31152485ecf@redhat.com>

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>

---
 drivers/md/dm-pcache/backing_dev.c |   14 +++-----------
 drivers/md/dm-pcache/backing_dev.h |    1 -
 drivers/md/dm-pcache/cache.h       |    1 -
 drivers/md/dm-pcache/cache_key.c   |   13 ++-----------
 drivers/md/dm-pcache/dm_pcache.c   |   28 +++++++++++++++++++++++++++-
 drivers/md/dm-pcache/dm_pcache.h   |    3 +++
 6 files changed, 35 insertions(+), 25 deletions(-)

Index: linux-2.6/drivers/md/dm-pcache/backing_dev.h
===================================================================
--- linux-2.6.orig/drivers/md/dm-pcache/backing_dev.h	2025-07-07 12:00:56.000000000 +0200
+++ linux-2.6/drivers/md/dm-pcache/backing_dev.h	2025-07-07 12:14:27.000000000 +0200
@@ -43,7 +43,6 @@ struct pcache_backing_dev {
 	struct pcache_cache		*cache;
 
 	struct dm_dev			*dm_dev;
-	struct kmem_cache		*backing_req_cache;
 	mempool_t			req_pool;
 
 	struct list_head		submit_list;
Index: linux-2.6/drivers/md/dm-pcache/cache.h
===================================================================
--- linux-2.6.orig/drivers/md/dm-pcache/cache.h	2025-07-07 12:00:56.000000000 +0200
+++ linux-2.6/drivers/md/dm-pcache/cache.h	2025-07-07 12:14:48.000000000 +0200
@@ -102,7 +102,6 @@ struct pcache_cache_subtree {
 struct pcache_cache_tree {
 	struct pcache_cache		*cache;
 	u32				n_subtrees;
-	struct kmem_cache		*key_cache;
 	mempool_t			key_pool;
 	struct pcache_cache_subtree	*subtrees;
 };
Index: linux-2.6/drivers/md/dm-pcache/dm_pcache.c
===================================================================
--- linux-2.6.orig/drivers/md/dm-pcache/dm_pcache.c	2025-07-07 12:00:56.000000000 +0200
+++ linux-2.6/drivers/md/dm-pcache/dm_pcache.c	2025-07-07 12:23:13.000000000 +0200
@@ -9,6 +9,9 @@
 #include "cache.h"
 #include "dm_pcache.h"
 
+struct kmem_cache *backing_req_cache;
+struct kmem_cache *key_cache;
+
 void pcache_defer_reqs_kick(struct dm_pcache *pcache)
 {
 	struct pcache_cache *cache = &pcache->cache;
@@ -451,13 +454,36 @@ static struct target_type dm_pcache_targ
 
 static int __init dm_pcache_init(void)
 {
-	return dm_register_target(&dm_pcache_target);
+	int r;
+	backing_req_cache = KMEM_CACHE(pcache_backing_dev_req, 0);
+	if (!backing_req_cache) {
+		r = -ENOMEM;
+		goto err0;
+	}
+	key_cache = KMEM_CACHE(pcache_cache_key, 0);
+	if (!key_cache) {
+		r = -ENOMEM;
+		goto err1;
+	}
+	r = dm_register_target(&dm_pcache_target);
+	if (r)
+		goto err2;
+	return 0;
+
+err2:
+	kmem_cache_destroy(key_cache);
+err1:
+	kmem_cache_destroy(backing_req_cache);
+err0:
+	return r;
 }
 module_init(dm_pcache_init);
 
 static void __exit dm_pcache_exit(void)
 {
 	dm_unregister_target(&dm_pcache_target);
+	kmem_cache_destroy(key_cache);
+	kmem_cache_destroy(backing_req_cache);
 }
 module_exit(dm_pcache_exit);
 
Index: linux-2.6/drivers/md/dm-pcache/backing_dev.c
===================================================================
--- linux-2.6.orig/drivers/md/dm-pcache/backing_dev.c	2025-07-07 12:00:56.000000000 +0200
+++ linux-2.6/drivers/md/dm-pcache/backing_dev.c	2025-07-07 12:21:27.000000000 +0200
@@ -11,7 +11,6 @@
 static void backing_dev_exit(struct pcache_backing_dev *backing_dev)
 {
 	mempool_exit(&backing_dev->req_pool);
-	kmem_cache_destroy(backing_dev->backing_req_cache);
 }
 
 static void req_submit_fn(struct work_struct *work);
@@ -21,15 +20,9 @@ static int backing_dev_init(struct dm_pc
 	struct pcache_backing_dev *backing_dev = &pcache->backing_dev;
 	int ret;
 
-	backing_dev->backing_req_cache = KMEM_CACHE(pcache_backing_dev_req, 0);
-	if (!backing_dev->backing_req_cache) {
-		ret = -ENOMEM;
-		goto err;
-	}
-
-	ret = mempool_init_slab_pool(&backing_dev->req_pool, 128, backing_dev->backing_req_cache);
+	ret = mempool_init_slab_pool(&backing_dev->req_pool, 128, backing_req_cache);
 	if (ret)
-		goto cache_destroy;
+		goto err;
 
 	INIT_LIST_HEAD(&backing_dev->submit_list);
 	INIT_LIST_HEAD(&backing_dev->complete_list);
@@ -39,8 +32,7 @@ static int backing_dev_init(struct dm_pc
 	INIT_WORK(&backing_dev->req_complete_work, req_complete_fn);
 
 	return 0;
-cache_destroy:
-	kmem_cache_destroy(backing_dev->backing_req_cache);
+
 err:
 	return ret;
 }
Index: linux-2.6/drivers/md/dm-pcache/cache_key.c
===================================================================
--- linux-2.6.orig/drivers/md/dm-pcache/cache_key.c	2025-07-07 12:00:56.000000000 +0200
+++ linux-2.6/drivers/md/dm-pcache/cache_key.c	2025-07-07 12:22:17.000000000 +0200
@@ -836,15 +836,9 @@ int cache_tree_init(struct pcache_cache
 	cache_tree->cache = cache;
 	cache_tree->n_subtrees = n_subtrees;
 
-	cache_tree->key_cache = KMEM_CACHE(pcache_cache_key, 0);
-	if (!cache_tree->key_cache) {
-		ret = -ENOMEM;
-		goto err;
-	}
-
-	ret = mempool_init_slab_pool(&cache_tree->key_pool, 1024, cache_tree->key_cache);
+	ret = mempool_init_slab_pool(&cache_tree->key_pool, 1024, key_cache);
 	if (ret)
-		goto destroy_key_cache;
+		goto err;
 
 	/*
 	 * Allocate and initialize the subtrees array.
@@ -868,8 +862,6 @@ int cache_tree_init(struct pcache_cache
 
 key_pool_exit:
 	mempool_exit(&cache_tree->key_pool);
-destroy_key_cache:
-	kmem_cache_destroy(cache_tree->key_cache);
 err:
 	return ret;
 }
@@ -896,5 +888,4 @@ void cache_tree_exit(struct pcache_cache
 	}
 	kvfree(cache_tree->subtrees);
 	mempool_exit(&cache_tree->key_pool);
-	kmem_cache_destroy(cache_tree->key_cache);
 }
Index: linux-2.6/drivers/md/dm-pcache/dm_pcache.h
===================================================================
--- linux-2.6.orig/drivers/md/dm-pcache/dm_pcache.h	2025-07-07 12:00:56.000000000 +0200
+++ linux-2.6/drivers/md/dm-pcache/dm_pcache.h	2025-07-07 12:19:42.000000000 +0200
@@ -32,6 +32,9 @@ struct dm_pcache {
 	atomic_t			state;
 };
 
+extern struct kmem_cache *backing_req_cache;
+extern struct kmem_cache *key_cache;
+
 static inline bool pcache_is_stopping(struct dm_pcache *pcache)
 {
 	return (atomic_read(&pcache->state) == PCACHE_STATE_STOPPING);


  parent reply	other threads:[~2025-07-07 20:17 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-07  6:57 [PATCH v2 00/11] dm-pcache – persistent-memory cache for block devices Dongsheng Yang
2025-07-07  6:57 ` [PATCH v2 01/11] dm-pcache: add pcache_internal.h Dongsheng Yang
2025-07-07  6:58 ` [PATCH v2 02/11] dm-pcache: add backing device management Dongsheng Yang
2025-07-07  6:58 ` [PATCH v2 03/11] dm-pcache: add cache device Dongsheng Yang
2025-07-07  6:58 ` [PATCH v2 04/11] dm-pcache: add segment layer Dongsheng Yang
2025-07-07  6:58 ` [PATCH v2 05/11] dm-pcache: add cache_segment Dongsheng Yang
2025-07-07  6:58 ` [PATCH v2 06/11] dm-pcache: add cache_writeback Dongsheng Yang
2025-07-07  6:58 ` [PATCH v2 07/11] dm-pcache: add cache_gc Dongsheng Yang
2025-07-07  6:58 ` [PATCH v2 08/11] dm-pcache: add cache_key Dongsheng Yang
2025-07-07  6:58 ` [PATCH v2 09/11] dm-pcache: add cache_req Dongsheng Yang
2025-07-07  6:58 ` [PATCH v2 10/11] dm-pcache: add cache core Dongsheng Yang
2025-07-07  6:58 ` [PATCH v2 11/11] dm-pcache: initial dm-pcache target Dongsheng Yang
2025-07-07 20:16 ` [PATCH v2 00/11] dm-pcache – persistent-memory cache for block devices Mikulas Patocka
2025-07-07 20:17   ` Mikulas Patocka
2025-07-07 20:17   ` Mikulas Patocka [this message]
2025-07-09  9:45   ` Dongsheng Yang
2025-07-10 10:59     ` Dongsheng Yang
2025-07-14 15:43     ` Mikulas Patocka

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=621900fd-1b17-cab3-5c4a-a12631440cd3@redhat.com \
    --to=mpatocka@redhat.com \
    --cc=Jonathan.Cameron@Huawei.com \
    --cc=agk@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=dan.j.williams@intel.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=dongsheng.yang@linux.dev \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nvdimm@lists.linux.dev \
    --cc=snitzer@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