[Intel-gfx] [RFC] drm/i915: Extend CREATE_CONTEXT to allow inheritance ala clone()

Michał Winiarski michal.winiarski at intel.com
Tue Dec 19 12:15:39 UTC 2017


On Fri, Dec 15, 2017 at 01:20:17PM +0000, Chris Wilson wrote:
> A context encompasses the driver's view of process related state, and
> encapsulates the logical GPU state where available. Each context is
> currently equivalent to a process in CPU terms. Like with processes,
> sometimes the user wants a lighter encapsulation that shares some state
> with the parent process, for example two threads have unique register
> state but share the virtual memory mappings. We can support exactly the
> same principle using contexts where we may share the GTT but keep the
> logical GPU state distinct. This allows quicker switching between those
> contexts, and for userspace to allocate a single offset in the GTT and
> use it across multiple contexts. Like with clone(), in the future we may
> wish to allow userspace to select more features to copy across from the
> parent, but for now we only allow sharing of the GTT.

Our timelines are still per-vm and not per-ctx.
This means that schedule() will have slightly unexpected behavior when dealing
with two context of different priority sharing a VM.

-Michał

> 
> Note that if full per-process GTT is not supported on the harder, the
> GTT are already implicitly shared between contexts, and this request
> to create contexts with shared GTT fails. With full ppGTT, every fd
> (i.e. every process) is allocated a unique GTT so this request cannot be
> used to share GTT between processes/fds, it can only share GTT belonging
> to this fd.
> Testcase: igt/gem_ctx_shared
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
> Cc: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> Cc: Mika Kuoppala <mika.kuoppala at linux.intel.com>
> Cc: Michał Winiarski <michal.winiarski at intel.com>
> ---
>  drivers/gpu/drm/i915/i915_gem_context.c           |  62 ++++--
>  drivers/gpu/drm/i915/i915_gem_gtt.c               |   4 +-
>  drivers/gpu/drm/i915/i915_gem_gtt.h               |   1 -
>  drivers/gpu/drm/i915/selftests/huge_pages.c       |   1 -
>  drivers/gpu/drm/i915/selftests/i915_gem_context.c | 234 +++++++++++++++++-----
>  drivers/gpu/drm/i915/selftests/i915_gem_gtt.c     |   1 -
>  drivers/gpu/drm/i915/selftests/mock_context.c     |   2 +-
>  include/uapi/drm/i915_drm.h                       |  11 +-
>  8 files changed, 241 insertions(+), 75 deletions(-)


More information about the Intel-gfx mailing list