From: John Hubbard <jhubbard@nvidia.com>
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>, linux-mm@kvack.org
Cc: Christoph Hellwig <hch@infradead.org>,
William Kucharski <william.kucharski@oracle.com>,
linux-kernel@vger.kernel.org, Jason Gunthorpe <jgg@ziepe.ca>
Subject: Re: [PATCH v2 26/28] gup: Convert compound_range_next() to gup_folio_range_next()
Date: Mon, 10 Jan 2022 23:44:55 -0800 [thread overview]
Message-ID: <280540de-99bb-91f0-1850-1efe828e4b45@nvidia.com> (raw)
In-Reply-To: <20220110042406.499429-27-willy@infradead.org>
On 1/9/22 20:24, Matthew Wilcox (Oracle) wrote:
> Convert the only caller to work on folios instead of pages.
> This removes the last caller of put_compound_head(), so delete it.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
> include/linux/mm.h | 4 ++--
> mm/gup.c | 38 ++++++++++++++++++--------------------
> 2 files changed, 20 insertions(+), 22 deletions(-)
>
Reviewed-by: John Hubbard <jhubbard@nvidia.com>
thanks,
--
John Hubbard
NVIDIA
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index c103c6401ecd..1ddb0a55b5ca 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -216,10 +216,10 @@ int overcommit_policy_handler(struct ctl_table *, int, void *, size_t *,
>
> #if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP)
> #define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n))
> -#define page_nth(head, tail) (page_to_pfn(tail) - page_to_pfn(head))
> +#define folio_nth(folio, page) (page_to_pfn(page) - folio_pfn(folio))
> #else
> #define nth_page(page,n) ((page) + (n))
> -#define page_nth(head, tail) ((tail) - (head))
> +#define folio_nth(folio, tail) ((tail) - &(folio)->page)
> #endif
>
> /* to align the pointer to the (next) page boundary */
> diff --git a/mm/gup.c b/mm/gup.c
> index 0cf2d5fd8d2d..1cdd5f2887a8 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -156,12 +156,6 @@ static void gup_put_folio(struct folio *folio, int refs, unsigned int flags)
> folio_put_refs(folio, refs);
> }
>
> -static void put_compound_head(struct page *page, int refs, unsigned int flags)
> -{
> - VM_BUG_ON_PAGE(PageTail(page), page);
> - gup_put_folio((struct folio *)page, refs, flags);
> -}
> -
> /**
> * try_grab_page() - elevate a page's refcount by a flag-dependent amount
> *
> @@ -204,20 +198,21 @@ void unpin_user_page(struct page *page)
> }
> EXPORT_SYMBOL(unpin_user_page);
>
> -static inline struct page *compound_range_next(unsigned long i,
> +static inline struct folio *gup_folio_range_next(unsigned long i,
> unsigned long npages, struct page *start, unsigned int *ntails)
> {
> - struct page *next, *page;
> + struct page *next;
> + struct folio *folio;
> unsigned int nr = 1;
>
> next = nth_page(start, i);
> - page = compound_head(next);
> - if (PageHead(page))
> + folio = page_folio(next);
> + if (folio_test_large(folio))
> nr = min_t(unsigned int, npages - i,
> - compound_nr(page) - page_nth(page, next));
> + folio_nr_pages(folio) - folio_nth(folio, next));
>
> *ntails = nr;
> - return page;
> + return folio;
> }
>
> static inline struct folio *gup_folio_next(unsigned long i,
> @@ -326,15 +321,18 @@ EXPORT_SYMBOL(unpin_user_pages_dirty_lock);
> 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;
> + unsigned long i;
> + struct folio *folio;
> + unsigned int nr;
>
> - for (index = 0; index < npages; index += ntails) {
> - head = compound_range_next(index, npages, page, &ntails);
> - if (make_dirty && !PageDirty(head))
> - set_page_dirty_lock(head);
> - put_compound_head(head, ntails, FOLL_PIN);
> + for (i = 0; i < npages; i += nr) {
> + folio = gup_folio_range_next(i, npages, page, &nr);
> + if (make_dirty && !folio_test_dirty(folio)) {
> + folio_lock(folio);
> + folio_mark_dirty(folio);
> + folio_unlock(folio);
> + }
> + gup_put_folio(folio, nr, FOLL_PIN);
> }
> }
> EXPORT_SYMBOL(unpin_user_page_range_dirty_lock);
next prev parent reply other threads:[~2022-01-11 7:45 UTC|newest]
Thread overview: 96+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-10 4:23 [PATCH v2 00/28] Convert GUP to folios Matthew Wilcox (Oracle)
2022-01-10 4:23 ` [PATCH v2 01/28] gup: Remove for_each_compound_range() Matthew Wilcox (Oracle)
2022-01-10 8:22 ` Christoph Hellwig
2022-01-11 1:07 ` John Hubbard
2022-01-10 4:23 ` [PATCH v2 02/28] gup: Remove for_each_compound_head() Matthew Wilcox (Oracle)
2022-01-10 8:23 ` Christoph Hellwig
2022-01-11 1:11 ` John Hubbard
2022-01-10 4:23 ` [PATCH v2 03/28] gup: Change the calling convention for compound_range_next() Matthew Wilcox (Oracle)
2022-01-10 8:25 ` Christoph Hellwig
2022-01-11 1:14 ` John Hubbard
2022-01-10 4:23 ` [PATCH v2 04/28] gup: Optimise compound_range_next() Matthew Wilcox (Oracle)
2022-01-10 8:26 ` Christoph Hellwig
2022-01-11 1:16 ` John Hubbard
2022-01-10 4:23 ` [PATCH v2 05/28] gup: Change the calling convention for compound_next() Matthew Wilcox (Oracle)
2022-01-10 8:27 ` Christoph Hellwig
2022-01-10 13:28 ` Matthew Wilcox
2022-01-11 1:18 ` John Hubbard
2022-01-10 4:23 ` [PATCH v2 06/28] gup: Fix some contiguous memmap assumptions Matthew Wilcox (Oracle)
2022-01-10 8:29 ` Christoph Hellwig
2022-01-10 13:37 ` Matthew Wilcox
2022-01-10 19:05 ` [External] : " Mike Kravetz
2022-01-11 1:47 ` John Hubbard
2022-01-10 4:23 ` [PATCH v2 07/28] gup: Remove an assumption of a contiguous memmap Matthew Wilcox (Oracle)
2022-01-10 8:30 ` Christoph Hellwig
2022-01-11 3:27 ` John Hubbard
2022-01-10 4:23 ` [PATCH v2 08/28] gup: Handle page split race more efficiently Matthew Wilcox (Oracle)
2022-01-10 8:31 ` Christoph Hellwig
2022-01-11 3:30 ` John Hubbard
2022-01-10 4:23 ` [PATCH v2 09/28] gup: Turn hpage_pincount_add() into page_pincount_add() Matthew Wilcox (Oracle)
2022-01-10 8:31 ` Christoph Hellwig
2022-01-11 3:35 ` John Hubbard
2022-01-11 4:32 ` John Hubbard
2022-01-11 13:46 ` Matthew Wilcox
2022-01-10 4:23 ` [PATCH v2 10/28] gup: Turn hpage_pincount_sub() into page_pincount_sub() Matthew Wilcox (Oracle)
2022-01-10 8:32 ` Christoph Hellwig
2022-01-11 6:40 ` John Hubbard
2022-01-10 4:23 ` [PATCH v2 11/28] mm: Make compound_pincount always available Matthew Wilcox (Oracle)
2022-01-11 4:06 ` John Hubbard
2022-01-11 4:38 ` Matthew Wilcox
2022-01-11 5:10 ` John Hubbard
2022-01-20 9:15 ` Christoph Hellwig
2022-01-10 4:23 ` [PATCH v2 12/28] mm: Add folio_put_refs() Matthew Wilcox (Oracle)
2022-01-10 8:32 ` Christoph Hellwig
2022-01-11 4:14 ` John Hubbard
2022-01-10 4:23 ` [PATCH v2 13/28] mm: Add folio_pincount_ptr() Matthew Wilcox (Oracle)
2022-01-10 8:33 ` Christoph Hellwig
2022-01-11 4:22 ` John Hubbard
2022-01-10 4:23 ` [PATCH v2 14/28] mm: Convert page_maybe_dma_pinned() to use a folio Matthew Wilcox (Oracle)
2022-01-10 8:33 ` Christoph Hellwig
2022-01-11 4:27 ` John Hubbard
2022-01-10 4:23 ` [PATCH v2 15/28] gup: Add try_get_folio() and try_grab_folio() Matthew Wilcox (Oracle)
2022-01-10 8:34 ` Christoph Hellwig
2022-01-11 5:00 ` John Hubbard
2022-01-10 4:23 ` [PATCH v2 16/28] mm: Remove page_cache_add_speculative() and page_cache_get_speculative() Matthew Wilcox (Oracle)
2022-01-10 8:35 ` Christoph Hellwig
2022-01-11 5:14 ` John Hubbard
2022-01-10 4:23 ` [PATCH v2 17/28] gup: Add gup_put_folio() Matthew Wilcox (Oracle)
2022-01-10 8:35 ` Christoph Hellwig
2022-01-11 6:44 ` John Hubbard
2022-01-10 4:23 ` [PATCH v2 18/28] hugetlb: Use try_grab_folio() instead of try_grab_compound_head() Matthew Wilcox (Oracle)
2022-01-10 8:36 ` Christoph Hellwig
2022-01-11 6:47 ` John Hubbard
2022-01-10 4:23 ` [PATCH v2 19/28] gup: Convert try_grab_page() to call try_grab_folio() Matthew Wilcox (Oracle)
2022-01-10 8:36 ` Christoph Hellwig
2022-01-11 7:01 ` John Hubbard
2022-01-10 4:23 ` [PATCH v2 20/28] gup: Convert gup_pte_range() to use a folio Matthew Wilcox (Oracle)
2022-01-10 8:37 ` Christoph Hellwig
2022-01-11 7:06 ` John Hubbard
2022-01-10 4:23 ` [PATCH v2 21/28] gup: Convert gup_hugepte() " Matthew Wilcox (Oracle)
2022-01-10 8:37 ` Christoph Hellwig
2022-01-11 7:33 ` John Hubbard
2022-01-10 4:24 ` [PATCH v2 22/28] gup: Convert gup_huge_pmd() " Matthew Wilcox (Oracle)
2022-01-10 8:37 ` Christoph Hellwig
2022-01-11 7:36 ` John Hubbard
2022-01-10 4:24 ` [PATCH v2 23/28] gup: Convert gup_huge_pud() " Matthew Wilcox (Oracle)
2022-01-10 8:38 ` Christoph Hellwig
2022-01-11 7:38 ` John Hubbard
2022-01-10 4:24 ` [PATCH v2 24/28] gup: Convert gup_huge_pgd() " Matthew Wilcox (Oracle)
2022-01-10 8:38 ` Christoph Hellwig
2022-01-11 7:38 ` John Hubbard
2022-01-10 4:24 ` [PATCH v2 25/28] gup: Convert compound_next() to gup_folio_next() Matthew Wilcox (Oracle)
2022-01-10 8:39 ` Christoph Hellwig
2022-01-11 7:41 ` John Hubbard
2022-01-10 4:24 ` [PATCH v2 26/28] gup: Convert compound_range_next() to gup_folio_range_next() Matthew Wilcox (Oracle)
2022-01-10 8:41 ` Christoph Hellwig
2022-01-10 13:41 ` Matthew Wilcox
2022-01-11 7:44 ` John Hubbard [this message]
2022-01-10 4:24 ` [PATCH v2 27/28] mm: Add isolate_lru_folio() Matthew Wilcox (Oracle)
2022-01-10 8:42 ` Christoph Hellwig
2022-01-11 7:49 ` John Hubbard
2022-01-10 4:24 ` [PATCH v2 28/28] gup: Convert check_and_migrate_movable_pages() to use a folio Matthew Wilcox (Oracle)
2022-01-10 8:42 ` Christoph Hellwig
2022-01-11 7:52 ` John Hubbard
2022-01-10 15:31 ` [PATCH v2 00/28] Convert GUP to folios Jason Gunthorpe
2022-01-10 16:09 ` Matthew Wilcox
2022-01-10 17:26 ` William Kucharski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=280540de-99bb-91f0-1850-1efe828e4b45@nvidia.com \
--to=jhubbard@nvidia.com \
--cc=hch@infradead.org \
--cc=jgg@ziepe.ca \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=william.kucharski@oracle.com \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox