All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Deucher <alexdeucher@gmail.com>
To: Peter Maucher <bellosilicio@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: Difference GART/GTT and related questions
Date: Mon, 10 Oct 2022 10:05:09 -0400	[thread overview]
Message-ID: <CADnq5_MfSNHP--KyQe2GEWCvg4XAwLV5FAw+0B-0DwvXBcACtw@mail.gmail.com> (raw)
In-Reply-To: <fa9d4fe7-9b3b-678c-f014-96008877de45@gmail.com>

On Sat, Oct 8, 2022 at 7:14 AM Peter Maucher <bellosilicio@gmail.com> wrote:
>
> Hi dri-devel,
>
> what is the difference between GTT and GART for AMD GPUs?
>  From what I gathered when looking through the mailing list archives and
> the freedesktop docs [1] as well as wikipedia [2],
> these terms seem to be synonymous, but that can not be the whole truth
> (different sizes in dmesg log, different kernel parameters in
> amdgpu/radeon, ...).
>
> As far as I understand it currently,
> the size of the GART is depending on some HW/ASIC functionality [3].
> On the other hand, I was successfully able to increase the size of the
> GART mapping(?) from 512MB to 1024MB by using amdgpu.gartsize=1024 on my
> RX 6600, and booting the system.
>
> GTT, on the other hand, is the maximum amount of system memory visible
> to the GPU, shared between all processes connected to the GPU.
> As I understand it, using GPUVM, each process can have one or more GARTs
> for mapping?
> Apparently, there is also something called a GART table window,
> what's up with that?
>
> Also, according to what I found in the mailing list archives,
> the GPUVM functionality "replaces" old GART with new GART features,
> so what is the difference and what exactly is GPUVM?
> If I understood correctly, GPUVM is a MMU using page tables on the GPU?
>
> And, additionally, the addresses translated by the GART(s) are
> optionally translated once more by the PCIe IOMMU,
> as the former is located on the GPU and the latter is in the CPU's PCIe
> root complex?
> Wikipedia mentions something about (another?) GART in an AMD IOMMU...
>
> Lastly, do any of these numbers influence what the longest contiguous
> mapping is for one buffer to the GPU?
> As in: can I map 95% or so of the available (GART/GTT?) space into one
> buffer and have the GPU work on it?

Modern AMD GPUs have multiple GPU virtual address spaces (GPU Virtual
Memory -- GPUVM) that can be active at any given time.  Each address
space is designated by a token called a VMID (Virtual Memory ID).  The
kernel driver uses one of these IDs for its own memory management.
The others are used dynamically for user processes.  It's pretty much
like virtual memory on a CPU, but because the GPU has really deep
pipelines, we have the concept of multiple address spaces being active
at any given time denoted by the VMIDs.  The GPU also has lots of
asynchronous engines (graphics, compute, transfer, media, etc.). E.g.,
if you have two user applications using the GPU at the same time and
the GPU kernel driver is moving some memory, you'd have 3 different
virtual address spaces that need to be active at the same time.  For
example, when the kernel driver submits a user job to the gfx engine,
it tells the engine which VMID (and hence GPUVM address space) it
should use for that job

GART defines the amount of platform address space (system memory or
MMIO space) that the GPU kernel driver can have mapped into the GPU's
virtual address space used by the kernel driver.  The kernel driver
generally doesn't need that much system space to be mapped at any
given time so we keep the GART pretty small to minimize GPU page table
size.

GTT defines the amount of platform address space that can be mapped
into the GPU virtual address space used by user processes.

TTM (the kernel memory management infrastructure that the driver uses)
imposes a default limit of 50% of system memory due to the way the OOM
handler works on Linux.  Memory allocated via a kernel driver on
behalf of a user process does not currently get counted towards the
application that allocated it.    This is a complex problem to fix so
it's persisted for a while.

The IOMMU provides virtualization for device access to the system
address space (system memory and MMIO space) so the DMA addresses the
the GPU driver gets from the Linux DMA subsystem and uses in the
driver are actualyl IO virtual addresses (IOVAs); i.e., they are IOMMU
virtual addresses.  So when the GPU kernel driver sets up the GPUVM
page tables the "physical" addresses will actually be IOVAs when an
IOMMU is present.

GPUVM provides a 48 bit GPU virtual address space so each process
using the GPU can have up to 48 bits of virtual GPU address space
mapped.  This address space can map a combination of on-device memory
(VRAM), system address space allocated through the driver (GTT) and
user pointer memory (e.g., malloced memory from the application).

Alex

>
> Thanks, Peter
>
> [1] https://dri.freedesktop.org/wiki/GART/
> [2] https://en.wikipedia.org/wiki/Graphics_address_remapping_table
> [3] https://www.kernel.org/doc/html/v6.0/gpu/amdgpu/module-parameters.html
>

  reply	other threads:[~2022-10-10 14:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-08 11:14 Difference GART/GTT and related questions Peter Maucher
2022-10-10 14:05 ` Alex Deucher [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-10-07 15:49 Peter Maucher

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=CADnq5_MfSNHP--KyQe2GEWCvg4XAwLV5FAw+0B-0DwvXBcACtw@mail.gmail.com \
    --to=alexdeucher@gmail.com \
    --cc=bellosilicio@gmail.com \
    --cc=dri-devel@lists.freedesktop.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 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.