All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boaz Harrosh <boaz@plexistor.com>
To: Ingo Molnar <mingo@redhat.com>,
	x86@kernel.org, linux-kernel <linux-kernel@vger.kernel.org>,
	"Roger C. Pao" <rcpao.enmotus@gmail.com>,
	Dan Williams <dan.j.williams@intel.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-nvdimm <linux-nvdimm@lists.01.org>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Matthew Wilcox <willy@linux.intel.com>,
	Andy Lutomirski <luto@amacapital.net>,
	Christoph Hellwig <hch@infradead.org>
Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
Subject: [PATCH 7/8] pmem: Add support for page structs
Date: Thu, 05 Mar 2015 13:59:52 +0200	[thread overview]
Message-ID: <54F84538.8080500@plexistor.com> (raw)
In-Reply-To: <54F830D4.7030205@plexistor.com>


One of the current shortcomings of the NVDIMM/PMEM
support is that this memory does not have a page-struct(s)
associated with its memory and therefor cannot be passed
to a block-device or network or DMAed in any way through
another device in the system.

The use of add_persistent_memory() fixes all this. After this patch
an FS can do:
	bdev_direct_access(,&pfn,);
	page = pfn_to_page(pfn);
And use that page for a lock_page(), set_page_dirty(), and/or
anything else one might do with a page *.
(Note that with brd one can already do this)

[pmem-pages-ref-count]
pmem will serve it's pages with ref==0. Once an FS does
an blkdev_get_XXX(,FMODE_EXCL,), that memory is own by the FS.
The FS needs to manage its allocation, just as it already does
for its disk blocks. The fs should set page->count = 2, before
submission to any Kernel subsystem so when it returns it will
never be released to the Kernel's page-allocators. (page_freeze)

Signed-off-by: Boaz Harrosh <boaz@plexistor.com>
---
 drivers/block/Kconfig | 13 +++++++++++++
 drivers/block/pmem.c  | 20 ++++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 1530c2a..635fa6a 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -422,6 +422,19 @@ config BLK_DEV_PMEM
 	  Most normal users won't need this functionality, and can thus say N
 	  here.
 
+config BLK_DEV_PMEM_USE_PAGES
+	bool "Enable use of page struct pages with pmem"
+	depends on BLK_DEV_PMEM
+	depends on PERSISTENT_MEMORY_DEPENDENCY
+	select DRIVER_NEEDS_PERSISTENT_MEMORY
+	default y
+	help
+	  If a user of PMEM device needs "struct page" associated
+	  with its memory, so this memory can be sent to other
+	  block devices, or sent on the network, or be DMA transferred
+	  to other devices in the system, then you must say "Yes" here.
+	  If unsure leave as Yes.
+
 config CDROM_PKTCDVD
 	tristate "Packet writing on CD/DVD media"
 	depends on !UML
diff --git a/drivers/block/pmem.c b/drivers/block/pmem.c
index f0f0ba0..d0c80f4 100644
--- a/drivers/block/pmem.c
+++ b/drivers/block/pmem.c
@@ -20,6 +20,7 @@
 #include <linux/blkdev.h>
 #include <linux/hdreg.h>
 #include <linux/init.h>
+#include <linux/memory_hotplug.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/slab.h>
@@ -141,6 +142,24 @@ MODULE_PARM_DESC(map,
 
 static LIST_HEAD(pmem_devices);
 
+#ifdef CONFIG_BLK_DEV_PMEM_USE_PAGES
+/* pmem->phys_addr and pmem->size need to be set.
+ * Will then set pmem->virt_addr if successful.
+ */
+int pmem_mapmem(struct pmem_device *pmem)
+{
+	return add_persistent_memory(pmem->phys_addr, pmem->size,
+				     &pmem->virt_addr);
+}
+
+static void pmem_unmapmem(struct pmem_device *pmem)
+{
+	remove_persistent_memory(pmem->phys_addr, pmem->size);
+}
+
+#define PMEM_ALIGNMEM (1UL << SECTION_SIZE_BITS)
+#else /* !CONFIG_BLK_DEV_PMEM_USE_PAGES */
+
 /* pmem->phys_addr and pmem->size need to be set.
  * Will then set virt_addr if successful.
  */
@@ -180,6 +199,7 @@ void pmem_unmapmem(struct pmem_device *pmem)
 }
 
 #define PMEM_ALIGNMEM PAGE_SIZE
+#endif /* ! CONFIG_BLK_DEV_PMEM_USE_PAGES */
 
 static struct pmem_device *pmem_alloc(phys_addr_t phys_addr, size_t disk_size,
 				      int i)
-- 
1.9.3


WARNING: multiple messages have this Message-ID (diff)
From: Boaz Harrosh <boaz@plexistor.com>
To: Ingo Molnar <mingo@redhat.com>,
	x86@kernel.org, linux-kernel <linux-kernel@vger.kernel.org>,
	"Roger C. Pao" <rcpao.enmotus@gmail.com>,
	Dan Williams <dan.j.williams@intel.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-nvdimm <linux-nvdimm@ml01.01.org>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Matthew Wilcox <willy@linux.intel.com>,
	Andy Lutomirski <luto@amacapital.net>,
	Christoph Hellwig <hch@infradead.org>
Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
Subject: [PATCH 7/8] pmem: Add support for page structs
Date: Thu, 05 Mar 2015 13:59:52 +0200	[thread overview]
Message-ID: <54F84538.8080500@plexistor.com> (raw)
In-Reply-To: <54F830D4.7030205@plexistor.com>


One of the current shortcomings of the NVDIMM/PMEM
support is that this memory does not have a page-struct(s)
associated with its memory and therefor cannot be passed
to a block-device or network or DMAed in any way through
another device in the system.

The use of add_persistent_memory() fixes all this. After this patch
an FS can do:
	bdev_direct_access(,&pfn,);
	page = pfn_to_page(pfn);
And use that page for a lock_page(), set_page_dirty(), and/or
anything else one might do with a page *.
(Note that with brd one can already do this)

[pmem-pages-ref-count]
pmem will serve it's pages with ref==0. Once an FS does
an blkdev_get_XXX(,FMODE_EXCL,), that memory is own by the FS.
The FS needs to manage its allocation, just as it already does
for its disk blocks. The fs should set page->count = 2, before
submission to any Kernel subsystem so when it returns it will
never be released to the Kernel's page-allocators. (page_freeze)

Signed-off-by: Boaz Harrosh <boaz@plexistor.com>
---
 drivers/block/Kconfig | 13 +++++++++++++
 drivers/block/pmem.c  | 20 ++++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 1530c2a..635fa6a 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -422,6 +422,19 @@ config BLK_DEV_PMEM
 	  Most normal users won't need this functionality, and can thus say N
 	  here.
 
+config BLK_DEV_PMEM_USE_PAGES
+	bool "Enable use of page struct pages with pmem"
+	depends on BLK_DEV_PMEM
+	depends on PERSISTENT_MEMORY_DEPENDENCY
+	select DRIVER_NEEDS_PERSISTENT_MEMORY
+	default y
+	help
+	  If a user of PMEM device needs "struct page" associated
+	  with its memory, so this memory can be sent to other
+	  block devices, or sent on the network, or be DMA transferred
+	  to other devices in the system, then you must say "Yes" here.
+	  If unsure leave as Yes.
+
 config CDROM_PKTCDVD
 	tristate "Packet writing on CD/DVD media"
 	depends on !UML
diff --git a/drivers/block/pmem.c b/drivers/block/pmem.c
index f0f0ba0..d0c80f4 100644
--- a/drivers/block/pmem.c
+++ b/drivers/block/pmem.c
@@ -20,6 +20,7 @@
 #include <linux/blkdev.h>
 #include <linux/hdreg.h>
 #include <linux/init.h>
+#include <linux/memory_hotplug.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/slab.h>
@@ -141,6 +142,24 @@ MODULE_PARM_DESC(map,
 
 static LIST_HEAD(pmem_devices);
 
+#ifdef CONFIG_BLK_DEV_PMEM_USE_PAGES
+/* pmem->phys_addr and pmem->size need to be set.
+ * Will then set pmem->virt_addr if successful.
+ */
+int pmem_mapmem(struct pmem_device *pmem)
+{
+	return add_persistent_memory(pmem->phys_addr, pmem->size,
+				     &pmem->virt_addr);
+}
+
+static void pmem_unmapmem(struct pmem_device *pmem)
+{
+	remove_persistent_memory(pmem->phys_addr, pmem->size);
+}
+
+#define PMEM_ALIGNMEM (1UL << SECTION_SIZE_BITS)
+#else /* !CONFIG_BLK_DEV_PMEM_USE_PAGES */
+
 /* pmem->phys_addr and pmem->size need to be set.
  * Will then set virt_addr if successful.
  */
@@ -180,6 +199,7 @@ void pmem_unmapmem(struct pmem_device *pmem)
 }
 
 #define PMEM_ALIGNMEM PAGE_SIZE
+#endif /* ! CONFIG_BLK_DEV_PMEM_USE_PAGES */
 
 static struct pmem_device *pmem_alloc(phys_addr_t phys_addr, size_t disk_size,
 				      int i)
-- 
1.9.3


  parent reply	other threads:[~2015-03-05 11:59 UTC|newest]

Thread overview: 83+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-05 10:16 [PATCH 0/3 v5] e820: Fix handling of NvDIMM chips Boaz Harrosh
2015-03-05 10:16 ` Boaz Harrosh
2015-03-05 10:20 ` [PATCH 1/3] e820: Don't let unknown DIMM type come out BUSY Boaz Harrosh
2015-03-05 10:20   ` Boaz Harrosh
2015-03-05 20:41   ` Dan Williams
2015-03-05 20:41     ` Dan Williams
2015-03-09 10:54     ` Boaz Harrosh
2015-03-09 10:54       ` Boaz Harrosh
2015-03-05 10:21 ` [PATCH 2/3] resource: Add new flag IORESOURCE_MEM_WARN Boaz Harrosh
2015-03-05 10:21   ` Boaz Harrosh
2015-03-05 10:24 ` [PATCH 3/3] e820: Add the unknown-12 Memory type (DDR3-NvDIMM) Boaz Harrosh
2015-03-05 10:24   ` Boaz Harrosh
2015-03-05 20:56   ` Dan Williams
2015-03-05 20:56     ` Dan Williams
2015-03-05 23:09     ` Andy Lutomirski
2015-03-05 23:09       ` Andy Lutomirski
2015-03-09 12:10       ` Boaz Harrosh
2015-03-09 12:10         ` Boaz Harrosh
2015-03-10  5:11         ` joeyli
2015-03-10  5:11           ` joeyli
2015-03-10  8:56           ` Boaz Harrosh
2015-03-10  8:56             ` Boaz Harrosh
2015-03-10 13:19           ` Andy Lutomirski
2015-03-10 13:19             ` Andy Lutomirski
2015-03-09 11:19     ` Boaz Harrosh
2015-03-09 11:19       ` Boaz Harrosh
2015-03-09 14:44       ` Dan Williams
2015-03-09 14:44         ` Dan Williams
2015-03-09 15:14         ` Andy Lutomirski
2015-03-09 15:14           ` Andy Lutomirski
2015-03-09 15:17           ` Dan Williams
2015-03-09 15:17             ` Dan Williams
2015-03-10  8:47             ` Boaz Harrosh
2015-03-10  8:47               ` Boaz Harrosh
2015-03-05 10:32 ` [RFC 0/8] pmem: Submission of the Persistent memory block device Boaz Harrosh
2015-03-05 10:32   ` Boaz Harrosh
2015-03-05 11:55   ` [PATCH 1/8] pmem: Initial version of persistent memory driver Boaz Harrosh
2015-03-05 11:55     ` Boaz Harrosh
2015-03-05 20:35     ` Paul Bolle
2015-03-05 20:35       ` Paul Bolle
2015-03-05 23:03     ` Andy Lutomirski
2015-03-05 23:03       ` Andy Lutomirski
2015-03-09 12:20       ` Boaz Harrosh
2015-03-09 12:20         ` Boaz Harrosh
2015-03-18 18:06         ` Andy Lutomirski
2015-03-18 18:06           ` Andy Lutomirski
2015-03-26  4:00           ` Elliott, Robert (Server Storage)
2015-03-26  4:00             ` Elliott, Robert (Server Storage)
2015-03-26  7:51             ` Boaz Harrosh
2015-03-26  7:51               ` Boaz Harrosh
2015-03-26 21:31             ` Dave Chinner
2015-03-26 21:31               ` Dave Chinner
2015-03-18 17:43     ` Ross Zwisler
2015-03-18 17:43       ` Ross Zwisler
2015-03-19  9:24       ` Boaz Harrosh
2015-03-19  9:24         ` Boaz Harrosh
2015-03-20  0:11         ` Dan Williams
2015-03-20  0:11           ` Dan Williams
2015-03-05 11:55   ` [PATCH 2/8] pmem: KISS, remove register_blkdev Boaz Harrosh
2015-03-05 11:55     ` Boaz Harrosh
2015-03-05 11:56   ` [PATCH 3/8] pmem: Add support for rw_page() Boaz Harrosh
2015-03-05 11:56     ` Boaz Harrosh
2015-03-05 11:57   ` [PATCH 4/8] pmem: Add support for direct_access() Boaz Harrosh
2015-03-05 11:57     ` Boaz Harrosh
2015-03-05 11:58   ` [PATCH 5/8] mm: Let sparse_{add,remove}_one_section receive a node_id Boaz Harrosh
2015-03-05 11:58     ` Boaz Harrosh
2015-03-06 18:43     ` Ross Zwisler
2015-03-06 18:43       ` Ross Zwisler
2015-03-05 11:59   ` [PATCH 6/8] mm: New add_persistent_memory/remove_persistent_memory Boaz Harrosh
2015-03-05 11:59     ` Boaz Harrosh
2015-03-05 11:59   ` Boaz Harrosh [this message]
2015-03-05 11:59     ` [PATCH 7/8] pmem: Add support for page structs Boaz Harrosh
2015-03-23 20:59     ` Dan Williams
2015-03-23 20:59       ` Dan Williams
2015-03-05 12:01   ` [PATCH 8/8] OUT-OF-TREE: pmem: Allow request_mem to fail (BLK_DEV_PMEM_IGNORE_REQUEST_MEM_RET) Boaz Harrosh
2015-03-05 12:01     ` Boaz Harrosh
2015-03-06 18:37   ` [RFC 0/8] pmem: Submission of the Persistent memory block device Ross Zwisler
2015-03-06 18:37     ` Ross Zwisler
2015-03-07  1:39     ` Christoph Hellwig
2015-03-09 12:41     ` Boaz Harrosh
2015-03-09 12:41       ` Boaz Harrosh
2015-03-05 22:48 ` [PATCH 0/3 v5] e820: Fix handling of NvDIMM chips H. Peter Anvin
2015-03-05 23:06   ` Andy Lutomirski

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=54F84538.8080500@plexistor.com \
    --to=boaz@plexistor.com \
    --cc=dan.j.williams@intel.com \
    --cc=hch@infradead.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvdimm@lists.01.org \
    --cc=luto@amacapital.net \
    --cc=mingo@redhat.com \
    --cc=rcpao.enmotus@gmail.com \
    --cc=ross.zwisler@linux.intel.com \
    --cc=tglx@linutronix.de \
    --cc=willy@linux.intel.com \
    --cc=x86@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 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.