All of lore.kernel.org
 help / color / mirror / Atom feed
From: Srinivas Aji <srinivas.aji@memverge.com>
To: linux-nvdimm <linux-nvdimm@lists.01.org>, Linux MM <linux-mm@kvack.org>
Cc: Dan Williams <dan.j.williams@intel.com>,
	David Hildenbrand <david@redhat.com>,
	Vivek Goyal <vgoyal@redhat.com>,
	David Woodhouse <dwmw@amazon.com>,
	"Gowans, James" <jgowans@amazon.com>,
	Yue Li <yue.li@memverge.com>,
	Beau Beauchamp <beau.beauchamp@memverge.com>
Subject: [RFC PATCH 3/4] device-dax: Add a NONE type for DAX KMEM persistence
Date: Tue, 2 Aug 2022 23:40:04 +0530	[thread overview]
Message-ID: <YulofMrVeA4Ap//a@memverge.com> (raw)
In-Reply-To: <YullhqZFF9yL27EI@memverge.com>

The NONE type allows us to format DAX KMEM so that all the memory is
usable as system memory. This does not allow us to store any
persistent data.

Signed-off-by: Srinivas Aji <srinivas.aji@memverge.com>
---
 drivers/dax/kmem.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/drivers/dax/kmem.c b/drivers/dax/kmem.c
index df7cfc8ace78..0ca6e14f7e73 100644
--- a/drivers/dax/kmem.c
+++ b/drivers/dax/kmem.c
@@ -474,6 +474,46 @@ int kmem_persist_cleanup(struct dev_dax *dev_dax,
 	return 0;
 }
 
+/*
+ * A NONE type for DAX KMEM persistence which does not expose any persistent
+ * device or filesystem on the memory.
+ */
+
+static int kmem_persist_none_format(struct dev_dax *dev_dax)
+{
+	struct kmem_persist_superblock *super =
+		kmap_local_page(dax_kmem_index_to_page(0, dev_dax));
+	super->magic = kmem_persist_magic;
+	super->type = KMEM_PERSIST_NONE;
+	kunmap_local(super);
+	return 0;
+}
+
+static int kmem_persist_none_probe(struct dev_dax *dev_dax, void **data)
+{
+	unsigned long num_pages = dax_kmem_num_pages(dev_dax);
+	unsigned long i;
+
+	for (i = 1; i < num_pages; i++)
+		__free_page(dax_kmem_index_to_page(i, dev_dax));
+
+	*data = NULL;
+	return 0;
+}
+
+static int kmem_persist_none_cleanup(struct dev_dax *dev_dax, void *data)
+{
+	__free_page(dax_kmem_index_to_page(0, dev_dax));
+	return 0;
+}
+
+static struct kmem_persist_ops kmem_persist_none_ops = {
+	.type = KMEM_PERSIST_NONE,
+	.format = kmem_persist_none_format,
+	.probe = kmem_persist_none_probe,
+	.cleanup = kmem_persist_none_cleanup
+};
+
 #endif /* CONFIG_DEV_DAX_KMEM_PERSIST */
 
 static struct dax_device_driver device_dax_kmem_driver = {
@@ -493,6 +533,10 @@ static int __init dax_kmem_init(void)
 	rc = dax_driver_register(&device_dax_kmem_driver);
 	if (rc)
 		kfree_const(kmem_name);
+#ifdef CONFIG_DEV_DAX_KMEM_PERSIST
+	if (rc == 0)
+		kmem_persist_type_register(&kmem_persist_none_ops);
+#endif
 	return rc;
 }
 
-- 
2.30.2



  parent reply	other threads:[~2022-08-02 18:10 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-02 17:57 [RFC PATCH 0/4] Allow persistent data on DAX device being used as KMEM Srinivas Aji
2022-08-02 18:02 ` [RFC PATCH 1/4] mm/memory_hotplug: Add MHP_ALLOCATE flag which treats hotplugged memory as allocated Srinivas Aji
2022-08-02 18:03 ` [RFC PATCH 0/4] Allow persistent data on DAX device being used as KMEM David Hildenbrand
2022-08-02 18:53   ` Srinivas Aji
2022-08-02 18:07 ` [RFC PATCH 2/4] device-dax: Add framework for keeping persistent data in DAX KMEM Srinivas Aji
2022-08-02 18:10 ` Srinivas Aji [this message]
2022-08-02 18:12 ` [RFC PATCH 4/4] device-dax: Add a block device persistent type, BLK, for " Srinivas Aji
2022-08-03 20:00   ` kernel test robot
2022-08-03 21:19   ` Fabio M. De Francesco
2022-08-04 10:45   ` kernel test robot
2022-08-05 12:46 ` [RFC PATCH 0/4] Allow persistent data on DAX device being used as KMEM David Hildenbrand
2022-08-08 21:21   ` Srinivas Aji
2022-08-08 23:05     ` Dan Williams

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=YulofMrVeA4Ap//a@memverge.com \
    --to=srinivas.aji@memverge.com \
    --cc=beau.beauchamp@memverge.com \
    --cc=dan.j.williams@intel.com \
    --cc=david@redhat.com \
    --cc=dwmw@amazon.com \
    --cc=jgowans@amazon.com \
    --cc=linux-mm@kvack.org \
    --cc=linux-nvdimm@lists.01.org \
    --cc=vgoyal@redhat.com \
    --cc=yue.li@memverge.com \
    /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 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.