All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Marek Olšák" <maraeo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: "Michel Dänzer" <michel-otUistvHUpPR7s880joybQ@public.gmane.org>
Cc: amd-gfx mailing list
	<amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>
Subject: Re: Plan: BO move throttling for visible VRAM evictions
Date: Tue, 28 Mar 2017 12:51:36 +0200	[thread overview]
Message-ID: <CAAxE2A5kSU5pW6-5fg9oh8dVUvqgRQu7e1s3j2ibwPXi4zZTVw@mail.gmail.com> (raw)
In-Reply-To: <03c34461-6918-0875-10c3-488bacbae0e4-otUistvHUpPR7s880joybQ@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 4479 bytes --]

On Mar 28, 2017 3:07 AM, "Michel Dänzer" <michel-otUistvHUpPR7s880joybQ@public.gmane.org> wrote:

On 27/03/17 07:29 PM, Marek Olšák wrote:
> On Mar 27, 2017 9:35 AM, "Michel Dänzer" <michel-otUistvHUpPR7s880joybQ@public.gmane.org
> <mailto:michel-otUistvHUpPR7s880joybQ@public.gmane.org>> wrote:
>
>     On 25/03/17 01:33 AM, Marek Olšák wrote:
>     > Hi,
>     >
>     > I'm sharing this idea here, because it's something that has been
>     > decreasing our performance a lot recently, for example:
>     >
>     http://openbenchmarking.org/prospect/1703011-RI-RADEONDIR06/
7b7668cfc109d1c3dc27e871c8aea71ca13f23fa
>     <http://openbenchmarking.org/prospect/1703011-RI-RADEONDIR06/
7b7668cfc109d1c3dc27e871c8aea71ca13f23fa>
>     >
>     > I think the problem there is that Mesa git started uploading
>     > descriptors and uniforms to VRAM, which helps when TC L2 has a low
>     > hit/miss ratio, but the performance can randomly drop by an order of
>     > magnitude. I've heard rumours that kernel 4.11 has an improved
>     > allocator that should perform better, but the situation is still far
>     > from ideal.
>     >
>     > AMD CPUs and APUs will hopefully suffer less, because we can resize
>     > the visible VRAM with the help of our CPU hw specs, but Intel CPUs
>     > will remain limited to 256 MB. The following plan describes how to
do
>     > throttling for visible VRAM evictions.
>     >
>     >
>     > 1) Theory
>     >
>     > Initially, the driver doesn't care about where buffers are in VRAM,
>     > because VRAM buffers are only moved to visible VRAM on CPU page
faults
>     > (when the CPU touches the buffer memory but the memory is in the
>     > invisible part of VRAM). When it happens,
>     > amdgpu_bo_fault_reserve_notify is called, which moves the buffer to
>     > visible VRAM, and the app continues. amdgpu_bo_fault_reserve_notify
>     > also marks the buffer as contiguous, which makes memory
fragmentation
>     > worse.
>     >
>     > I verified this with DiRT Rally where amdgpu_bo_fault_reserve_notify
>     > was much higher in a CPU profiler than anything else in the kernel.
>     >
>     >
>     > 2) Monitoring via Gallium HUD
>     >
>     > We need to expose 2 kernel counters via the INFO ioctl and display
>     > those via Gallium HUD:
>     > - The number of VRAM CPU page faults. (the number of calls to
>     > amdgpu_bo_fault_reserve_notify).
>     > - The number of bytes moved by ttm_bo_validate inside
>     > amdgpu_bo_fault_reserve_notify.
>     >
>     > This will help us observe what exactly is happening and fine-tune
the
>     > throttling when it's done.
>     >
>     >
>     > 3) Solution
>     >
>     > a) When amdgpu_bo_fault_reserve_notify is called, record the fact.
>     > (amdgpu_bo::had_cpu_page_fault = true)
>     >
>     > b) Monitor the MB/s rate at which buffers are moved by
>     > amdgpu_bo_fault_reserve_notify. If we get above a specific
threshold,
>     > don't move the buffer to visible VRAM. Move it to GTT instead. Note
>     > that moving to GTT can be cheaper, because moving to visible VRAM is
>     > likely to evict a lot of buffers there and unmap them from the CPU,
>
>     FWIW, this can be avoided by only setting GTT in busy_placement. Then
>     TTM will only move the BO to visible VRAM if that can be done without
>     evicting anything from there.
>
>
>     > but moving to GTT shouldn't evict or unmap anything.
>     >
>     > c) When we get into the CS ioctl and a buffer has
had_cpu_page_fault,
>     > it can be moved to VRAM if:
>     > - the GTT->VRAM move rate is low enough to allow it (this is the
>     > existing throttling mechanism)
>     > - the visible VRAM move rate is low enough that we will be OK with
>     > another CPU page fault if it happens.
>
>     Some other ideas that might be worth trying:
>
>     Evicting BOs to GTT instead of moving them to CPU accessible VRAM in
>     principle in some cases (e.g. for all BOs except those with
>     AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED) or even always.
>
>
> I've tried this and it made things even worse.

