Commit 06090e8ed89ea2113a236befb41f71d51f100e60

Authored by David S. Miller
1 parent ef3e035c3a

sparc64: Implement __get_user_pages_fast().

It is not sufficient to only implement get_user_pages_fast(), you
must also implement the atomic version __get_user_pages_fast()
otherwise you end up using the weak symbol fallback implementation
which simply returns zero.

This is dangerous, because it causes the futex code to loop forever
if transparent hugepages are supported (see get_futex_key()).

Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 1 changed file with 30 additions and 0 deletions Side-by-side Diff

... ... @@ -160,6 +160,36 @@
160 160 return 1;
161 161 }
162 162  
  163 +int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
  164 + struct page **pages)
  165 +{
  166 + struct mm_struct *mm = current->mm;
  167 + unsigned long addr, len, end;
  168 + unsigned long next, flags;
  169 + pgd_t *pgdp;
  170 + int nr = 0;
  171 +
  172 + start &= PAGE_MASK;
  173 + addr = start;
  174 + len = (unsigned long) nr_pages << PAGE_SHIFT;
  175 + end = start + len;
  176 +
  177 + local_irq_save(flags);
  178 + pgdp = pgd_offset(mm, addr);
  179 + do {
  180 + pgd_t pgd = *pgdp;
  181 +
  182 + next = pgd_addr_end(addr, end);
  183 + if (pgd_none(pgd))
  184 + break;
  185 + if (!gup_pud_range(pgd, addr, next, write, pages, &nr))
  186 + break;
  187 + } while (pgdp++, addr = next, addr != end);
  188 + local_irq_restore(flags);
  189 +
  190 + return nr;
  191 +}
  192 +
163 193 int get_user_pages_fast(unsigned long start, int nr_pages, int write,
164 194 struct page **pages)
165 195 {