linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/memory: Use kmap_local_page() in __wp_page_copy_user()
@ 2023-11-20 14:24 Fabio M. De Francesco
  0 siblings, 0 replies; only message in thread
From: Fabio M. De Francesco @ 2023-11-20 14:24 UTC (permalink / raw)
  To: Andrew Morton, linux-mm, linux-kernel; +Cc: Fabio M. De Francesco, Ira Weiny

From: "Fabio M. De Francesco" <fabio.maria.de.francesco@linux.intel.com>

kmap_atomic() has been deprecated in favor of kmap_local_{folio,page}.

Therefore, replace kmap_atomic() with kmap_local_page in
__wp_page_copy_user().

kmap_atomic() disables preemption in !PREEMPT_RT kernels and
unconditionally disables also page-faults. My limited knowledge of the
implementation of __wp_page_copy_user() makes me think that the latter
side effect is still needed here, but kmap_local_page() is implemented
not to disable page-faults.

So, in addition to the conversion to local mapping, add explicit
pagefault_disable() / pagefault_enable() between mapping and un-mapping.

Cc: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Fabio M. De Francesco <fabio.maria.de.francesco@linux.intel.com>
---
 mm/memory.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/mm/memory.c b/mm/memory.c
index 1f18ed4a5497..0ba63007c580 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -2835,7 +2835,8 @@ static inline int __wp_page_copy_user(struct page *dst, struct page *src,
 	 * just copying from the original user address. If that
 	 * fails, we just zero-fill it. Live with it.
 	 */
-	kaddr = kmap_atomic(dst);
+	kaddr = kmap_local_page(dst);
+	pagefault_disable();
 	uaddr = (void __user *)(addr & PAGE_MASK);
 
 	/*
@@ -2903,7 +2904,8 @@ static inline int __wp_page_copy_user(struct page *dst, struct page *src,
 pte_unlock:
 	if (vmf->pte)
 		pte_unmap_unlock(vmf->pte, vmf->ptl);
-	kunmap_atomic(kaddr);
+	pagefault_enable();
+	kunmap_local(kaddr);
 	flush_dcache_page(dst);
 
 	return ret;
-- 
2.42.0



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-11-20 14:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-20 14:24 [PATCH] mm/memory: Use kmap_local_page() in __wp_page_copy_user() Fabio M. De Francesco

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox