From: David Hildenbrand <david@redhat.com>
To: Vivek Kasireddy <vivek.kasireddy@intel.com>,
dri-devel@lists.freedesktop.org, linux-mm@kvack.org
Cc: Matthew Wilcox <willy@infradead.org>,
Christoph Hellwig <hch@infradead.org>,
Jason Gunthorpe <jgg@nvidia.com>, Peter Xu <peterx@redhat.com>
Subject: Re: [PATCH v12 1/8] mm/gup: Introduce unpin_folio/unpin_folios helpers
Date: Tue, 2 Apr 2024 16:14:09 +0200 [thread overview]
Message-ID: <17756b00-b051-40de-afa2-c3df97de755f@redhat.com> (raw)
In-Reply-To: <54381897-35bc-442d-951d-b9a89f16b1a5@redhat.com>
On 02.04.24 15:52, David Hildenbrand wrote:
> On 25.02.24 08:56, Vivek Kasireddy wrote:
>> These helpers are the folio versions of unpin_user_page/unpin_user_pages.
>> They are currently only useful for unpinning folios pinned by
>> memfd_pin_folios() or other associated routines. However, they could
>> find new uses in the future, when more and more folio-only helpers
>> are added to GUP.
>>
>> Cc: David Hildenbrand <david@redhat.com>
>> Cc: Matthew Wilcox <willy@infradead.org>
>> Cc: Christoph Hellwig <hch@infradead.org>
>> Cc: Jason Gunthorpe <jgg@nvidia.com>
>> Cc: Peter Xu <peterx@redhat.com>
>> Suggested-by: David Hildenbrand <david@redhat.com>
>> Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
>> ---
>> include/linux/mm.h | 2 ++
>> mm/gup.c | 81 ++++++++++++++++++++++++++++++++++++++++------
>> 2 files changed, 74 insertions(+), 9 deletions(-)
>>
>> diff --git a/include/linux/mm.h b/include/linux/mm.h
>> index 6f4825d82965..36e4c2b22600 100644
>> --- a/include/linux/mm.h
>> +++ b/include/linux/mm.h
>> @@ -1601,11 +1601,13 @@ static inline void put_page(struct page *page)
>> #define GUP_PIN_COUNTING_BIAS (1U << 10)
>>
>> void unpin_user_page(struct page *page);
>> +void unpin_folio(struct folio *folio);
>> void unpin_user_pages_dirty_lock(struct page **pages, unsigned long npages,
>> bool make_dirty);
>> void unpin_user_page_range_dirty_lock(struct page *page, unsigned long npages,
>> bool make_dirty);
>> void unpin_user_pages(struct page **pages, unsigned long npages);
>> +void unpin_folios(struct folio **folios, unsigned long nfolios);
>>
>> static inline bool is_cow_mapping(vm_flags_t flags)
>> {
>> diff --git a/mm/gup.c b/mm/gup.c
>> index df83182ec72d..0a45eda6aaeb 100644
>> --- a/mm/gup.c
>> +++ b/mm/gup.c
>> @@ -30,6 +30,23 @@ struct follow_page_context {
>> unsigned int page_mask;
>> };
>>
>> +static inline void sanity_check_pinned_folios(struct folio **folios,
>> + unsigned long nfolios)
>> +{
>> + if (!IS_ENABLED(CONFIG_DEBUG_VM))
>> + return;
>> +
>> + for (; nfolios; nfolios--, folios++) {
>> + struct folio *folio = *folios;
>> +
>> + if (is_zero_folio(folio) ||
>> + !folio_test_anon(folio))
>> + continue;
>> +
>> + VM_BUG_ON_FOLIO(!PageAnonExclusive(&folio->page), folio);
>
> That change is wrong (and the split makes the check confusing).
>
> It could be that the first subpage is no longer exclusive, but the given
> (sanity_check_pinned_pages() ) subpage is exclusive for large folios.
>
> I suggest dropping that change, and instead, in
> unpin_folio()/unpin_folios(), reject any anon folios for now.
>
> So, replace the sanity_check_pinned_folios() in unpin_folio() /
> unpin_folios() by a VM_WARN_ON(folio_test_anon(folio));
After reading patch #2: drop both the sanity check and VM_WARN_ON() from
unpin_folio()/unpin_folios(), and add a comment to the patch description
that we cannot do the sanity checking without the subpage, and that we
can reintroduce it once we have a single per-folio AnonExclusive bit.
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2024-04-02 14:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-25 7:56 [PATCH v12 0/8] mm/gup: Introduce memfd_pin_folios() for pinning memfd folios Vivek Kasireddy
2024-02-25 7:56 ` [PATCH v12 1/8] mm/gup: Introduce unpin_folio/unpin_folios helpers Vivek Kasireddy
[not found] ` <54381897-35bc-442d-951d-b9a89f16b1a5@redhat.com>
2024-04-02 14:14 ` David Hildenbrand [this message]
2024-02-25 7:56 ` [PATCH v12 2/8] mm/gup: Introduce check_and_migrate_movable_folios() Vivek Kasireddy
2024-04-02 14:26 ` David Hildenbrand
2024-02-25 7:56 ` [PATCH v12 3/8] mm/gup: Introduce memfd_pin_folios() for pinning memfd folios Vivek Kasireddy
2024-02-25 7:57 ` [PATCH v12 4/8] udmabuf: Use vmf_insert_pfn and VM_PFNMAP for handling mmap Vivek Kasireddy
2024-02-25 7:57 ` [PATCH v12 5/8] udmabuf: Add back support for mapping hugetlb pages Vivek Kasireddy
2024-02-25 7:57 ` [PATCH v12 6/8] udmabuf: Convert udmabuf driver to use folios Vivek Kasireddy
2024-02-25 7:57 ` [PATCH v12 7/8] udmabuf: Pin the pages using memfd_pin_folios() API Vivek Kasireddy
2024-02-25 7:57 ` [PATCH v12 8/8] selftests/udmabuf: Add tests to verify data after page migration Vivek Kasireddy
2024-03-26 16:12 ` [PATCH v12 0/8] mm/gup: Introduce memfd_pin_folios() for pinning memfd folios David Hildenbrand
2024-03-29 5:38 ` Kasireddy, Vivek
2024-03-29 11:42 ` David Hildenbrand
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=17756b00-b051-40de-afa2-c3df97de755f@redhat.com \
--to=david@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=hch@infradead.org \
--cc=jgg@nvidia.com \
--cc=linux-mm@kvack.org \
--cc=peterx@redhat.com \
--cc=vivek.kasireddy@intel.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