Re: [PATCH v4] Add power/gpu_frequency tracepoint.

2020-12-02 Thread Brian Starkey
Hi Peiyong,

On Mon, Nov 30, 2020 at 02:33:59PM -0800, Peiyong Lin wrote:
> On Tue, Nov 17, 2020 at 1:31 PM Peiyong Lin  wrote:
> >
> > On Thu, Oct 22, 2020 at 10:34 AM Peiyong Lin  wrote:
> > >
> > > Historically there is no common trace event for GPU frequency, in
> > > downstream Android each different hardware vendor implements their own
> > > way to expose GPU frequency, for example as a debugfs node.  This patch
> > > standardize it as a common trace event in upstream linux kernel to help
> > > the ecosystem have a common implementation across hardware vendors.
> > > Toolings in the Linux ecosystem will benefit from this especially in the
> > > downstream Android, where this information is critical to graphics
> > > developers.
> > >
> > > Signed-off-by: Peiyong Lin 
> > > ---
> > >
> > > Changelog since v3:
> > >  - Correct copyright title.
> > >
> > > Changelog since v2:
> > >  - Add more comments to indicate when the event should be emitted.
> > >  - Change state to frequency.
> > >
> > > Changelog since v1:
> > >  - Use %u in TP_printk
> > >
> > >  drivers/gpu/Makefile|  1 +
> > >  drivers/gpu/trace/Kconfig   |  3 +++
> > >  drivers/gpu/trace/Makefile  |  1 +
> > >  drivers/gpu/trace/trace_gpu_frequency.c | 13 ++
> > >  include/trace/events/power.h| 33 +
> > >  5 files changed, 51 insertions(+)
> > >  create mode 100644 drivers/gpu/trace/trace_gpu_frequency.c
> > >
> > > diff --git a/drivers/gpu/Makefile b/drivers/gpu/Makefile
> > > index 835c88318cec..f289a47eb031 100644
> > > --- a/drivers/gpu/Makefile
> > > +++ b/drivers/gpu/Makefile
> > > @@ -6,3 +6,4 @@ obj-$(CONFIG_TEGRA_HOST1X)  += host1x/
> > >  obj-y  += drm/ vga/
> > >  obj-$(CONFIG_IMX_IPUV3_CORE)   += ipu-v3/
> > >  obj-$(CONFIG_TRACE_GPU_MEM)+= trace/
> > > +obj-$(CONFIG_TRACE_GPU_FREQUENCY)  += trace/
> > > diff --git a/drivers/gpu/trace/Kconfig b/drivers/gpu/trace/Kconfig
> > > index c24e9edd022e..ac4aec8d5845 100644
> > > --- a/drivers/gpu/trace/Kconfig
> > > +++ b/drivers/gpu/trace/Kconfig
> > > @@ -2,3 +2,6 @@
> > >
> > >  config TRACE_GPU_MEM
> > > bool
> > > +
> > > +config TRACE_GPU_FREQUENCY
> > > +   bool
> > > diff --git a/drivers/gpu/trace/Makefile b/drivers/gpu/trace/Makefile
> > > index b70fbdc5847f..2b7ae69327d6 100644
> > > --- a/drivers/gpu/trace/Makefile
> > > +++ b/drivers/gpu/trace/Makefile
> > > @@ -1,3 +1,4 @@
> > >  # SPDX-License-Identifier: GPL-2.0
> > >
> > >  obj-$(CONFIG_TRACE_GPU_MEM) += trace_gpu_mem.o
> > > +obj-$(CONFIG_TRACE_GPU_FREQUENCY) += trace_gpu_frequency.o
> > > diff --git a/drivers/gpu/trace/trace_gpu_frequency.c 
> > > b/drivers/gpu/trace/trace_gpu_frequency.c
> > > new file mode 100644
> > > index ..668fabd6b77a
> > > --- /dev/null
> > > +++ b/drivers/gpu/trace/trace_gpu_frequency.c
> > > @@ -0,0 +1,13 @@
> > > +// SPDX-License-Identifier: GPL-2.0
> > > +/*
> > > + * GPU frequency trace points
> > > + *
> > > + * Copyright (C) 2020 Google LLC
> > > + */
> > > +
> > > +#include 
> > > +
> > > +#define CREATE_TRACE_POINTS
> > > +#include 
> > > +
> > > +EXPORT_TRACEPOINT_SYMBOL(gpu_frequency);
> > > diff --git a/include/trace/events/power.h b/include/trace/events/power.h
> > > index af5018aa9517..343825a76953 100644
> > > --- a/include/trace/events/power.h
> > > +++ b/include/trace/events/power.h
> > > @@ -500,6 +500,39 @@ DEFINE_EVENT(dev_pm_qos_request, 
> > > dev_pm_qos_remove_request,
> > >
> > > TP_ARGS(name, type, new_value)
> > >  );
> > > +
> > > +/**
> > > + * gpu_frequency - Reports the GPU frequency in GPU clock domains.
> > > + *
> > > + * This event should be emitted whenever there's a GPU frequency change 
> > > happens,
> > > + * or a GPU goes from idle state to active state, or vice versa.
> > > + *
> > > + * When the GPU goes from idle state to active state, this event should 
> > > report
> > > + * the GPU frequency of the active state. When the GPU goes from active 
> > > state to
> > > + * idle state, this event should report a zero frequency value.
> > > + *
> > > + * @frequency:  New frequency (in KHz)
> > > + * @gpu_id: Id for each GPU clock domain

Thinking about options for how to assign this, there are a few
existing tracepoints (I see block device and jb2) which use dev_t, so
perhaps that would be an option. We'd still want to be able to expose
multiple clocks per device though, either with a separate field or
with a defined packing into this one.

dev_t is a little bit tricky because the packing can (is?) different
between the kernel and C library. major + minor + clock domain as
3 separate fields would be the most explicit.

As the intended use-case is tools, I imagine userspace will want to
link this to data exposed via other APIs, so gpu_id needs to somehow
allow that. That probably means some opaque integer assigned within
the kernel isn't OK.

Hopefully some other vendors have thoughts on what 

Re: [PATCH v4] Add power/gpu_frequency tracepoint.

2020-11-17 Thread Alex Deucher
On Tue, Nov 17, 2020 at 1:00 PM Rafael J. Wysocki
 wrote:
>
> On 11/16/2020 10:05 PM, Steven Rostedt wrote:
> > On Mon, 16 Nov 2020 12:55:29 -0800
> > Peiyong Lin  wrote:
> >
> >> Hi there,
> >>
> >> May I ask whether the merge window has passed? If so is it possible to
> >> ask for a review?
> > This is up to the maintainers of power management to accept this.
> >
> > Rafael?
>
> I'd say up to the GPU people rather (dri-devel CCed) since that's where
> it is going to be used.
>
> Also it would be good to see at least one in-the-tree user of this (or a
> usage example at least).

Can you resend the patches and cc dri-devel or point out the previous
patch discussion?

Alex
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v4] Add power/gpu_frequency tracepoint.

2020-11-17 Thread Rafael J. Wysocki

On 11/16/2020 10:05 PM, Steven Rostedt wrote:

On Mon, 16 Nov 2020 12:55:29 -0800
Peiyong Lin  wrote:


Hi there,

May I ask whether the merge window has passed? If so is it possible to
ask for a review?

This is up to the maintainers of power management to accept this.

Rafael?


I'd say up to the GPU people rather (dri-devel CCed) since that's where 
it is going to be used.


Also it would be good to see at least one in-the-tree user of this (or a 
usage example at least).


Cheers!


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel