linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH RESEND 0/3] mm modifications / helpers for emulated GPU coherent memory
@ 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
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Thomas Hellstrom @ 2019-03-21 13:22 UTC (permalink / raw)
  To: dri-devel, Linux-graphics-maintainer
  Cc: Thomas Hellstrom, Andrew Morton, Matthew Wilcox, Will Deacon,
	Peter Zijlstra, Rik van Riel, Minchan Kim, Michal Hocko,
	Huang Ying, Souptick Joarder, Jérôme Glisse, linux-mm,
	linux-kernel

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@surriel.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Huang Ying <ying.huang@intel.com>
Cc: Souptick Joarder <jrdr.linux@gmail.com>
Cc: "Jérôme Glisse" <jglisse@redhat.com>
Cc: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org

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.

There's also a change to x_mkwrite() to allow dropping the mmap_sem while
waiting.

Any comments or suggestions appreciated.

Thanks,
Thomas




^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2019-03-21 21:07 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-21 13:22 [RFC PATCH RESEND 0/3] mm modifications / helpers for emulated GPU coherent memory 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 ` [RFC PATCH RESEND 0/3] mm modifications / helpers for emulated GPU coherent memory Jerome Glisse
2019-03-21 19:51   ` Thomas Hellstrom
2019-03-21 20:28     ` Jerome Glisse

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).