What exactly did you try?


I only set the placement to GTT, but I think I kept the contiguous flag.

Marek



--
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer

[-- Attachment #1.2: Type: text/html, Size: 6863 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2017-03-28 10:51 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-24 16:33 Plan: BO move throttling for visible VRAM evictions Marek Olšák
     [not found] ` <CAAxE2A4ap8BoOEg1tOF+Ec1vBfZRSANOebikYBaHUfXokY7EwA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-24 16:45   ` Christian König
     [not found]     ` <2667ea68-b700-69a1-391c-b34fe1ed0605-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-03-24 16:57       ` Marek Olšák
2017-03-24 16:59   ` Deucher, Alexander
2017-03-24 20:17   ` Samuel Pitoiset
2017-03-27  7:35   ` Michel Dänzer
     [not found]     ` <ba8058ce-805b-3e52-095a-01806673344f-otUistvHUpPR7s880joybQ@public.gmane.org>
2017-03-27  7:53       ` Zhou, David(ChunMing)
     [not found]         ` <MWHPR1201MB0206FD6ABB9A0029624E4AF6B4330-3iK1xFAIwjrUF/YbdlDdgWrFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-03-27  9:29           ` Christian König
     [not found]             ` <a675c878-f191-a6fc-72f3-fd07062c8737-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-03-27  9:36               ` zhoucm1
     [not found]                 ` <58D8DD01.8050901-5C7GfCeVMHo@public.gmane.org>
2017-03-27  9:55                   ` Christian König
     [not found]                     ` <f9850969-e4ff-f9f2-ed18-53cd2bb031f3-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-03-28  3:58                       ` zhoucm1
2017-03-28  2:40           ` Michel Dänzer
     [not found]             ` <441ea5b9-d37d-140d-e029-26a7c3ae58cb-otUistvHUpPR7s880joybQ@public.gmane.org>
2017-03-28  3:50               ` zhoucm1
     [not found]                 ` <58D9DD8D.4000803-5C7GfCeVMHo@public.gmane.org>
2017-03-28  6:00                   ` Michel Dänzer
     [not found]                     ` <10958b11-6d28-228a-5142-2c5edadb70ef-otUistvHUpPR7s880joybQ@public.gmane.org>
2017-03-28  8:29                       ` Christian König
     [not found]                         ` <f7ee08e8-46ca-8146-f3a3-d28080e5267f-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-03-28  8:35                           ` Michel Dänzer
     [not found]                             ` <bb6d20b3-06d1-3f7d-f782-ae18d66d4423-otUistvHUpPR7s880joybQ@public.gmane.org>
2017-03-28  8:41                               ` Christian König
     [not found]                                 ` <efb4f99c-c0b9-56ab-d73c-a03a7e136d66-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-03-28 10:47                                   ` Marek Olšák
2017-03-28 13:58                           ` Alex Deucher
     [not found]                             ` <CADnq5_P5X1zS4DJ63XQ6Hgi_rGOWYKCdUkGgU2uGMb2Sh1ZnKw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-28 14:05                               ` Christian König
2017-03-27 10:29       ` Marek Olšák
     [not found]         ` <CAAxE2A5OCfgu4k-GzNFhGSkgn21jEJoQysdZ6QbdxZaGwPnrEA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-28  1:07           ` Michel Dänzer
     [not found]             ` <03c34461-6918-0875-10c3-488bacbae0e4-otUistvHUpPR7s880joybQ@public.gmane.org>
2017-03-28 10:51               ` Marek Olšák [this message]
2017-03-30 10:03   ` Michel Dänzer
     [not found]     ` <9220eda1-5176-36cd-e6b3-801c3e4f759a-otUistvHUpPR7s880joybQ@public.gmane.org>
2017-03-31  3:24       ` Michel Dänzer
     [not found]         ` <78989271-9812-f891-3a00-0d5b39a06b7c-otUistvHUpPR7s880joybQ@public.gmane.org>
2017-04-03 20:11           ` Marek Olšák
     [not found]             ` <CAAxE2A60hubc8jbZkO101sxqVZKR8iub=GsfRovj17+P2zKDKQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-04-14 10:14               ` Michel Dänzer
     [not found]                 ` <aee1e2b7-dd00-e24b-bcfc-e2299e31908b-otUistvHUpPR7s880joybQ@public.gmane.org>
2017-04-16 22:58                   ` Marek Olšák
     [not found]                     ` <CAAxE2A5g7tJG+94XxPr-mdGXkeL1GPMNMaYgc7ATEk7pxsiXfA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-04-17  9:55                       ` Michel Dänzer
     [not found]                         ` <c343b89c-318f-d3af-d02e-4e6843c422f6-otUistvHUpPR7s880joybQ@public.gmane.org>
2017-05-13 21:31                           ` Marek Olšák
     [not found]                             ` <CAAxE2A5_tiOEvLVegNvkuvYrFcsU52H6EfCff3faKBZwPfbuYQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-05-15  2:29                               ` Michel Dänzer
     [not found]                                 ` <a5a8428e-444a-34b9-7fa9-60e77582819a-otUistvHUpPR7s880joybQ@public.gmane.org>
2017-05-15 10:11                                   ` Marek Olšák
     [not found]                                     ` <CAAxE2A4ex4e-5ShqesZ8oXJj1CnmH6Enhvu4fXs9kDKu9NHeiQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-05-16  1:57                                       ` Michel Dänzer
     [not found]                                         ` <78fe31b2-2a0a-a1af-6af8-954d892e34ba-otUistvHUpPR7s880joybQ@public.gmane.org>
2017-05-17 12:35                                           ` Marek Olšák
     [not found]                                             ` <CAAxE2A7mh7pmbbszk1qnChPxZtVMzRBWY2GkB1DEcrEZ0t5m3w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-05-18  8:17                                               ` Michel Dänzer
     [not found]                                                 ` <4548bad6-2dc9-29be-b62e-33c181db77af-otUistvHUpPR7s880joybQ@public.gmane.org>
2017-05-18  8:39                                                   ` Christian König
2017-05-18 10:22                                                   ` Marek Olšák
     [not found]                                                     ` <CAAxE2A5L3vRth0dL=niTUR=M5i7_VmP4FEUPBeaEjtY8cveOmw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-05-19  7:45                                                       ` Michel Dänzer
2017-05-15  4:37                               ` zhoucm1
     [not found]                                 ` <5919307C.4020704-5C7GfCeVMHo@public.gmane.org>
2017-05-15 10:18                                   ` Marek Olšák
     [not found]                                     ` <CAAxE2A5Yz8GoRnXwWeeSt5ZxwRbiT9W1RLYPTTUE=vojKukQug-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-05-16  1:58                                       ` Michel Dänzer

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=CAAxE2A5kSU5pW6-5fg9oh8dVUvqgRQu7e1s3j2ibwPXi4zZTVw@mail.gmail.com \
    --to=maraeo-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=michel-otUistvHUpPR7s880joybQ@public.gmane.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.