From: Jan Vesely Subject: Re: VM on GPUs Date: Mon, 23 Feb 2015 12:40:40 -0500 Message-ID: <1424713240.13274.210.camel@rutgers.edu> References: <1424453729.13274.161.camel@rutgers.edu> <1424478069.13274.203.camel@rutgers.edu> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2090300243==" Return-path: Received: from mail-qc0-f179.google.com (mail-qc0-f179.google.com [209.85.216.179]) by gabe.freedesktop.org (Postfix) with ESMTP id 7B68C6E48C for ; Mon, 23 Feb 2015 09:40:42 -0800 (PST) Received: by qcvs11 with SMTP id s11so12253907qcv.11 for ; Mon, 23 Feb 2015 09:40:41 -0800 (PST) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Alex Deucher Cc: ML dri-devel List-Id: dri-devel@lists.freedesktop.org --===============2090300243== Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-0pSpugz6cvs5n9CFFgKR" --=-0pSpugz6cvs5n9CFFgKR Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, thank you. I found a presentation on AMD APUs that mentions throughtput differences between different types of memory. This information helps me a lot. thanks again, Jan On Sat, 2015-02-21 at 10:24 -0500, Alex Deucher wrote: > On Fri, Feb 20, 2015 at 7:21 PM, Jan Vesely wrot= e: > > Hi, > > > > thank you for exhaustive answer. I have few more > > questions/clarifications: > > is the DMA address used to access system pages further translated using > > IOMMU (if present), or are GPUs treated specially? > > >=20 > Yes, the address may be further translated via an IOMMU. That's why I > said dma address rather than bus address or physical address. >=20 > > I have only seen references to TLB flush, so I guess invalidating > > individual entries is not supported? >=20 > You can flush individual vmids, but not individual entries. >=20 > > does it mean that if a page needs to be moved/migrated a complete VMID > > tlb flush is required? >=20 > Yes. >=20 > > > > I was a bit surprised to find about PCIe cache snoop, since the work I > > have seen before assumes DMA is not cache coherent. I guess there's a > > latency penalty for for using it, do you have any idea how much worse i= t > > gets (relatively to non-snoop access)? >=20 > It is slower than non-snooped. I don't remember the numbers off hand. > I think some of the compute documents or HSA developer summit > presentations on the AMD developer site go into the details. >=20 > Alex >=20 > > > > thanks again, > > jan > > > > On Fri, 2015-02-20 at 17:19 -0500, Alex Deucher wrote: > >> On Fri, Feb 20, 2015 at 12:35 PM, Jan Vesely = wrote: > >> > Hello radeon devs, > >> > > >> > I have been trying to find out more about VM implementation on SI+ h= w, > >> > but unfortunately I could not find much in the public documents[0]. > >> > > >> > SI ISA manual suggests that there is a limited form of privileged mo= de > >> > on these chips, so I wondered if it could be used for VM management = too > >> > (the docs only deal with numerical exceptions). Or does it always ha= ve > >> > to be handled by host (driver)? > >> > >> These are related to trap/exception privilege for debugging for > >> example. I'm not that familiar with how that stuff works. It's > >> unrelated to GPUVM. > >> > >> > > >> > One of the older patches [1] mentions different page sizes, is there= any > >> > public documentation on things like page table format, and GPU MMU > >> > hierarchy? I could only get limited picture going through the code a= nd > >> > comments. > >> > >> There is not any public documentation on the VM hardware other than > >> what is available in the driver. I can try and give you an overview > >> of how it works. There are 16 VM contexts (8 on cayman/TN/RL) on the > >> GPU that can be active at any given time. GPUVM supports a 40 bit > >> address space. Each context has an id, we call them vmids. vmid 0 is > >> a bit special. It's called the system context and behaves a bit > >> differently to the other ones. It's designed to be for the kernel > >> driver's view of GPU accessible memory. I can go into further detail > >> if you want, but I don't think it's critical for this discussion. > >> Just think of it as the context used by the kernel driver. So that > >> leaves 16 contexts (7 on cayman and TN/RL) available for use by user > >> clients. vmid 0 has one set of configuration registers and vmids 1-15 > >> share the same configuration (other than the page tables). E.g., > >> contexts 1-15 all have to use single or 2 level page tables for > >> example. You select which VM context is used for a particular command > >> buffer by a field in the command buffer packet. Some engines (e.g., > >> UVD or the display hardware) do not support VM so they always use vmid > >> 0. Right now only the graphics, compute, and DMA engines support VM. > >> > >> With single level page tables, you just have a big array of page table > >> entries (PTEs) that represent the entire virtual address space. With > >> multi-level page tables, the address space is represented by an array > >> of page directory entries (PDEs) that point to page table blocks > >> (PTBs) which are arrays of PTEs. > >> > >> PTEs and PDEs are 64 bits per entry. > >> > >> PDE: > >> 39:12 - PTB address > >> 0 - PDE valid (the entry is valid) > >> > >> PTE: > >> 39:12 - page address > >> 11:7 - fragment > >> 6 - write > >> 5 - read > >> 2 - CPU cache snoop (for accessing cached system memory) > >> 1 - system (page is in system memory rather than vram) > >> 0 - PTE valid (the entry is valid) > >> > >> Fragment needs some explanation. The logical/physical fragment size in > >> bytes =3D 2 ^ (12 + fragment). A fragment size of 0 means 4k, 1 means= , > >> 8k, etc. The logical address must be aligned to the fragment size and > >> the memory backing it must be contiguous and at least as large as the > >> fragment size. Larger fragment sizes reduce the pressure on the TLB > >> since fewer entries are required for the same amount of memory. > >> > >> For system pages, the page address is the dma address of the page. > >> The system bit must be set and the snoop bit can be optionally set > >> depending on whether you are using cachable memory. > >> > >> For vram pages, the address is the GPU physical address of vram > >> (starts at 0 on dGPUs, starts at MC_VM_FB_OFFSET (dma address of > >> "vram" carve out) on APUs). > >> > >> You can also adjust the page table block size which controls the > >> number of pages per PTB. I.e., how many PDEs you need to cover the > >> address space. E.g., if you set the block size to 0, each PTB is 4k > >> which holds 512 PTEs; if you set it to 1 each PTB is 8k which holds > >> 1024 PTEs, etc. > >> > >> GPUVM is only concerned with memory management and protection. There > >> are other protection features in other hw blocks for things beyond > >> memory. For example, on CI and newer asics, the CP and SDMA blocks > >> execute command buffers in a secure mode that limits them to accessing > >> only registers that are relevant for those blocks (e.g., gfx or > >> compute state registers, but not display registers) or only executing > >> certain packets. > >> > >> I hope this helps. Let me know if you have any more questions. > >> > >> Alex > >> > >> > > >> > > >> > thank you, > >> > Jan > >> > > >> > [0]http://developer.amd.com/resources/documentation-articles/develop= er-guides-manuals/ > >> > [1]http://lists.freedesktop.org/archives/dri-devel/2014-May/058858.h= tml > >> > > >> > > >> > -- > >> > Jan Vesely > > > > -- > > Jan Vesely --=20 Jan Vesely --=-0pSpugz6cvs5n9CFFgKR Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABCgAGBQJU62YYAAoJEDhUsXb6ZiH/7R4P/0jPSRm8HpPbu6q2ZMjdYc6W jb+u/t+oLGjZemUNyfkHmuCM+x4f+p4JdECSGcekK/L4yCWCiPR0i20ZtkZNprzp 2oOeTHDMTViTQBj54Nvrd3m4uMnXKXdc+PLhtVYgrHoBT+uD5ZoAcw8hXsAQX8pV hG+dhu83kW2+8VS0tr3NiC664wu8S9V1PPWBGkMWHCgC5bjF94ylpycjqYJGRgVH 7fA/gs9EGPWqkhR5sM6oc/L934EC+v4u561zzKXcjhyrp/4HyZzPNpziSbeYATzD Mc+TRgVkY62FmaNC6Ms3pGDUF7+7o/P0nC3mPTIdj35N43iXJnN38J0ktGwK/FbC +cK/BJfUCCvNJezbII5boQGSJ70s7365+D6PLfrg/B45Wft6Z72WKKnYJEj0gEF0 RCovP/vC97W53XC4aoCrfe93MVnr3U0/Ay38a0yobbpBuL1PHLEy0FPHyGPaRwR1 NSduhHAh6UIANLfN8GqQCU6p+59Rv/gHrRJXKmTzoPRLRu0RUFkGG13FgIzBFoNR b6DGrQebryHsopXdBf4oFFOAcEESFYQ/EvLh+NkhvK6kgqa3c9w9XzknRyNovLuJ H68MLAPmdhLm1/OoKad5gois0tglsrlGRJAcfMhV5NcZq7G4oA21CqpwW4ziammp b6XERyVsmg8Oc5Nw7K+K =p/WS -----END PGP SIGNATURE----- --=-0pSpugz6cvs5n9CFFgKR-- --===============2090300243== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHA6Ly9saXN0 cy5mcmVlZGVza3RvcC5vcmcvbWFpbG1hbi9saXN0aW5mby9kcmktZGV2ZWwK --===============2090300243==--