lkml.org 
[lkml]   [2020]   [Feb]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 13/25] fs: Add zero_user_large
Date
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>

We can't kmap() a THP, so add a wrapper around zero_user() for large
pages.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
include/linux/highmem.h | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)

diff --git a/include/linux/highmem.h b/include/linux/highmem.h
index ea5cdbd8c2c3..4465b8784353 100644
--- a/include/linux/highmem.h
+++ b/include/linux/highmem.h
@@ -245,6 +245,28 @@ static inline void zero_user(struct page *page,
zero_user_segments(page, start, start + size, 0, 0);
}

+static inline void zero_user_large(struct page *page,
+ unsigned start, unsigned size)
+{
+ unsigned int i;
+
+ for (i = 0; i < thp_order(page); i++) {
+ if (start > PAGE_SIZE) {
+ start -= PAGE_SIZE;
+ } else {
+ unsigned this_size = size;
+
+ if (size > (PAGE_SIZE - start))
+ this_size = PAGE_SIZE - start;
+ zero_user(page + i, start, this_size);
+ start = 0;
+ size -= this_size;
+ if (!size)
+ break;
+ }
+ }
+}
+
#ifndef __HAVE_ARCH_COPY_USER_HIGHPAGE

static inline void copy_user_highpage(struct page *to, struct page *from,
--
2.25.0
\
 
 \ /
  Last update: 2020-02-12 05:20    [W:0.177 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site