linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Steven Sistare <steven.sistare@oracle.com>
To: David Hildenbrand <david@redhat.com>, Jason Gunthorpe <jgg@nvidia.com>
Cc: linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
	Matthew Wilcox <willy@infradead.org>
Subject: Re: [PATCH V2] mm/gup: folio_split_user_page_pin
Date: Fri, 4 Oct 2024 13:20:00 -0400	[thread overview]
Message-ID: <9dc54dbf-18b3-43f9-af4f-39ce44406ebe@oracle.com> (raw)
In-Reply-To: <210cb725-fdc5-4878-9e6b-4357d34afb9f@redhat.com>

On 10/4/2024 6:04 AM, David Hildenbrand wrote:
> On 01.10.24 19:17, Steven Sistare wrote:
>> On 9/27/2024 11:58 AM, Jason Gunthorpe wrote:
>>> On Fri, Sep 27, 2024 at 05:44:52PM +0200, David Hildenbrand wrote:
>>>> /**
>>>>    * folio_try_add_pins() - add pins to an already-pinned folio
>>>>    * @folio: the folio to add more pins to
>>>>    *
>>>>    * Try to add more pins to an already-pinned folio. The semantics
>>>>    * of the pin (e.g., FOLL_WRITE) follow any existing pin and cannot
>>>>    * be changed.
>>>>    *
>>>>    * This function is helpful when having obtained a pin on a large folio
>>>>    * using memfd_pin_folios(), but wanting to logically unpin parts
>>>>    * (e.g., individual pages) of the folio later, for example, using
>>>>    * unpin_user_page_range_dirty_lock().
>>>>    *
>>>>    * This is not the right interface to initially pin a folio.
>>>>    */
>>>> int folio_try_add_pins(struct folio *folio, unsigned int pins)
>>>> {
>>>>     VM_WARN_ON_ONCE(!folio_maybe_dma_pinned(folio));
>>>>
>>>>     return try_grab_folio(folio, pins, FOLL_PIN);
>>>> }
>>>
>>> That looks pretty good to me too
>>
>> Looks good and passes my tests, I will add this version in V3 of the patch series.
>>
>> Are you sure you want "try" in the name folio_try_add_pins?  Usually try means
>> that any failure is transient and a future call may succeed
> 
> And now I took another look at the codebase and we already do have folio_add_pin() that adds a single pin, but continues on overflows (not sure I like that, but at least it can be caught and debugged).
> 
> So yes, we could simply turn folio_add_pin() into a wrapper around a folio_add_pins() that adds multiple pins.
> Looking at folio_add_pin() vs. try_grab_folio() I am not sure if the open-coding the logic in folio_add_pin() got the NR_FOLL_PIN_ACQUIRED accounting correct.

To be clear, I am only suggesting that I use your folio_try_add_pins implementation, but
rename it to folio_add_pins.  And not touch the existing folio_add_pin.

I am ready to send V3 of the iommu_ioas_map_file series, and I would like to add this
patch back to the series as Jason requested.

- Steve



  reply	other threads:[~2024-10-04 17:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-24 15:05 Steve Sistare
2024-09-24 16:55 ` Jason Gunthorpe
2024-09-27 15:44 ` David Hildenbrand
2024-09-27 15:58   ` Jason Gunthorpe
2024-10-01 17:17     ` Steven Sistare
2024-10-04 10:04       ` David Hildenbrand
2024-10-04 17:20         ` Steven Sistare [this message]
2024-10-04 20:19           ` 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=9dc54dbf-18b3-43f9-af4f-39ce44406ebe@oracle.com \
    --to=steven.sistare@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=jgg@nvidia.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox