All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kalesh Singh <kaleshsingh@google.com>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: "Mark Underwood" <Mark.Underwood@arm.com>,
	"Stephen Mansfield" <Stephen.Mansfield@imgtec.com>,
	"Christian König" <christian.koenig@amd.com>,
	Kenny.Ho@amd.com, "Lingfeng Yang" <lfy@google.com>,
	"Steven Rostedt" <rostedt@goodmis.org>,
	"Gurchetan Singh" <gurchetansingh@chromium.org>,
	"Peiyong Lin" <lpy@google.com>,
	"John Reitan" <John.Reitan@arm.com>,
	"Yiwei Zhang" <zzyiwei@google.com>,
	"DRI mailing list" <dri-devel@lists.freedesktop.org>,
	"Gary Sweet" <gary.sweet@broadcom.com>,
	android-kernel-team <android-kernel-team@google.com>,
	"Hridya Valsaraju" <hridya@google.com>,
	"Deucher, Alexander" <Alexander.Deucher@amd.com>,
	"Ørjan Eide" <Orjan.Eide@arm.com>,
	"Suren Baghdasaryan" <surenb@google.com>,
	"Chris Forbes" <chrisforbes@google.com>,
	"John Reck" <jreck@google.com>
Subject: Re: [RFC PATCH 0/8] GPU memory tracepoints
Date: Wed, 17 Nov 2021 10:06:38 -0800	[thread overview]
Message-ID: <CAC_TJvcLcD37+Q4CNH3LutkvbiNjD3-y0FaH3T=2R6oUjjnZCQ@mail.gmail.com> (raw)
In-Reply-To: <CAC_TJvcmghJ25m=+Ai71Ftt3mW9nYAP8UwwZwL1R8GDLVzUnLA@mail.gmail.com>

On Mon, Nov 1, 2021 at 11:54 AM Kalesh Singh <kaleshsingh@google.com> wrote:
>
> On Thu, Oct 21, 2021 at 3:38 PM Kalesh Singh <kaleshsingh@google.com> wrote:
> >
> > On Thu, Oct 21, 2021 at 5:00 AM Daniel Vetter <daniel@ffwll.ch> wrote:
> > >
> > > On Wed, Oct 20, 2021 at 08:10:19PM -0700, Gurchetan Singh wrote:
> > > > This is latest iteration of GPU memory tracepoints [1].
> > > >
> > > > In the past, there were questions about the "big picture" of memory
> > > > accounting [2], especially given related work on dma-buf heaps and DRM
> > > > cgroups [3].  Also, there was a desire for a non-driver specific solution.
> > > >
> > > > The great news is the dma-buf heaps work as recently landed [4].  It uses
> > > > sys-fs and the plan is to use it in conjunction with the tracepoint
> > > > solution [5].  We're aiming for the GPU tracepoint to calculate totals
> > > > per DRM-instance (a proxy for per-process on Android) and per-DRM device.
> > > >
> > > > The cgroups work looks terrific too and hopefully we can deduplicate code once
> > > > that's merged.  Though that's abit of an implementation detail, so long as
> > > > the "GPU tracepoints" +  "dma-buf heap stats" plan sounds good for Android.
> > >
> > > Can we please start out with depulicated code, and integrate this with
> > > cgroups?
> >
> > Thanks for the comments Dan,
> >
> > The cgroups work is currently targeting allocator attribution so it
> > wouldn’t give insight to shared / imported memory - this is included
> > as part of the totals in the tracepoint. We will start a separate
> > discussion with the gpu community on including imported memory into
> > cgroups design. Who would you recommend to be included? (in case we
> > don't already know all the interested parties).
> >
> > The current tracepoint and the cgroups are not conflicting designs but
> > rather complimentary. These are some of the gaps which the tracepoint
> > helps to cover:
> > 1. Imported gpu memory accounting
> > 2. The tracepoint can be used to track gpu memory usage over time
> > (useful to detect memory usage spikes, for example), while cgroups can
> > be used to view usage as a more granular and static state.
> > 3. For systems where cgroups aren't enabled the tracepoint data can be
> > a good alternative to identify memory issues.
> > 4. Non-drm devices can make use of the tracepoint for reporting.
> >
> > It would be great if we can also keep the tracepoint, as we don’t have
> > another alternative that provides all it offers (cgroups can certainly
> > be extended to cover some of these),  and it's currently being used by
> > all Android devices.
>
> Hi Daniel,
>
> We had a follow up discussion with Kenny on using drm cgroups. In
> summary, we think that the tracepoints and croups here are orthogonal
> and should not block each other. Would appreciate any advice you have
> on moving this forward.

Hi Daniel,

Friendly ping on this. After discussion with Kenny, we think the
tracepoint and cgroups are complimentary accounting mechanisms. One of
the main use cases for the tracepoint in Android is for profiling GPU
memory using tools like perfetto [1], instead of using periodic
polling. Are there still objections to this? Please advise.

[1] https://perfetto.dev/docs/quickstart/android-tracing

Thanks,
Kalesh

>
> Thanks,
> Kalesh
>
> >
> > Thanks,
> > Kalesh
> >
> > >
> > > The problem with gpu memory account is that everyone wants their own
> > > thing, they're all slightly differently, and all supported by a different
> > > subset of drivers. That doesn't make sense to support in upstream at all.
> > >
> > > Please huddle together so that there's one set of "track gpu memory"
> > > calls, and that does cgroups, tracepoints and everything else that an OS
> > > might want to have.
> > >
> > > Also ideally this thing works for both integrated soc gpu (including an
> > > answer for special memory pools like cma) _and_ discrete gpus using ttm.
> > > Or at least has an answer to both, because again if we end up with totally
> > > different tracking for the soc vs the discrete gpu world, we've lost.
> > > -Daniel
> > >
> > > >
> > > > This series modifies the GPU memory tracepoint API in a non-breaking fashion
> > > > (patch 1), and adds accounting via the GEM subsystem (patches 2 --> 7). Given
> > > > the multiple places where memory events happen, there's a bunch trace events
> > > > scattered in various places.  The hardest part is allocation, where each driver
> > > > has their own API.  If there's a better way, do say so.
> > > >
> > > > The last patch is incomplete; we would like general feedback before proceeding
> > > > further.
> > > >
> > > > [1] https://lore.kernel.org/lkml/20200302235044.59163-1-zzyiwei@google.com/
> > > > [2] https://lists.freedesktop.org/archives/dri-devel/2021-January/295120.html
> > > > [3] https://www.spinics.net/lists/cgroups/msg27867.html
> > > > [4] https://www.spinics.net/lists/linux-doc/msg97788.html
> > > > [5] https://source.android.com/devices/graphics/implement-dma-buf-gpu-mem
> > > >
> > > > Gurchetan Singh (8):
> > > >   tracing/gpu: modify gpu_mem_total
> > > >   drm: add new tracepoint fields to drm_device and drm_file
> > > >   drm: add helper functions for gpu_mem_total and gpu_mem_instance
> > > >   drm: start using drm_gem_trace_gpu_mem_total
> > > >   drm: start using drm_gem_trace_gpu_mem_instance
> > > >   drm: track real and fake imports in drm_prime_member
> > > >   drm: trace memory import per DRM file
> > > >   drm: trace memory import per DRM device
> > > >
> > > >  drivers/gpu/drm/Kconfig        |  1 +
> > > >  drivers/gpu/drm/drm_gem.c      | 65 +++++++++++++++++++++++++++++++++-
> > > >  drivers/gpu/drm/drm_internal.h |  4 +--
> > > >  drivers/gpu/drm/drm_prime.c    | 22 +++++++++---
> > > >  include/drm/drm_device.h       | 16 +++++++++
> > > >  include/drm/drm_file.h         | 16 +++++++++
> > > >  include/drm/drm_gem.h          |  7 ++++
> > > >  include/trace/events/gpu_mem.h | 61 +++++++++++++++++++++----------
> > > >  8 files changed, 166 insertions(+), 26 deletions(-)
> > > >
> > > > --
> > > > 2.25.1
> > > >
> > >
> > > --
> > > Daniel Vetter
> > > Software Engineer, Intel Corporation
> > > http://blog.ffwll.ch

      reply	other threads:[~2021-11-17 18:06 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-21  3:10 [RFC PATCH 0/8] GPU memory tracepoints Gurchetan Singh
2021-10-21  3:10 ` [RFC PATCH 1/8] tracing/gpu: modify gpu_mem_total Gurchetan Singh
2021-10-21 11:56   ` Daniel Vetter
2021-10-21 13:07     ` Steven Rostedt
2021-10-28 15:21       ` Daniel Vetter
2021-10-21  3:10 ` [RFC PATCH 2/8] drm: add new tracepoint fields to drm_device and drm_file Gurchetan Singh
2021-10-21  3:10 ` [RFC PATCH 3/8] drm: add helper functions for gpu_mem_total and gpu_mem_instance Gurchetan Singh
2021-10-21  3:10 ` [RFC PATCH 4/8] drm: start using drm_gem_trace_gpu_mem_total Gurchetan Singh
2021-10-21  3:49   ` Steven Rostedt
2021-10-21  3:10 ` [RFC PATCH 5/8] drm: start using drm_gem_trace_gpu_mem_instance Gurchetan Singh
2021-10-21  3:50   ` Steven Rostedt
2021-11-05  8:24   ` [drm] a31246115b: BUG:kernel_NULL_pointer_dereference,address kernel test robot
2021-11-05  8:24     ` kernel test robot
2021-10-21  3:10 ` [RFC PATCH 6/8] drm: track real and fake imports in drm_prime_member Gurchetan Singh
2021-10-21  3:10 ` [RFC PATCH 7/8] drm: trace memory import per DRM file Gurchetan Singh
2021-10-21  3:10 ` [RFC PATCH 8/8] drm: trace memory import per DRM device Gurchetan Singh
2021-10-21 12:00 ` [RFC PATCH 0/8] GPU memory tracepoints Daniel Vetter
2021-10-21 22:38   ` Kalesh Singh
2021-11-01 18:54     ` Kalesh Singh
2021-11-17 18:06       ` Kalesh Singh [this message]

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='CAC_TJvcLcD37+Q4CNH3LutkvbiNjD3-y0FaH3T=2R6oUjjnZCQ@mail.gmail.com' \
    --to=kaleshsingh@google.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=John.Reitan@arm.com \
    --cc=Kenny.Ho@amd.com \
    --cc=Mark.Underwood@arm.com \
    --cc=Orjan.Eide@arm.com \
    --cc=Stephen.Mansfield@imgtec.com \
    --cc=android-kernel-team@google.com \
    --cc=chrisforbes@google.com \
    --cc=christian.koenig@amd.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gary.sweet@broadcom.com \
    --cc=gurchetansingh@chromium.org \
    --cc=hridya@google.com \
    --cc=jreck@google.com \
    --cc=lfy@google.com \
    --cc=lpy@google.com \
    --cc=rostedt@goodmis.org \
    --cc=surenb@google.com \
    --cc=zzyiwei@google.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.