From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: Dave Airlie <airlied@gmail.com>,
Shashank Sharma <shashank.sharma@amd.com>
Cc: alexander.deucher@amd.com,
Shashank Sharma <contactshashanksharma@gmail.com>,
christian.koenig@amd.com, amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH 0/8] AMDGPU usermode queues
Date: Mon, 6 Feb 2023 09:57:29 +0100 [thread overview]
Message-ID: <109edfda-3fd9-6bfb-97ec-752b583572cf@gmail.com> (raw)
In-Reply-To: <CAPM=9tzTKj3M_tKiwvSyN+jKsYFbE2yRvjgMkZGmGdUWabnwiA@mail.gmail.com>
Am 06.02.23 um 01:52 schrieb Dave Airlie:
> On Sat, 4 Feb 2023 at 07:54, Shashank Sharma <shashank.sharma@amd.com> wrote:
>> From: Shashank Sharma <contactshashanksharma@gmail.com>
>>
>> This patch series introduces AMDGPU usermode graphics queues.
>> User queues is a method of GPU workload submission into the graphics
>> hardware without any interaction with kernel/DRM schedulers. In this
>> method, a userspace graphics application can create its own workqueue
>> and submit it directly in the GPU HW.
>>
>> The general idea of how this is supposed to work:
>> - The application creates the following GPU objetcs:
>> - A queue object to hold the workload packets.
>> - A read pointer object.
>> - A write pointer object.
>> - A doorbell page.
>> - Kernel picks any 32-bit offset in the doorbell page for this queue.
>> - The application uses the usermode_queue_create IOCTL introduced in
>> this patch, by passing the the GPU addresses of these objects (read
>> ptr, write ptr, queue base address and doorbell address)
>> - The kernel creates the queue and maps it in the HW.
>> - The application can start submitting the data in the queue as soon as
>> the kernel IOCTL returns.
>> - Once the data is filled in the queue, the app must write the number of
>> dwords in the doorbell offset, and the GPU will start fetching the data.
> So I just have one question about forward progress here, let's call it
> the 51% of VRAM problem.
>
> You have two apps they both have working sets that allocate > 51% of VRAM.
Marek and I have been working on this quite extensively.
> Application (a) has the VRAM and mapping for the user queues and is
> submitting work
> Application (b) wants to submit work, it has no queue mapping as it
> was previously evicted, does (b) have to call an ioctl to get it's
> mapping back?
Long story short: No, but that's a bit more complicated to explain.
> When (b) calls the ioctl (a) loses it mapping. Control returns to (b),
> but before it submits any work on the ring mapping it has, (a) gets
> control and notices it has no queues, so calls the ioctl, and (b)
> loses it mapping, and around and around they go never making forward
> progress.
>
> What's the exit strategy for something like that, fall back to kernel
> submit so you can get a memory objects validated and submit some work?
First of all the fw makes sure that processes can only be evicted after
they used up their time slice. So when you have two processes fighting
over a shared resource (can be memory, locks or whatever) they will
always get until the end of their time slice before they are pushed away
from the hw.
Then when a process is evicted we take a look at what the process has
already scheduled as work on the hw. If the process isn't idle we start
a delayed work item to get it going again (similar to what the KFD is
doing at the moment). When the process is idle we unmap the doorbell
page(s) from the CPU and wait for the page fault which signals that the
process wants to submit something again.
And the last component is a static resource management which distributes
the available resources equally between the different active processes
fighting over them. Activity of a process is determined by the periodic
interrupts send by the hw for running processes.
I call the memory management algorithm based on this Robin Hood
(https://drive.google.com/file/d/1vIrX37c3B2IgWFtZ2UpeKxh0-YMlV6NU/view)
and simulated that a bit in some spread sheets, but it isn't fully
implemented yet. I'm working on this for a couple of years now and
slowly pushing DRM/TTM into the direction we need for this to work.
Christian.
>
> Dave.
next prev parent reply other threads:[~2023-02-06 8:57 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-03 21:54 [PATCH 0/8] AMDGPU usermode queues Shashank Sharma
2023-02-03 21:54 ` [PATCH 1/8] drm/amdgpu: UAPI for user queue management Shashank Sharma
2023-02-03 22:07 ` Alex Deucher
2023-02-03 22:26 ` Shashank Sharma
2023-02-06 16:56 ` Alex Deucher
2023-02-06 17:01 ` Christian König
2023-02-06 21:03 ` Alex Deucher
2023-02-07 7:03 ` Christian König
2023-02-07 7:38 ` Shashank Sharma
2023-02-07 14:07 ` Alex Deucher
2023-02-07 14:11 ` Christian König
2023-02-07 14:17 ` Alex Deucher
2023-02-07 14:19 ` Christian König
2023-02-07 14:20 ` Alex Deucher
2023-02-07 14:36 ` Shashank Sharma
2023-02-03 21:54 ` [PATCH 2/8] drm/amdgpu: add usermode queues Shashank Sharma
2023-02-07 7:08 ` Christian König
2023-02-07 7:40 ` Shashank Sharma
2023-02-07 14:54 ` Alex Deucher
2023-02-07 15:02 ` Shashank Sharma
2023-02-03 21:54 ` [PATCH 3/8] drm/amdgpu: introduce userqueue MQD handlers Shashank Sharma
2023-02-07 7:11 ` Christian König
2023-02-07 7:41 ` Shashank Sharma
2023-02-07 14:59 ` Alex Deucher
2023-02-03 21:54 ` [PATCH 4/8] drm/amdgpu: Add V11 graphics MQD functions Shashank Sharma
2023-02-07 15:17 ` Alex Deucher
2023-02-07 15:43 ` Shashank Sharma
2023-02-07 16:05 ` Alex Deucher
2023-02-07 16:37 ` Shashank Sharma
2023-02-07 16:54 ` Alex Deucher
2023-02-07 17:13 ` Shashank Sharma
2023-02-07 17:57 ` Alex Deucher
2023-02-07 18:28 ` Shashank Sharma
2023-02-07 18:32 ` Alex Deucher
2023-02-03 21:54 ` [PATCH 5/8] drm/amdgpu: Create context for usermode queue Shashank Sharma
2023-02-07 7:14 ` Christian König
2023-02-07 7:51 ` Shashank Sharma
2023-02-07 7:55 ` Christian König
2023-02-07 8:13 ` Shashank Sharma
2023-02-07 16:51 ` Alex Deucher
2023-02-07 16:53 ` Alex Deucher
2023-02-03 21:54 ` [PATCH 6/8] drm/amdgpu: Map userqueue into HW Shashank Sharma
2023-02-07 7:20 ` Christian König
2023-02-07 7:55 ` Shashank Sharma
2023-02-03 21:54 ` [PATCH 7/8] drm/amdgpu: DO-NOT-MERGE add busy-waiting delay Shashank Sharma
2023-02-03 21:54 ` [PATCH 8/8] drm/amdgpu: DO-NOT-MERGE doorbell hack Shashank Sharma
2023-02-06 0:52 ` [PATCH 0/8] AMDGPU usermode queues Dave Airlie
2023-02-06 8:57 ` Christian König [this message]
2023-02-06 15:39 ` Michel Dänzer
2023-02-06 16:11 ` Alex Deucher
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=109edfda-3fd9-6bfb-97ec-752b583572cf@gmail.com \
--to=ckoenig.leichtzumerken@gmail.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=contactshashanksharma@gmail.com \
--cc=shashank.sharma@amd.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.