From: Steven Sistare <steven.sistare@oracle.com>
To: David Hildenbrand <david@redhat.com>, linux-mm@kvack.org
Cc: Jason Gunthorpe <jgg@nvidia.com>,
Kevin Tian <kevin.tian@intel.com>,
Nicolin Chen <nicolinc@nvidia.com>,
iommu@lists.linux.dev, Andrew Morton <akpm@linux-foundation.org>,
Matthew Wilcox <willy@infradead.org>
Subject: Re: [PATCH V1 1/9] mm/gup: repin_folio_unhugely
Date: Wed, 18 Sep 2024 10:51:21 -0400 [thread overview]
Message-ID: <98004c8e-f941-480e-b1be-8f6fd925871a@oracle.com> (raw)
In-Reply-To: <6aea6530-9f9c-4a9c-9c9c-2c29e8ae9e9d@redhat.com>
On 9/17/2024 8:25 AM, David Hildenbrand wrote:
> On 14.09.24 15:19, Steven Sistare wrote:
>> cc'ing linux-mm for review of this one patch of the series.
>>
>> This proposes a new KAPI function repin_folio_unhugely(), for use in this
>> patch of the iommu_ioas_map_file series:
>>
>> iommufd: IOMMU_IOAS_MAP_FILE implementation
>> https://lore.kernel.org/linux-iommu/1726319158-283074-7-git-send-email-steven.sistare@oracle.com
>>
>> - Steve
>>
>> On 9/14/2024 9:05 AM, Steve Sistare wrote:
>>> Export a function that repins a huge-page folio at small-page granularity.
>>> This allows any range of small pages within the folio to be unpinned later.
>>> For example, pages pinned via memfd_pin_folios and modified by
>>> repin_folio_unhugely could be unpinned via unpin_user_page(s).
>>>
>>> Suggested-by: Jason Gunthorpe <jgg@nvidia.com>
>>> Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
>>> ---
>>> include/linux/mm.h | 1 +
>>> mm/gup.c | 18 ++++++++++++++++++
>>> 2 files changed, 19 insertions(+)
>>>
>>> diff --git a/include/linux/mm.h b/include/linux/mm.h
>>> index 1470736..ba8344f 100644
>>> --- a/include/linux/mm.h
>>> +++ b/include/linux/mm.h
>>> @@ -2514,6 +2514,7 @@ long pin_user_pages_unlocked(unsigned long start, unsigned long nr_pages,
>>> long memfd_pin_folios(struct file *memfd, loff_t start, loff_t end,
>>> struct folio **folios, unsigned int max_folios,
>>> pgoff_t *offset);
>>> +void repin_folio_unhugely(struct folio *folio, unsigned long npin);
>>> int get_user_pages_fast(unsigned long start, int nr_pages,
>>> unsigned int gup_flags, struct page **pages);
>>> diff --git a/mm/gup.c b/mm/gup.c
>>> index 947881ff..f8f3f2a 100644
>>> --- a/mm/gup.c
>>> +++ b/mm/gup.c
>>> @@ -3720,3 +3720,21 @@ long memfd_pin_folios(struct file *memfd, loff_t start, loff_t end,
>>> return ret;
>>> }
>>> EXPORT_SYMBOL_GPL(memfd_pin_folios);
>>> +
>>> +/**
>>> + * repin_folio_unhugely() - repin a folio at small page granularity
>>> + * @folio: the folio to repin
>>> + * @npin: the number of pages pinned in the folio
>>> + *
>>> + * Given a huge page folio that is already pinned, and the number of small
>
> s/huge page folio/large folio/
>
>>> + * pages that are pinned in it, adjust the pincount to reflect small-page
>>> + * granularity. Each small page can later be unpinned individually.
>>> + */
>>> +void repin_folio_unhugely(struct folio *folio, unsigned long npin)
>>> +{
>>> + if (!folio_test_large(folio) || is_huge_zero_folio(folio) || npin == 1)
>
> Why not the huge zero folio? That looks very odd here.
The zero page is treated specially here and elsewhere, it can never be deleted so
reference fiddling is skipped.
>>> + return;
>>> + atomic_add(npin - 1, &folio->_refcount);
>>> + atomic_add(npin - 1, &folio->_pincount);
>>> +}
>>> +EXPORT_SYMBOL_GPL(repin_folio_unhugely);
>
> Can we ... find a better name? For example, it's "large" folio not "huge"...
>
> And repin is really misleading. We are simply adding more pins to an already pinned one ...
Jason suggests a better name in the other thread.
- Steve
next prev parent reply other threads:[~2024-09-18 14:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1726319158-283074-1-git-send-email-steven.sistare@oracle.com>
[not found] ` <1726319158-283074-2-git-send-email-steven.sistare@oracle.com>
2024-09-14 13:19 ` Steven Sistare
2024-09-17 12:25 ` David Hildenbrand
2024-09-18 14:51 ` Steven Sistare [this message]
2024-09-19 8:11 ` David Hildenbrand
2024-09-19 21:06 ` Steven Sistare
2024-09-26 11:38 ` David Hildenbrand
2024-09-20 13:28 ` Jason Gunthorpe
2024-09-26 11:32 ` David Hildenbrand
2024-09-26 11:40 ` Jason Gunthorpe
2024-09-26 12:57 ` David Hildenbrand
2024-09-26 12:58 ` David Hildenbrand
[not found] ` <ZudFcANtENlaRJ+r@nvidia.com>
2024-09-18 14:51 ` Steven Sistare
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=98004c8e-f941-480e-b1be-8f6fd925871a@oracle.com \
--to=steven.sistare@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=kevin.tian@intel.com \
--cc=linux-mm@kvack.org \
--cc=nicolinc@nvidia.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