All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: "Christian König" <christian.koenig@amd.com>,
	Intel-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org,
	Tvrtko Ursulin <tvrtko.ursulin@intel.com>,
	David M Nieto <David.Nieto@amd.com>,
	Daniel Vetter <daniel@ffwll.ch>,
	Daniel Stone <daniel@fooishbar.org>
Subject: Re: [RFC 6/8] drm: Document fdinfo format specification
Date: Tue, 24 Aug 2021 10:25:54 +0100	[thread overview]
Message-ID: <337f3b5d-f903-1eb4-9597-d00191dc8788@linux.intel.com> (raw)
In-Reply-To: <52ba613b-be4b-b9f4-5a9e-91c772b810cd@amd.com>


On 23/08/2021 14:32, Christian König wrote:
> Am 23.08.21 um 13:28 schrieb Tvrtko Ursulin:
>> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>>
>> Proposal to standardise the fdinfo text format as optionally output by 
>> DRM
>> drivers.
>>
>> Idea is that a simple but, well defined, spec will enable generic
>> userspace tools to be written while at the same time avoiding a more 
>> heavy
>> handed approach of adding a mid-layer to DRM.
>>
>> i915 implements a subset of the spec, everything apart from the memory
>> stats currently, and a matching intel_gpu_top tool exists.
>>
>> Open is to see if AMD can migrate to using the proposed GPU utilisation
>> key-value pairs, or if they are not workable to see whether to go
>> vendor specific, or if a standardised  alternative can be found which is
>> workable for both drivers.
>>
>> Same for the memory utilisation key-value pairs proposal.
>>
>> v2:
>>   * Update for removal of name and pid.
>>
>> v3:
>>   * 'Drm-driver' tag will be obtained from struct drm_driver.name. 
>> (Daniel)
>>
>> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>> Cc: David M Nieto <David.Nieto@amd.com>
>> Cc: Christian König <christian.koenig@amd.com>
>> Cc: Daniel Vetter <daniel@ffwll.ch>
>> Cc: Daniel Stone <daniel@fooishbar.org>
> 
> I'm not an expert on that stuff, but as far as I can see this totally 
> makes sense to me.

Thanks!

> Feel free to add an Acked-by: Christian König <christian.koenig@amd.com> 
> to those three patches.

However note that the last one is full of TODO markers, including the 
commit message, where I was hoping to nudge the feature owners of the 
amdgpu side to fill in the blanks in my understanding of how things work 
over there. At least the different semantics need to be documented so 
random userspace can interpret the amdgpu values correctly.

Or alternatively I drop the last patch and if someone is interested they 
can resurrect and complete it at their leisure.

Just not sure how Daniel would accept this since his push was to gate 
i915 addition behind a drive for common solution.

Regards,

Tvrtko

