Skip to content

Commit ef467f3

Browse files
kerneltoastPlaidCat
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> Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent 8d76595 commit ef467f3

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
@@ -2571,6 +2571,8 @@ int get_user_pages_fast(unsigned long start, int nr_pages,
25712571
unsigned int gup_flags, struct page **pages);
25722572
int pin_user_pages_fast(unsigned long start, int nr_pages,
25732573
unsigned int gup_flags, struct page **pages);
2574+
int pin_user_pages_fast_only(unsigned long start, int nr_pages,
2575+
unsigned int gup_flags, struct page **pages);
25742576
void folio_add_pin(struct folio *folio);
25752577

25762578
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
@@ -3359,6 +3359,20 @@ int pin_user_pages_fast(unsigned long start, int nr_pages,
33593359
}
33603360
EXPORT_SYMBOL_GPL(pin_user_pages_fast);
33613361

3362+
/*
3363+
* This is the FOLL_PIN equivalent of get_user_pages_fast_only(). Behavior is
3364+
* the same, except that this one sets FOLL_PIN instead of FOLL_GET.
3365+
*/
3366+
int pin_user_pages_fast_only(unsigned long start, int nr_pages,
3367+
unsigned int gup_flags, struct page **pages)
3368+
{
3369+
if (!is_valid_gup_args(pages, NULL, &gup_flags,
3370+
FOLL_PIN | FOLL_FAST_ONLY))
3371+
return -EINVAL;
3372+
return internal_get_user_pages_fast(start, nr_pages, gup_flags, pages);
3373+
}
3374+
EXPORT_SYMBOL_GPL(pin_user_pages_fast_only);
3375+
33623376
/**
33633377
* pin_user_pages_remote() - pin pages of a remote process
33643378
*

0 commit comments

Comments
 (0)