From: David Hildenbrand <david@redhat.com>
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org
Subject: Re: [PATCH 5/7] gup: Use folios for gup_devmap
Date: Thu, 25 Apr 2024 11:49:01 +0200 [thread overview]
Message-ID: <3f317def-9690-44b5-8d17-9a31e6eee32a@redhat.com> (raw)
In-Reply-To: <20240424191914.361554-6-willy@infradead.org>
On 24.04.24 21:19, Matthew Wilcox (Oracle) wrote:
Nit: s/gup_devmap/gup_fast_devmap/
> Use try_grab_folio() instead of try_grab_page() so we get the folio
> back that we calculated, and then use folio_set_referenced() instead
> of SetPageReferenced(). Correspondingly, use gup_put_folio() to
> put any unneeded references.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
> mm/gup.c | 17 ++++++++---------
> 1 file changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/mm/gup.c b/mm/gup.c
> index 49376f756936..e4cc12b8e985 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -2877,13 +2877,10 @@ static void __maybe_unused gup_fast_undo_dev_pagemap(int *nr, int nr_start,
> unsigned int flags, struct page **pages)
> {
> while ((*nr) - nr_start) {
> - struct page *page = pages[--(*nr)];
> + struct folio *folio = page_folio(pages[--(*nr)]);
>
> - ClearPageReferenced(page);
I stumbled over that likely unwarranted ClearPageReferenced() recently
as well: what if the page was already referenced before we called
SetPageReferenced?
> - if (flags & FOLL_PIN)
> - unpin_user_page(page);
> - else
> - put_page(page);
> + folio_clear_referenced(folio);
> + gup_put_folio(folio, 1, flags);
For !FOLL_PIN, we wouldn't have done the
if (!put_devmap_managed_page_refs(&folio->page, refs))
folio_put_refs(folio, refs);
Magic in gup_put_folio()
... was that a BUG?
This devmap crap is so confusing.
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2024-04-25 9:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-24 19:19 [PATCH 0/7] More folio compat code removal Matthew Wilcox (Oracle)
2024-04-24 19:19 ` [PATCH 1/7] mm: Remove page_cache_alloc() Matthew Wilcox (Oracle)
2024-04-24 19:19 ` [PATCH 2/7] mm: Remove put_devmap_managed_page() Matthew Wilcox (Oracle)
2024-04-24 19:19 ` [PATCH 3/7] mm: Convert put_devmap_managed_page_refs() to put_devmap_managed_folio_refs() Matthew Wilcox (Oracle)
2024-04-24 19:19 ` [PATCH 4/7] mm: Remove page_ref_sub_return() Matthew Wilcox (Oracle)
2024-04-24 19:19 ` [PATCH 5/7] gup: Use folios for gup_devmap Matthew Wilcox (Oracle)
2024-04-25 9:49 ` David Hildenbrand [this message]
2024-04-25 12:43 ` Matthew Wilcox
2024-04-24 19:19 ` [PATCH 6/7] mm: Add kernel-doc for folio_mark_accessed() Matthew Wilcox (Oracle)
2024-04-24 19:19 ` [PATCH 7/7] mm: Remove PageReferenced Matthew Wilcox (Oracle)
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=3f317def-9690-44b5-8d17-9a31e6eee32a@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.