From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751836AbbHMDGm (ORCPT ); Wed, 12 Aug 2015 23:06:42 -0400 Received: from mga11.intel.com ([192.55.52.93]:48314 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751255AbbHMDGl (ORCPT ); Wed, 12 Aug 2015 23:06:41 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,666,1432623600"; d="scan'208";a="767732592" Subject: [PATCH v5 0/5] introduce __pfn_t for unmapped pfn I/O and DAX lifetime From: Dan Williams To: linux-kernel@vger.kernel.org Cc: axboe@kernel.dk, riel@redhat.com, linux-nvdimm@ml01.01.org, linux-mm@kvack.org, mgorman@suse.de, torvalds@linux-foundation.org, hch@lst.de Date: Wed, 12 Aug 2015 23:00:59 -0400 Message-ID: <20150813025112.36703.21333.stgit@otcpl-skl-sds-2.jf.intel.com> User-Agent: StGit/0.17.1-8-g92dd MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Changes since v4 [1]: 1/ Allow up to PAGE_SHIFT bits in PFN_ flags. Previously the __pfn_t value was a union with a 'struct page *', but now __pfn_t_to_page() internally does a pfn_to_page() instead of type-punning the value. (Linus, Matthew) 2/ Move the definition to include/linux/mm.h and squash the kmap_atomic_pfn_t() definition into the same patch. (Christoph) 3/ Kill dax_get_pfn(). Now replaced with dax_map_bh() (Matthew) 4/ The scatterlist cleanup patches are moved to their own series being carried by Christoph. [1]: https://lists.01.org/pipermail/linux-nvdimm/2015-June/001094.html --- We want persistent memory to have 4 modes of access: 1/ Block device: persistent memory treated as a ram disk (done) 2/ DAX: userspace mmap (done) 3/ Kernel "page-less". (this series) 4/ Kernel and userspace references to page-mapped persistent memory (future series) The "kernel 'page-less'" case leverages the fact that a 'struct page' object is not necessarily required for describing a DMA transfer from a device to a persistent memory address. A pfn will do, but code needs to be careful to not perform a pfn_to_page() operation on unmapped persistent memory. The __pfn_t type enforces that safety and kmap_atomic_pfn_t() covers cases where the I/O stack needs to touch the buffer on its way to the low-level-device-driver (i.e. current usages of kmap_atomic() in the block-layer). A subsequent patch series will add struct page coverage for persistent, "device", memory. We also use kmap_atomic_pfn_t() to solve races of pmem driver unbind vs usage in DAX. rcu_read_lock() protects the driver from unbinding while a mapping is held. --- Christoph Hellwig (1): mm: move __phys_to_pfn and __pfn_to_phys to asm/generic/memory_model.h Dan Williams (4): allow mapping page-less memremaped areas into KVA dax: drop size parameter to ->direct_access() dax: fix mapping lifetime handling, convert to __pfn_t + kmap_atomic_pfn_t() scatterlist: convert to __pfn_t arch/arm/include/asm/memory.h | 6 -- arch/arm64/include/asm/memory.h | 6 -- arch/powerpc/platforms/Kconfig | 1 arch/powerpc/sysdev/axonram.c | 24 +++++-- arch/unicore32/include/asm/memory.h | 6 -- drivers/block/brd.c | 9 +-- drivers/nvdimm/Kconfig | 1 drivers/nvdimm/pmem.c | 24 ++++--- drivers/s390/block/Kconfig | 1 drivers/s390/block/dcssblk.c | 23 ++++++- fs/Kconfig | 1 fs/block_dev.c | 4 + fs/dax.c | 79 +++++++++++++++++------- include/asm-generic/memory_model.h | 6 ++ include/linux/blkdev.h | 7 +- include/linux/kmap_pfn.h | 31 +++++++++ include/linux/mm.h | 78 +++++++++++++++++++++++ include/linux/scatterlist.h | 111 +++++++++++++++++++++++---------- mm/Kconfig | 3 + mm/Makefile | 1 mm/kmap_pfn.c | 117 +++++++++++++++++++++++++++++++++++ samples/kfifo/dma-example.c | 8 +- 22 files changed, 435 insertions(+), 112 deletions(-) create mode 100644 include/linux/kmap_pfn.h create mode 100644 mm/kmap_pfn.c