From: Boaz Harrosh <boaz@plexistor.com>
To: Ross Zwisler <ross.zwisler@linux.intel.com>,
Jens Axboe <axboe@fb.com>,
Matthew Wilcox <matthew.r.wilcox@intel.com>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
linux-nvdimm@ml01.01.org, Toshi Kani <toshi.kani@hp.com>,
Dave Hansen <dave.hansen@intel.com>,
linux-mm@kvack.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: [PATCH 7/9] pmem: Add support for page structs
Date: Tue, 09 Sep 2014 18:48:34 +0300 [thread overview]
Message-ID: <540F2152.4070406@plexistor.com> (raw)
In-Reply-To: <540F1EC6.4000504@plexistor.com>
From: Boaz Harrosh <boaz@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 | 19 +++++++++++++++++++
2 files changed, 32 insertions(+)
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 5da8cbf..8a5929c 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -416,6 +416,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 e07a373..b415b61 100644
--- a/drivers/block/pmem.c
+++ b/drivers/block/pmem.c
@@ -221,6 +221,23 @@ MODULE_PARM_DESC(map,
static LIST_HEAD(pmem_devices);
static int pmem_major;
+#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);
+}
+
+#else /* !CONFIG_BLK_DEV_PMEM_USE_PAGES */
+
/* pmem->phys_addr and pmem->size need to be set.
* Will then set virt_addr if successful.
*/
@@ -258,6 +275,8 @@ void pmem_unmapmem(struct pmem_device *pmem)
release_mem_region(pmem->phys_addr, pmem->size);
pmem->virt_addr = NULL;
}
+#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
next prev parent reply other threads:[~2014-09-09 15:48 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-27 21:11 [PATCH 0/4] Add persistent memory driver Ross Zwisler
2014-08-27 21:11 ` [PATCH 1/4] pmem: Initial version of " Ross Zwisler
2014-09-09 16:23 ` [PATCH v2] " Boaz Harrosh
2014-09-09 16:53 ` [Linux-nvdimm] " Dan Williams
2014-09-10 13:23 ` Boaz Harrosh
2014-09-10 17:03 ` Dan Williams
2014-09-10 17:47 ` Boaz Harrosh
2014-09-10 23:01 ` Dan Williams
2014-09-11 10:45 ` Boaz Harrosh
2014-09-11 16:31 ` Dan Williams
2014-09-14 11:18 ` Boaz Harrosh
2014-09-16 13:54 ` Jeff Moyer
2014-09-16 16:24 ` Boaz Harrosh
2014-09-19 16:27 ` Dan Williams
2014-09-21 9:27 ` Boaz Harrosh
2014-11-02 3:22 ` [PATCH 1/4] " Elliott, Robert (Server Storage)
2014-11-03 15:50 ` Jeff Moyer
2014-11-03 16:19 ` Wilcox, Matthew R
2014-11-04 10:37 ` Boaz Harrosh
2014-11-04 16:26 ` Elliott, Robert (Server Storage)
2014-11-04 16:41 ` Ross Zwisler
2014-11-04 17:06 ` Boaz Harrosh
2014-08-27 21:12 ` [PATCH 2/4] pmem: Add support for getgeo() Ross Zwisler
2014-11-02 3:27 ` Elliott, Robert (Server Storage)
2014-11-03 16:36 ` Wilcox, Matthew R
2014-08-27 21:12 ` [PATCH 3/4] pmem: Add support for rw_page() Ross Zwisler
2014-08-27 21:12 ` [PATCH 4/4] pmem: Add support for direct_access() Ross Zwisler
2014-09-09 15:37 ` [PATCH 0/9] pmem: Fixes and farther development (mm: add_persistent_memory) Boaz Harrosh
2014-09-09 15:44 ` [PATCH 4/9] SQUASHME: pmem: Support of multiple memory regions Boaz Harrosh
2014-09-09 15:45 ` [PATCH 5/9] mm: Let sparse_{add,remove}_one_section receive a node_id Boaz Harrosh
2014-09-09 18:36 ` Dave Hansen
2014-09-10 10:07 ` Boaz Harrosh
2014-09-10 16:10 ` Dave Hansen
2014-09-10 17:25 ` Boaz Harrosh
2014-09-10 18:28 ` Dave Hansen
2014-09-11 8:39 ` Boaz Harrosh
2014-09-11 17:07 ` Dave Hansen
2014-09-14 9:36 ` Boaz Harrosh
2014-09-09 15:47 ` [PATCH 6/9] mm: New add_persistent_memory/remove_persistent_memory Boaz Harrosh
2014-09-09 15:48 ` Boaz Harrosh [this message]
2014-09-09 15:51 ` [PATCH 9/9] pmem: KISS, remove register_blkdev Boaz Harrosh
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=540F2152.4070406@plexistor.com \
--to=boaz@plexistor.com \
--cc=akpm@linux-foundation.org \
--cc=axboe@fb.com \
--cc=dave.hansen@intel.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-nvdimm@ml01.01.org \
--cc=matthew.r.wilcox@intel.com \
--cc=ross.zwisler@linux.intel.com \
--cc=toshi.kani@hp.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome