[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1359365068-10147-3-git-send-email-kirill.shutemov@linux.intel.com>
Date: Mon, 28 Jan 2013 11:24:14 +0200
From: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
To: Andrea Arcangeli <aarcange@...hat.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Al Viro <viro@...iv.linux.org.uk>
Cc: Wu Fengguang <fengguang.wu@...el.com>, Jan Kara <jack@...e.cz>,
Mel Gorman <mgorman@...e.de>, linux-mm@...ck.org,
Andi Kleen <ak@...ux.intel.com>,
Matthew Wilcox <matthew.r.wilcox@...el.com>,
"Kirill A. Shutemov" <kirill@...temov.name>,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
Subject: [PATCH, RFC 02/16] mm: implement zero_huge_user_segment and friends
From: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
Let's add helpers to clear huge page segment(s). They provide the same
functionallity as zero_user_segment{,s} and zero_user, but for huge
pages.
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@...ux.intel.com>
---
include/linux/mm.h | 15 +++++++++++++++
mm/memory.c | 22 ++++++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index e4533a1..c011771 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1728,6 +1728,21 @@ extern void dump_page(struct page *page);
extern void clear_huge_page(struct page *page,
unsigned long addr,
unsigned int pages_per_huge_page);
+extern void zero_huge_user_segment(struct page *page,
+ unsigned start, unsigned end);
+static inline void zero_huge_user_segments(struct page *page,
+ unsigned start1, unsigned end1,
+ unsigned start2, unsigned end2)
+{
+ zero_huge_user_segment(page, start1, end1);
+ zero_huge_user_segment(page, start2, end2);
+}
+static inline void zero_huge_user(struct page *page,
+ unsigned start, unsigned len)
+{
+ zero_huge_user_segment(page, start, start+len);
+}
+
extern void copy_user_huge_page(struct page *dst, struct page *src,
unsigned long addr, struct vm_area_struct *vma,
unsigned int pages_per_huge_page);
diff --git a/mm/memory.c b/mm/memory.c
index c04078b..200a74d 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -4185,6 +4185,28 @@ void clear_huge_page(struct page *page,
}
}
+void zero_huge_user_segment(struct page *page, unsigned start, unsigned end)
+{
+ int i;
+
+ BUG_ON(end < start);
+
+ might_sleep();
+
+ /* start and end are on the same small page */
+ if ((start & PAGE_MASK) == (end & PAGE_MASK))
+ return zero_user_segment(page + (start >> PAGE_SHIFT),
+ start & ~PAGE_MASK, end & ~PAGE_MASK);
+
+ zero_user_segment(page + (start >> PAGE_SHIFT),
+ start & ~PAGE_MASK, PAGE_SIZE);
+ for (i = (start >> PAGE_SHIFT) + 1; i < (end >> PAGE_SHIFT) - 1; i++) {
+ cond_resched();
+ clear_highpage(page + i);
+ }
+ zero_user_segment(page + i, 0, end & ~PAGE_MASK);
+}
+
static void copy_user_gigantic_page(struct page *dst, struct page *src,
unsigned long addr,
struct vm_area_struct *vma,
--
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists