From: Matthew Wilcox <willy@infradead.org>
To: Vivek Kasireddy <vivek.kasireddy@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>,
Dongwon Kim <dongwon.kim@intel.com>,
David Hildenbrand <david@redhat.com>,
Daniel Vetter <daniel.vetter@ffwll.ch>,
Hugh Dickins <hughd@google.com>,
dri-devel@lists.freedesktop.org, linux-mm@kvack.org,
Peter Xu <peterx@redhat.com>, Jason Gunthorpe <jgg@nvidia.com>,
Junxiao Chang <junxiao.chang@intel.com>,
Mike Kravetz <mike.kravetz@oracle.com>
Subject: Re: [PATCH v7 4/6] udmabuf: Convert udmabuf driver to use folios
Date: Wed, 13 Dec 2023 18:00:31 +0000 [thread overview]
Message-ID: <ZXnxP5tsL0TWyo43@casper.infradead.org> (raw)
In-Reply-To: <20231212073803.3233055-5-vivek.kasireddy@intel.com>
On Mon, Dec 11, 2023 at 11:38:01PM -0800, Vivek Kasireddy wrote:
> @@ -42,7 +42,7 @@ static vm_fault_t udmabuf_vm_fault(struct vm_fault *vmf)
> if (pgoff >= ubuf->pagecount)
> return VM_FAULT_SIGBUS;
>
> - pfn = page_to_pfn(ubuf->pages[pgoff]);
> + pfn = page_to_pfn(&ubuf->folios[pgoff]->page);
We have folio_pfn().
> static int vmap_udmabuf(struct dma_buf *buf, struct iosys_map *map)
> {
> struct udmabuf *ubuf = buf->priv;
> + struct page **pages;
> void *vaddr;
> + pgoff_t pg;
>
> dma_resv_assert_held(buf->resv);
>
> - vaddr = vm_map_ram(ubuf->pages, ubuf->pagecount, -1);
> + pages = kmalloc_array(ubuf->pagecount, sizeof(*pages), GFP_KERNEL);
> + if (!pages)
> + return -ENOMEM;
> +
> + for (pg = 0; pg < ubuf->pagecount; pg++)
> + pages[pg] = &ubuf->folios[pg]->page;
> +
> + vaddr = vm_map_ram(pages, ubuf->pagecount, -1);
> + kfree(pages);
We don't yet have a vm_map_ram() variant that takes an array of
folios. We probably should; there was _something_ I was looking at
recently that would have liked it ...
> @@ -254,31 +262,70 @@ static int handle_shmem_pages(struct udmabuf *ubuf, struct file *memfd,
> pgoff_t *pgbuf)
> {
> pgoff_t pgidx, pgoff = offset >> PAGE_SHIFT;
> - struct page *page;
> + struct folio *folio = NULL;
>
> for (pgidx = 0; pgidx < pgcnt; pgidx++) {
> - page = shmem_read_mapping_page(memfd->f_mapping,
> - pgoff + pgidx);
> - if (IS_ERR(page))
> - return PTR_ERR(page);
> + folio = shmem_read_folio(memfd->f_mapping,
> + pgoff + pgidx);
You could join these two lines.
WARNING: multiple messages have this Message-ID (diff)
From: Matthew Wilcox <willy@infradead.org>
To: Vivek Kasireddy <vivek.kasireddy@intel.com>
Cc: dri-devel@lists.freedesktop.org, linux-mm@kvack.org,
David Hildenbrand <david@redhat.com>,
Daniel Vetter <daniel.vetter@ffwll.ch>,
Mike Kravetz <mike.kravetz@oracle.com>,
Hugh Dickins <hughd@google.com>, Peter Xu <peterx@redhat.com>,
Jason Gunthorpe <jgg@nvidia.com>,
Gerd Hoffmann <kraxel@redhat.com>,
Dongwon Kim <dongwon.kim@intel.com>,
Junxiao Chang <junxiao.chang@intel.com>
Subject: Re: [PATCH v7 4/6] udmabuf: Convert udmabuf driver to use folios
Date: Wed, 13 Dec 2023 18:00:31 +0000 [thread overview]
Message-ID: <ZXnxP5tsL0TWyo43@casper.infradead.org> (raw)
In-Reply-To: <20231212073803.3233055-5-vivek.kasireddy@intel.com>
On Mon, Dec 11, 2023 at 11:38:01PM -0800, Vivek Kasireddy wrote:
> @@ -42,7 +42,7 @@ static vm_fault_t udmabuf_vm_fault(struct vm_fault *vmf)
> if (pgoff >= ubuf->pagecount)
> return VM_FAULT_SIGBUS;
>
> - pfn = page_to_pfn(ubuf->pages[pgoff]);
> + pfn = page_to_pfn(&ubuf->folios[pgoff]->page);
We have folio_pfn().
> static int vmap_udmabuf(struct dma_buf *buf, struct iosys_map *map)
> {
> struct udmabuf *ubuf = buf->priv;
> + struct page **pages;
> void *vaddr;
> + pgoff_t pg;
>
> dma_resv_assert_held(buf->resv);
>
> - vaddr = vm_map_ram(ubuf->pages, ubuf->pagecount, -1);
> + pages = kmalloc_array(ubuf->pagecount, sizeof(*pages), GFP_KERNEL);
> + if (!pages)
> + return -ENOMEM;
> +
> + for (pg = 0; pg < ubuf->pagecount; pg++)
> + pages[pg] = &ubuf->folios[pg]->page;
> +
> + vaddr = vm_map_ram(pages, ubuf->pagecount, -1);
> + kfree(pages);
We don't yet have a vm_map_ram() variant that takes an array of
folios. We probably should; there was _something_ I was looking at
recently that would have liked it ...
> @@ -254,31 +262,70 @@ static int handle_shmem_pages(struct udmabuf *ubuf, struct file *memfd,
> pgoff_t *pgbuf)
> {
> pgoff_t pgidx, pgoff = offset >> PAGE_SHIFT;
> - struct page *page;
> + struct folio *folio = NULL;
>
> for (pgidx = 0; pgidx < pgcnt; pgidx++) {
> - page = shmem_read_mapping_page(memfd->f_mapping,
> - pgoff + pgidx);
> - if (IS_ERR(page))
> - return PTR_ERR(page);
> + folio = shmem_read_folio(memfd->f_mapping,
> + pgoff + pgidx);
You could join these two lines.
next prev parent reply other threads:[~2023-12-13 18:00 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-12 7:37 [PATCH v7 0/6] mm/gup: Introduce memfd_pin_folios() for pinning memfd folios (v7) Vivek Kasireddy
2023-12-12 7:37 ` Vivek Kasireddy
2023-12-12 7:37 ` [PATCH v7 1/6] udmabuf: Use vmf_insert_pfn and VM_PFNMAP for handling mmap Vivek Kasireddy
2023-12-12 7:37 ` Vivek Kasireddy
2023-12-12 7:37 ` [PATCH v7 2/6] udmabuf: Add back support for mapping hugetlb pages (v6) Vivek Kasireddy
2023-12-12 7:37 ` Vivek Kasireddy
2023-12-12 7:38 ` [PATCH v7 3/6] mm/gup: Introduce memfd_pin_folios() for pinning memfd folios (v7) Vivek Kasireddy
2023-12-12 7:38 ` Vivek Kasireddy
2023-12-12 12:13 ` David Hildenbrand
2023-12-12 12:13 ` David Hildenbrand
2023-12-13 8:44 ` Kasireddy, Vivek
2023-12-13 8:44 ` Kasireddy, Vivek
2023-12-13 12:31 ` Jason Gunthorpe
2023-12-13 12:31 ` Jason Gunthorpe
2023-12-13 15:36 ` Christoph Hellwig
2023-12-13 17:06 ` Jason Gunthorpe
2023-12-13 17:06 ` Jason Gunthorpe
2023-12-13 15:15 ` David Hildenbrand
2023-12-13 15:15 ` David Hildenbrand
2023-12-12 13:21 ` kernel test robot
2023-12-12 13:21 ` kernel test robot
2023-12-12 15:27 ` kernel test robot
2023-12-12 15:27 ` kernel test robot
2023-12-12 7:38 ` [PATCH v7 4/6] udmabuf: Convert udmabuf driver to use folios Vivek Kasireddy
2023-12-12 7:38 ` Vivek Kasireddy
2023-12-13 18:00 ` Matthew Wilcox [this message]
2023-12-13 18:00 ` Matthew Wilcox
2023-12-12 7:38 ` [PATCH v7 5/6] udmabuf: Pin the pages using memfd_pin_folios() API (v5) Vivek Kasireddy
2023-12-12 7:38 ` Vivek Kasireddy
2023-12-13 18:03 ` Matthew Wilcox
2023-12-13 18:03 ` Matthew Wilcox
2023-12-12 7:38 ` [PATCH v7 6/6] selftests/dma-buf/udmabuf: Add tests to verify data after page migration Vivek Kasireddy
2023-12-12 7:38 ` Vivek Kasireddy
2023-12-12 12:15 ` [PATCH v7 0/6] mm/gup: Introduce memfd_pin_folios() for pinning memfd folios (v7) David Hildenbrand
2023-12-12 12:15 ` 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=ZXnxP5tsL0TWyo43@casper.infradead.org \
--to=willy@infradead.org \
--cc=daniel.vetter@ffwll.ch \
--cc=david@redhat.com \
--cc=dongwon.kim@intel.com \
--cc=dri-devel@lists.freedesktop.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 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.