Skip to content

Commit a77ff35

Browse files
committed
mm/gup: reintroduce pin_user_pages_fast_only()
Like pin_user_pages_fast(), but with the internal-only FOLL_FAST_ONLY flag. This complements the get_user_pages*() API, which already has get_user_pages_fast_only(). Note that pin_user_pages_fast_only() used to exist but was removed in upstream commit edad1bb ("mm/gup: remove pin_user_pages_fast_only()") due to it not having any users. Signed-off-by: Sultan Alsawaf <sultan@ciq.com>
1 parent 2e8bf6e commit a77ff35

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

include/linux/mm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2529,6 +2529,8 @@ int get_user_pages_fast(unsigned long start, int nr_pages,
25292529
unsigned int gup_flags, struct page **pages);
25302530
int pin_user_pages_fast(unsigned long start, int nr_pages,
25312531
unsigned int gup_flags, struct page **pages);
2532+
int pin_user_pages_fast_only(unsigned long start, int nr_pages,
2533+
unsigned int gup_flags, struct page **pages);
25322534
void folio_add_pin(struct folio *folio);
25332535

25342536
int account_locked_vm(struct mm_struct *mm, unsigned long pages, bool inc);

mm/gup.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3544,6 +3544,20 @@ int pin_user_pages_fast(unsigned long start, int nr_pages,
35443544
}
35453545
EXPORT_SYMBOL_GPL(pin_user_pages_fast);
35463546

3547+
/*
3548+
* This is the FOLL_PIN equivalent of get_user_pages_fast_only(). Behavior is
3549+
* the same, except that this one sets FOLL_PIN instead of FOLL_GET.
3550+
*/
3551+
int pin_user_pages_fast_only(unsigned long start, int nr_pages,
3552+
unsigned int gup_flags, struct page **pages)
3553+
{
3554+
if (!is_valid_gup_args(pages, NULL, &gup_flags,
3555+
FOLL_PIN | FOLL_FAST_ONLY))
3556+
return -EINVAL;
3557+
return gup_fast_fallback(start, nr_pages, gup_flags, pages);
3558+
}
3559+
EXPORT_SYMBOL_GPL(pin_user_pages_fast_only);
3560+
35473561
/**
35483562
* pin_user_pages_remote() - pin pages of a remote process
35493563
*

0 commit comments

Comments
 (0)