Skip to content

Commit d081107

Browse files
mstsirkintorvalds
authored andcommitted
mm/gup.c: document return value
__get_user_pages_fast handles errors differently from get_user_pages_fast: the former always returns the number of pages pinned, the later might return a negative error code. Link: http://lkml.kernel.org/r/1522962072-182137-6-git-send-email-mst@redhat.com Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Andrew Morton <akpm@linux-foundation.org> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Huang Ying <ying.huang@intel.com> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Thorsten Leemhuis <regressions@leemhuis.info> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent c61611f commit d081107

File tree

6 files changed

+17
-3
lines changed

6 files changed

+17
-3
lines changed

arch/mips/mm/gup.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ static int gup_pud_range(pgd_t pgd, unsigned long addr, unsigned long end,
178178
/*
179179
* Like get_user_pages_fast() except its IRQ-safe in that it won't fall
180180
* back to the regular GUP.
181+
* Note a difference with get_user_pages_fast: this always returns the
182+
* number of pages pinned, 0 if no pages were pinned.
181183
*/
182184
int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
183185
struct page **pages)

arch/s390/mm/gup.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ static inline int gup_p4d_range(pgd_t *pgdp, pgd_t pgd, unsigned long addr,
220220
/*
221221
* Like get_user_pages_fast() except its IRQ-safe in that it won't fall
222222
* back to the regular GUP.
223+
* Note a difference with get_user_pages_fast: this always returns the
224+
* number of pages pinned, 0 if no pages were pinned.
223225
*/
224226
int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
225227
struct page **pages)

arch/sh/mm/gup.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ static int gup_pud_range(pgd_t pgd, unsigned long addr, unsigned long end,
160160
/*
161161
* Like get_user_pages_fast() except its IRQ-safe in that it won't fall
162162
* back to the regular GUP.
163+
* Note a difference with get_user_pages_fast: this always returns the
164+
* number of pages pinned, 0 if no pages were pinned.
163165
*/
164166
int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
165167
struct page **pages)

arch/sparc/mm/gup.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ static int gup_pud_range(pgd_t pgd, unsigned long addr, unsigned long end,
193193
return 1;
194194
}
195195

196+
/*
197+
* Note a difference with get_user_pages_fast: this always returns the
198+
* number of pages pinned, 0 if no pages were pinned.
199+
*/
196200
int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
197201
struct page **pages)
198202
{

mm/gup.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1740,7 +1740,9 @@ bool gup_fast_permitted(unsigned long start, int nr_pages, int write)
17401740

17411741
/*
17421742
* Like get_user_pages_fast() except it's IRQ-safe in that it won't fall back to
1743-
* the regular GUP. It will only return non-negative values.
1743+
* the regular GUP.
1744+
* Note a difference with get_user_pages_fast: this always returns the
1745+
* number of pages pinned, 0 if no pages were pinned.
17441746
*/
17451747
int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
17461748
struct page **pages)

mm/util.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack)
297297
/*
298298
* Like get_user_pages_fast() except its IRQ-safe in that it won't fall
299299
* back to the regular GUP.
300-
* If the architecture not support this function, simply return with no
301-
* page pinned
300+
* Note a difference with get_user_pages_fast: this always returns the
301+
* number of pages pinned, 0 if no pages were pinned.
302+
* If the architecture does not support this function, simply return with no
303+
* pages pinned.
302304
*/
303305
int __weak __get_user_pages_fast(unsigned long start,
304306
int nr_pages, int write, struct page **pages)

0 commit comments

Comments
 (0)