From: David Hildenbrand <david@redhat.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: "Kasireddy, Vivek" <vivek.kasireddy@intel.com>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
Christoph Hellwig <hch@infradead.org>,
Daniel Vetter <daniel.vetter@ffwll.ch>,
Mike Kravetz <mike.kravetz@oracle.com>,
Hugh Dickins <hughd@google.com>, Peter Xu <peterx@redhat.com>,
Gerd Hoffmann <kraxel@redhat.com>,
"Kim, Dongwon" <dongwon.kim@intel.com>,
"Chang, Junxiao" <junxiao.chang@intel.com>
Subject: Re: [PATCH v6 3/5] mm/gup: Introduce memfd_pin_user_pages() for pinning memfd pages (v6)
Date: Thu, 7 Dec 2023 14:35:43 +0100 [thread overview]
Message-ID: <5e9ca410-3273-493b-bb8a-8496ab0879c0@redhat.com> (raw)
In-Reply-To: <20231207130532.GH2692119@nvidia.com>
On 07.12.23 14:05, Jason Gunthorpe wrote:
> On Thu, Dec 07, 2023 at 10:44:14AM +0100, David Hildenbrand wrote:
>
>>>> If you always want to return folios, then better name it
>>>> "memfd_pin_user_folios" (or just "memfd_pin_folios") and pass in a range
>>>> (instead of a nr_pages parameter), and somehow indicate to the caller
>>>> how many folio were in that range, and if that range was fully covered.
>>> I think it makes sense to return folios from this interface; and considering my
>>> use-case, I'd like have this API return an error if it cannot pin (or allocate)
>>> the exact number of folios the caller requested.
>>
>> Okay, then better use folios.
>>
>> Assuming a caller puts in "start = X" and gets some large folio back. How is
>> the caller supposed to know at which offset to look into that folio (IOW<
>> which subpage)? For "pages" it was obvious (you get the actual subpages),
>> but as soon as we return a large folio, some information is missing for the
>> caller.
>>
>> How can the caller figure that out?
>
> This can only work if the memfd is required to only have full folios
> at aligned locations. Under that restriction computing the first folio
> offset is easy enough:
>
> folio offset = (start % folio size)
>
> But is that true for the memfds here?
I assume folios are always naturally aligned, like:
[ 2m ][ 2m ][1m][1m][ 2m ]
^f0 ^f1 ^f2 ^f3 ^f4
If you query the range "3m -> 7m", you get back f1,f2,f3,f4 and have to
start in the middle of the first folio with offset 1m. From there, it is
indeed simply continuing with the full folio size -- until the last
folio, where you want to only process 1m.
folio offset = (1m % 2m)
would be correct in that case.
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2023-12-07 13:35 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-05 5:35 [PATCH v6 0/5] " Vivek Kasireddy
2023-12-05 5:35 ` [PATCH v6 1/5] udmabuf: Use vmf_insert_pfn and VM_PFNMAP for handling mmap Vivek Kasireddy
2023-12-05 5:35 ` [PATCH v6 2/5] udmabuf: Add back support for mapping hugetlb pages (v5) Vivek Kasireddy
2023-12-06 9:16 ` Christoph Hellwig
2023-12-05 5:35 ` [PATCH v6 3/5] mm/gup: Introduce memfd_pin_user_pages() for pinning memfd pages (v6) Vivek Kasireddy
2023-12-06 9:18 ` Christoph Hellwig
2023-12-07 5:06 ` Kasireddy, Vivek
2023-12-06 11:19 ` David Hildenbrand
2023-12-07 5:09 ` Kasireddy, Vivek
2023-12-07 9:44 ` David Hildenbrand
2023-12-07 13:05 ` Jason Gunthorpe
2023-12-07 13:35 ` David Hildenbrand [this message]
2023-12-08 7:57 ` Kasireddy, Vivek
2023-12-08 9:53 ` David Hildenbrand
2023-12-05 5:35 ` [PATCH v6 4/5] udmabuf: Pin the pages using memfd_pin_user_pages() API (v4) Vivek Kasireddy
2023-12-05 5:35 ` [PATCH v6 5/5] selftests/dma-buf/udmabuf: Add tests to verify data after page migration Vivek Kasireddy
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=5e9ca410-3273-493b-bb8a-8496ab0879c0@redhat.com \
--to=david@redhat.com \
--cc=daniel.vetter@ffwll.ch \
--cc=dongwon.kim@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=hch@infradead.org \
--cc=hughd@google.com \
--cc=jgg@nvidia.com \
--cc=junxiao.chang@intel.com \
--cc=kraxel@redhat.com \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
--cc=peterx@redhat.com \
--cc=vivek.kasireddy@intel.com \
/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