Skip to content

Commit 5ed3cdc

Browse files
kerneltoastbmastbergen
authored andcommitted
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 71db71d commit 5ed3cdc

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
@@ -2577,6 +2577,8 @@ int get_user_pages_fast(unsigned long start, int nr_pages,
25772577
unsigned int gup_flags, struct page **pages);
25782578
int pin_user_pages_fast(unsigned long start, int nr_pages,
25792579
unsigned int gup_flags, struct page **pages);
2580+
int pin_user_pages_fast_only(unsigned long start, int nr_pages,
2581+
unsigned int gup_flags, struct page **pages);
25802582
void folio_add_pin(struct folio *folio);
25812583

25822584
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
@@ -3491,6 +3491,20 @@ int pin_user_pages_fast(unsigned long start, int nr_pages,
34913491
}
34923492
EXPORT_SYMBOL_GPL(pin_user_pages_fast);
34933493

3494+
/*
3495+
* This is the FOLL_PIN equivalent of get_user_pages_fast_only(). Behavior is
3496+
* the same, except that this one sets FOLL_PIN instead of FOLL_GET.
3497+
*/
3498+
int pin_user_pages_fast_only(unsigned long start, int nr_pages,
3499+
unsigned int gup_flags, struct page **pages)
3500+
{
3501+
if (!is_valid_gup_args(pages, NULL, &gup_flags,
3502+
FOLL_PIN | FOLL_FAST_ONLY))
3503+
return -EINVAL;
3504+
return internal_get_user_pages_fast(start, nr_pages, gup_flags, pages);
3505+
}
3506+
EXPORT_SYMBOL_GPL(pin_user_pages_fast_only);
3507+
34943508
/**
34953509
* pin_user_pages_remote() - pin pages of a remote process
34963510
*

0 commit comments

Comments
 (0)