dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Dave Airlie <airlied@gmail.com>
To: Faith Ekstrand <faith@gfxstrand.net>
Cc: matthew.brost@intel.com, willy@infradead.org,
	dri-devel@lists.freedesktop.org, corbet@lwn.net,
	nouveau@lists.freedesktop.org, ogabbay@kernel.org,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	mripard@kernel.org, boris.brezillon@collabora.com,
	Danilo Krummrich <dakr@redhat.com>,
	bskeggs@redhat.com, tzimmermann@suse.de, Liam.Howlett@oracle.com,
	bagasdotme@gmail.com, christian.koenig@amd.com,
	jason@jlekstrand.net, donald.robson@imgtec.com
Subject: Re: [PATCH drm-misc-next v8 11/12] drm/nouveau: implement new VM_BIND uAPI
Date: Mon, 24 Jul 2023 09:54:34 +1000	[thread overview]
Message-ID: <CAPM=9tyQQTn=+Af1kWySde75T=MLFeboTErLv3NxqtQ8pvqtzA@mail.gmail.com> (raw)
In-Reply-To: <CAOFGe945tp344=g-++=EAT89t0qJHZ=3yeW-k9OTbGNJodvwAg@mail.gmail.com>

On Sun, 23 Jul 2023 at 01:12, Faith Ekstrand <faith@gfxstrand.net> wrote:
>
> On Wed, Jul 19, 2023 at 7:15 PM Danilo Krummrich <dakr@redhat.com> wrote:
>>
>> This commit provides the implementation for the new uapi motivated by the
>> Vulkan API. It allows user mode drivers (UMDs) to:
>>
>> 1) Initialize a GPU virtual address (VA) space via the new
>>    DRM_IOCTL_NOUVEAU_VM_INIT ioctl for UMDs to specify the portion of VA
>>    space managed by the kernel and userspace, respectively.
>>
>> 2) Allocate and free a VA space region as well as bind and unbind memory
>>    to the GPUs VA space via the new DRM_IOCTL_NOUVEAU_VM_BIND ioctl.
>>    UMDs can request the named operations to be processed either
>>    synchronously or asynchronously. It supports DRM syncobjs
>>    (incl. timelines) as synchronization mechanism. The management of the
>>    GPU VA mappings is implemented with the DRM GPU VA manager.
>>
>> 3) Execute push buffers with the new DRM_IOCTL_NOUVEAU_EXEC ioctl. The
>>    execution happens asynchronously. It supports DRM syncobj (incl.
>>    timelines) as synchronization mechanism. DRM GEM object locking is
>>    handled with drm_exec.
>>
>> Both, DRM_IOCTL_NOUVEAU_VM_BIND and DRM_IOCTL_NOUVEAU_EXEC, use the DRM
>> GPU scheduler for the asynchronous paths.
>
>
> IDK where the best place to talk about this is but this seems as good as any.
>
> I've been looking into why the Vulkan CTS runs about 2x slower for me on the new UAPI and I created a little benchmark to facilitate testing:
>
> https://gitlab.freedesktop.org/mesa/crucible/-/merge_requests/141
>
> The test, roughly, does the following:
>  1. Allocates and binds 1000 BOs
>  2. Constructs a pushbuf that executes a no-op compute shader.
>  3. Does a single EXEC/wait combo to warm up the kernel
>  4. Loops 10,000 times, doing SYNCOBJ_RESET (fast), EXEC, and then SYNCOBJ_WAIT and times the loop
>
> Of course, there's a bit of userspace driver overhead but that's negledgable.
>
> If you drop the top patch which allocates 1k buffers, the submit time on the old uAPI is 54 us/exec vs. 66 us/exec on the new UAPI. This includes the time to do a SYNCOBJ_RESET (fast), EXEC, and SYNCOBJ_WAIT. The Intel driver, by comparison, is 33us/exec so it's not syncobj overhead. This is a bit concerning (you'd think the new thing would be faster) but what really has me concerned is the 1k buffer case.
>
> If you include the top patch in the crucible MR, it allocates 1000 BOs and VM_BINDs them. All the binding is done before the warmup EXEC. Suddenly, the submit time jumps to 257 us/exec with the new UAPI. The old UAPI is much worse (1134 us/exec) but that's not the point. Once we've done the first EXEC and created our VM bindings, the cost per EXEC shouldn't change at all based on the number of BOs bound.  Part of the point of VM_BIND is to get all that binding logic and BO walking off the EXEC path.
>
> Normally, I wouldn't be too worried about a little performance problem like this. This is the first implementation and we can improve it later. I get that. However, I suspect the solution to this problem involves more UAPI and I want to make sure we have it all before we call this all done and dusted and land it.
>
> The way AMD solves this problem as well as the new Xe driver for Intel is to have a concept of internal vs. external BOs. Basically, there's an INTERNAL bit specified somewhere in BO creation that has a few userspace implications:
>  1. In the Xe world where VMs are objects, INTERNAL BOs are assigned a VM on creation and can never be bound to any other VM.
>  2. Any attempt to export an INTERNAL BO via prime or a similar mechanism will fail with -EINVAL (I think?).

Okay I've done a first pass at implementing this,

https://gitlab.freedesktop.org/nouvelles/kernel/-/commit/005a0005ff80ec85f3e9a314cae0576b7441076c

Danilo we should probably pick that up for the next iteration. with
corresponding mesa work it gets the latency for me from 180us down to
70us.

Dave.

  reply	other threads:[~2023-07-23 23:54 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-20  0:14 [PATCH drm-misc-next v8 00/12] DRM GPUVA Manager & Nouveau VM_BIND UAPI Danilo Krummrich
2023-07-20  0:14 ` [PATCH drm-misc-next v8 01/12] drm: manager to keep track of GPUs VA mappings Danilo Krummrich
2023-07-20 10:44   ` Steven Price
2023-07-20 21:48     ` Danilo Krummrich
2023-07-28 11:31   ` Maxime Ripard
2023-07-28 12:26     ` Boris Brezillon
2023-07-31 12:04       ` Maxime Ripard
2023-07-20  0:14 ` [PATCH drm-misc-next v8 02/12] drm: debugfs: provide infrastructure to dump a DRM GPU VA space Danilo Krummrich
2023-07-20 10:51   ` Steven Price
2023-07-20  0:14 ` [PATCH drm-misc-next v8 03/12] drm/nouveau: new VM_BIND uapi interfaces Danilo Krummrich
2023-07-21 22:58   ` Faith Ekstrand
2023-07-25  2:03     ` Danilo Krummrich
2023-07-25 15:42       ` Faith Ekstrand
2023-07-20  0:14 ` [PATCH drm-misc-next v8 04/12] drm/nouveau: get vmm via nouveau_cli_vmm() Danilo Krummrich
2023-07-20  0:14 ` [PATCH drm-misc-next v8 05/12] drm/nouveau: bo: initialize GEM GPU VA interface Danilo Krummrich
2023-07-20  0:14 ` [PATCH drm-misc-next v8 06/12] drm/nouveau: move usercopy helpers to nouveau_drv.h Danilo Krummrich
2023-07-20  0:14 ` [PATCH drm-misc-next v8 07/12] drm/nouveau: fence: separate fence alloc and emit Danilo Krummrich
2023-07-20  0:14 ` [PATCH drm-misc-next v8 08/12] drm/nouveau: fence: fail to emit when fence context is killed Danilo Krummrich
2023-07-20  0:14 ` [PATCH drm-misc-next v8 09/12] drm/nouveau: chan: provide nouveau_channel_kill() Danilo Krummrich
2023-07-20  0:14 ` [PATCH drm-misc-next v8 10/12] drm/nouveau: nvkm/vmm: implement raw ops to manage uvmm Danilo Krummrich
2023-07-20  0:14 ` [PATCH drm-misc-next v8 11/12] drm/nouveau: implement new VM_BIND uAPI Danilo Krummrich
2023-07-22 15:12   ` Faith Ekstrand
2023-07-23 23:54     ` Dave Airlie [this message]
2023-07-25  2:04     ` Danilo Krummrich
2023-07-25 16:16       ` Faith Ekstrand
2023-07-25 16:43         ` Danilo Krummrich
2023-07-25 21:00           ` Danilo Krummrich
2023-07-31  3:30             ` Faith Ekstrand
2023-07-31 16:39               ` Faith Ekstrand
2023-07-20  0:14 ` [PATCH drm-misc-next v8 12/12] drm/nouveau: debugfs: implement DRM GPU VA debugfs Danilo Krummrich

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='CAPM=9tyQQTn=+Af1kWySde75T=MLFeboTErLv3NxqtQ8pvqtzA@mail.gmail.com' \
    --to=airlied@gmail.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=bagasdotme@gmail.com \
    --cc=boris.brezillon@collabora.com \
    --cc=bskeggs@redhat.com \
    --cc=christian.koenig@amd.com \
    --cc=corbet@lwn.net \
    --cc=dakr@redhat.com \
    --cc=donald.robson@imgtec.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=faith@gfxstrand.net \
    --cc=jason@jlekstrand.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew.brost@intel.com \
    --cc=mripard@kernel.org \
    --cc=nouveau@lists.freedesktop.org \
    --cc=ogabbay@kernel.org \
    --cc=tzimmermann@suse.de \
    --cc=willy@infradead.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).