Re: [PATCH 3/4] mm/gup: add a range variant of unpin_user_pages_dirty_lock()
From: John Hubbard <jhubbard@nvidia.com>
Date: 2021-02-04 00:12:14
Also in:
linux-mm, lkml
From: John Hubbard <jhubbard@nvidia.com>
Date: 2021-02-04 00:12:14
Also in:
linux-mm, lkml
On 2/3/21 2:00 PM, Joao Martins wrote: ...
+void unpin_user_page_range_dirty_lock(struct page *page, unsigned long npages,
+ bool make_dirty)
+{
+ unsigned long index;
+ struct page *head;
+ unsigned int ntails;
+
+ for_each_compound_range(index, &page, npages, head, ntails) {
+ if (make_dirty && !PageDirty(head))
+ set_page_dirty_lock(head);
+ put_compound_head(head, ntails, FOLL_PIN);
+ }
+}
+EXPORT_SYMBOL(unpin_user_page_range_dirty_lock);
+Also, looking at this again while trying to verify the sg diffs in patch #4, I noticed that the name is tricky. Usually a "range" would not have a single struct page* as the argument. So in this case, perhaps a comment above the function would help, something approximately like this: /* * The "range" in the function name refers to the fact that the page may be a * compound page. If so, then that compound page will be treated as one or more * ranges of contiguous tail pages. */ ...I guess. Or maybe the name is just wrong (a comment block explaining a name is always a bad sign). Perhaps we should rename it to something like: unpin_user_compound_page_dirty_lock() ? thanks, -- John Hubbard NVIDIA