linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* Mirroring process address space on device
@ 2016-03-16 17:10 Olu Ogunbowale
  2016-03-16 17:10 ` [PATCH] mm: Export symbols unmapped_area() & unmapped_area_topdown() Olu Ogunbowale
  0 siblings, 1 reply; 10+ messages in thread
From: Olu Ogunbowale @ 2016-03-16 17:10 UTC (permalink / raw)
  To: linux-mm
  Cc: linux-kernel, Linus Torvalds, Michel Lespinasse, Andrew Morton,
	Rik van Riel, Hugh Dickins, Russell King, Ralf Baechle,
	Paul Mundt, David S. Miller, Chris Metcalf, Ingo Molnar,
	Thomas Gleixner, H. Peter Anvin, Olu Ogunbowale

In a nutshell:

Export the memory management functions, unmapped_area() &
unmapped_area_topdown(), as GPL symbols; this allows the kernel to
better support process address space mirroring on both CPU and device
for out-of-tree drivers by allowing the use of vm_unmapped_area() in a
driver's file operation get_unmapped_area().

This is required by drivers that want to control or limit a process VMA
range into which shared-virtual-memory (SVM) buffers are mapped during
an mmap() call in order to ensure that said SVM VMA does not collide
with any pre-existing VMAs used by non-buffer regions on the device
because SVM buffers must have identical VMAs on both CPU and device.

Exporting these functions is particularly useful for graphics devices as
SVM support is required by the OpenCL & HSA specifications and also SVM
support for 64-bit CPUs where the useable device SVM address range
is/maybe a subset of the full 64-bit range of the CPU. Exporting also
avoids the need to duplicate the VMA search code in such drivers.

Why do this:

The OpenCL API & Heterogeneous System Architecture (HSA) specifications
requires mirroring a process address space on both the CPU and GPU, a so
called shared-virtual-memory (SVM) support wherein the same virtual
address is used to address the same content on both the CPU and GPU.

There are different levels of support from coarse to fine-grained with
slightly different semantics (1: coarse-grained buffer SVM, 2:
fine-grained buffer SVM & 3: fine-grained system SVM); furthermore
support for the highest level, fine-grained system SVM, is optional and
this fact is central to the need for this requirement as explained
below.

For hardware & drivers implementing support for SVM up to the second
level only, i.e. fine-grained buffer SVM level, this mirroring is
effectively at a buffer allocation level and therefore excludes the need
for any heterogeneous memory management (HMM) like functionality which
is required to support SVM up to the highest level, i.e. fine-grained
system SVM (see http://lwn.net/Articles/597289/ for details). In this
case, drivers would benefit from being able to specify/control the SVM
VMA range during a mmap() call especially if the device SVM VMA range is
a subset of the full 32-bit/64-bit CPU (process/mmap) range.

As the kernel already provides a char driver
file->f_op->get_unmapped_area() entry point for this, the backend of
such a call would require a constrained search for an unmapped address
range using vm_unmapped_area() which currently calls into either
unmapped_area() or  unmapped_area_topdown() both of which are not
currently exported symbols. Therefore, exporting these symbols allows
the kerne to provide better support this type of process address space
and it also avoids duplicating the VMA search code in these drivers.

As always, comments are welcome and many thanks in advance for
consideration.

Olu Ogunbowale (1):
  mm: Export symbols unmapped_area() & unmapped_area_topdown()

 mm/mmap.c | 4 ++++
 1 file changed, 4 insertions(+)

-- 
2.7.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2016-03-17 17:42 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-16 17:10 Mirroring process address space on device Olu Ogunbowale
2016-03-16 17:10 ` [PATCH] mm: Export symbols unmapped_area() & unmapped_area_topdown() Olu Ogunbowale
2016-03-16 20:36   ` Christoph Hellwig
2016-03-16 21:00     ` Rik van Riel
2016-03-17  7:24       ` Ingo Molnar
2016-03-17 14:37   ` Jerome Glisse
2016-03-17 15:38     ` Oded Gabbay
2016-03-17 15:46     ` Olu Ogunbowale
2016-03-17 17:03       ` Jerome Glisse
2016-03-17 17:42         ` Olu Ogunbowale

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