From: "Kasireddy, Vivek" <vivek.kasireddy@intel.com>
To: David Hildenbrand <david@redhat.com>,
John Hubbard <jhubbard@nvidia.com>,
Alistair Popple <apopple@nvidia.com>,
Jason Gunthorpe <jgg@nvidia.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: Christoph Hellwig <hch@infradead.org>,
LKML <linux-kernel@vger.kernel.org>,
"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"Marciniszyn, Mike" <mike.marciniszyn@intel.com>,
Leon Romanovsky <leon@kernel.org>,
Artemy Kovalyov <artemyko@nvidia.com>,
Michael Guralnik <michaelgur@nvidia.com>,
Pak Markthub <pmarkthub@nvidia.com>
Subject: RE: [RFC] RDMA/umem: pin_user_pages*() can temporarily fail due to migration glitches
Date: Sat, 11 May 2024 00:32:19 +0000 [thread overview]
Message-ID: <IA0PR11MB7185E9238489E5AE829E587FF8E02@IA0PR11MB7185.namprd11.prod.outlook.com> (raw)
In-Reply-To: <f7511bd9-edc7-4ad7-ba1f-2920d7d94517@redhat.com>
Hi David,
>
> On 02.05.24 20:10, John Hubbard wrote:
> > On 5/1/24 11:56 PM, David Hildenbrand wrote:
> >> On 02.05.24 03:05, Alistair Popple wrote:
> >>> Jason Gunthorpe <jgg@nvidia.com> writes:
> > ...
> >>>>> This doesn't make sense. IFF a blind retry is all that is needed
> >>>>> it should be done in the core functionality. I fear it's not that
> >>>>> easy, though.
> >>>>
> >>>> +1
> >>>>
> >>>> This migration retry weirdness is a GUP issue, it needs to be
> >>>> solved in the mm not exposed to every pin_user_pages caller.
> >>>>
> >>>> If it turns out ZONE_MOVEABLE pages can't actually be reliably
> >>>> moved then it is pretty broken..
> >>>
> >>> I wonder if we should remove the arbitrary retry limit in
> >>> migrate_pages() entirely for ZONE_MOVEABLE pages and just loop until
> >>> they migrate? By definition there should only be transient
> >>> references on these pages so why do we need to limit the number of
> >>> retries in the first place?
> >>
> >> There are some weird things that still needs fixing: vmsplice() is
> >> the example that doesn't use FOLL_LONGTERM.
> >>
> >
> > Hi David!
> >
>
> Sorry for the late reply!
>
> > Do you have any other call sites in mind? It sounds like one way
> > forward is to fix each call site...
>
> We also have udmabuf, that is currently getting fixed [1] similarly to how we
> handle GUP. Could you and/or Jason also have a look at the GUP-related
> bits? I acked it but the patch set does not seem to make progress.
>
> https://lkml.kernel.org/r/20240411070157.3318425-1-vivek.kasireddy@intel.com
I am hoping Andrew would pick this series up for the upcoming 6.10 cycle given
that most patches have Acks and I was planning to maintain the udmabuf bits.
Thanks,
Vivek
>
> The sad story is:
>
> (a) vmsplice() is harder to fix (identify all put_page() and replace them by
> unpin_user_page()), but will get fixed at some point.
>
> (b) even !longterm DMA can take double-digit seconds
>
> (c) other wrong code is likely to exist or to appear again and it's
> rather hard to identify+prevent reliably
>
> IMHO we should expect migration to take a longer time and maybe never
> happening in some cases.
>
> Memory offlining (e.g., echo "offline" >
> sys/devices/system/memory/memory0/state) currently tries forever to
> migrate pages and can be killed if started from user space using a fatal signal.
> If memory offlining happens from kernel context (unplugging DIMM, ACPI
> code triggers offlining), we'd much rather want to fail at some point instead
> of looping forever, but it hasn't really popped up as a problem so far.
>
> virtio-mem uses alloc_contig_range() for best-effort allocation and will skip
> such temporarily unmovable ranges to try again later. Here, we really don't
> want to loop forever in migration code but rather fail earlier and try unplug
> of another memory block.
>
> So as long as page pinning is triggered from user context where the user can
> simply abort the process (e.g., kill the process), sleep+retry on
> ZONE_MOVABLE + MIGRATE_CMA sounds reasonable.
>
> >
> > This is an unhappy story right now: the pin_user_pages*() APIs are
> > significantly worse than before the "migrate pages away automatically"
> > upgrade, from a user point of view. Because now, the APIs fail
> > intermittently for callers who follow the rules--because
> > pin_user_pages() is not fully working yet, basically.
> >
> > Other ideas, large or small, about how to approach a fix?
>
> What Jason says makes sense to me: sleep+retry. My only concern is when
> pin_user_pages_*() is called from non-killable context where failing at some
> point might be more reasonable. But maybe that use case doesn't really
> exist?
>
> --
> Cheers,
>
> David / dhildenb
prev parent reply other threads:[~2024-05-11 0:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-01 0:31 [RFC] RDMA/umem: pin_user_pages*() can temporarily fail due to migration glitches John Hubbard
2024-05-01 5:10 ` Christoph Hellwig
2024-05-01 12:10 ` Jason Gunthorpe
2024-05-01 17:32 ` John Hubbard
2024-05-02 1:05 ` Alistair Popple
2024-05-02 6:49 ` John Hubbard
2024-05-02 6:56 ` David Hildenbrand
2024-05-02 18:10 ` John Hubbard
2024-05-02 18:34 ` Jason Gunthorpe
2024-05-02 18:44 ` Matthew Wilcox
2024-05-10 7:54 ` David Hildenbrand
2024-05-11 0:32 ` Kasireddy, Vivek [this message]
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=IA0PR11MB7185E9238489E5AE829E587FF8E02@IA0PR11MB7185.namprd11.prod.outlook.com \
--to=vivek.kasireddy@intel.com \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=artemyko@nvidia.com \
--cc=david@redhat.com \
--cc=hch@infradead.org \
--cc=jgg@nvidia.com \
--cc=jhubbard@nvidia.com \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-rdma@vger.kernel.org \
--cc=michaelgur@nvidia.com \
--cc=mike.marciniszyn@intel.com \
--cc=pmarkthub@nvidia.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).