From: "Kasireddy, Vivek" <vivek.kasireddy@intel.com>
To: Andrew Morton <akpm@linux-foundation.org>, SeongJae Park <sj@kernel.org>
Cc: "dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
David Hildenbrand <david@redhat.com>,
Matthew Wilcox <willy@infradead.org>,
Christoph Hellwig <hch@infradead.org>,
Daniel Vetter <daniel.vetter@ffwll.ch>,
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>,
Jason Gunthorpe <jgg@nvidia.com>,
"Christoph Hellwig" <hch@lst.de>,
Dave Airlie <airlied@redhat.com>
Subject: RE: [PATCH v16 3/9] mm/gup: Introduce memfd_pin_folios() for pinning memfd folios
Date: Fri, 5 Jul 2024 22:11:14 +0000 [thread overview]
Message-ID: <IA0PR11MB7185570E3FCFAE3E7BDE7991F8DF2@IA0PR11MB7185.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20240705142320.000b1e520b856b7c034bc829@linux-foundation.org>
Hi Andrew and SJ,
>
> On Fri, 5 Jul 2024 13:48:25 -0700 SeongJae Park <sj@kernel.org> wrote:
>
> > > + * memfd_pin_folios() - pin folios associated with a memfd
> > [...]
> > > + for (i = 0; i < nr_found; i++) {
> > > + /*
> > > + * As there can be multiple entries for a
> > > + * given folio in the batch returned by
> > > + * filemap_get_folios_contig(), the below
> > > + * check is to ensure that we pin and return a
> > > + * unique set of folios between start and end.
> > > + */
> > > + if (next_idx &&
> > > + next_idx != folio_index(fbatch.folios[i]))
> > > + continue;
> > > +
> > > + folio = try_grab_folio(&fbatch.folios[i]->page,
> > > + 1, FOLL_PIN);
> > > + if (!folio) {
> > > + folio_batch_release(&fbatch);
> > > + ret = -EINVAL;
> > > + goto err;
> > > + }
> >
> > I found this patch is applied on mm-unstable as commit 7618d1ff59ef
> ("mm/gup:
> > introduce memfd_pin_folios() for pinning memfd folios"). Somehow,
> however, the
> > commit has changd the above try_grab_folio() call to try_grab_folio_fast()
> > call.
> >
> > As a result, building kernel without CONFIG_MMU fais as below:
> >
> > ...
> >
> > Maybe the change has made to fix conflict with another mm-unstable
> commit
> > 02a2d55767d1 ("mm: gup: stop abusing try_grab_folio"), but forgot the
> > CONFIG_MMU unset case?
>
> Yes. That patch didn't add a CONFIG_MMU=n version of
> try_grab_folio_fast(). Maybe it should have?
>
> > I confirmed the failure disappears after further cleanup like below:
> >
> > diff --git a/mm/gup.c b/mm/gup.c
> > index 46a266ed84f7..9f4902425070 100644
> > --- a/mm/gup.c
> > +++ b/mm/gup.c
> > @@ -3859,9 +3859,9 @@ long memfd_pin_folios(struct file *memfd, loff_t
> start, loff_t end,
> > next_idx != folio_index(fbatch.folios[i]))
> > continue;
> >
> > - folio = try_grab_folio_fast(&fbatch.folios[i]->page,
> > - 1, FOLL_PIN);
> > - if (!folio) {
> > + folio = page_folio(&fbatch.folios[i]->page);
> > +
> > + if (try_grab_folio(folio, 1, FOLL_PIN)) {
> > folio_batch_release(&fbatch);
> > ret = -EINVAL;
> > goto err;
> >
> > I didn't look deep into the patch, so unsure if that's a valid fix, though.
> > May I ask your thoughts?
>
> Perhaps we should propagate the errno which was returned by
> try_grab_folio()?
>
> I'll do it this way. Vivek, please check and let us know?
Yeah, memfd_pin_folios() doesn't need the fast version, so replacing with
the slow version (try_grab_folio) should be fine. And, as you suggest,
propagating the errno returned by try_grab_folio() would be the right thing
to do instead of explicitly setting errno to -EINVAL. Either way, this change is
Acked-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
Thanks,
Vivek
next prev parent reply other threads:[~2024-07-05 22:11 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-24 6:36 [PATCH v16 0/9] " Vivek Kasireddy
2024-06-24 6:36 ` [PATCH v16 1/9] mm/gup: Introduce unpin_folio/unpin_folios helpers Vivek Kasireddy
2024-06-24 6:36 ` [PATCH v16 2/9] mm/gup: Introduce check_and_migrate_movable_folios() Vivek Kasireddy
2024-06-24 6:36 ` [PATCH v16 3/9] mm/gup: Introduce memfd_pin_folios() for pinning memfd folios Vivek Kasireddy
2024-07-05 20:48 ` SeongJae Park
2024-07-05 21:23 ` Andrew Morton
2024-07-05 22:11 ` Kasireddy, Vivek [this message]
2024-07-05 22:55 ` Andrew Morton
2024-07-12 22:32 ` Andrew Morton
2024-07-14 2:30 ` Kasireddy, Vivek
2024-06-24 6:36 ` [PATCH v16 4/9] udmabuf: add CONFIG_MMU dependency Vivek Kasireddy
2024-06-24 6:36 ` [PATCH v16 5/9] udmabuf: Use vmf_insert_pfn and VM_PFNMAP for handling mmap Vivek Kasireddy
2024-06-24 6:36 ` [PATCH v16 6/9] udmabuf: Add back support for mapping hugetlb pages Vivek Kasireddy
2024-06-24 6:36 ` [PATCH v16 7/9] udmabuf: Convert udmabuf driver to use folios Vivek Kasireddy
2024-06-24 6:36 ` [PATCH v16 8/9] udmabuf: Pin the pages using memfd_pin_folios() API Vivek Kasireddy
2024-06-24 6:36 ` [PATCH v16 9/9] selftests/udmabuf: Add tests to verify data after page migration Vivek Kasireddy
2024-06-26 19:13 ` [PATCH v16 0/9] mm/gup: Introduce memfd_pin_folios() for pinning memfd folios Kasireddy, Vivek
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=IA0PR11MB7185570E3FCFAE3E7BDE7991F8DF2@IA0PR11MB7185.namprd11.prod.outlook.com \
--to=vivek.kasireddy@intel.com \
--cc=airlied@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=daniel.vetter@ffwll.ch \
--cc=david@redhat.com \
--cc=dongwon.kim@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=hch@infradead.org \
--cc=hch@lst.de \
--cc=hughd@google.com \
--cc=jgg@nvidia.com \
--cc=junxiao.chang@intel.com \
--cc=kraxel@redhat.com \
--cc=linux-mm@kvack.org \
--cc=peterx@redhat.com \
--cc=sj@kernel.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