Skip to contentSkip to conversation

ARM: *: mm: Implement get_user_pages_fast()

PATCH New Yuriy Romanenko 2 participants 2 messages Sep 21, 2016 – Sep 29, 2016 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: *: mm: Implement get_user_pages_fast()

Quoted 1 line

From 6be781314e78ad43d797915189145a0aae41f639 Mon Sep 17 00:00:00 2001

From: Yuriy Romanenko <[email protected]>
Date: Tue, 20 Sep 2016 18:50:16 -0700
Subject: [PATCH] ARM: *: mm: Implement get_user_pages_fast()

Will do an unlocked walk of the page table, if that provides everything necessary, it will succeed and return, otherwise it will call the old slow path on the remainder

---
 arch/arm/mm/Makefile |  2 +-
 arch/arm/mm/gup.c    | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 91 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/mm/gup.c
arch/arm/mm/Makefile +1 -1
index 7f76d96..096cfcb 100644
@@ -6,7 +6,7 @@ obj-y := dma-mapping.o extable.o fault.o init.o \
    iomap.o
 
 obj-$(CONFIG_MMU) += fault-armv.o flush.o idmap.o ioremap.o \
-   mmap.o pgd.o mmu.o pageattr.o
+   mmap.o pgd.o mmu.o pageattr.o gup.o
 
 ifneq ($(CONFIG_MMU),y)
 obj-y += nommu.o
arch/arm/mm/gup.c new file +90 -0

91 lines not on this page · raw message

Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 ARM: *: mm: Implement get_user_pages_fast()

Quoted 15 lines · Yuriy Romanenko
arch/arm/mm/gup.c new file +15 -0
+int get_user_pages_fast(unsigned long start, int nr_pages, int write,
+ struct page **pages)
+{
+ struct mm_struct *mm = current->mm;
+ int ret;
+ unsigned long page_addr = (start & PAGE_MASK);
+ int nr = 0;
+
+ struct gup_private_data private_data = {
+ .nr = 0,
+ .pages = pages,
+ .write = write
+ };
+
+ struct mm_walk gup_walk = {

arch/arm/mm/gup.c line 73

Quoted 10 lines
arch/arm/mm/gup.c new file +10 -0
+ .pte_entry = gup_pte_entry,
+ .pte_hole = gup_pte_hole_entry,
+ .mm = mm,
+ .private = (void *)&private_data
+ };
+
+ ret = walk_page_range(page_addr,
+ page_addr + nr_pages * PAGE_SIZE,
+ &gup_walk);
+ nr = ret ? ret : nr_pages;

walk_page_range() can't be called without the mmap_sem.

* Locking:

  *   Callers of walk_page_range() and walk_page_vma() should hold
  *   @walk->mm->mmap_sem, because these function traverse vma list and/or
  *   access to vma's data.

*/
int walk_page_range(unsigned long start, unsigned long end,
struct mm_walk *walk)
{
int err = 0;
unsigned long next;
struct vm_area_struct *vma;

if (start >= end)
return -EINVAL;

if (!walk->mm)
return -EINVAL;

VM_BUG_ON_MM(!rwsem_is_locked(&walk->mm->mmap_sem), walk->mm);