>> ---
>>   Documentation/gpu/drm-usage-stats.rst | 97 +++++++++++++++++++++++++++
>>   Documentation/gpu/index.rst           |  1 +
>>   2 files changed, 98 insertions(+)
>>   create mode 100644 Documentation/gpu/drm-usage-stats.rst
>>
>> diff --git a/Documentation/gpu/drm-usage-stats.rst 
>> b/Documentation/gpu/drm-usage-stats.rst
>> new file mode 100644
>> index 000000000000..c669026be244
>> --- /dev/null
>> +++ b/Documentation/gpu/drm-usage-stats.rst
>> @@ -0,0 +1,97 @@
>> +.. _drm-client-usage-stats:
>> +
>> +======================
>> +DRM client usage stats
>> +======================
>> +
>> +DRM drivers can choose to export partly standardised text output via the
>> +`fops->show_fdinfo()` as part of the driver specific file operations 
>> registered
>> +in the `struct drm_driver` object registered with the DRM core.
>> +
>> +One purpose of this output is to enable writing as generic as practicaly
>> +feasible `top(1)` like userspace monitoring tools.
>> +
>> +Given the differences between various DRM drivers the specification 
>> of the
>> +output is split between common and driver specific parts. Having said 
>> that,
>> +wherever possible effort should still be made to standardise as much as
>> +possible.
>> +
>> +File format specification
>> +=========================
>> +
>> +- File shall contain one key value pair per one line of text.
>> +- Colon character (`:`) must be used to delimit keys and values.
>> +- All keys shall be prefixed with `drm-`.
>> +- Whitespace between the delimiter and first non-whitespace character 
>> shall be
>> +  ignored when parsing.
>> +- Neither keys or values are allowed to contain whitespace characters.
>> +- Numerical key value pairs can end with optional unit string.
>> +- Data type of the value is fixed as defined in the specification.
>> +
>> +Key types
>> +---------
>> +
>> +1. Mandatory, fully standardised.
>> +2. Optional, fully standardised.
>> +3. Driver specific.
>> +
>> +Data types
>> +----------
>> +
>> +- <uint> - Unsigned integer without defining the maximum value.
>> +- <str> - String excluding any above defined reserved characters or 
>> whitespace.
>> +
>> +Mandatory fully standardised keys
>> +---------------------------------
>> +
>> +- drm-driver: <str>
>> +
>> +String shall contain the name this driver registered as via the 
>> respective
>> +`struct drm_driver` data structure.
>> +
>> +Optional fully standardised keys
>> +--------------------------------
>> +
>> +- drm-pdev: <aaaa:bb.cc.d>
>> +
>> +For PCI devices this should contain the PCI slot address of the 
>> device in
>> +question.
>> +
>> +- drm-client-id: <uint>
>> +
>> +Unique value relating to the open DRM file descriptor used to 
>> distinguish
>> +duplicated and shared file descriptors. Conceptually the value should 
>> map 1:1
>> +to the in kernel representation of `struct drm_file` instances.
>> +
>> +Uniqueness of the value shall be either globally unique, or unique 
>> within the
>> +scope of each device, in which case `drm-pdev` shall be present as well.
>> +
>> +Userspace should make sure to not double account any usage statistics 
>> by using
>> +the above described criteria in order to associate data to individual 
>> clients.
>> +
>> +- drm-engine-<str>: <uint> ns
>> +
>> +GPUs usually contain multiple execution engines. Each shall be given 
>> a stable
>> +and unique name (str), with possible values documented in the driver 
>> specific
>> +documentation.
>> +
>> +Value shall be in specified time units which the respective GPU 
>> engine spent
>> +busy executing workloads belonging to this client.
>> +
>> +Values are not required to be constantly monotonic if it makes the 
>> driver
>> +implementation easier, but are required to catch up with the 
>> previously reported
>> +larger value within a reasonable period. Upon observing a value lower 
>> than what
>> +was previously read, userspace is expected to stay with that larger 
>> previous
>> +value until a monotonic update is seen.
>> +
>> +- drm-memory-<str>: <uint> [KiB|MiB]
>> +
>> +Each possible memory type which can be used to store buffer objects 
>> by the
>> +GPU in question shall be given a stable and unique name to be 
>> returned as the
>> +string here.
>> +
>> +Value shall reflect the amount of storage currently consumed by the 
>> buffer
>> +object belong to this client, in the respective memory region.
>> +
>> +Default unit shall be bytes with optional unit specifiers of 'KiB' or 
>> 'MiB'
>> +indicating kibi- or mebi-bytes.
>> diff --git a/Documentation/gpu/index.rst b/Documentation/gpu/index.rst
>> index b9c1214d8f23..b99dede9a5b1 100644
>> --- a/Documentation/gpu/index.rst
>> +++ b/Documentation/gpu/index.rst
>> @@ -10,6 +10,7 @@ Linux GPU Driver Developer's Guide
>>      drm-kms
>>      drm-kms-helpers
>>      drm-uapi
>> +   drm-usage-stats
>>      driver-uapi
>>      drm-client
>>      drivers
> 

WARNING: multiple messages have this Message-ID (diff)
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: "Christian König" <christian.koenig@amd.com>,
	Intel-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org,
	Tvrtko Ursulin <tvrtko.ursulin@intel.com>,
	David M Nieto <David.Nieto@amd.com>,
	Daniel Vetter <daniel@ffwll.ch>,
	Daniel Stone <daniel@fooishbar.org>
Subject: Re: [Intel-gfx] [RFC 6/8] drm: Document fdinfo format specification
Date: Tue, 24 Aug 2021 10:25:54 +0100	[thread overview]
Message-ID: <337f3b5d-f903-1eb4-9597-d00191dc8788@linux.intel.com> (raw)
In-Reply-To: <52ba613b-be4b-b9f4-5a9e-91c772b810cd@amd.com>


On 23/08/2021 14:32, Christian König wrote:
> Am 23.08.21 um 13:28 schrieb Tvrtko Ursulin:
>> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>>
>> Proposal to standardise the fdinfo text format as optionally output by 
>> DRM
>> drivers.
>>
>> Idea is that a simple but, well defined, spec will enable generic
>> userspace tools to be written while at the same time avoiding a more 
>> heavy
>> handed approach of adding a mid-layer to DRM.
>>
>> i915 implements a subset of the spec, everything apart from the memory
>> stats currently, and a matching intel_gpu_top tool exists.
>>
>> Open is to see if AMD can migrate to using the proposed GPU utilisation
>> key-value pairs, or if they are not workable to see whether to go
>> vendor specific, or if a standardised  alternative can be found which is
>> workable for both drivers.
>>
>> Same for the memory utilisation key-value pairs proposal.
>>
>> v2:
>>   * Update for removal of name and pid.
>>
>> v3:
>>   * 'Drm-driver' tag will be obtained from struct drm_driver.name. 
>> (Daniel)
>>
>> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>> Cc: David M Nieto <David.Nieto@amd.com>
>> Cc: Christian König <christian.koenig@amd.com>
>> Cc: Daniel Vetter <daniel@ffwll.ch>
>> Cc: Daniel Stone <daniel@fooishbar.org>
> 
> I'm not an expert on that stuff, but as far as I can see this totally 
> makes sense to me.

Thanks!

> Feel free to add an Acked-by: Christian König <christian.koenig@amd.com> 
> to those three patches.

However note that the last one is full of TODO markers, including the 
commit message, where I was hoping to nudge the feature owners of the 
amdgpu side to fill in the blanks in my understanding of how things work 
over there. At least the different semantics need to be documented so 
random userspace can interpret the amdgpu values correctly.

Or alternatively I drop the last patch and if someone is interested they 
can resurrect and complete it at their leisure.

Just not sure how Daniel would accept this since his push was to gate 
i915 addition behind a drive for common solution.

Regards,

Tvrtko

>> ---
>>   Documentation/gpu/drm-usage-stats.rst | 97 +++++++++++++++++++++++++++
>>   Documentation/gpu/index.rst           |  1 +
>>   2 files changed, 98 insertions(+)
>>   create mode 100644 Documentation/gpu/drm-usage-stats.rst
>>
>> diff --git a/Documentation/gpu/drm-usage-stats.rst 
>> b/Documentation/gpu/drm-usage-stats.rst
>> new file mode 100644
>> index 000000000000..c669026be244
>> --- /dev/null
>> +++ b/Documentation/gpu/drm-usage-stats.rst
>> @@ -0,0 +1,97 @@
>> +.. _drm-client-usage-stats:
>> +
>> +======================
>> +DRM client usage stats
>> +======================
>> +
>> +DRM drivers can choose to export partly standardised text output via the
>> +`fops->show_fdinfo()` as part of the driver specific file operations 
>> registered
>> +in the `struct drm_driver` object registered with the DRM core.
>> +
>> +One purpose of this output is to enable writing as generic as practicaly
>> +feasible `top(1)` like userspace monitoring tools.
>> +
>> +Given the differences between various DRM drivers the specification 
>> of the
>> +output is split between common and driver specific parts. Having said 
>> that,
>> +wherever possible effort should still be made to standardise as much as
>> +possible.
>> +
>> +File format specification
>> +=========================
>> +
>> +- File shall contain one key value pair per one line of text.
>> +- Colon character (`:`) must be used to delimit keys and values.
>> +- All keys shall be prefixed with `drm-`.
>> +- Whitespace between the delimiter and first non-whitespace character 
>> shall be
>> +  ignored when parsing.
>> +- Neither keys or values are allowed to contain whitespace characters.
>> +- Numerical key value pairs can end with optional unit string.
>> +- Data type of the value is fixed as defined in the specification.
>> +
>> +Key types
>> +---------
>> +
>> +1. Mandatory, fully standardised.
>> +2. Optional, fully standardised.
>> +3. Driver specific.
>> +
>> +Data types
>> +----------
>> +
>> +- <uint> - Unsigned integer without defining the maximum value.
>> +- <str> - String excluding any above defined reserved characters or 
>> whitespace.
>> +
>> +Mandatory fully standardised keys
>> +---------------------------------
>> +
>> +- drm-driver: <str>
>> +
>> +String shall contain the name this driver registered as via the 
>> respective
>> +`struct drm_driver` data structure.
>> +
>> +Optional fully standardised keys
>> +--------------------------------
>> +
>> +- drm-pdev: <aaaa:bb.cc.d>
>> +
>> +For PCI devices this should contain the PCI slot address of the 
>> device in
>> +question.
>> +
>> +- drm-client-id: <uint>
>> +
>> +Unique value relating to the open DRM file descriptor used to 
>> distinguish
>> +duplicated and shared file descriptors. Conceptually the value should 
>> map 1:1
>> +to the in kernel representation of `struct drm_file` instances.
>> +
>> +Uniqueness of the value shall be either globally unique, or unique 
>> within the
>> +scope of each device, in which case `drm-pdev` shall be present as well.
>> +
>> +Userspace should make sure to not double account any usage statistics 
>> by using
>> +the above described criteria in order to associate data to individual 
>> clients.
>> +
>> +- drm-engine-<str>: <uint> ns
>> +
>> +GPUs usually contain multiple execution engines. Each shall be given 
>> a stable
>> +and unique name (str), with possible values documented in the driver 
>> specific
>> +documentation.
>> +
>> +Value shall be in specified time units which the respective GPU 
>> engine spent
>> +busy executing workloads belonging to this client.
>> +
>> +Values are not required to be constantly monotonic if it makes the 
>> driver
>> +implementation easier, but are required to catch up with the 
>> previously reported
>> +larger value within a reasonable period. Upon observing a value lower 
>> than what
>> +was previously read, userspace is expected to stay with that larger 
>> previous
>> +value until a monotonic update is seen.
>> +
>> +- drm-memory-<str>: <uint> [KiB|MiB]
>> +
>> +Each possible memory type which can be used to store buffer objects 
>> by the
>> +GPU in question shall be given a stable and unique name to be 
>> returned as the
>> +string here.
>> +
>> +Value shall reflect the amount of storage currently consumed by the 
>> buffer
>> +object belong to this client, in the respective memory region.
>> +
>> +Default unit shall be bytes with optional unit specifiers of 'KiB' or 
>> 'MiB'
>> +indicating kibi- or mebi-bytes.
>> diff --git a/Documentation/gpu/index.rst b/Documentation/gpu/index.rst
>> index b9c1214d8f23..b99dede9a5b1 100644
>> --- a/Documentation/gpu/index.rst
>> +++ b/Documentation/gpu/index.rst
>> @@ -10,6 +10,7 @@ Linux GPU Driver Developer's Guide
>>      drm-kms
>>      drm-kms-helpers
>>      drm-uapi
>> +   drm-usage-stats
>>      driver-uapi
>>      drm-client
>>      drivers
> 

  reply	other threads:[~2021-08-24  9:26 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-23 11:28 [RFC 0/8] Per client GPU stats Tvrtko Ursulin
2021-08-23 11:28 ` [Intel-gfx] " Tvrtko Ursulin
2021-08-23 11:28 ` [RFC 1/8] drm/i915: Explicitly track DRM clients Tvrtko Ursulin
2021-08-23 11:28   ` [Intel-gfx] " Tvrtko Ursulin
2021-08-23 11:28 ` [RFC 2/8] drm/i915: Make GEM contexts " Tvrtko Ursulin
2021-08-23 11:28   ` [Intel-gfx] " Tvrtko Ursulin
2021-08-23 11:28 ` [RFC 3/8] drm/i915: Track runtime spent in closed and unreachable GEM contexts Tvrtko Ursulin
2021-08-23 11:28   ` [Intel-gfx] " Tvrtko Ursulin
2021-08-23 11:28 ` [RFC 4/8] drm/i915: Track all user contexts per client Tvrtko Ursulin
2021-08-23 11:28   ` [Intel-gfx] " Tvrtko Ursulin
2021-08-23 11:28 ` [RFC 5/8] drm/i915: Track context current active time Tvrtko Ursulin
2021-08-23 11:28   ` [Intel-gfx] " Tvrtko Ursulin
2021-08-23 11:28 ` [RFC 6/8] drm: Document fdinfo format specification Tvrtko Ursulin
2021-08-23 11:28   ` [Intel-gfx] " Tvrtko Ursulin
2021-08-23 13:32   ` Christian König
2021-08-23 13:32     ` [Intel-gfx] " Christian König
2021-08-24  9:25     ` Tvrtko Ursulin [this message]
2021-08-24  9:25       ` Tvrtko Ursulin
2021-08-24  9:34       ` Christian König
2021-08-24  9:34         ` [Intel-gfx] " Christian König
2021-08-23 11:28 ` [RFC 7/8] drm/i915: Expose client engine utilisation via fdinfo Tvrtko Ursulin
2021-08-23 11:28   ` [Intel-gfx] " Tvrtko Ursulin
2021-08-23 11:28 ` [RFC 8/8] drm/amdgpu: Convert to common fdinfo format Tvrtko Ursulin
2021-08-23 11:28   ` [Intel-gfx] " Tvrtko Ursulin
2021-08-23 11:37 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for Per client GPU stats (rev3) Patchwork
2021-08-23 11:38 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2021-08-23 11:42 ` [Intel-gfx] ✗ Fi.CI.DOCS: " Patchwork
2021-08-23 12:07 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2021-08-23 13:42 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2021-07-15  9:18 [RFC 0/8] Per client GPU stats Tvrtko Ursulin
2021-07-15  9:18 ` [RFC 6/8] drm: Document fdinfo format specification Tvrtko Ursulin
2021-07-23 16:43   ` Daniel Stone
2021-07-23 16:47     ` Daniel Vetter
2021-07-23 17:45       ` Nieto, David M
2021-07-26  9:01         ` Tvrtko Ursulin
2021-07-26  8:57     ` Tvrtko Ursulin

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=337f3b5d-f903-1eb4-9597-d00191dc8788@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=David.Nieto@amd.com \
    --cc=Intel-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=daniel@ffwll.ch \
    --cc=daniel@fooishbar.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=tvrtko.ursulin@intel.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.