From: Jerome Glisse <jglisse@redhat.com>
To: Thomas Hellstrom <thellstrom@vmware.com>
Cc: "dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
Linux-graphics-maintainer <Linux-graphics-maintainer@vmware.com>,
Andrew Morton <akpm@linux-foundation.org>,
Matthew Wilcox <willy@infradead.org>,
Will Deacon <will.deacon@arm.com>,
Peter Zijlstra <peterz@infradead.org>,
Rik van Riel <riel@surriel.com>, Minchan Kim <minchan@kernel.org>,
Michal Hocko <mhocko@suse.com>, Huang Ying <ying.huang@intel.com>,
Souptick Joarder <jrdr.linux@gmail.com>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [RFC PATCH RESEND 0/3] mm modifications / helpers for emulated GPU coherent memory
Date: Thu, 21 Mar 2019 09:46:04 -0400 [thread overview]
Message-ID: <20190321134603.GB2904@redhat.com> (raw)
In-Reply-To: <20190321132140.114878-1-thellstrom@vmware.com>
On Thu, Mar 21, 2019 at 01:22:22PM +0000, Thomas Hellstrom wrote:
> Resending since last series was sent through a mis-configured SMTP server.
>
> Hi,
> This is an early RFC to make sure I don't go too far in the wrong direction.
>
> Non-coherent GPUs that can't directly see contents in CPU-visible memory,
> like VMWare's SVGA device, run into trouble when trying to implement
> coherent memory requirements of modern graphics APIs. Examples are
> Vulkan and OpenGL 4.4's ARB_buffer_storage.
>
> To remedy, we need to emulate coherent memory. Typically when it's detected
> that a buffer object is about to be accessed by the GPU, we need to
> gather the ranges that have been dirtied by the CPU since the last operation,
> apply an operation to make the content visible to the GPU and clear the
> the dirty tracking.
>
> Depending on the size of the buffer object and the access pattern there are
> two major possibilities:
>
> 1) Use page_mkwrite() and pfn_mkwrite(). (GPU buffer objects are backed
> either by PCI device memory or by driver-alloced pages).
> The dirty-tracking needs to be reset by write-protecting the affected ptes
> and flush tlb. This has a complexity of O(num_dirty_pages), but the
> write page-fault is of course costly.
>
> 2) Use hardware dirty-flags in the ptes. The dirty-tracking needs to be reset
> by clearing the dirty bits and flush tlb. This has a complexity of
> O(num_buffer_object_pages) and dirty bits need to be scanned in full before
> each gpu-access.
>
> So in practice the two methods need to be interleaved for best performance.
>
> So to facilitate this, I propose two new helpers, apply_as_wrprotect() and
> apply_as_clean() ("as" stands for address-space) both inspired by
> unmap_mapping_range(). Users of these helpers are in the making, but needs
> some cleaning-up.
To be clear this should _only be use_ for mmap of device file ? If so
the API should try to enforce that as much as possible for instance by
mandating the file as argument so that the function can check it is
only use in that case. Also big scary comment to make sure no one just
start using those outside this very limited frame.
>
> There's also a change to x_mkwrite() to allow dropping the mmap_sem while
> waiting.
This will most likely conflict with userfaultfd write protection. Maybe
building your thing on top of that would be better.
https://lwn.net/Articles/783571/
I will take a cursory look at the patches.
Cheers,
Jérôme
next prev parent reply other threads:[~2019-03-21 13:46 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-21 13:22 Thomas Hellstrom
2019-03-21 13:22 ` [RFC PATCH RESEND 1/3] mm: Allow the [page|pfn]_mkwrite callbacks to drop the mmap_sem Thomas Hellstrom
2019-03-21 13:22 ` [RFC PATCH RESEND 2/3] mm: Add an apply_to_pfn_range interface Thomas Hellstrom
2019-03-21 13:52 ` Jerome Glisse
2019-03-21 19:59 ` Thomas Hellstrom
2019-03-21 20:24 ` Jerome Glisse
2019-03-21 13:22 ` [RFC PATCH RESEND 3/3] mm: Add write-protect and clean utilities for address space ranges Thomas Hellstrom
2019-03-21 14:12 ` Jerome Glisse
2019-03-21 20:29 ` Thomas Hellstrom
2019-03-21 21:07 ` Jerome Glisse
2019-03-21 13:46 ` Jerome Glisse [this message]
2019-03-21 19:51 ` [RFC PATCH RESEND 0/3] mm modifications / helpers for emulated GPU coherent memory Thomas Hellstrom
2019-03-21 20:28 ` Jerome Glisse
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=20190321134603.GB2904@redhat.com \
--to=jglisse@redhat.com \
--cc=Linux-graphics-maintainer@vmware.com \
--cc=akpm@linux-foundation.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jrdr.linux@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=minchan@kernel.org \
--cc=peterz@infradead.org \
--cc=riel@surriel.com \
--cc=thellstrom@vmware.com \
--cc=will.deacon@arm.com \
--cc=willy@infradead.org \
--cc=ying.huang@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