From: Mike Kravetz <mike.kravetz@oracle.com>
To: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: Andrea Arcangeli <aarcange@redhat.com>,
Hugh Dickins <hughd@google.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>,
Hillf Danton <hillf.zj@alibaba-inc.com>,
Michal Hocko <mhocko@suse.com>,
Andrew Morton <akpm@linux-foundation.org>,
Mike Kravetz <mike.kravetz@oracle.com>
Subject: [RFC PATCH 1/6] mm/memory: add copy_huge_page_from_user for hugetlb userfaultfd support
Date: Mon, 6 Jun 2016 10:45:26 -0700 [thread overview]
Message-ID: <1465235131-6112-2-git-send-email-mike.kravetz@oracle.com> (raw)
In-Reply-To: <1465235131-6112-1-git-send-email-mike.kravetz@oracle.com>
userfaultfd UFFDIO_COPY allows user level code to copy data to a page
at fault time. The data is copied from user space to a newly allocated
huge page. The new routine copy_huge_page_from_user performs this copy.
Signed-off-by: Mike Kravetz <mike.kravetz@oracle.com>
---
include/linux/mm.h | 3 +++
mm/memory.c | 22 ++++++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 0510282..7ecc7e7 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2355,6 +2355,9 @@ extern void clear_huge_page(struct page *page,
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);
+extern long copy_huge_page_from_user(const void __user *usr_src,
+ struct page *dst_page,
+ unsigned int pages_per_huge_page);
#endif /* CONFIG_TRANSPARENT_HUGEPAGE || CONFIG_HUGETLBFS */
extern struct page_ext_operations debug_guardpage_ops;
diff --git a/mm/memory.c b/mm/memory.c
index 19584b9..c44ddad 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3970,6 +3970,28 @@ void copy_user_huge_page(struct page *dst, struct page *src,
copy_user_highpage(dst + i, src + i, addr + i*PAGE_SIZE, vma);
}
}
+
+long copy_huge_page_from_user(const void __user *usr_src,
+ struct page *dst_page,
+ unsigned int pages_per_huge_page)
+{
+ void *src = (void *)usr_src;
+ void *page_kaddr;
+ long i, rc = 0;
+
+ for (i = 0; i < pages_per_huge_page; i++) {
+ page_kaddr = kmap_atomic(dst_page + i);
+ rc = copy_from_user(page_kaddr,
+ (const void __user *)(src + i * PAGE_SIZE),
+ PAGE_SIZE);
+ kunmap_atomic(page_kaddr);
+ if (rc)
+ break;
+
+ cond_resched();
+ }
+ return rc;
+}
#endif /* CONFIG_TRANSPARENT_HUGEPAGE || CONFIG_HUGETLBFS */
#if USE_SPLIT_PTE_PTLOCKS && ALLOC_SPLIT_PTLOCKS
--
2.4.11
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2016-06-06 17:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-06 17:45 [RFC PATCH 0/6] hugetlb support for userfaultfd Mike Kravetz
2016-06-06 17:45 ` Mike Kravetz [this message]
2016-06-06 17:45 ` [RFC PATCH 2/6] mm/hugetlb: add hugetlb_mcopy_atomic_pte for userfaultfd support Mike Kravetz
2016-06-06 17:45 ` [RFC PATCH 3/6] mm/userfaultfd: add __mcopy_atomic_hugetlb for huge page UFFDIO_COPY Mike Kravetz
2016-06-07 6:27 ` Hillf Danton
2016-06-07 16:35 ` Mike Kravetz
2016-06-06 17:45 ` [RFC PATCH 4/6] mm/hugetlb: add userfaultfd hugetlb hook Mike Kravetz
2016-06-06 17:45 ` [RFC PATCH 5/6] fs/userfaultfd: allow registration of ranges containing huge pages Mike Kravetz
2016-06-06 17:45 ` [RFC PATCH 6/6] selftests/userfaultfd: add userfaultfd_hugetlb test Mike Kravetz
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=1465235131-6112-2-git-send-email-mike.kravetz@oracle.com \
--to=mike.kravetz@oracle.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=dave.hansen@linux.intel.com \
--cc=hillf.zj@alibaba-inc.com \
--cc=hughd@google.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=n-horiguchi@ah.jp.nec.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).