From: Jason Gunthorpe <jgg@ziepe.ca>
To: John Hubbard <jhubbard@nvidia.com>
Cc: "Chris Wilson" <chris@chris-wilson.co.uk>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
intel-gfx@lists.freedesktop.org,
"Andrew Morton" <akpm@linux-foundation.org>,
"Jan Kara" <jack@suse.cz>, "Jérôme Glisse" <jglisse@redhat.com>,
"Claudio Imbrenda" <imbrenda@linux.ibm.com>,
"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>
Subject: Re: [PATCH] mm: Skip opportunistic reclaim for dma pinned pages
Date: Wed, 24 Jun 2020 20:20:47 -0300 [thread overview]
Message-ID: <20200624232047.GP6578@ziepe.ca> (raw)
In-Reply-To: <44708b2e-479f-7d58-fe01-29cfd6c70bdb@nvidia.com>
On Wed, Jun 24, 2020 at 01:47:23PM -0700, John Hubbard wrote:
> On 2020-06-24 12:21, Jason Gunthorpe wrote:
> > On Wed, Jun 24, 2020 at 08:14:17PM +0100, Chris Wilson wrote:
> > > A general rule of thumb is that shrinkers should be fast and effective.
> > > They are called from direct reclaim at the most incovenient of times when
> > > the caller is waiting for a page. If we attempt to reclaim a page being
> > > pinned for active dma [pin_user_pages()], we will incur far greater
> > > latency than a normal anonymous page mapped multiple times. Worse the
> > > page may be in use indefinitely by the HW and unable to be reclaimed
> > > in a timely manner.
> >
> > A pinned page can't be migrated, discarded or swapped by definition -
> > it would cause data corruption.
> >
> > So, how do things even get here and/or work today at all? I think the
> > explanation is missing something important.
> >
>
> Well, those activities generally try to unmap the page, and
> have to be prepared to deal with failure to unmap. From my reading,
> it seemed very clear.
I think Yang explained it - the page is removed from the mappings but
freeing it does not happen because page_ref_freeze() does not succeed
due to the pin.
Presumably the mappings can reconnect to the same physical page if
it is re-faulted to avoid any data corruption.
So, the issue here is the mappings are trashed while the page remains
- and trashing the mapping triggers a mmu notifier which upsets i915.
> What's less clear is why the comment and the commit description
> only talk about reclaim, when there are additional things that call
> try_to_unmap(), including:
>
> migrate_vma_unmap()
> split_huge_page_to_list() --> unmap_page()
It looks like the same unmap first then abort if the refcount is still
elevated design as shrink_page_list() ?
> I do like this code change, though. And I *think* it's actually safe to
> do this, as it stays away from writeback or other filesystem activity.
> But let me double check that, in case I'm forgetting something.
It would be nice to have an explanation why it is OK now to change
it..
I don't know, but could it be that try_to_unmap() has to be done
before checking the refcount as each mapping is included in the
refcount? ie we couldn't know a DMA pin was active in advance?
Now that we have your pin stuff we can detect a DMA pin without doing
all the unmaps?
Jason
next prev parent reply other threads:[~2020-06-24 23:20 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-24 19:14 [PATCH] mm: Skip opportunistic reclaim for dma pinned pages Chris Wilson
2020-06-24 19:21 ` Jason Gunthorpe
2020-06-24 20:23 ` Yang Shi
2020-06-24 21:02 ` Yang Shi
2020-06-24 20:47 ` John Hubbard
2020-06-24 23:20 ` Jason Gunthorpe [this message]
2020-06-25 0:11 ` John Hubbard
2020-06-25 11:24 ` Jan Kara
2020-06-25 7:57 ` Michal Hocko
[not found] ` <159308284703.4527.16058577374955415124@build.alporthouse.com>
2020-06-25 15:12 ` Michal Hocko
2020-06-25 11:42 ` Matthew Wilcox
2020-06-25 13:40 ` Jan Kara
2020-06-25 16:05 ` Matthew Wilcox
2020-06-25 16:32 ` Yang Shi
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=20200624232047.GP6578@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=akpm@linux-foundation.org \
--cc=chris@chris-wilson.co.uk \
--cc=imbrenda@linux.ibm.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jack@suse.cz \
--cc=jglisse@redhat.com \
--cc=jhubbard@nvidia.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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;
as well as URLs for NNTP newsgroup(s).