public inbox for linux-mm@kvack.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@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>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Dongwon Kim <dongwon.kim@intel.com>,
	Junxiao Chang <junxiao.chang@intel.com>,
	Jason Gunthorpe <jgg@nvidia.com>
Subject: Re: [PATCH v5 3/5] mm/gup: Introduce pin_user_pages_fd() for pinning shmem/hugetlbfs file pages (v5)
Date: Tue, 28 Nov 2023 01:12:47 -0800	[thread overview]
Message-ID: <ZWWvD4B4hurV62gH@infradead.org> (raw)
In-Reply-To: <20231123064443.1035709-4-vivek.kasireddy@intel.com>

> +static struct page *alloc_file_page(struct file *file, pgoff_t idx)

alloc_file_pages seems like a weird name for something that assumes
it is called either on a hugetlbfs or shmemfs file (without any
asserts that this is true).  gup.c also seems like a very odd place
for such a helper.

> + * Attempt to pin pages associated with a file that belongs to either shmem
> + * or hugetlb.

Why do we need a special case for hugetlb or shmemfs?

> +	if (!file)
> +	    return -EINVAL;
> +
> +	if (!shmem_file(file) && !is_file_hugepages(file))
> +	    return -EINVAL;

Indentation is messed up here.

> +		for (i = 0; i < nr_pages; i++) {
> +			/*
> + 			 * In most cases, we should be able to find the page
> +			 * in the page cache. If we cannot find it, we try to
> +			 * allocate one and add it to the page cache.
> +			 */
> +retry:
> +			folio = __filemap_get_folio(file->f_mapping,
> +						    start + i,
> +						    FGP_ACCESSED, 0);

__filemap_get_folio is a very inefficient way to find a
contiguous range of folios, I'd suggest to look into something that
batches instead.

> +			page = IS_ERR(folio) ? NULL: &folio->page;
> +			if (!page) {
> +				page = alloc_file_page(file, start + i);
> +				if (IS_ERR(page)) {
> +					ret = PTR_ERR(page);
> +					if (ret == -EEXIST)
> +						goto retry;
> +					goto err;
> +				}

This mix of folios and pages is odd.  Especially as hugetlbfs by
definitions uses large folios.



  reply	other threads:[~2023-11-28  9:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-23  6:44 [PATCH v5 0/5] mm/gup: Introduce pin_user_pages_fd() for pinning shmem/hugetlbfs file pages (v5) Vivek Kasireddy
2023-11-23  6:44 ` [PATCH v5 1/5] udmabuf: Use vmf_insert_pfn and VM_PFNMAP for handling mmap Vivek Kasireddy
2023-11-23  6:44 ` [PATCH v5 2/5] udmabuf: Add back support for mapping hugetlb pages (v4) Vivek Kasireddy
2023-11-23  6:44 ` [PATCH v5 3/5] mm/gup: Introduce pin_user_pages_fd() for pinning shmem/hugetlbfs file pages (v5) Vivek Kasireddy
2023-11-28  9:12   ` Christoph Hellwig [this message]
2023-11-30  6:41     ` Kasireddy, Vivek
2023-12-04  8:16       ` Christoph Hellwig
2023-12-04  9:05         ` David Hildenbrand
2023-11-23  6:44 ` [PATCH v5 4/5] udmabuf: Pin the pages using pin_user_pages_fd() API (v3) Vivek Kasireddy
2023-11-23  6:44 ` [PATCH v5 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=ZWWvD4B4hurV62gH@infradead.org \
    --to=hch@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox