All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>, Thomas Gleixner <tglx@linutronix.de>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Geoff Levand <geoff@infradead.org>,
	Ilya Dryomov <idryomov@gmail.com>,
	Dongsheng Yang <dongsheng.yang@easystack.cn>,
	Mike Snitzer <snitzer@redhat.com>,
	"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	Ira Weiny <ira.weiny@intel.com>,
	dm-devel@redhat.com, linux-mips@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
	linuxppc-dev@lists.ozlabs.org, ceph-devel@vger.kernel.org,
	linux-arch@vger.kernel.org
Subject: [PATCH 01/18] mm: add a kunmap_local_dirty helper
Date: Tue, 15 Jun 2021 15:24:39 +0200	[thread overview]
Message-ID: <20210615132456.753241-2-hch@lst.de> (raw)
In-Reply-To: <20210615132456.753241-1-hch@lst.de>

Add a helper that calls flush_kernel_dcache_page before unmapping the
local mapping.  flush_kernel_dcache_page is required for all pages
potentially mapped into userspace that were written to using kmap*,
so having a helper that does the right thing can be very convenient.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 include/linux/highmem-internal.h | 7 +++++++
 include/linux/highmem.h          | 4 ++++
 2 files changed, 11 insertions(+)

diff --git a/include/linux/highmem-internal.h b/include/linux/highmem-internal.h
index 7902c7d8b55f..bd37706db147 100644
--- a/include/linux/highmem-internal.h
+++ b/include/linux/highmem-internal.h
@@ -224,4 +224,11 @@ do {								\
 	__kunmap_local(__addr);					\
 } while (0)
 
+#define kunmap_local_dirty(__page, __addr)			\
+do {								\
+	if (!PageSlab(__page))					\
+		flush_kernel_dcache_page(__page);		\
+	kunmap_local(__addr);					\
+} while (0)
+
 #endif
diff --git a/include/linux/highmem.h b/include/linux/highmem.h
index 832b49b50c7b..65f548db4f2d 100644
--- a/include/linux/highmem.h
+++ b/include/linux/highmem.h
@@ -93,6 +93,10 @@ static inline void kmap_flush_unused(void);
  * On HIGHMEM enabled systems mapping a highmem page has the side effect of
  * disabling migration in order to keep the virtual address stable across
  * preemption. No caller of kmap_local_page() can rely on this side effect.
+ *
+ * If data is written to the returned kernel mapping, the callers needs to
+ * unmap the mapping using kunmap_local_dirty(), else kunmap_local() should
+ * be used.
  */
 static inline void *kmap_local_page(struct page *page);
 
-- 
2.30.2


WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>, Thomas Gleixner <tglx@linutronix.de>
Cc: linux-arch@vger.kernel.org, linux-block@vger.kernel.org,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Mike Snitzer <snitzer@redhat.com>,
	Geoff Levand <geoff@infradead.org>,
	linuxppc-dev@lists.ozlabs.org, linux-mips@vger.kernel.org,
	Dongsheng Yang <dongsheng.yang@easystack.cn>,
	linux-kernel@vger.kernel.org,
	"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	dm-devel@redhat.com, Ilya Dryomov <idryomov@gmail.com>,
	Ira Weiny <ira.weiny@intel.com>,
	ceph-devel@vger.kernel.org
Subject: [PATCH 01/18] mm: add a kunmap_local_dirty helper
Date: Tue, 15 Jun 2021 15:24:39 +0200	[thread overview]
Message-ID: <20210615132456.753241-2-hch@lst.de> (raw)
In-Reply-To: <20210615132456.753241-1-hch@lst.de>

Add a helper that calls flush_kernel_dcache_page before unmapping the
local mapping.  flush_kernel_dcache_page is required for all pages
potentially mapped into userspace that were written to using kmap*,
so having a helper that does the right thing can be very convenient.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 include/linux/highmem-internal.h | 7 +++++++
 include/linux/highmem.h          | 4 ++++
 2 files changed, 11 insertions(+)

diff --git a/include/linux/highmem-internal.h b/include/linux/highmem-internal.h
index 7902c7d8b55f..bd37706db147 100644
--- a/include/linux/highmem-internal.h
+++ b/include/linux/highmem-internal.h
@@ -224,4 +224,11 @@ do {								\
 	__kunmap_local(__addr);					\
 } while (0)
 
+#define kunmap_local_dirty(__page, __addr)			\
+do {								\
+	if (!PageSlab(__page))					\
+		flush_kernel_dcache_page(__page);		\
+	kunmap_local(__addr);					\
+} while (0)
+
 #endif
diff --git a/include/linux/highmem.h b/include/linux/highmem.h
index 832b49b50c7b..65f548db4f2d 100644
--- a/include/linux/highmem.h
+++ b/include/linux/highmem.h
@@ -93,6 +93,10 @@ static inline void kmap_flush_unused(void);
  * On HIGHMEM enabled systems mapping a highmem page has the side effect of
  * disabling migration in order to keep the virtual address stable across
  * preemption. No caller of kmap_local_page() can rely on this side effect.
+ *
+ * If data is written to the returned kernel mapping, the callers needs to
+ * unmap the mapping using kunmap_local_dirty(), else kunmap_local() should
+ * be used.
  */
 static inline void *kmap_local_page(struct page *page);
 
-- 
2.30.2


WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>, Thomas Gleixner <tglx@linutronix.de>
Cc: linux-arch@vger.kernel.org, linux-block@vger.kernel.org,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Mike Snitzer <snitzer@redhat.com>,
	Geoff Levand <geoff@infradead.org>,
	linuxppc-dev@lists.ozlabs.org, linux-mips@vger.kernel.org,
	Dongsheng Yang <dongsheng.yang@easystack.cn>,
	linux-kernel@vger.kernel.org,
	"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	dm-devel@redhat.com, Ilya Dryomov <idryomov@gmail.com>,
	Ira Weiny <ira.weiny@intel.com>,
	ceph-devel@vger.kernel.org
Subject: [dm-devel] [PATCH 01/18] mm: add a kunmap_local_dirty helper
Date: Tue, 15 Jun 2021 15:24:39 +0200	[thread overview]
Message-ID: <20210615132456.753241-2-hch@lst.de> (raw)
In-Reply-To: <20210615132456.753241-1-hch@lst.de>

Add a helper that calls flush_kernel_dcache_page before unmapping the
local mapping.  flush_kernel_dcache_page is required for all pages
potentially mapped into userspace that were written to using kmap*,
so having a helper that does the right thing can be very convenient.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 include/linux/highmem-internal.h | 7 +++++++
 include/linux/highmem.h          | 4 ++++
 2 files changed, 11 insertions(+)

diff --git a/include/linux/highmem-internal.h b/include/linux/highmem-internal.h
index 7902c7d8b55f..bd37706db147 100644
--- a/include/linux/highmem-internal.h
+++ b/include/linux/highmem-internal.h
@@ -224,4 +224,11 @@ do {								\
 	__kunmap_local(__addr);					\
 } while (0)
 
+#define kunmap_local_dirty(__page, __addr)			\
+do {								\
+	if (!PageSlab(__page))					\
+		flush_kernel_dcache_page(__page);		\
+	kunmap_local(__addr);					\
+} while (0)
+
 #endif
diff --git a/include/linux/highmem.h b/include/linux/highmem.h
index 832b49b50c7b..65f548db4f2d 100644
--- a/include/linux/highmem.h
+++ b/include/linux/highmem.h
@@ -93,6 +93,10 @@ static inline void kmap_flush_unused(void);
  * On HIGHMEM enabled systems mapping a highmem page has the side effect of
  * disabling migration in order to keep the virtual address stable across
  * preemption. No caller of kmap_local_page() can rely on this side effect.
+ *
+ * If data is written to the returned kernel mapping, the callers needs to
+ * unmap the mapping using kunmap_local_dirty(), else kunmap_local() should
+ * be used.
  */
 static inline void *kmap_local_page(struct page *page);
 
-- 
2.30.2

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


  reply	other threads:[~2021-06-15 13:26 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-15 13:24 switch the block layer to use kmap_local_page v2 Christoph Hellwig
2021-06-15 13:24 ` [dm-devel] " Christoph Hellwig
2021-06-15 13:24 ` Christoph Hellwig
2021-06-15 13:24 ` Christoph Hellwig [this message]
2021-06-15 13:24   ` [dm-devel] [PATCH 01/18] mm: add a kunmap_local_dirty helper Christoph Hellwig
2021-06-15 13:24   ` Christoph Hellwig
2021-06-18  3:01   ` Ira Weiny
2021-06-18  3:01     ` [dm-devel] " Ira Weiny
2021-06-18  3:01     ` Ira Weiny
2021-06-18  3:37     ` Herbert Xu
2021-06-18  3:37       ` [dm-devel] " Herbert Xu
2021-06-18  3:37       ` Herbert Xu
2021-06-18 18:12       ` Ira Weiny
2021-06-18 18:12         ` [dm-devel] " Ira Weiny
2021-06-18 18:12         ` Ira Weiny
2021-06-24  6:32         ` [PATCH] crypto: scatterwalk - Remove obsolete PageSlab check Herbert Xu
2021-06-24  6:32           ` [dm-devel] " Herbert Xu
2021-06-24  6:32           ` Herbert Xu
2021-06-15 13:24 ` [PATCH 02/18] mm: use kunmap_local_dirty in memcpy_to_page Christoph Hellwig
2021-06-15 13:24   ` [dm-devel] " Christoph Hellwig
2021-06-15 13:24   ` Christoph Hellwig
2021-06-15 13:24 ` [PATCH 03/18] mm: use kmap_local_page in memzero_page Christoph Hellwig
2021-06-15 13:24   ` [dm-devel] " Christoph Hellwig
2021-06-15 13:24   ` Christoph Hellwig
2021-06-15 13:24 ` [PATCH 04/18] MIPS: don't include <linux/genhd.h> in <asm/mach-rc32434/rb.h> Christoph Hellwig
2021-06-15 13:24   ` [dm-devel] " Christoph Hellwig
2021-06-15 13:24   ` Christoph Hellwig
2021-06-15 13:24 ` [PATCH 05/18] bvec: fix the include guards for bvec.h Christoph Hellwig
2021-06-15 13:24   ` [dm-devel] " Christoph Hellwig
2021-06-15 13:24   ` Christoph Hellwig
2021-06-15 13:24 ` [PATCH 06/18] bvec: add a bvec_kmap_local helper Christoph Hellwig
2021-06-15 13:24   ` [dm-devel] " Christoph Hellwig
2021-06-15 13:24   ` Christoph Hellwig
2021-06-16 16:52   ` [dm-devel] " Bart Van Assche
2021-06-16 16:52     ` Bart Van Assche
2021-06-16 16:52     ` Bart Van Assche
2021-06-15 13:24 ` [PATCH 07/18] bvec: add memcpy_{from,to}_bvec and memzero_bvec helper Christoph Hellwig
2021-06-15 13:24   ` [dm-devel] [PATCH 07/18] bvec: add memcpy_{from, to}_bvec " Christoph Hellwig
2021-06-15 13:24   ` Christoph Hellwig
2021-06-15 13:24 ` [PATCH 08/18] block: use memzero_page in zero_fill_bio Christoph Hellwig
2021-06-15 13:24   ` [dm-devel] " Christoph Hellwig
2021-06-15 13:24   ` Christoph Hellwig
2021-06-15 13:24 ` [PATCH 09/18] rbd: use memzero_bvec Christoph Hellwig
2021-06-15 13:24   ` [dm-devel] " Christoph Hellwig
2021-06-15 13:24   ` Christoph Hellwig
2021-06-15 13:24 ` [PATCH 10/18] dm-writecache: use bvec_kmap_local instead of bvec_kmap_irq Christoph Hellwig
2021-06-15 13:24   ` [dm-devel] " Christoph Hellwig
2021-06-15 13:24   ` Christoph Hellwig
2021-06-15 13:24 ` [PATCH 11/18] ps3disk: use memcpy_{from,to}_bvec Christoph Hellwig
2021-06-15 13:24   ` [dm-devel] " Christoph Hellwig
2021-06-15 13:24   ` Christoph Hellwig
2021-06-16 16:36   ` Geoff Levand
2021-06-16 16:36     ` [dm-devel] " Geoff Levand
2021-06-16 16:36     ` Geoff Levand
2021-06-15 13:24 ` [PATCH 12/18] block: remove bvec_kmap_irq and bvec_kunmap_irq Christoph Hellwig
2021-06-15 13:24   ` [dm-devel] " Christoph Hellwig
2021-06-15 13:24   ` Christoph Hellwig
2021-06-15 13:24 ` [PATCH 13/18] block: rewrite bio_copy_data_iter to use bvec_kmap_local and memcpy_to_bvec Christoph Hellwig
2021-06-15 13:24   ` [dm-devel] " Christoph Hellwig
2021-06-15 13:24   ` Christoph Hellwig
2021-06-15 13:24 ` [PATCH 14/18] block: use memcpy_to_bvec in copy_to_high_bio_irq Christoph Hellwig
2021-06-15 13:24   ` [dm-devel] " Christoph Hellwig
2021-06-15 13:24   ` Christoph Hellwig
2021-06-15 13:24 ` [PATCH 15/18] block: use memcpy_from_bvec in bio_copy_kern_endio_read Christoph Hellwig
2021-06-15 13:24   ` [dm-devel] " Christoph Hellwig
2021-06-15 13:24   ` Christoph Hellwig
2021-06-15 13:24 ` [PATCH 16/18] block: use memcpy_from_bvec in __blk_queue_bounce Christoph Hellwig
2021-06-15 13:24   ` [dm-devel] " Christoph Hellwig
2021-06-15 13:24   ` Christoph Hellwig
2021-06-15 13:24 ` [PATCH 17/18] block: use bvec_kmap_local in t10_pi_type1_{prepare,complete} Christoph Hellwig
2021-06-15 13:24   ` [dm-devel] [PATCH 17/18] block: use bvec_kmap_local in t10_pi_type1_{prepare, complete} Christoph Hellwig
2021-06-15 13:24   ` Christoph Hellwig
2021-06-15 13:24 ` [PATCH 18/18] block: use bvec_kmap_local in bio_integrity_process Christoph Hellwig
2021-06-15 13:24   ` [dm-devel] " Christoph Hellwig
2021-06-15 13:24   ` Christoph Hellwig
2021-06-16 16:03 ` switch the block layer to use kmap_local_page v2 Martin K. Petersen
2021-06-16 16:03   ` [dm-devel] " Martin K. Petersen
2021-06-16 16:03   ` Martin K. Petersen

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=20210615132456.753241-2-hch@lst.de \
    --to=hch@lst.de \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=axboe@kernel.dk \
    --cc=ceph-devel@vger.kernel.org \
    --cc=dm-devel@redhat.com \
    --cc=dongsheng.yang@easystack.cn \
    --cc=geoff@infradead.org \
    --cc=idryomov@gmail.com \
    --cc=ira.weiny@intel.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=snitzer@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=tsbogend@alpha.franken.de \
    /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.