All of lore.kernel.org
 help / color / mirror / Atom feed
* [CI 0/8] Per client GPU utilisation
@ 2022-04-01 14:21 ` Tvrtko Ursulin
  0 siblings, 0 replies; 35+ messages in thread
From: Tvrtko Ursulin @ 2022-04-01 14:21 UTC (permalink / raw)
  To: Intel-gfx; +Cc: dri-devel

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Test-with: 20220401141155.3122817-1-tvrtko.ursulin@linux.intel.com

Tvrtko Ursulin (8):
  drm/i915: Explicitly track DRM clients
  drm/i915: Make GEM contexts track DRM clients
  drm/i915: Track runtime spent in closed and unreachable GEM contexts
  drm/i915: Track all user contexts per client
  drm/i915: Track context current active time
  drm: Document fdinfo format specification
  drm/i915: Count engine instances per uabi class
  drm/i915: Expose client engine utilisation via fdinfo

 Documentation/gpu/drm-usage-stats.rst         | 112 +++++++++++++
 Documentation/gpu/i915.rst                    |  28 ++++
 Documentation/gpu/index.rst                   |   1 +
 drivers/gpu/drm/i915/Makefile                 |   1 +
 drivers/gpu/drm/i915/gem/i915_gem_context.c   |  43 ++++-
 .../gpu/drm/i915/gem/i915_gem_context_types.h |   6 +
 drivers/gpu/drm/i915/gt/intel_context.c       |  27 ++-
 drivers/gpu/drm/i915/gt/intel_context.h       |  15 +-
 drivers/gpu/drm/i915/gt/intel_context_types.h |  24 ++-
 drivers/gpu/drm/i915/gt/intel_engine_user.c   |  11 +-
 .../drm/i915/gt/intel_execlists_submission.c  |  23 ++-
 .../gpu/drm/i915/gt/intel_gt_clock_utils.c    |   4 +
 drivers/gpu/drm/i915/gt/intel_lrc.c           |  27 +--
 drivers/gpu/drm/i915/gt/intel_lrc.h           |  27 ++-
 drivers/gpu/drm/i915/gt/selftest_lrc.c        |  10 +-
 drivers/gpu/drm/i915/i915_driver.c            |   9 +
 drivers/gpu/drm/i915/i915_drm_client.c        | 154 ++++++++++++++++++
 drivers/gpu/drm/i915/i915_drm_client.h        |  68 ++++++++
 drivers/gpu/drm/i915/i915_drv.h               |   4 +
 drivers/gpu/drm/i915/i915_file_private.h      |   3 +
 drivers/gpu/drm/i915/i915_gem.c               |  21 ++-
 drivers/gpu/drm/i915/i915_gpu_error.c         |   9 +-
 drivers/gpu/drm/i915/i915_gpu_error.h         |   2 +-
 23 files changed, 569 insertions(+), 60 deletions(-)
 create mode 100644 Documentation/gpu/drm-usage-stats.rst
 create mode 100644 drivers/gpu/drm/i915/i915_drm_client.c
 create mode 100644 drivers/gpu/drm/i915/i915_drm_client.h

-- 
2.32.0


^ permalink raw reply	[flat|nested] 35+ messages in thread

* [Intel-gfx] [CI 0/8] Per client GPU utilisation
@ 2022-04-01 14:21 ` Tvrtko Ursulin
  0 siblings, 0 replies; 35+ messages in thread
From: Tvrtko Ursulin @ 2022-04-01 14:21 UTC (permalink / raw)
  To: Intel-gfx; +Cc: dri-devel

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Test-with: 20220401141155.3122817-1-tvrtko.ursulin@linux.intel.com

Tvrtko Ursulin (8):
  drm/i915: Explicitly track DRM clients
  drm/i915: Make GEM contexts track DRM clients
  drm/i915: Track runtime spent in closed and unreachable GEM contexts
  drm/i915: Track all user contexts per client
  drm/i915: Track context current active time
  drm: Document fdinfo format specification
  drm/i915: Count engine instances per uabi class
  drm/i915: Expose client engine utilisation via fdinfo

 Documentation/gpu/drm-usage-stats.rst         | 112 +++++++++++++
 Documentation/gpu/i915.rst                    |  28 ++++
 Documentation/gpu/index.rst                   |   1 +
 drivers/gpu/drm/i915/Makefile                 |   1 +
 drivers/gpu/drm/i915/gem/i915_gem_context.c   |  43 ++++-
 .../gpu/drm/i915/gem/i915_gem_context_types.h |   6 +
 drivers/gpu/drm/i915/gt/intel_context.c       |  27 ++-
 drivers/gpu/drm/i915/gt/intel_context.h       |  15 +-
 drivers/gpu/drm/i915/gt/intel_context_types.h |  24 ++-
 drivers/gpu/drm/i915/gt/intel_engine_user.c   |  11 +-
 .../drm/i915/gt/intel_execlists_submission.c  |  23 ++-
 .../gpu/drm/i915/gt/intel_gt_clock_utils.c    |   4 +
 drivers/gpu/drm/i915/gt/intel_lrc.c           |  27 +--
 drivers/gpu/drm/i915/gt/intel_lrc.h           |  27 ++-
 drivers/gpu/drm/i915/gt/selftest_lrc.c        |  10 +-
 drivers/gpu/drm/i915/i915_driver.c            |   9 +
 drivers/gpu/drm/i915/i915_drm_client.c        | 154 ++++++++++++++++++
 drivers/gpu/drm/i915/i915_drm_client.h        |  68 ++++++++
 drivers/gpu/drm/i915/i915_drv.h               |   4 +
 drivers/gpu/drm/i915/i915_file_private.h      |   3 +
 drivers/gpu/drm/i915/i915_gem.c               |  21 ++-
 drivers/gpu/drm/i915/i915_gpu_error.c         |   9 +-
 drivers/gpu/drm/i915/i915_gpu_error.h         |   2 +-
 23 files changed, 569 insertions(+), 60 deletions(-)
 create mode 100644 Documentation/gpu/drm-usage-stats.rst
 create mode 100644 drivers/gpu/drm/i915/i915_drm_client.c
 create mode 100644 drivers/gpu/drm/i915/i915_drm_client.h

-- 
2.32.0


^ permalink raw reply	[flat|nested] 35+ messages in thread

* [CI 1/8] drm/i915: Explicitly track DRM clients
  2022-04-01 14:21 ` [Intel-gfx] " Tvrtko Ursulin
@ 2022-04-01 14:21   ` Tvrtko Ursulin
  -1 siblings, 0 replies; 35+ messages in thread
From: Tvrtko Ursulin @ 2022-04-01 14:21 UTC (permalink / raw)
  To: Intel-gfx; +Cc: dri-devel

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Tracking DRM clients more explicitly will allow later patches to
accumulate past and current GPU usage in a centralised place and also
consolidate access to owning task pid/name.

Unique client id is also assigned for the purpose of distinguishing/
consolidating between multiple file descriptors owned by the same process.

v2:
 Chris Wilson:
 * Enclose new members into dedicated structs.
 * Protect against failed sysfs registration.

v3:
 * sysfs_attr_init.

v4:
 * Fix for internal clients.

v5:
 * Use cyclic ida for client id. (Chris)
 * Do not leak pid reference. (Chris)
 * Tidy code with some locals.

v6:
 * Use xa_alloc_cyclic to simplify locking. (Chris)
 * No need to unregister individial sysfs files. (Chris)
 * Rebase on top of fpriv kref.
 * Track client closed status and reflect in sysfs.

v7:
 * Make drm_client more standalone concept.

v8:
 * Simplify sysfs show. (Chris)
 * Always track name and pid.

v9:
 * Fix cyclic id assignment.

v10:
 * No need for a mutex around xa_alloc_cyclic.
 * Refactor sysfs into own function.
 * Unregister sysfs before freeing pid and name.
 * Move clients setup into own function.

v11:
 * Call clients init directly from driver init. (Chris)

v12:
 * Do not fail client add on id wrap. (Maciej)

v13 (Lucas): Rebase.

v14:
 * Dropped sysfs bits.

v15:
 * Dropped tracking of pid/ and name.
 * Dropped RCU freeing of the client object.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> # v11
Reviewed-by: Aravind Iddamsetty <aravind.iddamsetty@intel.com> # v11
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
---
 drivers/gpu/drm/i915/Makefile            |  1 +
 drivers/gpu/drm/i915/i915_driver.c       |  6 +++
 drivers/gpu/drm/i915/i915_drm_client.c   | 68 ++++++++++++++++++++++++
 drivers/gpu/drm/i915/i915_drm_client.h   | 50 +++++++++++++++++
 drivers/gpu/drm/i915/i915_drv.h          |  3 ++
 drivers/gpu/drm/i915/i915_file_private.h |  3 ++
 drivers/gpu/drm/i915/i915_gem.c          | 21 ++++++--
 7 files changed, 149 insertions(+), 3 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/i915_drm_client.c
 create mode 100644 drivers/gpu/drm/i915/i915_drm_client.h

diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index c1d5540f6052..6d4c628ae355 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -32,6 +32,7 @@ subdir-ccflags-y += -I$(srctree)/$(src)
 
 # core driver code
 i915-y += i915_driver.o \
+	  i915_drm_client.o \
 	  i915_config.o \
 	  i915_getparam.o \
 	  i915_ioctl.o \
diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
index 15808ecc421a..b2df273e6d7b 100644
--- a/drivers/gpu/drm/i915/i915_driver.c
+++ b/drivers/gpu/drm/i915/i915_driver.c
@@ -77,6 +77,7 @@
 #include "i915_file_private.h"
 #include "i915_debugfs.h"
 #include "i915_driver.h"
+#include "i915_drm_client.h"
 #include "i915_drv.h"
 #include "i915_getparam.h"
 #include "i915_ioc32.h"
@@ -355,6 +356,8 @@ static int i915_driver_early_probe(struct drm_i915_private *dev_priv)
 
 	intel_root_gt_init_early(dev_priv);
 
+	i915_drm_clients_init(&dev_priv->clients, dev_priv);
+
 	i915_gem_init_early(dev_priv);
 
 	/* This must be called before any calls to HAS_PCH_* */
@@ -375,6 +378,7 @@ static int i915_driver_early_probe(struct drm_i915_private *dev_priv)
 err_gem:
 	i915_gem_cleanup_early(dev_priv);
 	intel_gt_driver_late_release_all(dev_priv);
+	i915_drm_clients_fini(&dev_priv->clients);
 	intel_region_ttm_device_fini(dev_priv);
 err_ttm:
 	vlv_suspend_cleanup(dev_priv);
@@ -394,6 +398,7 @@ static void i915_driver_late_release(struct drm_i915_private *dev_priv)
 	intel_power_domains_cleanup(dev_priv);
 	i915_gem_cleanup_early(dev_priv);
 	intel_gt_driver_late_release_all(dev_priv);
+	i915_drm_clients_fini(&dev_priv->clients);
 	intel_region_ttm_device_fini(dev_priv);
 	vlv_suspend_cleanup(dev_priv);
 	i915_workqueues_cleanup(dev_priv);
@@ -1009,6 +1014,7 @@ static void i915_driver_postclose(struct drm_device *dev, struct drm_file *file)
 	struct drm_i915_file_private *file_priv = file->driver_priv;
 
 	i915_gem_context_close(file);
+	i915_drm_client_put(file_priv->client);
 
 	kfree_rcu(file_priv, rcu);
 
diff --git a/drivers/gpu/drm/i915/i915_drm_client.c b/drivers/gpu/drm/i915/i915_drm_client.c
new file mode 100644
index 000000000000..e61e9ba15256
--- /dev/null
+++ b/drivers/gpu/drm/i915/i915_drm_client.c
@@ -0,0 +1,68 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2020 Intel Corporation
+ */
+
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/types.h>
+
+#include "i915_drm_client.h"
+#include "i915_gem.h"
+#include "i915_utils.h"
+
+void i915_drm_clients_init(struct i915_drm_clients *clients,
+			   struct drm_i915_private *i915)
+{
+	clients->i915 = i915;
+	clients->next_id = 0;
+
+	xa_init_flags(&clients->xarray, XA_FLAGS_ALLOC | XA_FLAGS_LOCK_IRQ);
+}
+
+struct i915_drm_client *i915_drm_client_add(struct i915_drm_clients *clients)
+{
+	struct i915_drm_client *client;
+	struct xarray *xa = &clients->xarray;
+	int ret;
+
+	client = kzalloc(sizeof(*client), GFP_KERNEL);
+	if (!client)
+		return ERR_PTR(-ENOMEM);
+
+	xa_lock_irq(xa);
+	ret = __xa_alloc_cyclic(xa, &client->id, client, xa_limit_32b,
+				&clients->next_id, GFP_KERNEL);
+	xa_unlock_irq(xa);
+	if (ret < 0)
+		goto err;
+
+	kref_init(&client->kref);
+	client->clients = clients;
+
+	return client;
+
+err:
+	kfree(client);
+
+	return ERR_PTR(ret);
+}
+
+void __i915_drm_client_free(struct kref *kref)
+{
+	struct i915_drm_client *client =
+		container_of(kref, typeof(*client), kref);
+	struct xarray *xa = &client->clients->xarray;
+	unsigned long flags;
+
+	xa_lock_irqsave(xa, flags);
+	__xa_erase(xa, client->id);
+	xa_unlock_irqrestore(xa, flags);
+	kfree(client);
+}
+
+void i915_drm_clients_fini(struct i915_drm_clients *clients)
+{
+	GEM_BUG_ON(!xa_empty(&clients->xarray));
+	xa_destroy(&clients->xarray);
+}
diff --git a/drivers/gpu/drm/i915/i915_drm_client.h b/drivers/gpu/drm/i915/i915_drm_client.h
new file mode 100644
index 000000000000..e8986ad51176
--- /dev/null
+++ b/drivers/gpu/drm/i915/i915_drm_client.h
@@ -0,0 +1,50 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2020 Intel Corporation
+ */
+
+#ifndef __I915_DRM_CLIENT_H__
+#define __I915_DRM_CLIENT_H__
+
+#include <linux/kref.h>
+#include <linux/xarray.h>
+
+struct drm_i915_private;
+
+struct i915_drm_clients {
+	struct drm_i915_private *i915;
+
+	struct xarray xarray;
+	u32 next_id;
+};
+
+struct i915_drm_client {
+	struct kref kref;
+
+	unsigned int id;
+
+	struct i915_drm_clients *clients;
+};
+
+void i915_drm_clients_init(struct i915_drm_clients *clients,
+			   struct drm_i915_private *i915);
+
+static inline struct i915_drm_client *
+i915_drm_client_get(struct i915_drm_client *client)
+{
+	kref_get(&client->kref);
+	return client;
+}
+
+void __i915_drm_client_free(struct kref *kref);
+
+static inline void i915_drm_client_put(struct i915_drm_client *client)
+{
+	kref_put(&client->kref, __i915_drm_client_free);
+}
+
+struct i915_drm_client *i915_drm_client_add(struct i915_drm_clients *clients);
+
+void i915_drm_clients_fini(struct i915_drm_clients *clients);
+
+#endif /* !__I915_DRM_CLIENT_H__ */
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 799f386a7ef2..bbda3e01d03d 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -61,6 +61,7 @@
 #include "gt/intel_workarounds.h"
 #include "gt/uc/intel_uc.h"
 
+#include "i915_drm_client.h"
 #include "i915_gem.h"
 #include "i915_gpu_error.h"
 #include "i915_params.h"
@@ -826,6 +827,8 @@ struct drm_i915_private {
 
 	struct i915_pmu pmu;
 
+	struct i915_drm_clients clients;
+
 	struct i915_hdcp_comp_master *hdcp_master;
 	bool hdcp_comp_added;
 
diff --git a/drivers/gpu/drm/i915/i915_file_private.h b/drivers/gpu/drm/i915/i915_file_private.h
index fb16cc431b2a..f42877869692 100644
--- a/drivers/gpu/drm/i915/i915_file_private.h
+++ b/drivers/gpu/drm/i915/i915_file_private.h
@@ -12,6 +12,7 @@
 
 struct drm_i915_private;
 struct drm_file;
+struct i915_drm_client;
 
 struct drm_i915_file_private {
 	struct drm_i915_private *dev_priv;
@@ -103,6 +104,8 @@ struct drm_i915_file_private {
 	/** ban_score: Accumulated score of all ctx bans and fast hangs. */
 	atomic_t ban_score;
 	unsigned long hang_timestamp;
+
+	struct i915_drm_client *client;
 };
 
 #endif /* __I915_FILE_PRIVATE_H__ */
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 44741f842852..702e5b89be22 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1227,25 +1227,40 @@ void i915_gem_cleanup_early(struct drm_i915_private *dev_priv)
 int i915_gem_open(struct drm_i915_private *i915, struct drm_file *file)
 {
 	struct drm_i915_file_private *file_priv;
-	int ret;
+	struct i915_drm_client *client;
+	int ret = -ENOMEM;
 
 	DRM_DEBUG("\n");
 
 	file_priv = kzalloc(sizeof(*file_priv), GFP_KERNEL);
 	if (!file_priv)
-		return -ENOMEM;
+		goto err_alloc;
+
+	client = i915_drm_client_add(&i915->clients);
+	if (IS_ERR(client)) {
+		ret = PTR_ERR(client);
+		goto err_client;
+	}
 
 	file->driver_priv = file_priv;
 	file_priv->dev_priv = i915;
 	file_priv->file = file;
+	file_priv->client = client;
 
 	file_priv->bsd_engine = -1;
 	file_priv->hang_timestamp = jiffies;
 
 	ret = i915_gem_context_open(i915, file);
 	if (ret)
-		kfree(file_priv);
+		goto err_context;
+
+	return 0;
 
+err_context:
+	i915_drm_client_put(client);
+err_client:
+	kfree(file_priv);
+err_alloc:
 	return ret;
 }
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [Intel-gfx] [CI 1/8] drm/i915: Explicitly track DRM clients
@ 2022-04-01 14:21   ` Tvrtko Ursulin
  0 siblings, 0 replies; 35+ messages in thread
From: Tvrtko Ursulin @ 2022-04-01 14:21 UTC (permalink / raw)
  To: Intel-gfx; +Cc: dri-devel

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Tracking DRM clients more explicitly will allow later patches to
accumulate past and current GPU usage in a centralised place and also
consolidate access to owning task pid/name.

Unique client id is also assigned for the purpose of distinguishing/
consolidating between multiple file descriptors owned by the same process.

v2:
 Chris Wilson:
 * Enclose new members into dedicated structs.
 * Protect against failed sysfs registration.

v3:
 * sysfs_attr_init.

v4:
 * Fix for internal clients.

v5:
 * Use cyclic ida for client id. (Chris)
 * Do not leak pid reference. (Chris)
 * Tidy code with some locals.

v6:
 * Use xa_alloc_cyclic to simplify locking. (Chris)
 * No need to unregister individial sysfs files. (Chris)
 * Rebase on top of fpriv kref.
 * Track client closed status and reflect in sysfs.

v7:
 * Make drm_client more standalone concept.

v8:
 * Simplify sysfs show. (Chris)
 * Always track name and pid.

v9:
 * Fix cyclic id assignment.

v10:
 * No need for a mutex around xa_alloc_cyclic.
 * Refactor sysfs into own function.
 * Unregister sysfs before freeing pid and name.
 * Move clients setup into own function.

v11:
 * Call clients init directly from driver init. (Chris)

v12:
 * Do not fail client add on id wrap. (Maciej)

v13 (Lucas): Rebase.

v14:
 * Dropped sysfs bits.

v15:
 * Dropped tracking of pid/ and name.
 * Dropped RCU freeing of the client object.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> # v11
Reviewed-by: Aravind Iddamsetty <aravind.iddamsetty@intel.com> # v11
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
---
 drivers/gpu/drm/i915/Makefile            |  1 +
 drivers/gpu/drm/i915/i915_driver.c       |  6 +++
 drivers/gpu/drm/i915/i915_drm_client.c   | 68 ++++++++++++++++++++++++
 drivers/gpu/drm/i915/i915_drm_client.h   | 50 +++++++++++++++++
 drivers/gpu/drm/i915/i915_drv.h          |  3 ++
 drivers/gpu/drm/i915/i915_file_private.h |  3 ++
 drivers/gpu/drm/i915/i915_gem.c          | 21 ++++++--
 7 files changed, 149 insertions(+), 3 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/i915_drm_client.c
 create mode 100644 drivers/gpu/drm/i915/i915_drm_client.h

diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index c1d5540f6052..6d4c628ae355 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -32,6 +32,7 @@ subdir-ccflags-y += -I$(srctree)/$(src)
 
 # core driver code
 i915-y += i915_driver.o \
+	  i915_drm_client.o \
 	  i915_config.o \
 	  i915_getparam.o \
 	  i915_ioctl.o \
diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
index 15808ecc421a..b2df273e6d7b 100644
--- a/drivers/gpu/drm/i915/i915_driver.c
+++ b/drivers/gpu/drm/i915/i915_driver.c
@@ -77,6 +77,7 @@
 #include "i915_file_private.h"
 #include "i915_debugfs.h"
 #include "i915_driver.h"
+#include "i915_drm_client.h"
 #include "i915_drv.h"
 #include "i915_getparam.h"
 #include "i915_ioc32.h"
@@ -355,6 +356,8 @@ static int i915_driver_early_probe(struct drm_i915_private *dev_priv)
 
 	intel_root_gt_init_early(dev_priv);
 
+	i915_drm_clients_init(&dev_priv->clients, dev_priv);
+
 	i915_gem_init_early(dev_priv);
 
 	/* This must be called before any calls to HAS_PCH_* */
@@ -375,6 +378,7 @@ static int i915_driver_early_probe(struct drm_i915_private *dev_priv)
 err_gem:
 	i915_gem_cleanup_early(dev_priv);
 	intel_gt_driver_late_release_all(dev_priv);
+	i915_drm_clients_fini(&dev_priv->clients);
 	intel_region_ttm_device_fini(dev_priv);
 err_ttm:
 	vlv_suspend_cleanup(dev_priv);
@@ -394,6 +398,7 @@ static void i915_driver_late_release(struct drm_i915_private *dev_priv)
 	intel_power_domains_cleanup(dev_priv);
 	i915_gem_cleanup_early(dev_priv);
 	intel_gt_driver_late_release_all(dev_priv);
+	i915_drm_clients_fini(&dev_priv->clients);
 	intel_region_ttm_device_fini(dev_priv);
 	vlv_suspend_cleanup(dev_priv);
 	i915_workqueues_cleanup(dev_priv);
@@ -1009,6 +1014,7 @@ static void i915_driver_postclose(struct drm_device *dev, struct drm_file *file)
 	struct drm_i915_file_private *file_priv = file->driver_priv;
 
 	i915_gem_context_close(file);
+	i915_drm_client_put(file_priv->client);
 
 	kfree_rcu(file_priv, rcu);
 
diff --git a/drivers/gpu/drm/i915/i915_drm_client.c b/drivers/gpu/drm/i915/i915_drm_client.c
new file mode 100644
index 000000000000..e61e9ba15256
--- /dev/null
+++ b/drivers/gpu/drm/i915/i915_drm_client.c
@@ -0,0 +1,68 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2020 Intel Corporation
+ */
+
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/types.h>
+
+#include "i915_drm_client.h"
+#include "i915_gem.h"
+#include "i915_utils.h"
+
+void i915_drm_clients_init(struct i915_drm_clients *clients,
+			   struct drm_i915_private *i915)
+{
+	clients->i915 = i915;
+	clients->next_id = 0;
+
+	xa_init_flags(&clients->xarray, XA_FLAGS_ALLOC | XA_FLAGS_LOCK_IRQ);
+}
+
+struct i915_drm_client *i915_drm_client_add(struct i915_drm_clients *clients)
+{
+	struct i915_drm_client *client;
+	struct xarray *xa = &clients->xarray;
+	int ret;
+
+	client = kzalloc(sizeof(*client), GFP_KERNEL);
+	if (!client)
+		return ERR_PTR(-ENOMEM);
+
+	xa_lock_irq(xa);
+	ret = __xa_alloc_cyclic(xa, &client->id, client, xa_limit_32b,
+				&clients->next_id, GFP_KERNEL);
+	xa_unlock_irq(xa);
+	if (ret < 0)
+		goto err;
+
+	kref_init(&client->kref);
+	client->clients = clients;
+
+	return client;
+
+err:
+	kfree(client);
+
+	return ERR_PTR(ret);
+}
+
+void __i915_drm_client_free(struct kref *kref)
+{
+	struct i915_drm_client *client =
+		container_of(kref, typeof(*client), kref);
+	struct xarray *xa = &client->clients->xarray;
+	unsigned long flags;
+
+	xa_lock_irqsave(xa, flags);
+	__xa_erase(xa, client->id);
+	xa_unlock_irqrestore(xa, flags);
+	kfree(client);
+}
+
+void i915_drm_clients_fini(struct i915_drm_clients *clients)
+{
+	GEM_BUG_ON(!xa_empty(&clients->xarray));
+	xa_destroy(&clients->xarray);
+}
diff --git a/drivers/gpu/drm/i915/i915_drm_client.h b/drivers/gpu/drm/i915/i915_drm_client.h
new file mode 100644
index 000000000000..e8986ad51176
--- /dev/null
+++ b/drivers/gpu/drm/i915/i915_drm_client.h
@@ -0,0 +1,50 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2020 Intel Corporation
+ */
+
+#ifndef __I915_DRM_CLIENT_H__
+#define __I915_DRM_CLIENT_H__
+
+#include <linux/kref.h>
+#include <linux/xarray.h>
+
+struct drm_i915_private;
+
+struct i915_drm_clients {
+	struct drm_i915_private *i915;
+
+	struct xarray xarray;
+	u32 next_id;
+};
+
+struct i915_drm_client {
+	struct kref kref;
+
+	unsigned int id;
+
+	struct i915_drm_clients *clients;
+};
+
+void i915_drm_clients_init(struct i915_drm_clients *clients,
+			   struct drm_i915_private *i915);
+
+static inline struct i915_drm_client *
+i915_drm_client_get(struct i915_drm_client *client)
+{
+	kref_get(&client->kref);
+	return client;
+}
+
+void __i915_drm_client_free(struct kref *kref);
+
+static inline void i915_drm_client_put(struct i915_drm_client *client)
+{
+	kref_put(&client->kref, __i915_drm_client_free);
+}
+
+struct i915_drm_client *i915_drm_client_add(struct i915_drm_clients *clients);
+
+void i915_drm_clients_fini(struct i915_drm_clients *clients);
+
+#endif /* !__I915_DRM_CLIENT_H__ */
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 799f386a7ef2..bbda3e01d03d 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -61,6 +61,7 @@
 #include "gt/intel_workarounds.h"
 #include "gt/uc/intel_uc.h"
 
+#include "i915_drm_client.h"
 #include "i915_gem.h"
 #include "i915_gpu_error.h"
 #include "i915_params.h"
@@ -826,6 +827,8 @@ struct drm_i915_private {
 
 	struct i915_pmu pmu;
 
+	struct i915_drm_clients clients;
+
 	struct i915_hdcp_comp_master *hdcp_master;
 	bool hdcp_comp_added;
 
diff --git a/drivers/gpu/drm/i915/i915_file_private.h b/drivers/gpu/drm/i915/i915_file_private.h
index fb16cc431b2a..f42877869692 100644
--- a/drivers/gpu/drm/i915/i915_file_private.h
+++ b/drivers/gpu/drm/i915/i915_file_private.h
@@ -12,6 +12,7 @@
 
 struct drm_i915_private;
 struct drm_file;
+struct i915_drm_client;
 
 struct drm_i915_file_private {
 	struct drm_i915_private *dev_priv;
@@ -103,6 +104,8 @@ struct drm_i915_file_private {
 	/** ban_score: Accumulated score of all ctx bans and fast hangs. */
 	atomic_t ban_score;
 	unsigned long hang_timestamp;
+
+	struct i915_drm_client *client;
 };
 
 #endif /* __I915_FILE_PRIVATE_H__ */
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 44741f842852..702e5b89be22 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1227,25 +1227,40 @@ void i915_gem_cleanup_early(struct drm_i915_private *dev_priv)
 int i915_gem_open(struct drm_i915_private *i915, struct drm_file *file)
 {
 	struct drm_i915_file_private *file_priv;
-	int ret;
+	struct i915_drm_client *client;
+	int ret = -ENOMEM;
 
 	DRM_DEBUG("\n");
 
 	file_priv = kzalloc(sizeof(*file_priv), GFP_KERNEL);
 	if (!file_priv)
-		return -ENOMEM;
+		goto err_alloc;
+
+	client = i915_drm_client_add(&i915->clients);
+	if (IS_ERR(client)) {
+		ret = PTR_ERR(client);
+		goto err_client;
+	}
 
 	file->driver_priv = file_priv;
 	file_priv->dev_priv = i915;
 	file_priv->file = file;
+	file_priv->client = client;
 
 	file_priv->bsd_engine = -1;
 	file_priv->hang_timestamp = jiffies;
 
 	ret = i915_gem_context_open(i915, file);
 	if (ret)
-		kfree(file_priv);
+		goto err_context;
+
+	return 0;
 
+err_context:
+	i915_drm_client_put(client);
+err_client:
+	kfree(file_priv);
+err_alloc:
 	return ret;
 }
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [CI 2/8] drm/i915: Make GEM contexts track DRM clients
  2022-04-01 14:21 ` [Intel-gfx] " Tvrtko Ursulin
@ 2022-04-01 14:21   ` Tvrtko Ursulin
  -1 siblings, 0 replies; 35+ messages in thread
From: Tvrtko Ursulin @ 2022-04-01 14:21 UTC (permalink / raw)
  To: Intel-gfx; +Cc: dri-devel

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Make GEM contexts keep a reference to i915_drm_client for the whole of
of their lifetime which will come handy in following patches.

v2: Don't bother supporting selftests contexts from debugfs. (Chris)
v3 (Lucas): Finish constructing ctx before adding it to the list
v4 (Ram): Rebase.
v5: Trivial rebase for proto ctx changes.
v6: Rebase after clients no longer track name and pid.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> # v5
Reviewed-by: Aravind Iddamsetty <aravind.iddamsetty@intel.com> # v5
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_context.c       | 5 +++++
 drivers/gpu/drm/i915/gem/i915_gem_context_types.h | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
index 5394fbed8bf0..6781ee34646c 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
@@ -1257,6 +1257,9 @@ static void i915_gem_context_release_work(struct work_struct *work)
 	if (ctx->pxp_wakeref)
 		intel_runtime_pm_put(&ctx->i915->runtime_pm, ctx->pxp_wakeref);
 
+	if (ctx->client)
+		i915_drm_client_put(ctx->client);
+
 	mutex_destroy(&ctx->engines_mutex);
 	mutex_destroy(&ctx->lut_mutex);
 
@@ -1663,6 +1666,8 @@ static void gem_context_register(struct i915_gem_context *ctx,
 	ctx->file_priv = fpriv;
 
 	ctx->pid = get_task_pid(current, PIDTYPE_PID);
+	ctx->client = i915_drm_client_get(fpriv->client);
+
 	snprintf(ctx->name, sizeof(ctx->name), "%s[%d]",
 		 current->comm, pid_nr(ctx->pid));
 
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context_types.h b/drivers/gpu/drm/i915/gem/i915_gem_context_types.h
index 282cdb8a5c5a..93d24f189ba9 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context_types.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context_types.h
@@ -293,6 +293,9 @@ struct i915_gem_context {
 	/** @link: place with &drm_i915_private.context_list */
 	struct list_head link;
 
+	/** @client: struct i915_drm_client */
+	struct i915_drm_client *client;
+
 	/**
 	 * @ref: reference count
 	 *
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [Intel-gfx] [CI 2/8] drm/i915: Make GEM contexts track DRM clients
@ 2022-04-01 14:21   ` Tvrtko Ursulin
  0 siblings, 0 replies; 35+ messages in thread
From: Tvrtko Ursulin @ 2022-04-01 14:21 UTC (permalink / raw)
  To: Intel-gfx; +Cc: dri-devel

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Make GEM contexts keep a reference to i915_drm_client for the whole of
of their lifetime which will come handy in following patches.

v2: Don't bother supporting selftests contexts from debugfs. (Chris)
v3 (Lucas): Finish constructing ctx before adding it to the list
v4 (Ram): Rebase.
v5: Trivial rebase for proto ctx changes.
v6: Rebase after clients no longer track name and pid.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> # v5
Reviewed-by: Aravind Iddamsetty <aravind.iddamsetty@intel.com> # v5
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_context.c       | 5 +++++
 drivers/gpu/drm/i915/gem/i915_gem_context_types.h | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
index 5394fbed8bf0..6781ee34646c 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
@@ -1257,6 +1257,9 @@ static void i915_gem_context_release_work(struct work_struct *work)
 	if (ctx->pxp_wakeref)
 		intel_runtime_pm_put(&ctx->i915->runtime_pm, ctx->pxp_wakeref);
 
+	if (ctx->client)
+		i915_drm_client_put(ctx->client);
+
 	mutex_destroy(&ctx->engines_mutex);
 	mutex_destroy(&ctx->lut_mutex);
 
@@ -1663,6 +1666,8 @@ static void gem_context_register(struct i915_gem_context *ctx,
 	ctx->file_priv = fpriv;
 
 	ctx->pid = get_task_pid(current, PIDTYPE_PID);
+	ctx->client = i915_drm_client_get(fpriv->client);
+
 	snprintf(ctx->name, sizeof(ctx->name), "%s[%d]",
 		 current->comm, pid_nr(ctx->pid));
 
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context_types.h b/drivers/gpu/drm/i915/gem/i915_gem_context_types.h
index 282cdb8a5c5a..93d24f189ba9 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context_types.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context_types.h
@@ -293,6 +293,9 @@ struct i915_gem_context {
 	/** @link: place with &drm_i915_private.context_list */
 	struct list_head link;
 
+	/** @client: struct i915_drm_client */
+	struct i915_drm_client *client;
+
 	/**
 	 * @ref: reference count
 	 *
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [CI 3/8] drm/i915: Track runtime spent in closed and unreachable GEM contexts
  2022-04-01 14:21 ` [Intel-gfx] " Tvrtko Ursulin
@ 2022-04-01 14:22   ` Tvrtko Ursulin
  -1 siblings, 0 replies; 35+ messages in thread
From: Tvrtko Ursulin @ 2022-04-01 14:22 UTC (permalink / raw)
  To: Intel-gfx; +Cc: dri-devel

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

As contexts are abandoned we want to remember how much GPU time they used
(per class) so later we can used it for smarter purposes.

As GEM contexts are closed we want to have the DRM client remember how
much GPU time they used (per class) so later we can used it for smarter
purposes.

v2:
 * Size past runtimes array by uabi class, not internal.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Aravind Iddamsetty <aravind.iddamsetty@intel.com> # v1
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> # v1
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_context.c | 25 +++++++++++++++++++--
 drivers/gpu/drm/i915/i915_drm_client.h      |  9 ++++++++
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
index 6781ee34646c..50cc87b0cf97 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
@@ -1031,23 +1031,44 @@ static void free_engines_rcu(struct rcu_head *rcu)
 	free_engines(engines);
 }
 
+static void accumulate_runtime(struct i915_drm_client *client,
+			       struct i915_gem_engines *engines)
+{
+	struct i915_gem_engines_iter it;
+	struct intel_context *ce;
+
+	if (!client)
+		return;
+
+	/* Transfer accumulated runtime to the parent GEM context. */
+	for_each_gem_engine(ce, engines, it) {
+		unsigned int class = ce->engine->uabi_class;
+
+		GEM_BUG_ON(class >= ARRAY_SIZE(client->past_runtime));
+		atomic64_add(intel_context_get_total_runtime_ns(ce),
+			     &client->past_runtime[class]);
+	}
+}
+
 static int
 engines_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state)
 {
 	struct i915_gem_engines *engines =
 		container_of(fence, typeof(*engines), fence);
+	struct i915_gem_context *ctx = engines->ctx;
 
 	switch (state) {
 	case FENCE_COMPLETE:
 		if (!list_empty(&engines->link)) {
-			struct i915_gem_context *ctx = engines->ctx;
 			unsigned long flags;
 
 			spin_lock_irqsave(&ctx->stale.lock, flags);
 			list_del(&engines->link);
 			spin_unlock_irqrestore(&ctx->stale.lock, flags);
 		}
-		i915_gem_context_put(engines->ctx);
+		accumulate_runtime(ctx->client, engines);
+		i915_gem_context_put(ctx);
+
 		break;
 
 	case FENCE_FREE:
diff --git a/drivers/gpu/drm/i915/i915_drm_client.h b/drivers/gpu/drm/i915/i915_drm_client.h
index e8986ad51176..cbc3161ab021 100644
--- a/drivers/gpu/drm/i915/i915_drm_client.h
+++ b/drivers/gpu/drm/i915/i915_drm_client.h
@@ -9,6 +9,10 @@
 #include <linux/kref.h>
 #include <linux/xarray.h>
 
+#include "gt/intel_engine_types.h"
+
+#define I915_LAST_UABI_ENGINE_CLASS I915_ENGINE_CLASS_VIDEO_ENHANCE
+
 struct drm_i915_private;
 
 struct i915_drm_clients {
@@ -24,6 +28,11 @@ struct i915_drm_client {
 	unsigned int id;
 
 	struct i915_drm_clients *clients;
+
+	/**
+	 * @past_runtime: Accumulation of pphwsp runtimes from closed contexts.
+	 */
+	atomic64_t past_runtime[I915_LAST_UABI_ENGINE_CLASS + 1];
 };
 
 void i915_drm_clients_init(struct i915_drm_clients *clients,
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [Intel-gfx] [CI 3/8] drm/i915: Track runtime spent in closed and unreachable GEM contexts
@ 2022-04-01 14:22   ` Tvrtko Ursulin
  0 siblings, 0 replies; 35+ messages in thread
From: Tvrtko Ursulin @ 2022-04-01 14:22 UTC (permalink / raw)
  To: Intel-gfx; +Cc: dri-devel

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

As contexts are abandoned we want to remember how much GPU time they used
(per class) so later we can used it for smarter purposes.

As GEM contexts are closed we want to have the DRM client remember how
much GPU time they used (per class) so later we can used it for smarter
purposes.

v2:
 * Size past runtimes array by uabi class, not internal.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Aravind Iddamsetty <aravind.iddamsetty@intel.com> # v1
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> # v1
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_context.c | 25 +++++++++++++++++++--
 drivers/gpu/drm/i915/i915_drm_client.h      |  9 ++++++++
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
index 6781ee34646c..50cc87b0cf97 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
@@ -1031,23 +1031,44 @@ static void free_engines_rcu(struct rcu_head *rcu)
 	free_engines(engines);
 }
 
+static void accumulate_runtime(struct i915_drm_client *client,
+			       struct i915_gem_engines *engines)
+{
+	struct i915_gem_engines_iter it;
+	struct intel_context *ce;
+
+	if (!client)
+		return;
+
+	/* Transfer accumulated runtime to the parent GEM context. */
+	for_each_gem_engine(ce, engines, it) {
+		unsigned int class = ce->engine->uabi_class;
+
+		GEM_BUG_ON(class >= ARRAY_SIZE(client->past_runtime));
+		atomic64_add(intel_context_get_total_runtime_ns(ce),
+			     &client->past_runtime[class]);
+	}
+}
+
 static int
 engines_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state)
 {
 	struct i915_gem_engines *engines =
 		container_of(fence, typeof(*engines), fence);
+	struct i915_gem_context *ctx = engines->ctx;
 
 	switch (state) {
 	case FENCE_COMPLETE:
 		if (!list_empty(&engines->link)) {
-			struct i915_gem_context *ctx = engines->ctx;
 			unsigned long flags;
 
 			spin_lock_irqsave(&ctx->stale.lock, flags);
 			list_del(&engines->link);
 			spin_unlock_irqrestore(&ctx->stale.lock, flags);
 		}
-		i915_gem_context_put(engines->ctx);
+		accumulate_runtime(ctx->client, engines);
+		i915_gem_context_put(ctx);
+
 		break;
 
 	case FENCE_FREE:
diff --git a/drivers/gpu/drm/i915/i915_drm_client.h b/drivers/gpu/drm/i915/i915_drm_client.h
index e8986ad51176..cbc3161ab021 100644
--- a/drivers/gpu/drm/i915/i915_drm_client.h
+++ b/drivers/gpu/drm/i915/i915_drm_client.h
@@ -9,6 +9,10 @@
 #include <linux/kref.h>
 #include <linux/xarray.h>
 
+#include "gt/intel_engine_types.h"
+
+#define I915_LAST_UABI_ENGINE_CLASS I915_ENGINE_CLASS_VIDEO_ENHANCE
+
 struct drm_i915_private;
 
 struct i915_drm_clients {
@@ -24,6 +28,11 @@ struct i915_drm_client {
 	unsigned int id;
 
 	struct i915_drm_clients *clients;
+
+	/**
+	 * @past_runtime: Accumulation of pphwsp runtimes from closed contexts.
+	 */
+	atomic64_t past_runtime[I915_LAST_UABI_ENGINE_CLASS + 1];
 };
 
 void i915_drm_clients_init(struct i915_drm_clients *clients,
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [CI 4/8] drm/i915: Track all user contexts per client
  2022-04-01 14:21 ` [Intel-gfx] " Tvrtko Ursulin
@ 2022-04-01 14:22   ` Tvrtko Ursulin
  -1 siblings, 0 replies; 35+ messages in thread
From: Tvrtko Ursulin @ 2022-04-01 14:22 UTC (permalink / raw)
  To: Intel-gfx; +Cc: dri-devel

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

We soon want to start answering questions like how much GPU time is the
context belonging to a client which exited still using.

To enable this we start tracking all context belonging to a client on a
separate list.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Aravind Iddamsetty <aravind.iddamsetty@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_context.c       | 13 +++++++++++++
 drivers/gpu/drm/i915/gem/i915_gem_context_types.h |  3 +++
 drivers/gpu/drm/i915/i915_drm_client.c            |  2 ++
 drivers/gpu/drm/i915/i915_drm_client.h            |  5 +++++
 4 files changed, 23 insertions(+)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
index 50cc87b0cf97..92652528b7f9 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
@@ -1491,6 +1491,8 @@ static void set_closed_name(struct i915_gem_context *ctx)
 
 static void context_close(struct i915_gem_context *ctx)
 {
+	struct i915_drm_client *client;
+
 	/* Flush any concurrent set_engines() */
 	mutex_lock(&ctx->engines_mutex);
 	unpin_engines(__context_engines_static(ctx));
@@ -1515,6 +1517,13 @@ static void context_close(struct i915_gem_context *ctx)
 	list_del(&ctx->link);
 	spin_unlock(&ctx->i915->gem.contexts.lock);
 
+	client = ctx->client;
+	if (client) {
+		spin_lock(&client->ctx_lock);
+		list_del_rcu(&ctx->client_link);
+		spin_unlock(&client->ctx_lock);
+	}
+
 	mutex_unlock(&ctx->mutex);
 
 	/*
@@ -1696,6 +1705,10 @@ static void gem_context_register(struct i915_gem_context *ctx,
 	old = xa_store(&fpriv->context_xa, id, ctx, GFP_KERNEL);
 	WARN_ON(old);
 
+	spin_lock(&ctx->client->ctx_lock);
+	list_add_tail_rcu(&ctx->client_link, &ctx->client->ctx_list);
+	spin_unlock(&ctx->client->ctx_lock);
+
 	spin_lock(&i915->gem.contexts.lock);
 	list_add_tail(&ctx->link, &i915->gem.contexts.list);
 	spin_unlock(&i915->gem.contexts.lock);
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context_types.h b/drivers/gpu/drm/i915/gem/i915_gem_context_types.h
index 93d24f189ba9..5946dcb11cf5 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context_types.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context_types.h
@@ -296,6 +296,9 @@ struct i915_gem_context {
 	/** @client: struct i915_drm_client */
 	struct i915_drm_client *client;
 
+	/** link: &drm_client.context_list */
+	struct list_head client_link;
+
 	/**
 	 * @ref: reference count
 	 *
diff --git a/drivers/gpu/drm/i915/i915_drm_client.c b/drivers/gpu/drm/i915/i915_drm_client.c
index e61e9ba15256..91a8559bebf7 100644
--- a/drivers/gpu/drm/i915/i915_drm_client.c
+++ b/drivers/gpu/drm/i915/i915_drm_client.c
@@ -38,6 +38,8 @@ struct i915_drm_client *i915_drm_client_add(struct i915_drm_clients *clients)
 		goto err;
 
 	kref_init(&client->kref);
+	spin_lock_init(&client->ctx_lock);
+	INIT_LIST_HEAD(&client->ctx_list);
 	client->clients = clients;
 
 	return client;
diff --git a/drivers/gpu/drm/i915/i915_drm_client.h b/drivers/gpu/drm/i915/i915_drm_client.h
index cbc3161ab021..191368386ace 100644
--- a/drivers/gpu/drm/i915/i915_drm_client.h
+++ b/drivers/gpu/drm/i915/i915_drm_client.h
@@ -7,6 +7,8 @@
 #define __I915_DRM_CLIENT_H__
 
 #include <linux/kref.h>
+#include <linux/list.h>
+#include <linux/spinlock.h>
 #include <linux/xarray.h>
 
 #include "gt/intel_engine_types.h"
@@ -27,6 +29,9 @@ struct i915_drm_client {
 
 	unsigned int id;
 
+	spinlock_t ctx_lock; /* For add/remove from ctx_list. */
+	struct list_head ctx_list; /* List of contexts belonging to client. */
+
 	struct i915_drm_clients *clients;
 
 	/**
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [Intel-gfx] [CI 4/8] drm/i915: Track all user contexts per client
@ 2022-04-01 14:22   ` Tvrtko Ursulin
  0 siblings, 0 replies; 35+ messages in thread
From: Tvrtko Ursulin @ 2022-04-01 14:22 UTC (permalink / raw)
  To: Intel-gfx; +Cc: dri-devel

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

We soon want to start answering questions like how much GPU time is the
context belonging to a client which exited still using.

To enable this we start tracking all context belonging to a client on a
separate list.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Aravind Iddamsetty <aravind.iddamsetty@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_context.c       | 13 +++++++++++++
 drivers/gpu/drm/i915/gem/i915_gem_context_types.h |  3 +++
 drivers/gpu/drm/i915/i915_drm_client.c            |  2 ++
 drivers/gpu/drm/i915/i915_drm_client.h            |  5 +++++
 4 files changed, 23 insertions(+)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
index 50cc87b0cf97..92652528b7f9 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
@@ -1491,6 +1491,8 @@ static void set_closed_name(struct i915_gem_context *ctx)
 
 static void context_close(struct i915_gem_context *ctx)
 {
+	struct i915_drm_client *client;
+
 	/* Flush any concurrent set_engines() */
 	mutex_lock(&ctx->engines_mutex);
 	unpin_engines(__context_engines_static(ctx));
@@ -1515,6 +1517,13 @@ static void context_close(struct i915_gem_context *ctx)
 	list_del(&ctx->link);
 	spin_unlock(&ctx->i915->gem.contexts.lock);
 
+	client = ctx->client;
+	if (client) {
+		spin_lock(&client->ctx_lock);
+		list_del_rcu(&ctx->client_link);
+		spin_unlock(&client->ctx_lock);
+	}
+
 	mutex_unlock(&ctx->mutex);
 
 	/*
@@ -1696,6 +1705,10 @@ static void gem_context_register(struct i915_gem_context *ctx,
 	old = xa_store(&fpriv->context_xa, id, ctx, GFP_KERNEL);
 	WARN_ON(old);
 
+	spin_lock(&ctx->client->ctx_lock);
+	list_add_tail_rcu(&ctx->client_link, &ctx->client->ctx_list);
+	spin_unlock(&ctx->client->ctx_lock);
+
 	spin_lock(&i915->gem.contexts.lock);
 	list_add_tail(&ctx->link, &i915->gem.contexts.list);
 	spin_unlock(&i915->gem.contexts.lock);
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context_types.h b/drivers/gpu/drm/i915/gem/i915_gem_context_types.h
index 93d24f189ba9..5946dcb11cf5 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context_types.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context_types.h
@@ -296,6 +296,9 @@ struct i915_gem_context {
 	/** @client: struct i915_drm_client */
 	struct i915_drm_client *client;
 
+	/** link: &drm_client.context_list */
+	struct list_head client_link;
+
 	/**
 	 * @ref: reference count
 	 *
diff --git a/drivers/gpu/drm/i915/i915_drm_client.c b/drivers/gpu/drm/i915/i915_drm_client.c
index e61e9ba15256..91a8559bebf7 100644
--- a/drivers/gpu/drm/i915/i915_drm_client.c
+++ b/drivers/gpu/drm/i915/i915_drm_client.c
@@ -38,6 +38,8 @@ struct i915_drm_client *i915_drm_client_add(struct i915_drm_clients *clients)
 		goto err;
 
 	kref_init(&client->kref);
+	spin_lock_init(&client->ctx_lock);
+	INIT_LIST_HEAD(&client->ctx_list);
 	client->clients = clients;
 
 	return client;
diff --git a/drivers/gpu/drm/i915/i915_drm_client.h b/drivers/gpu/drm/i915/i915_drm_client.h
index cbc3161ab021..191368386ace 100644
--- a/drivers/gpu/drm/i915/i915_drm_client.h
+++ b/drivers/gpu/drm/i915/i915_drm_client.h
@@ -7,6 +7,8 @@
 #define __I915_DRM_CLIENT_H__
 
 #include <linux/kref.h>
+#include <linux/list.h>
+#include <linux/spinlock.h>
 #include <linux/xarray.h>
 
 #include "gt/intel_engine_types.h"
@@ -27,6 +29,9 @@ struct i915_drm_client {
 
 	unsigned int id;
 
+	spinlock_t ctx_lock; /* For add/remove from ctx_list. */
+	struct list_head ctx_list; /* List of contexts belonging to client. */
+
 	struct i915_drm_clients *clients;
 
 	/**
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [CI 5/8] drm/i915: Track context current active time
  2022-04-01 14:21 ` [Intel-gfx] " Tvrtko Ursulin
@ 2022-04-01 14:22   ` Tvrtko Ursulin
  -1 siblings, 0 replies; 35+ messages in thread
From: Tvrtko Ursulin @ 2022-04-01 14:22 UTC (permalink / raw)
  To: Intel-gfx; +Cc: dri-devel

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Track context active (on hardware) status together with the start
timestamp.

This will be used to provide better granularity of context
runtime reporting in conjunction with already tracked pphwsp accumulated
runtime.

The latter is only updated on context save so does not give us visibility
to any currently executing work.

As part of the patch the existing runtime tracking data is moved under the
new ce->stats member and updated under the seqlock. This provides the
ability to atomically read out accumulated plus active runtime.

v2:
 * Rename and make __intel_context_get_active_time unlocked.

v3:
 * Use GRAPHICS_VER.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Aravind Iddamsetty <aravind.iddamsetty@intel.com> #  v1
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
---
 drivers/gpu/drm/i915/gt/intel_context.c       | 27 ++++++++++++++++++-
 drivers/gpu/drm/i915/gt/intel_context.h       | 15 ++++-------
 drivers/gpu/drm/i915/gt/intel_context_types.h | 24 +++++++++++------
 .../drm/i915/gt/intel_execlists_submission.c  | 23 ++++++++++++----
 .../gpu/drm/i915/gt/intel_gt_clock_utils.c    |  4 +++
 drivers/gpu/drm/i915/gt/intel_lrc.c           | 27 ++++++++++---------
 drivers/gpu/drm/i915/gt/intel_lrc.h           | 27 ++++++++++++++++++-
 drivers/gpu/drm/i915/gt/selftest_lrc.c        | 10 +++----
 drivers/gpu/drm/i915/i915_gpu_error.c         |  9 +++----
 drivers/gpu/drm/i915/i915_gpu_error.h         |  2 +-
 10 files changed, 118 insertions(+), 50 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_context.c b/drivers/gpu/drm/i915/gt/intel_context.c
index d87145b8fca0..4070cb5711d8 100644
--- a/drivers/gpu/drm/i915/gt/intel_context.c
+++ b/drivers/gpu/drm/i915/gt/intel_context.c
@@ -386,7 +386,7 @@ intel_context_init(struct intel_context *ce, struct intel_engine_cs *engine)
 	ce->ring = NULL;
 	ce->ring_size = SZ_4K;
 
-	ewma_runtime_init(&ce->runtime.avg);
+	ewma_runtime_init(&ce->stats.runtime.avg);
 
 	ce->vm = i915_vm_get(engine->gt->vm);
 
@@ -576,6 +576,31 @@ void intel_context_bind_parent_child(struct intel_context *parent,
 	child->parallel.parent = parent;
 }
 
+u64 intel_context_get_total_runtime_ns(const struct intel_context *ce)
+{
+	u64 total, active;
+
+	total = ce->stats.runtime.total;
+	if (ce->ops->flags & COPS_RUNTIME_CYCLES)
+		total *= ce->engine->gt->clock_period_ns;
+
+	active = READ_ONCE(ce->stats.active);
+	if (active)
+		active = intel_context_clock() - active;
+
+	return total + active;
+}
+
+u64 intel_context_get_avg_runtime_ns(struct intel_context *ce)
+{
+	u64 avg = ewma_runtime_read(&ce->stats.runtime.avg);
+
+	if (ce->ops->flags & COPS_RUNTIME_CYCLES)
+		avg *= ce->engine->gt->clock_period_ns;
+
+	return avg;
+}
+
 #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
 #include "selftest_context.c"
 #endif
diff --git a/drivers/gpu/drm/i915/gt/intel_context.h b/drivers/gpu/drm/i915/gt/intel_context.h
index d8c74bbf9aae..b7d3214d2cdd 100644
--- a/drivers/gpu/drm/i915/gt/intel_context.h
+++ b/drivers/gpu/drm/i915/gt/intel_context.h
@@ -351,18 +351,13 @@ intel_context_clear_nopreempt(struct intel_context *ce)
 	clear_bit(CONTEXT_NOPREEMPT, &ce->flags);
 }
 
-static inline u64 intel_context_get_total_runtime_ns(struct intel_context *ce)
-{
-	const u32 period = ce->engine->gt->clock_period_ns;
-
-	return READ_ONCE(ce->runtime.total) * period;
-}
+u64 intel_context_get_total_runtime_ns(const struct intel_context *ce);
+u64 intel_context_get_avg_runtime_ns(struct intel_context *ce);
 
-static inline u64 intel_context_get_avg_runtime_ns(struct intel_context *ce)
+static inline u64 intel_context_clock(void)
 {
-	const u32 period = ce->engine->gt->clock_period_ns;
-
-	return mul_u32_u32(ewma_runtime_read(&ce->runtime.avg), period);
+	/* As we mix CS cycles with CPU clocks, use the raw monotonic clock. */
+	return ktime_get_raw_fast_ns();
 }
 
 #endif /* __INTEL_CONTEXT_H__ */
diff --git a/drivers/gpu/drm/i915/gt/intel_context_types.h b/drivers/gpu/drm/i915/gt/intel_context_types.h
index 30cd81ad8911..09f82545789f 100644
--- a/drivers/gpu/drm/i915/gt/intel_context_types.h
+++ b/drivers/gpu/drm/i915/gt/intel_context_types.h
@@ -35,6 +35,9 @@ struct intel_context_ops {
 #define COPS_HAS_INFLIGHT_BIT 0
 #define COPS_HAS_INFLIGHT BIT(COPS_HAS_INFLIGHT_BIT)
 
+#define COPS_RUNTIME_CYCLES_BIT 1
+#define COPS_RUNTIME_CYCLES BIT(COPS_RUNTIME_CYCLES_BIT)
+
 	int (*alloc)(struct intel_context *ce);
 
 	void (*ban)(struct intel_context *ce, struct i915_request *rq);
@@ -134,14 +137,19 @@ struct intel_context {
 	} lrc;
 	u32 tag; /* cookie passed to HW to track this context on submission */
 
-	/* Time on GPU as tracked by the hw. */
-	struct {
-		struct ewma_runtime avg;
-		u64 total;
-		u32 last;
-		I915_SELFTEST_DECLARE(u32 num_underflow);
-		I915_SELFTEST_DECLARE(u32 max_underflow);
-	} runtime;
+	/** stats: Context GPU engine busyness tracking. */
+	struct intel_context_stats {
+		u64 active;
+
+		/* Time on GPU as tracked by the hw. */
+		struct {
+			struct ewma_runtime avg;
+			u64 total;
+			u32 last;
+			I915_SELFTEST_DECLARE(u32 num_underflow);
+			I915_SELFTEST_DECLARE(u32 max_underflow);
+		} runtime;
+	} stats;
 
 	unsigned int active_count; /* protected by timeline->mutex */
 
diff --git a/drivers/gpu/drm/i915/gt/intel_execlists_submission.c b/drivers/gpu/drm/i915/gt/intel_execlists_submission.c
index e23c1d0e980b..f8749c433b7c 100644
--- a/drivers/gpu/drm/i915/gt/intel_execlists_submission.c
+++ b/drivers/gpu/drm/i915/gt/intel_execlists_submission.c
@@ -625,8 +625,6 @@ static void __execlists_schedule_out(struct i915_request * const rq,
 		GEM_BUG_ON(test_bit(ccid - 1, &engine->context_tag));
 		__set_bit(ccid - 1, &engine->context_tag);
 	}
-
-	lrc_update_runtime(ce);
 	intel_engine_context_out(engine);
 	execlists_context_status_change(rq, INTEL_CONTEXT_SCHEDULE_OUT);
 	if (engine->fw_domain && !--engine->fw_active)
@@ -2005,8 +2003,23 @@ process_csb(struct intel_engine_cs *engine, struct i915_request **inactive)
 	 * and merits a fresh timeslice. We reinstall the timer after
 	 * inspecting the queue to see if we need to resumbit.
 	 */
-	if (*prev != *execlists->active) /* elide lite-restores */
+	if (*prev != *execlists->active) { /* elide lite-restores */
+		/*
+		 * Note the inherent discrepancy between the HW runtime,
+		 * recorded as part of the context switch, and the CPU
+		 * adjustment for active contexts. We have to hope that
+		 * the delay in processing the CS event is very small
+		 * and consistent. It works to our advantage to have
+		 * the CPU adjustment _undershoot_ (i.e. start later than)
+		 * the CS timestamp so we never overreport the runtime
+		 * and correct overselves later when updating from HW.
+		 */
+		if (*prev)
+			lrc_runtime_stop((*prev)->context);
+		if (*execlists->active)
+			lrc_runtime_start((*execlists->active)->context);
 		new_timeslice(execlists);
+	}
 
 	return inactive;
 }
@@ -2638,7 +2651,7 @@ execlists_create_parallel(struct intel_engine_cs **engines,
 }
 
 static const struct intel_context_ops execlists_context_ops = {
-	.flags = COPS_HAS_INFLIGHT,
+	.flags = COPS_HAS_INFLIGHT | COPS_RUNTIME_CYCLES,
 
 	.alloc = execlists_context_alloc,
 
@@ -3696,7 +3709,7 @@ virtual_get_sibling(struct intel_engine_cs *engine, unsigned int sibling)
 }
 
 static const struct intel_context_ops virtual_context_ops = {
-	.flags = COPS_HAS_INFLIGHT,
+	.flags = COPS_HAS_INFLIGHT | COPS_RUNTIME_CYCLES,
 
 	.alloc = virtual_context_alloc,
 
diff --git a/drivers/gpu/drm/i915/gt/intel_gt_clock_utils.c b/drivers/gpu/drm/i915/gt/intel_gt_clock_utils.c
index 0db822c3b7e5..d5d1b04dbcad 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_clock_utils.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt_clock_utils.c
@@ -161,6 +161,10 @@ void intel_gt_init_clock_frequency(struct intel_gt *gt)
 	if (gt->clock_frequency)
 		gt->clock_period_ns = intel_gt_clock_interval_to_ns(gt, 1);
 
+	/* Icelake appears to use another fixed frequency for CTX_TIMESTAMP */
+	if (GRAPHICS_VER(gt->i915) == 11)
+		gt->clock_period_ns = NSEC_PER_SEC / 13750000;
+
 	GT_TRACE(gt,
 		 "Using clock frequency: %dkHz, period: %dns, wrap: %lldms\n",
 		 gt->clock_frequency / 1000,
diff --git a/drivers/gpu/drm/i915/gt/intel_lrc.c b/drivers/gpu/drm/i915/gt/intel_lrc.c
index dffef6ab4baf..3f83a9038e13 100644
--- a/drivers/gpu/drm/i915/gt/intel_lrc.c
+++ b/drivers/gpu/drm/i915/gt/intel_lrc.c
@@ -778,7 +778,7 @@ static void init_common_regs(u32 * const regs,
 					   CTX_CTRL_RS_CTX_ENABLE);
 	regs[CTX_CONTEXT_CONTROL] = ctl;
 
-	regs[CTX_TIMESTAMP] = ce->runtime.last;
+	regs[CTX_TIMESTAMP] = ce->stats.runtime.last;
 }
 
 static void init_wa_bb_regs(u32 * const regs,
@@ -1734,11 +1734,12 @@ void lrc_init_wa_ctx(struct intel_engine_cs *engine)
 	}
 }
 
-static void st_update_runtime_underflow(struct intel_context *ce, s32 dt)
+static void st_runtime_underflow(struct intel_context_stats *stats, s32 dt)
 {
 #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
-	ce->runtime.num_underflow++;
-	ce->runtime.max_underflow = max_t(u32, ce->runtime.max_underflow, -dt);
+	stats->runtime.num_underflow++;
+	stats->runtime.max_underflow =
+		max_t(u32, stats->runtime.max_underflow, -dt);
 #endif
 }
 
@@ -1755,25 +1756,25 @@ static u32 lrc_get_runtime(const struct intel_context *ce)
 
 void lrc_update_runtime(struct intel_context *ce)
 {
+	struct intel_context_stats *stats = &ce->stats;
 	u32 old;
 	s32 dt;
 
-	if (intel_context_is_barrier(ce))
+	old = stats->runtime.last;
+	stats->runtime.last = lrc_get_runtime(ce);
+	dt = stats->runtime.last - old;
+	if (!dt)
 		return;
 
-	old = ce->runtime.last;
-	ce->runtime.last = lrc_get_runtime(ce);
-	dt = ce->runtime.last - old;
-
 	if (unlikely(dt < 0)) {
 		CE_TRACE(ce, "runtime underflow: last=%u, new=%u, delta=%d\n",
-			 old, ce->runtime.last, dt);
-		st_update_runtime_underflow(ce, dt);
+			 old, stats->runtime.last, dt);
+		st_runtime_underflow(stats, dt);
 		return;
 	}
 
-	ewma_runtime_add(&ce->runtime.avg, dt);
-	ce->runtime.total += dt;
+	ewma_runtime_add(&stats->runtime.avg, dt);
+	stats->runtime.total += dt;
 }
 
 #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
diff --git a/drivers/gpu/drm/i915/gt/intel_lrc.h b/drivers/gpu/drm/i915/gt/intel_lrc.h
index 6e4f9f58fca5..7371bb5c8129 100644
--- a/drivers/gpu/drm/i915/gt/intel_lrc.h
+++ b/drivers/gpu/drm/i915/gt/intel_lrc.h
@@ -11,9 +11,10 @@
 #include <linux/bitfield.h>
 #include <linux/types.h>
 
+#include "intel_context.h"
+
 struct drm_i915_gem_object;
 struct i915_gem_ww_ctx;
-struct intel_context;
 struct intel_engine_cs;
 struct intel_ring;
 struct kref;
@@ -120,4 +121,28 @@ static inline u32 lrc_desc_priority(int prio)
 		return GEN12_CTX_PRIORITY_NORMAL;
 }
 
+static inline void lrc_runtime_start(struct intel_context *ce)
+{
+	struct intel_context_stats *stats = &ce->stats;
+
+	if (intel_context_is_barrier(ce))
+		return;
+
+	if (stats->active)
+		return;
+
+	WRITE_ONCE(stats->active, intel_context_clock());
+}
+
+static inline void lrc_runtime_stop(struct intel_context *ce)
+{
+	struct intel_context_stats *stats = &ce->stats;
+
+	if (!stats->active)
+		return;
+
+	lrc_update_runtime(ce);
+	WRITE_ONCE(stats->active, 0);
+}
+
 #endif /* __INTEL_LRC_H__ */
diff --git a/drivers/gpu/drm/i915/gt/selftest_lrc.c b/drivers/gpu/drm/i915/gt/selftest_lrc.c
index 21c29d315cc0..6ba52ef1acb8 100644
--- a/drivers/gpu/drm/i915/gt/selftest_lrc.c
+++ b/drivers/gpu/drm/i915/gt/selftest_lrc.c
@@ -1753,8 +1753,8 @@ static int __live_pphwsp_runtime(struct intel_engine_cs *engine)
 	if (IS_ERR(ce))
 		return PTR_ERR(ce);
 
-	ce->runtime.num_underflow = 0;
-	ce->runtime.max_underflow = 0;
+	ce->stats.runtime.num_underflow = 0;
+	ce->stats.runtime.max_underflow = 0;
 
 	do {
 		unsigned int loop = 1024;
@@ -1792,11 +1792,11 @@ static int __live_pphwsp_runtime(struct intel_engine_cs *engine)
 		intel_context_get_avg_runtime_ns(ce));
 
 	err = 0;
-	if (ce->runtime.num_underflow) {
+	if (ce->stats.runtime.num_underflow) {
 		pr_err("%s: pphwsp underflow %u time(s), max %u cycles!\n",
 		       engine->name,
-		       ce->runtime.num_underflow,
-		       ce->runtime.max_underflow);
+		       ce->stats.runtime.num_underflow,
+		       ce->stats.runtime.max_underflow);
 		GEM_TRACE_DUMP();
 		err = -EOVERFLOW;
 	}
diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c
index fa14314e7d70..0512c66fa4f3 100644
--- a/drivers/gpu/drm/i915/i915_gpu_error.c
+++ b/drivers/gpu/drm/i915/i915_gpu_error.c
@@ -512,13 +512,10 @@ static void error_print_context(struct drm_i915_error_state_buf *m,
 				const char *header,
 				const struct i915_gem_context_coredump *ctx)
 {
-	const u32 period = to_gt(m->i915)->clock_period_ns;
-
 	err_printf(m, "%s%s[%d] prio %d, guilty %d active %d, runtime total %lluns, avg %lluns\n",
 		   header, ctx->comm, ctx->pid, ctx->sched_attr.priority,
 		   ctx->guilty, ctx->active,
-		   ctx->total_runtime * period,
-		   mul_u32_u32(ctx->avg_runtime, period));
+		   ctx->total_runtime, ctx->avg_runtime);
 }
 
 static struct i915_vma_coredump *
@@ -1359,8 +1356,8 @@ static bool record_context(struct i915_gem_context_coredump *e,
 	e->guilty = atomic_read(&ctx->guilty_count);
 	e->active = atomic_read(&ctx->active_count);
 
-	e->total_runtime = rq->context->runtime.total;
-	e->avg_runtime = ewma_runtime_read(&rq->context->runtime.avg);
+	e->total_runtime = intel_context_get_total_runtime_ns(rq->context);
+	e->avg_runtime = intel_context_get_avg_runtime_ns(rq->context);
 
 	simulated = i915_gem_context_no_error_capture(ctx);
 
diff --git a/drivers/gpu/drm/i915/i915_gpu_error.h b/drivers/gpu/drm/i915/i915_gpu_error.h
index 7977a01a708f..a611abacd9c2 100644
--- a/drivers/gpu/drm/i915/i915_gpu_error.h
+++ b/drivers/gpu/drm/i915/i915_gpu_error.h
@@ -94,7 +94,7 @@ struct intel_engine_coredump {
 		char comm[TASK_COMM_LEN];
 
 		u64 total_runtime;
-		u32 avg_runtime;
+		u64 avg_runtime;
 
 		pid_t pid;
 		int active;
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [Intel-gfx] [CI 5/8] drm/i915: Track context current active time
@ 2022-04-01 14:22   ` Tvrtko Ursulin
  0 siblings, 0 replies; 35+ messages in thread
From: Tvrtko Ursulin @ 2022-04-01 14:22 UTC (permalink / raw)
  To: Intel-gfx; +Cc: dri-devel

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Track context active (on hardware) status together with the start
timestamp.

This will be used to provide better granularity of context
runtime reporting in conjunction with already tracked pphwsp accumulated
runtime.

The latter is only updated on context save so does not give us visibility
to any currently executing work.

As part of the patch the existing runtime tracking data is moved under the
new ce->stats member and updated under the seqlock. This provides the
ability to atomically read out accumulated plus active runtime.

v2:
 * Rename and make __intel_context_get_active_time unlocked.

v3:
 * Use GRAPHICS_VER.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Aravind Iddamsetty <aravind.iddamsetty@intel.com> #  v1
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
---
 drivers/gpu/drm/i915/gt/intel_context.c       | 27 ++++++++++++++++++-
 drivers/gpu/drm/i915/gt/intel_context.h       | 15 ++++-------
 drivers/gpu/drm/i915/gt/intel_context_types.h | 24 +++++++++++------
 .../drm/i915/gt/intel_execlists_submission.c  | 23 ++++++++++++----
 .../gpu/drm/i915/gt/intel_gt_clock_utils.c    |  4 +++
 drivers/gpu/drm/i915/gt/intel_lrc.c           | 27 ++++++++++---------
 drivers/gpu/drm/i915/gt/intel_lrc.h           | 27 ++++++++++++++++++-
 drivers/gpu/drm/i915/gt/selftest_lrc.c        | 10 +++----
 drivers/gpu/drm/i915/i915_gpu_error.c         |  9 +++----
 drivers/gpu/drm/i915/i915_gpu_error.h         |  2 +-
 10 files changed, 118 insertions(+), 50 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_context.c b/drivers/gpu/drm/i915/gt/intel_context.c
index d87145b8fca0..4070cb5711d8 100644
--- a/drivers/gpu/drm/i915/gt/intel_context.c
+++ b/drivers/gpu/drm/i915/gt/intel_context.c
@@ -386,7 +386,7 @@ intel_context_init(struct intel_context *ce, struct intel_engine_cs *engine)
 	ce->ring = NULL;
 	ce->ring_size = SZ_4K;
 
-	ewma_runtime_init(&ce->runtime.avg);
+	ewma_runtime_init(&ce->stats.runtime.avg);
 
 	ce->vm = i915_vm_get(engine->gt->vm);
 
@@ -576,6 +576,31 @@ void intel_context_bind_parent_child(struct intel_context *parent,
 	child->parallel.parent = parent;
 }
 
+u64 intel_context_get_total_runtime_ns(const struct intel_context *ce)
+{
+	u64 total, active;
+
+	total = ce->stats.runtime.total;
+	if (ce->ops->flags & COPS_RUNTIME_CYCLES)
+		total *= ce->engine->gt->clock_period_ns;
+
+	active = READ_ONCE(ce->stats.active);
+	if (active)
+		active = intel_context_clock() - active;
+
+	return total + active;
+}
+
+u64 intel_context_get_avg_runtime_ns(struct intel_context *ce)
+{
+	u64 avg = ewma_runtime_read(&ce->stats.runtime.avg);
+
+	if (ce->ops->flags & COPS_RUNTIME_CYCLES)
+		avg *= ce->engine->gt->clock_period_ns;
+
+	return avg;
+}
+
 #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
 #include "selftest_context.c"
 #endif
diff --git a/drivers/gpu/drm/i915/gt/intel_context.h b/drivers/gpu/drm/i915/gt/intel_context.h
index d8c74bbf9aae..b7d3214d2cdd 100644
--- a/drivers/gpu/drm/i915/gt/intel_context.h
+++ b/drivers/gpu/drm/i915/gt/intel_context.h
@@ -351,18 +351,13 @@ intel_context_clear_nopreempt(struct intel_context *ce)
 	clear_bit(CONTEXT_NOPREEMPT, &ce->flags);
 }
 
-static inline u64 intel_context_get_total_runtime_ns(struct intel_context *ce)
-{
-	const u32 period = ce->engine->gt->clock_period_ns;
-
-	return READ_ONCE(ce->runtime.total) * period;
-}
+u64 intel_context_get_total_runtime_ns(const struct intel_context *ce);
+u64 intel_context_get_avg_runtime_ns(struct intel_context *ce);
 
-static inline u64 intel_context_get_avg_runtime_ns(struct intel_context *ce)
+static inline u64 intel_context_clock(void)
 {
-	const u32 period = ce->engine->gt->clock_period_ns;
-
-	return mul_u32_u32(ewma_runtime_read(&ce->runtime.avg), period);
+	/* As we mix CS cycles with CPU clocks, use the raw monotonic clock. */
+	return ktime_get_raw_fast_ns();
 }
 
 #endif /* __INTEL_CONTEXT_H__ */
diff --git a/drivers/gpu/drm/i915/gt/intel_context_types.h b/drivers/gpu/drm/i915/gt/intel_context_types.h
index 30cd81ad8911..09f82545789f 100644
--- a/drivers/gpu/drm/i915/gt/intel_context_types.h
+++ b/drivers/gpu/drm/i915/gt/intel_context_types.h
@@ -35,6 +35,9 @@ struct intel_context_ops {
 #define COPS_HAS_INFLIGHT_BIT 0
 #define COPS_HAS_INFLIGHT BIT(COPS_HAS_INFLIGHT_BIT)
 
+#define COPS_RUNTIME_CYCLES_BIT 1
+#define COPS_RUNTIME_CYCLES BIT(COPS_RUNTIME_CYCLES_BIT)
+
 	int (*alloc)(struct intel_context *ce);
 
 	void (*ban)(struct intel_context *ce, struct i915_request *rq);
@@ -134,14 +137,19 @@ struct intel_context {
 	} lrc;
 	u32 tag; /* cookie passed to HW to track this context on submission */
 
-	/* Time on GPU as tracked by the hw. */
-	struct {
-		struct ewma_runtime avg;
-		u64 total;
-		u32 last;
-		I915_SELFTEST_DECLARE(u32 num_underflow);
-		I915_SELFTEST_DECLARE(u32 max_underflow);
-	} runtime;
+	/** stats: Context GPU engine busyness tracking. */
+	struct intel_context_stats {
+		u64 active;
+
+		/* Time on GPU as tracked by the hw. */
+		struct {
+			struct ewma_runtime avg;
+			u64 total;
+			u32 last;
+			I915_SELFTEST_DECLARE(u32 num_underflow);
+			I915_SELFTEST_DECLARE(u32 max_underflow);
+		} runtime;
+	} stats;
 
 	unsigned int active_count; /* protected by timeline->mutex */
 
diff --git a/drivers/gpu/drm/i915/gt/intel_execlists_submission.c b/drivers/gpu/drm/i915/gt/intel_execlists_submission.c
index e23c1d0e980b..f8749c433b7c 100644
--- a/drivers/gpu/drm/i915/gt/intel_execlists_submission.c
+++ b/drivers/gpu/drm/i915/gt/intel_execlists_submission.c
@@ -625,8 +625,6 @@ static void __execlists_schedule_out(struct i915_request * const rq,
 		GEM_BUG_ON(test_bit(ccid - 1, &engine->context_tag));
 		__set_bit(ccid - 1, &engine->context_tag);
 	}
-
-	lrc_update_runtime(ce);
 	intel_engine_context_out(engine);
 	execlists_context_status_change(rq, INTEL_CONTEXT_SCHEDULE_OUT);
 	if (engine->fw_domain && !--engine->fw_active)
@@ -2005,8 +2003,23 @@ process_csb(struct intel_engine_cs *engine, struct i915_request **inactive)
 	 * and merits a fresh timeslice. We reinstall the timer after
 	 * inspecting the queue to see if we need to resumbit.
 	 */
-	if (*prev != *execlists->active) /* elide lite-restores */
+	if (*prev != *execlists->active) { /* elide lite-restores */
+		/*
+		 * Note the inherent discrepancy between the HW runtime,
+		 * recorded as part of the context switch, and the CPU
+		 * adjustment for active contexts. We have to hope that
+		 * the delay in processing the CS event is very small
+		 * and consistent. It works to our advantage to have
+		 * the CPU adjustment _undershoot_ (i.e. start later than)
+		 * the CS timestamp so we never overreport the runtime
+		 * and correct overselves later when updating from HW.
+		 */
+		if (*prev)
+			lrc_runtime_stop((*prev)->context);
+		if (*execlists->active)
+			lrc_runtime_start((*execlists->active)->context);
 		new_timeslice(execlists);
+	}
 
 	return inactive;
 }
@@ -2638,7 +2651,7 @@ execlists_create_parallel(struct intel_engine_cs **engines,
 }
 
 static const struct intel_context_ops execlists_context_ops = {
-	.flags = COPS_HAS_INFLIGHT,
+	.flags = COPS_HAS_INFLIGHT | COPS_RUNTIME_CYCLES,
 
 	.alloc = execlists_context_alloc,
 
@@ -3696,7 +3709,7 @@ virtual_get_sibling(struct intel_engine_cs *engine, unsigned int sibling)
 }
 
 static const struct intel_context_ops virtual_context_ops = {
-	.flags = COPS_HAS_INFLIGHT,
+	.flags = COPS_HAS_INFLIGHT | COPS_RUNTIME_CYCLES,
 
 	.alloc = virtual_context_alloc,
 
diff --git a/drivers/gpu/drm/i915/gt/intel_gt_clock_utils.c b/drivers/gpu/drm/i915/gt/intel_gt_clock_utils.c
index 0db822c3b7e5..d5d1b04dbcad 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_clock_utils.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt_clock_utils.c
@@ -161,6 +161,10 @@ void intel_gt_init_clock_frequency(struct intel_gt *gt)
 	if (gt->clock_frequency)
 		gt->clock_period_ns = intel_gt_clock_interval_to_ns(gt, 1);
 
+	/* Icelake appears to use another fixed frequency for CTX_TIMESTAMP */
+	if (GRAPHICS_VER(gt->i915) == 11)
+		gt->clock_period_ns = NSEC_PER_SEC / 13750000;
+
 	GT_TRACE(gt,
 		 "Using clock frequency: %dkHz, period: %dns, wrap: %lldms\n",
 		 gt->clock_frequency / 1000,
diff --git a/drivers/gpu/drm/i915/gt/intel_lrc.c b/drivers/gpu/drm/i915/gt/intel_lrc.c
index dffef6ab4baf..3f83a9038e13 100644
--- a/drivers/gpu/drm/i915/gt/intel_lrc.c
+++ b/drivers/gpu/drm/i915/gt/intel_lrc.c
@@ -778,7 +778,7 @@ static void init_common_regs(u32 * const regs,
 					   CTX_CTRL_RS_CTX_ENABLE);
 	regs[CTX_CONTEXT_CONTROL] = ctl;
 
-	regs[CTX_TIMESTAMP] = ce->runtime.last;
+	regs[CTX_TIMESTAMP] = ce->stats.runtime.last;
 }
 
 static void init_wa_bb_regs(u32 * const regs,
@@ -1734,11 +1734,12 @@ void lrc_init_wa_ctx(struct intel_engine_cs *engine)
 	}
 }
 
-static void st_update_runtime_underflow(struct intel_context *ce, s32 dt)
+static void st_runtime_underflow(struct intel_context_stats *stats, s32 dt)
 {
 #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
-	ce->runtime.num_underflow++;
-	ce->runtime.max_underflow = max_t(u32, ce->runtime.max_underflow, -dt);
+	stats->runtime.num_underflow++;
+	stats->runtime.max_underflow =
+		max_t(u32, stats->runtime.max_underflow, -dt);
 #endif
 }
 
@@ -1755,25 +1756,25 @@ static u32 lrc_get_runtime(const struct intel_context *ce)
 
 void lrc_update_runtime(struct intel_context *ce)
 {
+	struct intel_context_stats *stats = &ce->stats;
 	u32 old;
 	s32 dt;
 
-	if (intel_context_is_barrier(ce))
+	old = stats->runtime.last;
+	stats->runtime.last = lrc_get_runtime(ce);
+	dt = stats->runtime.last - old;
+	if (!dt)
 		return;
 
-	old = ce->runtime.last;
-	ce->runtime.last = lrc_get_runtime(ce);
-	dt = ce->runtime.last - old;
-
 	if (unlikely(dt < 0)) {
 		CE_TRACE(ce, "runtime underflow: last=%u, new=%u, delta=%d\n",
-			 old, ce->runtime.last, dt);
-		st_update_runtime_underflow(ce, dt);
+			 old, stats->runtime.last, dt);
+		st_runtime_underflow(stats, dt);
 		return;
 	}
 
-	ewma_runtime_add(&ce->runtime.avg, dt);
-	ce->runtime.total += dt;
+	ewma_runtime_add(&stats->runtime.avg, dt);
+	stats->runtime.total += dt;
 }
 
 #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
diff --git a/drivers/gpu/drm/i915/gt/intel_lrc.h b/drivers/gpu/drm/i915/gt/intel_lrc.h
index 6e4f9f58fca5..7371bb5c8129 100644
--- a/drivers/gpu/drm/i915/gt/intel_lrc.h
+++ b/drivers/gpu/drm/i915/gt/intel_lrc.h
@@ -11,9 +11,10 @@
 #include <linux/bitfield.h>
 #include <linux/types.h>
 
+#include "intel_context.h"
+
 struct drm_i915_gem_object;
 struct i915_gem_ww_ctx;
-struct intel_context;
 struct intel_engine_cs;
 struct intel_ring;
 struct kref;
@@ -120,4 +121,28 @@ static inline u32 lrc_desc_priority(int prio)
 		return GEN12_CTX_PRIORITY_NORMAL;
 }
 
+static inline void lrc_runtime_start(struct intel_context *ce)
+{
+	struct intel_context_stats *stats = &ce->stats;
+
+	if (intel_context_is_barrier(ce))
+		return;
+
+	if (stats->active)
+		return;
+
+	WRITE_ONCE(stats->active, intel_context_clock());
+}
+
+static inline void lrc_runtime_stop(struct intel_context *ce)
+{
+	struct intel_context_stats *stats = &ce->stats;
+
+	if (!stats->active)
+		return;
+
+	lrc_update_runtime(ce);
+	WRITE_ONCE(stats->active, 0);
+}
+
 #endif /* __INTEL_LRC_H__ */
diff --git a/drivers/gpu/drm/i915/gt/selftest_lrc.c b/drivers/gpu/drm/i915/gt/selftest_lrc.c
index 21c29d315cc0..6ba52ef1acb8 100644
--- a/drivers/gpu/drm/i915/gt/selftest_lrc.c
+++ b/drivers/gpu/drm/i915/gt/selftest_lrc.c
@@ -1753,8 +1753,8 @@ static int __live_pphwsp_runtime(struct intel_engine_cs *engine)
 	if (IS_ERR(ce))
 		return PTR_ERR(ce);
 
-	ce->runtime.num_underflow = 0;
-	ce->runtime.max_underflow = 0;
+	ce->stats.runtime.num_underflow = 0;
+	ce->stats.runtime.max_underflow = 0;
 
 	do {
 		unsigned int loop = 1024;
@@ -1792,11 +1792,11 @@ static int __live_pphwsp_runtime(struct intel_engine_cs *engine)
 		intel_context_get_avg_runtime_ns(ce));
 
 	err = 0;
-	if (ce->runtime.num_underflow) {
+	if (ce->stats.runtime.num_underflow) {
 		pr_err("%s: pphwsp underflow %u time(s), max %u cycles!\n",
 		       engine->name,
-		       ce->runtime.num_underflow,
-		       ce->runtime.max_underflow);
+		       ce->stats.runtime.num_underflow,
+		       ce->stats.runtime.max_underflow);
 		GEM_TRACE_DUMP();
 		err = -EOVERFLOW;
 	}
diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c
index fa14314e7d70..0512c66fa4f3 100644
--- a/drivers/gpu/drm/i915/i915_gpu_error.c
+++ b/drivers/gpu/drm/i915/i915_gpu_error.c
@@ -512,13 +512,10 @@ static void error_print_context(struct drm_i915_error_state_buf *m,
 				const char *header,
 				const struct i915_gem_context_coredump *ctx)
 {
-	const u32 period = to_gt(m->i915)->clock_period_ns;
-
 	err_printf(m, "%s%s[%d] prio %d, guilty %d active %d, runtime total %lluns, avg %lluns\n",
 		   header, ctx->comm, ctx->pid, ctx->sched_attr.priority,
 		   ctx->guilty, ctx->active,
-		   ctx->total_runtime * period,
-		   mul_u32_u32(ctx->avg_runtime, period));
+		   ctx->total_runtime, ctx->avg_runtime);
 }
 
 static struct i915_vma_coredump *
@@ -1359,8 +1356,8 @@ static bool record_context(struct i915_gem_context_coredump *e,
 	e->guilty = atomic_read(&ctx->guilty_count);
 	e->active = atomic_read(&ctx->active_count);
 
-	e->total_runtime = rq->context->runtime.total;
-	e->avg_runtime = ewma_runtime_read(&rq->context->runtime.avg);
+	e->total_runtime = intel_context_get_total_runtime_ns(rq->context);
+	e->avg_runtime = intel_context_get_avg_runtime_ns(rq->context);
 
 	simulated = i915_gem_context_no_error_capture(ctx);
 
diff --git a/drivers/gpu/drm/i915/i915_gpu_error.h b/drivers/gpu/drm/i915/i915_gpu_error.h
index 7977a01a708f..a611abacd9c2 100644
--- a/drivers/gpu/drm/i915/i915_gpu_error.h
+++ b/drivers/gpu/drm/i915/i915_gpu_error.h
@@ -94,7 +94,7 @@ struct intel_engine_coredump {
 		char comm[TASK_COMM_LEN];
 
 		u64 total_runtime;
-		u32 avg_runtime;
+		u64 avg_runtime;
 
 		pid_t pid;
 		int active;
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [CI 6/8] drm: Document fdinfo format specification
  2022-04-01 14:21 ` [Intel-gfx] " Tvrtko Ursulin
@ 2022-04-01 14:22   ` Tvrtko Ursulin
  -1 siblings, 0 replies; 35+ messages in thread
From: Tvrtko Ursulin @ 2022-04-01 14:22 UTC (permalink / raw)
  To: Intel-gfx; +Cc: dri-devel

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)

v4:
 * Added drm-engine-capacity- tag.

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>
Cc: Chris Healy <cphealy@gmail.com>
Acked-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
---
 Documentation/gpu/drm-usage-stats.rst | 106 ++++++++++++++++++++++++++
 Documentation/gpu/index.rst           |   1 +
 2 files changed, 107 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..b8cc28f4da6f
--- /dev/null
+++ b/Documentation/gpu/drm-usage-stats.rst
@@ -0,0 +1,106 @@
+.. _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-engine-capacity-<str>: <uint>
+
+Engine identifier string must be the same as the one specified in the
+drm-engine-<str> tag and shall contain a greater than zero number in case the
+exported engine corresponds to a group of identical hardware engines.
+
+In the absence of this tag parser shall assume capacity of one. Zero capacity
+is not allowed.
+
+- 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
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [Intel-gfx] [CI 6/8] drm: Document fdinfo format specification
@ 2022-04-01 14:22   ` Tvrtko Ursulin
  0 siblings, 0 replies; 35+ messages in thread
From: Tvrtko Ursulin @ 2022-04-01 14:22 UTC (permalink / raw)
  To: Intel-gfx; +Cc: dri-devel

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)

v4:
 * Added drm-engine-capacity- tag.

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>
Cc: Chris Healy <cphealy@gmail.com>
Acked-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
---
 Documentation/gpu/drm-usage-stats.rst | 106 ++++++++++++++++++++++++++
 Documentation/gpu/index.rst           |   1 +
 2 files changed, 107 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..b8cc28f4da6f
--- /dev/null
+++ b/Documentation/gpu/drm-usage-stats.rst
@@ -0,0 +1,106 @@
+.. _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-engine-capacity-<str>: <uint>
+
+Engine identifier string must be the same as the one specified in the
+drm-engine-<str> tag and shall contain a greater than zero number in case the
+exported engine corresponds to a group of identical hardware engines.
+
+In the absence of this tag parser shall assume capacity of one. Zero capacity
+is not allowed.
+
+- 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
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [CI 7/8] drm/i915: Count engine instances per uabi class
  2022-04-01 14:21 ` [Intel-gfx] " Tvrtko Ursulin
@ 2022-04-01 14:22   ` Tvrtko Ursulin
  -1 siblings, 0 replies; 35+ messages in thread
From: Tvrtko Ursulin @ 2022-04-01 14:22 UTC (permalink / raw)
  To: Intel-gfx; +Cc: dri-devel

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

This will be useful to have at hand in a following patch.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
---
 drivers/gpu/drm/i915/gt/intel_engine_user.c | 11 ++++++-----
 drivers/gpu/drm/i915/i915_drv.h             |  1 +
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_engine_user.c b/drivers/gpu/drm/i915/gt/intel_engine_user.c
index b8c9b6b89003..0f6cd96b459f 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine_user.c
+++ b/drivers/gpu/drm/i915/gt/intel_engine_user.c
@@ -193,7 +193,6 @@ static void add_legacy_ring(struct legacy_ring *ring,
 void intel_engines_driver_register(struct drm_i915_private *i915)
 {
 	struct legacy_ring ring = {};
-	u8 uabi_instances[5] = {};
 	struct list_head *it, *next;
 	struct rb_node **p, *prev;
 	LIST_HEAD(engines);
@@ -214,8 +213,10 @@ void intel_engines_driver_register(struct drm_i915_private *i915)
 		GEM_BUG_ON(engine->class >= ARRAY_SIZE(uabi_classes));
 		engine->uabi_class = uabi_classes[engine->class];
 
-		GEM_BUG_ON(engine->uabi_class >= ARRAY_SIZE(uabi_instances));
-		engine->uabi_instance = uabi_instances[engine->uabi_class]++;
+		GEM_BUG_ON(engine->uabi_class >=
+			   ARRAY_SIZE(i915->engine_uabi_class_count));
+		engine->uabi_instance =
+			i915->engine_uabi_class_count[engine->uabi_class]++;
 
 		/* Replace the internal name with the final user facing name */
 		memcpy(old, engine->name, sizeof(engine->name));
@@ -245,8 +246,8 @@ void intel_engines_driver_register(struct drm_i915_private *i915)
 		int class, inst;
 		int errors = 0;
 
-		for (class = 0; class < ARRAY_SIZE(uabi_instances); class++) {
-			for (inst = 0; inst < uabi_instances[class]; inst++) {
+		for (class = 0; class < ARRAY_SIZE(i915->engine_uabi_class_count); class++) {
+			for (inst = 0; inst < i915->engine_uabi_class_count[class]; inst++) {
 				engine = intel_engine_lookup_user(i915,
 								  class, inst);
 				if (!engine) {
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index bbda3e01d03d..7f33cf2afb9e 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -500,6 +500,7 @@ struct drm_i915_private {
 	struct pci_dev *bridge_dev;
 
 	struct rb_root uabi_engines;
+	unsigned int engine_uabi_class_count[I915_LAST_UABI_ENGINE_CLASS + 1];
 
 	struct resource mch_res;
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [Intel-gfx] [CI 7/8] drm/i915: Count engine instances per uabi class
@ 2022-04-01 14:22   ` Tvrtko Ursulin
  0 siblings, 0 replies; 35+ messages in thread
From: Tvrtko Ursulin @ 2022-04-01 14:22 UTC (permalink / raw)
  To: Intel-gfx; +Cc: dri-devel

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

This will be useful to have at hand in a following patch.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
---
 drivers/gpu/drm/i915/gt/intel_engine_user.c | 11 ++++++-----
 drivers/gpu/drm/i915/i915_drv.h             |  1 +
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_engine_user.c b/drivers/gpu/drm/i915/gt/intel_engine_user.c
index b8c9b6b89003..0f6cd96b459f 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine_user.c
+++ b/drivers/gpu/drm/i915/gt/intel_engine_user.c
@@ -193,7 +193,6 @@ static void add_legacy_ring(struct legacy_ring *ring,
 void intel_engines_driver_register(struct drm_i915_private *i915)
 {
 	struct legacy_ring ring = {};
-	u8 uabi_instances[5] = {};
 	struct list_head *it, *next;
 	struct rb_node **p, *prev;
 	LIST_HEAD(engines);
@@ -214,8 +213,10 @@ void intel_engines_driver_register(struct drm_i915_private *i915)
 		GEM_BUG_ON(engine->class >= ARRAY_SIZE(uabi_classes));
 		engine->uabi_class = uabi_classes[engine->class];
 
-		GEM_BUG_ON(engine->uabi_class >= ARRAY_SIZE(uabi_instances));
-		engine->uabi_instance = uabi_instances[engine->uabi_class]++;
+		GEM_BUG_ON(engine->uabi_class >=
+			   ARRAY_SIZE(i915->engine_uabi_class_count));
+		engine->uabi_instance =
+			i915->engine_uabi_class_count[engine->uabi_class]++;
 
 		/* Replace the internal name with the final user facing name */
 		memcpy(old, engine->name, sizeof(engine->name));
@@ -245,8 +246,8 @@ void intel_engines_driver_register(struct drm_i915_private *i915)
 		int class, inst;
 		int errors = 0;
 
-		for (class = 0; class < ARRAY_SIZE(uabi_instances); class++) {
-			for (inst = 0; inst < uabi_instances[class]; inst++) {
+		for (class = 0; class < ARRAY_SIZE(i915->engine_uabi_class_count); class++) {
+			for (inst = 0; inst < i915->engine_uabi_class_count[class]; inst++) {
 				engine = intel_engine_lookup_user(i915,
 								  class, inst);
 				if (!engine) {
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index bbda3e01d03d..7f33cf2afb9e 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -500,6 +500,7 @@ struct drm_i915_private {
 	struct pci_dev *bridge_dev;
 
 	struct rb_root uabi_engines;
+	unsigned int engine_uabi_class_count[I915_LAST_UABI_ENGINE_CLASS + 1];
 
 	struct resource mch_res;
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [CI 8/8] drm/i915: Expose client engine utilisation via fdinfo
  2022-04-01 14:21 ` [Intel-gfx] " Tvrtko Ursulin
@ 2022-04-01 14:22   ` Tvrtko Ursulin
  -1 siblings, 0 replies; 35+ messages in thread
From: Tvrtko Ursulin @ 2022-04-01 14:22 UTC (permalink / raw)
  To: Intel-gfx; +Cc: dri-devel

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Similar to AMD commit
874442541133 ("drm/amdgpu: Add show_fdinfo() interface"), using the
infrastructure added in previous patches, we add basic client info
and GPU engine utilisation for i915.

Example of the output:

  pos:    0
  flags:  0100002
  mnt_id: 21
  drm-driver: i915
  drm-pdev:   0000:00:02.0
  drm-client-id:      7
  drm-engine-render:  9288864723 ns
  drm-engine-copy:    2035071108 ns
  drm-engine-video:   0 ns
  drm-engine-video-enhance:   0 ns

v2:
 * Update for removal of name and pid.

v3:
 * Use drm_driver.name.

v4:
 * Added drm-engine-capacity- tag.
 * Fix typo. (Umesh)

v5:
 * Don't output engine data before Gen8.

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: Chris Healy <cphealy@gmail.com>
Acked-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
---
 Documentation/gpu/drm-usage-stats.rst  |  6 ++
 Documentation/gpu/i915.rst             | 28 +++++++++
 drivers/gpu/drm/i915/i915_driver.c     |  3 +
 drivers/gpu/drm/i915/i915_drm_client.c | 84 ++++++++++++++++++++++++++
 drivers/gpu/drm/i915/i915_drm_client.h |  4 ++
 5 files changed, 125 insertions(+)

diff --git a/Documentation/gpu/drm-usage-stats.rst b/Documentation/gpu/drm-usage-stats.rst
index b8cc28f4da6f..6c9f166a8d6f 100644
--- a/Documentation/gpu/drm-usage-stats.rst
+++ b/Documentation/gpu/drm-usage-stats.rst
@@ -104,3 +104,9 @@ 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.
+
+===============================
+Driver specific implementations
+===============================
+
+:ref:`i915-usage-stats`
diff --git a/Documentation/gpu/i915.rst b/Documentation/gpu/i915.rst
index 0f08693d05cd..54060cd6c419 100644
--- a/Documentation/gpu/i915.rst
+++ b/Documentation/gpu/i915.rst
@@ -697,3 +697,31 @@ The style guide for ``i915_reg.h``.
 
 .. kernel-doc:: drivers/gpu/drm/i915/i915_reg.h
    :doc: The i915 register macro definition style guide
+
+.. _i915-usage-stats:
+
+i915 DRM client usage stats implementation
+==========================================
+
+The drm/i915 driver implements the DRM client usage stats specification as
+documented in :ref:`drm-client-usage-stats`.
+
+Example of the output showing the implemented key value pairs and entirety of
+the currently possible format options:
+
+::
+
+      pos:    0
+      flags:  0100002
+      mnt_id: 21
+      drm-driver: i915
+      drm-pdev:   0000:00:02.0
+      drm-client-id:      7
+      drm-engine-render:  9288864723 ns
+      drm-engine-copy:    2035071108 ns
+      drm-engine-video:   0 ns
+      drm-engine-capacity-video:   2
+      drm-engine-video-enhance:   0 ns
+
+Possible `drm-engine-` key names are: `render`, `copy`, `video` and
+`video-enhance`.
diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
index b2df273e6d7b..3ffb617d75c9 100644
--- a/drivers/gpu/drm/i915/i915_driver.c
+++ b/drivers/gpu/drm/i915/i915_driver.c
@@ -1745,6 +1745,9 @@ static const struct file_operations i915_driver_fops = {
 	.read = drm_read,
 	.compat_ioctl = i915_ioc32_compat_ioctl,
 	.llseek = noop_llseek,
+#ifdef CONFIG_PROC_FS
+	.show_fdinfo = i915_drm_client_fdinfo,
+#endif
 };
 
 static int
diff --git a/drivers/gpu/drm/i915/i915_drm_client.c b/drivers/gpu/drm/i915/i915_drm_client.c
index 91a8559bebf7..e539f6b23060 100644
--- a/drivers/gpu/drm/i915/i915_drm_client.c
+++ b/drivers/gpu/drm/i915/i915_drm_client.c
@@ -7,7 +7,13 @@
 #include <linux/slab.h>
 #include <linux/types.h>
 
+#include <uapi/drm/i915_drm.h>
+
+#include <drm/drm_print.h>
+
+#include "gem/i915_gem_context.h"
 #include "i915_drm_client.h"
+#include "i915_file_private.h"
 #include "i915_gem.h"
 #include "i915_utils.h"
 
@@ -68,3 +74,81 @@ void i915_drm_clients_fini(struct i915_drm_clients *clients)
 	GEM_BUG_ON(!xa_empty(&clients->xarray));
 	xa_destroy(&clients->xarray);
 }
+
+#ifdef CONFIG_PROC_FS
+static const char * const uabi_class_names[] = {
+	[I915_ENGINE_CLASS_RENDER] = "render",
+	[I915_ENGINE_CLASS_COPY] = "copy",
+	[I915_ENGINE_CLASS_VIDEO] = "video",
+	[I915_ENGINE_CLASS_VIDEO_ENHANCE] = "video-enhance",
+};
+
+static u64 busy_add(struct i915_gem_context *ctx, unsigned int class)
+{
+	struct i915_gem_engines_iter it;
+	struct intel_context *ce;
+	u64 total = 0;
+
+	for_each_gem_engine(ce, rcu_dereference(ctx->engines), it) {
+		if (ce->engine->uabi_class != class)
+			continue;
+
+		total += intel_context_get_total_runtime_ns(ce);
+	}
+
+	return total;
+}
+
+static void
+show_client_class(struct seq_file *m,
+		  struct i915_drm_client *client,
+		  unsigned int class)
+{
+	const struct list_head *list = &client->ctx_list;
+	u64 total = atomic64_read(&client->past_runtime[class]);
+	const unsigned int capacity =
+		client->clients->i915->engine_uabi_class_count[class];
+	struct i915_gem_context *ctx;
+
+	rcu_read_lock();
+	list_for_each_entry_rcu(ctx, list, client_link)
+		total += busy_add(ctx, class);
+	rcu_read_unlock();
+
+	seq_printf(m, "drm-engine-%s:\t%llu ns\n",
+		   uabi_class_names[class], total);
+
+	if (capacity > 1)
+		seq_printf(m, "drm-engine-capacity-%s:\t%u\n",
+			   uabi_class_names[class],
+			   capacity);
+}
+
+void i915_drm_client_fdinfo(struct seq_file *m, struct file *f)
+{
+	struct drm_file *file = f->private_data;
+	struct drm_i915_file_private *file_priv = file->driver_priv;
+	struct drm_i915_private *i915 = file_priv->dev_priv;
+	struct i915_drm_client *client = file_priv->client;
+	struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
+	unsigned int i;
+
+	/*
+	 * ******************************************************************
+	 * For text output format description please see drm-usage-stats.rst!
+	 * ******************************************************************
+	 */
+
+	seq_printf(m, "drm-driver:\t%s\n", i915->drm.driver->name);
+	seq_printf(m, "drm-pdev:\t%04x:%02x:%02x.%d\n",
+		   pci_domain_nr(pdev->bus), pdev->bus->number,
+		   PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
+	seq_printf(m, "drm-client-id:\t%u\n", client->id);
+
+	if (GRAPHICS_VER(i915) < 8)
+		return;
+
+	for (i = 0; i < ARRAY_SIZE(uabi_class_names); i++)
+		show_client_class(m, client, i);
+}
+#endif
diff --git a/drivers/gpu/drm/i915/i915_drm_client.h b/drivers/gpu/drm/i915/i915_drm_client.h
index 191368386ace..5f5b02b01ba0 100644
--- a/drivers/gpu/drm/i915/i915_drm_client.h
+++ b/drivers/gpu/drm/i915/i915_drm_client.h
@@ -59,6 +59,10 @@ static inline void i915_drm_client_put(struct i915_drm_client *client)
 
 struct i915_drm_client *i915_drm_client_add(struct i915_drm_clients *clients);
 
+#ifdef CONFIG_PROC_FS
+void i915_drm_client_fdinfo(struct seq_file *m, struct file *f);
+#endif
+
 void i915_drm_clients_fini(struct i915_drm_clients *clients);
 
 #endif /* !__I915_DRM_CLIENT_H__ */
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [Intel-gfx] [CI 8/8] drm/i915: Expose client engine utilisation via fdinfo
@ 2022-04-01 14:22   ` Tvrtko Ursulin
  0 siblings, 0 replies; 35+ messages in thread
From: Tvrtko Ursulin @ 2022-04-01 14:22 UTC (permalink / raw)
  To: Intel-gfx; +Cc: dri-devel

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Similar to AMD commit
874442541133 ("drm/amdgpu: Add show_fdinfo() interface"), using the
infrastructure added in previous patches, we add basic client info
and GPU engine utilisation for i915.

Example of the output:

  pos:    0
  flags:  0100002
  mnt_id: 21
  drm-driver: i915
  drm-pdev:   0000:00:02.0
  drm-client-id:      7
  drm-engine-render:  9288864723 ns
  drm-engine-copy:    2035071108 ns
  drm-engine-video:   0 ns
  drm-engine-video-enhance:   0 ns

v2:
 * Update for removal of name and pid.

v3:
 * Use drm_driver.name.

v4:
 * Added drm-engine-capacity- tag.
 * Fix typo. (Umesh)

v5:
 * Don't output engine data before Gen8.

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: Chris Healy <cphealy@gmail.com>
Acked-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
---
 Documentation/gpu/drm-usage-stats.rst  |  6 ++
 Documentation/gpu/i915.rst             | 28 +++++++++
 drivers/gpu/drm/i915/i915_driver.c     |  3 +
 drivers/gpu/drm/i915/i915_drm_client.c | 84 ++++++++++++++++++++++++++
 drivers/gpu/drm/i915/i915_drm_client.h |  4 ++
 5 files changed, 125 insertions(+)

diff --git a/Documentation/gpu/drm-usage-stats.rst b/Documentation/gpu/drm-usage-stats.rst
index b8cc28f4da6f..6c9f166a8d6f 100644
--- a/Documentation/gpu/drm-usage-stats.rst
+++ b/Documentation/gpu/drm-usage-stats.rst
@@ -104,3 +104,9 @@ 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.
+
+===============================
+Driver specific implementations
+===============================
+
+:ref:`i915-usage-stats`
diff --git a/Documentation/gpu/i915.rst b/Documentation/gpu/i915.rst
index 0f08693d05cd..54060cd6c419 100644
--- a/Documentation/gpu/i915.rst
+++ b/Documentation/gpu/i915.rst
@@ -697,3 +697,31 @@ The style guide for ``i915_reg.h``.
 
 .. kernel-doc:: drivers/gpu/drm/i915/i915_reg.h
    :doc: The i915 register macro definition style guide
+
+.. _i915-usage-stats:
+
+i915 DRM client usage stats implementation
+==========================================
+
+The drm/i915 driver implements the DRM client usage stats specification as
+documented in :ref:`drm-client-usage-stats`.
+
+Example of the output showing the implemented key value pairs and entirety of
+the currently possible format options:
+
+::
+
+      pos:    0
+      flags:  0100002
+      mnt_id: 21
+      drm-driver: i915
+      drm-pdev:   0000:00:02.0
+      drm-client-id:      7
+      drm-engine-render:  9288864723 ns
+      drm-engine-copy:    2035071108 ns
+      drm-engine-video:   0 ns
+      drm-engine-capacity-video:   2
+      drm-engine-video-enhance:   0 ns
+
+Possible `drm-engine-` key names are: `render`, `copy`, `video` and
+`video-enhance`.
diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
index b2df273e6d7b..3ffb617d75c9 100644
--- a/drivers/gpu/drm/i915/i915_driver.c
+++ b/drivers/gpu/drm/i915/i915_driver.c
@@ -1745,6 +1745,9 @@ static const struct file_operations i915_driver_fops = {
 	.read = drm_read,
 	.compat_ioctl = i915_ioc32_compat_ioctl,
 	.llseek = noop_llseek,
+#ifdef CONFIG_PROC_FS
+	.show_fdinfo = i915_drm_client_fdinfo,
+#endif
 };
 
 static int
diff --git a/drivers/gpu/drm/i915/i915_drm_client.c b/drivers/gpu/drm/i915/i915_drm_client.c
index 91a8559bebf7..e539f6b23060 100644
--- a/drivers/gpu/drm/i915/i915_drm_client.c
+++ b/drivers/gpu/drm/i915/i915_drm_client.c
@@ -7,7 +7,13 @@
 #include <linux/slab.h>
 #include <linux/types.h>
 
+#include <uapi/drm/i915_drm.h>
+
+#include <drm/drm_print.h>
+
+#include "gem/i915_gem_context.h"
 #include "i915_drm_client.h"
+#include "i915_file_private.h"
 #include "i915_gem.h"
 #include "i915_utils.h"
 
@@ -68,3 +74,81 @@ void i915_drm_clients_fini(struct i915_drm_clients *clients)
 	GEM_BUG_ON(!xa_empty(&clients->xarray));
 	xa_destroy(&clients->xarray);
 }
+
+#ifdef CONFIG_PROC_FS
+static const char * const uabi_class_names[] = {
+	[I915_ENGINE_CLASS_RENDER] = "render",
+	[I915_ENGINE_CLASS_COPY] = "copy",
+	[I915_ENGINE_CLASS_VIDEO] = "video",
+	[I915_ENGINE_CLASS_VIDEO_ENHANCE] = "video-enhance",
+};
+
+static u64 busy_add(struct i915_gem_context *ctx, unsigned int class)
+{
+	struct i915_gem_engines_iter it;
+	struct intel_context *ce;
+	u64 total = 0;
+
+	for_each_gem_engine(ce, rcu_dereference(ctx->engines), it) {
+		if (ce->engine->uabi_class != class)
+			continue;
+
+		total += intel_context_get_total_runtime_ns(ce);
+	}
+
+	return total;
+}
+
+static void
+show_client_class(struct seq_file *m,
+		  struct i915_drm_client *client,
+		  unsigned int class)
+{
+	const struct list_head *list = &client->ctx_list;
+	u64 total = atomic64_read(&client->past_runtime[class]);
+	const unsigned int capacity =
+		client->clients->i915->engine_uabi_class_count[class];
+	struct i915_gem_context *ctx;
+
+	rcu_read_lock();
+	list_for_each_entry_rcu(ctx, list, client_link)
+		total += busy_add(ctx, class);
+	rcu_read_unlock();
+
+	seq_printf(m, "drm-engine-%s:\t%llu ns\n",
+		   uabi_class_names[class], total);
+
+	if (capacity > 1)
+		seq_printf(m, "drm-engine-capacity-%s:\t%u\n",
+			   uabi_class_names[class],
+			   capacity);
+}
+
+void i915_drm_client_fdinfo(struct seq_file *m, struct file *f)
+{
+	struct drm_file *file = f->private_data;
+	struct drm_i915_file_private *file_priv = file->driver_priv;
+	struct drm_i915_private *i915 = file_priv->dev_priv;
+	struct i915_drm_client *client = file_priv->client;
+	struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
+	unsigned int i;
+
+	/*
+	 * ******************************************************************
+	 * For text output format description please see drm-usage-stats.rst!
+	 * ******************************************************************
+	 */
+
+	seq_printf(m, "drm-driver:\t%s\n", i915->drm.driver->name);
+	seq_printf(m, "drm-pdev:\t%04x:%02x:%02x.%d\n",
+		   pci_domain_nr(pdev->bus), pdev->bus->number,
+		   PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
+	seq_printf(m, "drm-client-id:\t%u\n", client->id);
+
+	if (GRAPHICS_VER(i915) < 8)
+		return;
+
+	for (i = 0; i < ARRAY_SIZE(uabi_class_names); i++)
+		show_client_class(m, client, i);
+}
+#endif
diff --git a/drivers/gpu/drm/i915/i915_drm_client.h b/drivers/gpu/drm/i915/i915_drm_client.h
index 191368386ace..5f5b02b01ba0 100644
--- a/drivers/gpu/drm/i915/i915_drm_client.h
+++ b/drivers/gpu/drm/i915/i915_drm_client.h
@@ -59,6 +59,10 @@ static inline void i915_drm_client_put(struct i915_drm_client *client)
 
 struct i915_drm_client *i915_drm_client_add(struct i915_drm_clients *clients);
 
+#ifdef CONFIG_PROC_FS
+void i915_drm_client_fdinfo(struct seq_file *m, struct file *f);
+#endif
+
 void i915_drm_clients_fini(struct i915_drm_clients *clients);
 
 #endif /* !__I915_DRM_CLIENT_H__ */
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for Per client GPU utilisation (rev4)
  2022-04-01 14:21 ` [Intel-gfx] " Tvrtko Ursulin
                   ` (8 preceding siblings ...)
  (?)
@ 2022-04-01 15:57 ` Patchwork
  -1 siblings, 0 replies; 35+ messages in thread
From: Patchwork @ 2022-04-01 15:57 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: intel-gfx

== Series Details ==

Series: Per client GPU utilisation (rev4)
URL   : https://patchwork.freedesktop.org/series/100573/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
037908479101 drm/i915: Explicitly track DRM clients
-:130: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating?
#130: 
new file mode 100644

total: 0 errors, 1 warnings, 0 checks, 234 lines checked
8f73b6a749d5 drm/i915: Make GEM contexts track DRM clients
481b0788b111 drm/i915: Track runtime spent in closed and unreachable GEM contexts
f5a45bb5ac9c drm/i915: Track all user contexts per client
07ad43cd0f97 drm/i915: Track context current active time
-:140: WARNING:LINE_SPACING: Missing a blank line after declarations
#140: FILE: drivers/gpu/drm/i915/gt/intel_context_types.h:149:
+			u32 last;
+			I915_SELFTEST_DECLARE(u32 num_underflow);

total: 0 errors, 1 warnings, 0 checks, 308 lines checked
7d0f31c44ba2 drm: Document fdinfo format specification
-:45: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating?
#45: 
new file mode 100644

-:50: WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1
#50: FILE: Documentation/gpu/drm-usage-stats.rst:1:
+.. _drm-client-usage-stats:

total: 0 errors, 2 warnings, 0 checks, 113 lines checked
7703ec507d49 drm/i915: Count engine instances per uabi class
3deb854ecac2 drm/i915: Expose client engine utilisation via fdinfo



^ permalink raw reply	[flat|nested] 35+ messages in thread

* [Intel-gfx] ✗ Fi.CI.SPARSE: warning for Per client GPU utilisation (rev4)
  2022-04-01 14:21 ` [Intel-gfx] " Tvrtko Ursulin
                   ` (9 preceding siblings ...)
  (?)
@ 2022-04-01 15:59 ` Patchwork
  -1 siblings, 0 replies; 35+ messages in thread
From: Patchwork @ 2022-04-01 15:59 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: intel-gfx

== Series Details ==

Series: Per client GPU utilisation (rev4)
URL   : https://patchwork.freedesktop.org/series/100573/
State : warning

== Summary ==

$ dim sparse --fast origin/drm-tip
Sparse version: v0.6.2
Fast mode used, each commit won't be checked separately.



^ permalink raw reply	[flat|nested] 35+ messages in thread

* [Intel-gfx] ✗ Fi.CI.DOCS: warning for Per client GPU utilisation (rev4)
  2022-04-01 14:21 ` [Intel-gfx] " Tvrtko Ursulin
                   ` (10 preceding siblings ...)
  (?)
@ 2022-04-01 16:03 ` Patchwork
  -1 siblings, 0 replies; 35+ messages in thread
From: Patchwork @ 2022-04-01 16:03 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: intel-gfx

== Series Details ==

Series: Per client GPU utilisation (rev4)
URL   : https://patchwork.freedesktop.org/series/100573/
State : warning

== Summary ==

$ make htmldocs 2>&1 > /dev/null | grep i915
./drivers/gpu/drm/i915/gem/i915_gem_context_types.h:417: warning: Function parameter or member 'client_link' not described in 'i915_gem_context'



^ permalink raw reply	[flat|nested] 35+ messages in thread

* [Intel-gfx] ✗ Fi.CI.BAT: failure for Per client GPU utilisation (rev4)
  2022-04-01 14:21 ` [Intel-gfx] " Tvrtko Ursulin
                   ` (11 preceding siblings ...)
  (?)
@ 2022-04-01 16:38 ` Patchwork
  -1 siblings, 0 replies; 35+ messages in thread
From: Patchwork @ 2022-04-01 16:38 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: intel-gfx

[-- Attachment #1: Type: text/plain, Size: 4701 bytes --]

== Series Details ==

Series: Per client GPU utilisation (rev4)
URL   : https://patchwork.freedesktop.org/series/100573/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_11439 -> Patchwork_22760
====================================================

Summary
-------

  **FAILURE**

  Serious unknown changes coming with Patchwork_22760 absolutely need to be
  verified manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in Patchwork_22760, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22760/index.html

Participating hosts (43 -> 41)
------------------------------

  Additional (1): fi-pnv-d510 
  Missing    (3): fi-bsw-cyan fi-icl-u2 fi-bdw-samus 

Possible new issues
-------------------

  Here are the unknown changes that may have been introduced in Patchwork_22760:

### IGT changes ###

#### Possible regressions ####

  * igt@i915_selftest@live@guc:
    - bat-dg1-6:          [PASS][1] -> [INCOMPLETE][2]
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11439/bat-dg1-6/igt@i915_selftest@live@guc.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22760/bat-dg1-6/igt@i915_selftest@live@guc.html

  
Known issues
------------

  Here are the changes found in Patchwork_22760 that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@kms_flip@basic-flip-vs-modeset@a-edp1:
    - fi-tgl-u2:          [PASS][3] -> [DMESG-WARN][4] ([i915#402])
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11439/fi-tgl-u2/igt@kms_flip@basic-flip-vs-modeset@a-edp1.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22760/fi-tgl-u2/igt@kms_flip@basic-flip-vs-modeset@a-edp1.html

  * igt@kms_pipe_crc_basic@compare-crc-sanitycheck-pipe-c:
    - fi-pnv-d510:        NOTRUN -> [SKIP][5] ([fdo#109271] / [i915#5341])
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22760/fi-pnv-d510/igt@kms_pipe_crc_basic@compare-crc-sanitycheck-pipe-c.html

  * igt@prime_vgem@basic-userptr:
    - fi-pnv-d510:        NOTRUN -> [SKIP][6] ([fdo#109271]) +57 similar issues
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22760/fi-pnv-d510/igt@prime_vgem@basic-userptr.html

  
#### Possible fixes ####

  * igt@kms_flip@basic-flip-vs-modeset@a-edp1:
    - {bat-adlp-6}:       [DMESG-WARN][7] ([i915#3576]) -> [PASS][8]
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11439/bat-adlp-6/igt@kms_flip@basic-flip-vs-modeset@a-edp1.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22760/bat-adlp-6/igt@kms_flip@basic-flip-vs-modeset@a-edp1.html

  * igt@kms_flip@basic-plain-flip@a-edp1:
    - fi-tgl-u2:          [DMESG-WARN][9] ([i915#402]) -> [PASS][10]
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11439/fi-tgl-u2/igt@kms_flip@basic-plain-flip@a-edp1.html
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22760/fi-tgl-u2/igt@kms_flip@basic-plain-flip@a-edp1.html

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
  [i915#2867]: https://gitlab.freedesktop.org/drm/intel/issues/2867
  [i915#3576]: https://gitlab.freedesktop.org/drm/intel/issues/3576
  [i915#402]: https://gitlab.freedesktop.org/drm/intel/issues/402
  [i915#5341]: https://gitlab.freedesktop.org/drm/intel/issues/5341


Build changes
-------------

  * IGT: IGT_6405 -> IGTPW_6859
  * Linux: CI_DRM_11439 -> Patchwork_22760

  CI-20190529: 20190529
  CI_DRM_11439: 8ee0d50f44b1f5e36ee255bbff836d7c1f338ee2 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_6859: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6859/index.html
  IGT_6405: 50f7bc405cc1411f57855ed23322c6c4d2510b58 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
  Patchwork_22760: 3deb854ecac2ffa5e2d99fabf5faa01215f1ef18 @ git://anongit.freedesktop.org/gfx-ci/linux


== Linux commits ==

3deb854ecac2 drm/i915: Expose client engine utilisation via fdinfo
7703ec507d49 drm/i915: Count engine instances per uabi class
7d0f31c44ba2 drm: Document fdinfo format specification
07ad43cd0f97 drm/i915: Track context current active time
f5a45bb5ac9c drm/i915: Track all user contexts per client
481b0788b111 drm/i915: Track runtime spent in closed and unreachable GEM contexts
8f73b6a749d5 drm/i915: Make GEM contexts track DRM clients
037908479101 drm/i915: Explicitly track DRM clients

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22760/index.html

[-- Attachment #2: Type: text/html, Size: 5598 bytes --]

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for Per client GPU utilisation (rev5)
  2022-04-01 14:21 ` [Intel-gfx] " Tvrtko Ursulin
                   ` (12 preceding siblings ...)
  (?)
@ 2022-04-01 20:28 ` Patchwork
  -1 siblings, 0 replies; 35+ messages in thread
From: Patchwork @ 2022-04-01 20:28 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: intel-gfx

== Series Details ==

Series: Per client GPU utilisation (rev5)
URL   : https://patchwork.freedesktop.org/series/100573/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
7e9efd72439e drm/i915: Explicitly track DRM clients
-:130: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating?
#130: 
new file mode 100644

total: 0 errors, 1 warnings, 0 checks, 234 lines checked
20138e4593a9 drm/i915: Make GEM contexts track DRM clients
8112c9dac44d drm/i915: Track runtime spent in closed and unreachable GEM contexts
2f89085834a4 drm/i915: Track all user contexts per client
f8aa16bf3954 drm/i915: Track context current active time
-:140: WARNING:LINE_SPACING: Missing a blank line after declarations
#140: FILE: drivers/gpu/drm/i915/gt/intel_context_types.h:149:
+			u32 last;
+			I915_SELFTEST_DECLARE(u32 num_underflow);

total: 0 errors, 1 warnings, 0 checks, 308 lines checked
d68a3dd18e32 drm: Document fdinfo format specification
-:45: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating?
#45: 
new file mode 100644

-:50: WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1
#50: FILE: Documentation/gpu/drm-usage-stats.rst:1:
+.. _drm-client-usage-stats:

total: 0 errors, 2 warnings, 0 checks, 113 lines checked
358f40a1b272 drm/i915: Count engine instances per uabi class
0fa662dc40c3 drm/i915: Expose client engine utilisation via fdinfo



^ permalink raw reply	[flat|nested] 35+ messages in thread

* [Intel-gfx] ✗ Fi.CI.SPARSE: warning for Per client GPU utilisation (rev5)
  2022-04-01 14:21 ` [Intel-gfx] " Tvrtko Ursulin
                   ` (13 preceding siblings ...)
  (?)
@ 2022-04-01 20:29 ` Patchwork
  -1 siblings, 0 replies; 35+ messages in thread
From: Patchwork @ 2022-04-01 20:29 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: intel-gfx

== Series Details ==

Series: Per client GPU utilisation (rev5)
URL   : https://patchwork.freedesktop.org/series/100573/
State : warning

== Summary ==

$ dim sparse --fast origin/drm-tip
Sparse version: v0.6.2
Fast mode used, each commit won't be checked separately.



^ permalink raw reply	[flat|nested] 35+ messages in thread

* [Intel-gfx] ✗ Fi.CI.DOCS: warning for Per client GPU utilisation (rev5)
  2022-04-01 14:21 ` [Intel-gfx] " Tvrtko Ursulin
                   ` (14 preceding siblings ...)
  (?)
@ 2022-04-01 20:33 ` Patchwork
  -1 siblings, 0 replies; 35+ messages in thread
From: Patchwork @ 2022-04-01 20:33 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: intel-gfx

== Series Details ==

Series: Per client GPU utilisation (rev5)
URL   : https://patchwork.freedesktop.org/series/100573/
State : warning

== Summary ==

$ make htmldocs 2>&1 > /dev/null | grep i915
./drivers/gpu/drm/i915/gem/i915_gem_context_types.h:417: warning: Function parameter or member 'client_link' not described in 'i915_gem_context'



^ permalink raw reply	[flat|nested] 35+ messages in thread

* [Intel-gfx] ✓ Fi.CI.BAT: success for Per client GPU utilisation (rev5)
  2022-04-01 14:21 ` [Intel-gfx] " Tvrtko Ursulin
                   ` (15 preceding siblings ...)
  (?)
@ 2022-04-01 21:00 ` Patchwork
  -1 siblings, 0 replies; 35+ messages in thread
From: Patchwork @ 2022-04-01 21:00 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: intel-gfx

[-- Attachment #1: Type: text/plain, Size: 7542 bytes --]

== Series Details ==

Series: Per client GPU utilisation (rev5)
URL   : https://patchwork.freedesktop.org/series/100573/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_11440 -> Patchwork_22761
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/index.html

Participating hosts (45 -> 41)
------------------------------

  Additional (2): bat-rpls-2 fi-pnv-d510 
  Missing    (6): shard-tglu bat-dg2-8 fi-bsw-cyan fi-icl-u2 bat-jsl-2 fi-bdw-samus 

Known issues
------------

  Here are the changes found in Patchwork_22761 that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@amdgpu/amd_basic@semaphore:
    - fi-hsw-4770:        NOTRUN -> [SKIP][1] ([fdo#109271] / [fdo#109315]) +17 similar issues
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/fi-hsw-4770/igt@amdgpu/amd_basic@semaphore.html

  * igt@amdgpu/amd_cs_nop@fork-compute0:
    - fi-blb-e6850:       NOTRUN -> [SKIP][2] ([fdo#109271]) +17 similar issues
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/fi-blb-e6850/igt@amdgpu/amd_cs_nop@fork-compute0.html

  * igt@gem_exec_suspend@basic-s3@smem:
    - fi-rkl-11600:       [PASS][3] -> [INCOMPLETE][4] ([i915#5127])
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11440/fi-rkl-11600/igt@gem_exec_suspend@basic-s3@smem.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/fi-rkl-11600/igt@gem_exec_suspend@basic-s3@smem.html

  * igt@gem_huc_copy@huc-copy:
    - fi-pnv-d510:        NOTRUN -> [SKIP][5] ([fdo#109271]) +57 similar issues
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/fi-pnv-d510/igt@gem_huc_copy@huc-copy.html

  * igt@i915_selftest@live@execlists:
    - fi-bsw-nick:        [PASS][6] -> [INCOMPLETE][7] ([i915#2940])
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11440/fi-bsw-nick/igt@i915_selftest@live@execlists.html
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/fi-bsw-nick/igt@i915_selftest@live@execlists.html

  * igt@kms_pipe_crc_basic@compare-crc-sanitycheck-pipe-c:
    - fi-pnv-d510:        NOTRUN -> [SKIP][8] ([fdo#109271] / [i915#5341])
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/fi-pnv-d510/igt@kms_pipe_crc_basic@compare-crc-sanitycheck-pipe-c.html

  * igt@runner@aborted:
    - fi-bsw-nick:        NOTRUN -> [FAIL][9] ([fdo#109271] / [i915#1436] / [i915#3428] / [i915#4312])
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/fi-bsw-nick/igt@runner@aborted.html

  
#### Possible fixes ####

  * igt@core_hotunplug@unbind-rebind:
    - fi-blb-e6850:       [FAIL][10] ([i915#3194]) -> [PASS][11]
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11440/fi-blb-e6850/igt@core_hotunplug@unbind-rebind.html
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/fi-blb-e6850/igt@core_hotunplug@unbind-rebind.html

  * igt@i915_selftest@live@hangcheck:
    - bat-dg1-6:          [DMESG-FAIL][12] ([i915#4494] / [i915#4957]) -> [PASS][13]
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11440/bat-dg1-6/igt@i915_selftest@live@hangcheck.html
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/bat-dg1-6/igt@i915_selftest@live@hangcheck.html
    - fi-hsw-4770:        [INCOMPLETE][14] ([i915#4785]) -> [PASS][15]
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11440/fi-hsw-4770/igt@i915_selftest@live@hangcheck.html
   [15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/fi-hsw-4770/igt@i915_selftest@live@hangcheck.html

  * igt@i915_selftest@live@requests:
    - fi-blb-e6850:       [DMESG-FAIL][16] ([i915#4528]) -> [PASS][17]
   [16]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11440/fi-blb-e6850/igt@i915_selftest@live@requests.html
   [17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/fi-blb-e6850/igt@i915_selftest@live@requests.html

  * igt@kms_flip@basic-plain-flip@a-edp1:
    - fi-tgl-u2:          [DMESG-WARN][18] ([i915#402]) -> [PASS][19] +1 similar issue
   [18]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11440/fi-tgl-u2/igt@kms_flip@basic-plain-flip@a-edp1.html
   [19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/fi-tgl-u2/igt@kms_flip@basic-plain-flip@a-edp1.html

  * igt@kms_force_connector_basic@force-connector-state:
    - {bat-adlp-6}:       [DMESG-WARN][20] ([i915#3576]) -> [PASS][21] +1 similar issue
   [20]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11440/bat-adlp-6/igt@kms_force_connector_basic@force-connector-state.html
   [21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/bat-adlp-6/igt@kms_force_connector_basic@force-connector-state.html

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
  [fdo#109315]: https://bugs.freedesktop.org/show_bug.cgi?id=109315
  [fdo#111827]: https://bugs.freedesktop.org/show_bug.cgi?id=111827
  [i915#1436]: https://gitlab.freedesktop.org/drm/intel/issues/1436
  [i915#1982]: https://gitlab.freedesktop.org/drm/intel/issues/1982
  [i915#2940]: https://gitlab.freedesktop.org/drm/intel/issues/2940
  [i915#3194]: https://gitlab.freedesktop.org/drm/intel/issues/3194
  [i915#3282]: https://gitlab.freedesktop.org/drm/intel/issues/3282
  [i915#3428]: https://gitlab.freedesktop.org/drm/intel/issues/3428
  [i915#3576]: https://gitlab.freedesktop.org/drm/intel/issues/3576
  [i915#402]: https://gitlab.freedesktop.org/drm/intel/issues/402
  [i915#4103]: https://gitlab.freedesktop.org/drm/intel/issues/4103
  [i915#4312]: https://gitlab.freedesktop.org/drm/intel/issues/4312
  [i915#4494]: https://gitlab.freedesktop.org/drm/intel/issues/4494
  [i915#4528]: https://gitlab.freedesktop.org/drm/intel/issues/4528
  [i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613
  [i915#4785]: https://gitlab.freedesktop.org/drm/intel/issues/4785
  [i915#4957]: https://gitlab.freedesktop.org/drm/intel/issues/4957
  [i915#5127]: https://gitlab.freedesktop.org/drm/intel/issues/5127
  [i915#5195]: https://gitlab.freedesktop.org/drm/intel/issues/5195
  [i915#5341]: https://gitlab.freedesktop.org/drm/intel/issues/5341
  [i915#5482]: https://gitlab.freedesktop.org/drm/intel/issues/5482


Build changes
-------------

  * IGT: IGT_6405 -> IGTPW_6859
  * Linux: CI_DRM_11440 -> Patchwork_22761

  CI-20190529: 20190529
  CI_DRM_11440: 1aba80b3bc8c8e2cc405cd96fe95770ecbadde71 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_6859: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6859/index.html
  IGT_6405: 50f7bc405cc1411f57855ed23322c6c4d2510b58 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
  Patchwork_22761: 0fa662dc40c3c40358887cbdca2f25b534325b64 @ git://anongit.freedesktop.org/gfx-ci/linux


== Linux commits ==

0fa662dc40c3 drm/i915: Expose client engine utilisation via fdinfo
358f40a1b272 drm/i915: Count engine instances per uabi class
d68a3dd18e32 drm: Document fdinfo format specification
f8aa16bf3954 drm/i915: Track context current active time
2f89085834a4 drm/i915: Track all user contexts per client
8112c9dac44d drm/i915: Track runtime spent in closed and unreachable GEM contexts
20138e4593a9 drm/i915: Make GEM contexts track DRM clients
7e9efd72439e drm/i915: Explicitly track DRM clients

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/index.html

[-- Attachment #2: Type: text/html, Size: 8309 bytes --]

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [Intel-gfx] ✓ Fi.CI.IGT: success for Per client GPU utilisation (rev5)
  2022-04-01 14:21 ` [Intel-gfx] " Tvrtko Ursulin
                   ` (16 preceding siblings ...)
  (?)
@ 2022-04-01 23:04 ` Patchwork
  -1 siblings, 0 replies; 35+ messages in thread
From: Patchwork @ 2022-04-01 23:04 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: intel-gfx

[-- Attachment #1: Type: text/plain, Size: 30257 bytes --]

== Series Details ==

Series: Per client GPU utilisation (rev5)
URL   : https://patchwork.freedesktop.org/series/100573/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_11440_full -> Patchwork_22761_full
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  

Participating hosts (11 -> 11)
------------------------------

  No changes in participating hosts

New tests
---------

  New tests have been introduced between CI_DRM_11440_full and Patchwork_22761_full:

### New IGT tests (51) ###

  * igt@drm_fdinfo@all-busy-check-all:
    - Statuses : 6 pass(s) 1 skip(s)
    - Exec time: [0.0, 0.60] s

  * igt@drm_fdinfo@all-busy-idle-check-all:
    - Statuses : 6 pass(s) 1 skip(s)
    - Exec time: [0.0, 0.67] s

  * igt@drm_fdinfo@basics:
    - Statuses : 4 pass(s) 1 skip(s)
    - Exec time: [0.0] s

  * igt@drm_fdinfo@busy:
    - Statuses : 1 skip(s)
    - Exec time: [0.0] s

  * igt@drm_fdinfo@busy-check-all:
    - Statuses : 1 skip(s)
    - Exec time: [0.0] s

  * igt@drm_fdinfo@busy-check-all@bcs0:
    - Statuses : 4 pass(s)
    - Exec time: [0.52, 0.53] s

  * igt@drm_fdinfo@busy-check-all@rcs0:
    - Statuses : 4 pass(s)
    - Exec time: [0.52, 0.53] s

  * igt@drm_fdinfo@busy-check-all@vcs0:
    - Statuses : 4 pass(s)
    - Exec time: [0.52, 0.53] s

  * igt@drm_fdinfo@busy-check-all@vcs1:
    - Statuses : 1 pass(s)
    - Exec time: [0.52] s

  * igt@drm_fdinfo@busy-check-all@vecs0:
    - Statuses : 4 pass(s)
    - Exec time: [0.52, 0.53] s

  * igt@drm_fdinfo@busy-hang:
    - Statuses : 1 skip(s)
    - Exec time: [0.0] s

  * igt@drm_fdinfo@busy-hang@bcs0:
    - Statuses : 6 pass(s)
    - Exec time: [1.03, 1.13] s

  * igt@drm_fdinfo@busy-hang@rcs0:
    - Statuses : 6 pass(s)
    - Exec time: [1.02, 1.10] s

  * igt@drm_fdinfo@busy-hang@vcs0:
    - Statuses : 6 pass(s)
    - Exec time: [1.03, 1.12] s

  * igt@drm_fdinfo@busy-hang@vcs1:
    - Statuses : 2 pass(s)
    - Exec time: [1.02, 1.10] s

  * igt@drm_fdinfo@busy-hang@vecs0:
    - Statuses : 6 pass(s)
    - Exec time: [1.02, 1.10] s

  * igt@drm_fdinfo@busy-idle:
    - Statuses : 1 skip(s)
    - Exec time: [0.0] s

  * igt@drm_fdinfo@busy-idle-check-all:
    - Statuses : 1 skip(s)
    - Exec time: [0.0] s

  * igt@drm_fdinfo@busy-idle-check-all@bcs0:
    - Statuses : 6 pass(s)
    - Exec time: [0.62, 0.70] s

  * igt@drm_fdinfo@busy-idle-check-all@rcs0:
    - Statuses : 6 pass(s)
    - Exec time: [0.62, 0.69] s

  * igt@drm_fdinfo@busy-idle-check-all@vcs0:
    - Statuses : 6 pass(s)
    - Exec time: [0.62, 0.68] s

  * igt@drm_fdinfo@busy-idle-check-all@vcs1:
    - Statuses : 3 pass(s)
    - Exec time: [0.62, 0.63] s

  * igt@drm_fdinfo@busy-idle-check-all@vecs0:
    - Statuses : 6 pass(s)
    - Exec time: [0.62, 0.69] s

  * igt@drm_fdinfo@busy-idle@bcs0:
    - Statuses : 6 pass(s)
    - Exec time: [0.62, 0.71] s

  * igt@drm_fdinfo@busy-idle@rcs0:
    - Statuses : 6 pass(s)
    - Exec time: [0.62, 0.69] s

  * igt@drm_fdinfo@busy-idle@vcs0:
    - Statuses : 6 pass(s)
    - Exec time: [0.62, 0.70] s

  * igt@drm_fdinfo@busy-idle@vcs1:
    - Statuses : 3 pass(s)
    - Exec time: [0.62, 0.64] s

  * igt@drm_fdinfo@busy-idle@vecs0:
    - Statuses : 6 pass(s)
    - Exec time: [0.62, 0.69] s

  * igt@drm_fdinfo@busy@bcs0:
    - Statuses : 5 pass(s)
    - Exec time: [0.52, 0.59] s

  * igt@drm_fdinfo@busy@rcs0:
    - Statuses : 5 pass(s)
    - Exec time: [0.52, 0.58] s

  * igt@drm_fdinfo@busy@vcs0:
    - Statuses : 5 pass(s)
    - Exec time: [0.52, 0.58] s

  * igt@drm_fdinfo@busy@vcs1:
    - Statuses : 2 pass(s)
    - Exec time: [0.51, 0.52] s

  * igt@drm_fdinfo@busy@vecs0:
    - Statuses : 5 pass(s)
    - Exec time: [0.51, 0.58] s

  * igt@drm_fdinfo@idle:
    - Statuses : 1 skip(s)
    - Exec time: [0.0] s

  * igt@drm_fdinfo@idle@bcs0:
    - Statuses : 6 pass(s)
    - Exec time: [0.50, 0.51] s

  * igt@drm_fdinfo@idle@rcs0:
    - Statuses : 6 pass(s)
    - Exec time: [0.50, 0.52] s

  * igt@drm_fdinfo@idle@vcs0:
    - Statuses : 6 pass(s)
    - Exec time: [0.50, 0.52] s

  * igt@drm_fdinfo@idle@vcs1:
    - Statuses : 3 pass(s)
    - Exec time: [0.50] s

  * igt@drm_fdinfo@idle@vecs0:
    - Statuses : 6 pass(s)
    - Exec time: [0.50, 0.52] s

  * igt@drm_fdinfo@isolation@bcs0:
    - Statuses : 6 pass(s)
    - Exec time: [0.52, 0.59] s

  * igt@drm_fdinfo@isolation@rcs0:
    - Statuses : 6 pass(s)
    - Exec time: [0.52, 0.64] s

  * igt@drm_fdinfo@isolation@vcs0:
    - Statuses : 6 pass(s)
    - Exec time: [0.52, 0.60] s

  * igt@drm_fdinfo@isolation@vcs1:
    - Statuses : 2 pass(s)
    - Exec time: [0.52] s

  * igt@drm_fdinfo@isolation@vecs0:
    - Statuses : 6 pass(s)
    - Exec time: [0.52, 0.59] s

  * igt@drm_fdinfo@most-busy-check-all:
    - Statuses : 1 skip(s)
    - Exec time: [0.0] s

  * igt@drm_fdinfo@most-busy-check-all@bcs0:
    - Statuses : 6 pass(s)
    - Exec time: [0.51, 0.55] s

  * igt@drm_fdinfo@most-busy-check-all@rcs0:
    - Statuses : 6 pass(s)
    - Exec time: [0.51, 0.57] s

  * igt@drm_fdinfo@most-busy-check-all@vcs0:
    - Statuses : 6 pass(s)
    - Exec time: [0.52, 0.57] s

  * igt@drm_fdinfo@most-busy-check-all@vcs1:
    - Statuses : 2 pass(s)
    - Exec time: [0.51, 0.53] s

  * igt@drm_fdinfo@most-busy-check-all@vecs0:
    - Statuses : 6 pass(s)
    - Exec time: [0.52, 0.55] s

  * igt@drm_fdinfo@most-busy-idle-check-all:
    - Statuses :
    - Exec time: [None] s

  

Known issues
------------

  Here are the changes found in Patchwork_22761_full that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@core_hotunplug@unbind-rebind:
    - shard-snb:          [PASS][1] -> [DMESG-WARN][2] ([i915#4528])
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11440/shard-snb5/igt@core_hotunplug@unbind-rebind.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-snb7/igt@core_hotunplug@unbind-rebind.html

  * igt@feature_discovery@display-3x:
    - shard-tglb:         NOTRUN -> [SKIP][3] ([i915#1839])
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-tglb5/igt@feature_discovery@display-3x.html

  * igt@gem_ccs@block-copy-uncompressed:
    - shard-iclb:         NOTRUN -> [SKIP][4] ([i915#5327])
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-iclb4/igt@gem_ccs@block-copy-uncompressed.html

  * igt@gem_ctx_persistence@legacy-engines-hostile-preempt:
    - shard-snb:          NOTRUN -> [SKIP][5] ([fdo#109271] / [i915#1099]) +1 similar issue
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-snb7/igt@gem_ctx_persistence@legacy-engines-hostile-preempt.html

  * igt@gem_ctx_shared@q-in-order:
    - shard-snb:          NOTRUN -> [SKIP][6] ([fdo#109271]) +133 similar issues
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-snb5/igt@gem_ctx_shared@q-in-order.html

  * igt@gem_ctx_sseu@mmap-args:
    - shard-tglb:         NOTRUN -> [SKIP][7] ([i915#280]) +1 similar issue
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-tglb2/igt@gem_ctx_sseu@mmap-args.html

  * igt@gem_exec_balancer@parallel-balancer:
    - shard-iclb:         [PASS][8] -> [SKIP][9] ([i915#4525])
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11440/shard-iclb1/igt@gem_exec_balancer@parallel-balancer.html
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-iclb8/igt@gem_exec_balancer@parallel-balancer.html

  * igt@gem_exec_balancer@parallel-contexts:
    - shard-tglb:         NOTRUN -> [DMESG-WARN][10] ([i915#5076]) +1 similar issue
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-tglb6/igt@gem_exec_balancer@parallel-contexts.html
    - shard-kbl:          NOTRUN -> [DMESG-WARN][11] ([i915#5076]) +1 similar issue
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-kbl7/igt@gem_exec_balancer@parallel-contexts.html

  * igt@gem_exec_endless@dispatch@rcs0:
    - shard-iclb:         [PASS][12] -> [INCOMPLETE][13] ([i915#3778])
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11440/shard-iclb3/igt@gem_exec_endless@dispatch@rcs0.html
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-iclb7/igt@gem_exec_endless@dispatch@rcs0.html

  * igt@gem_exec_fair@basic-deadline:
    - shard-kbl:          NOTRUN -> [FAIL][14] ([i915#2846])
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-kbl6/igt@gem_exec_fair@basic-deadline.html
    - shard-apl:          NOTRUN -> [FAIL][15] ([i915#2846])
   [15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-apl4/igt@gem_exec_fair@basic-deadline.html

  * igt@gem_exec_fair@basic-none-rrul@rcs0:
    - shard-iclb:         NOTRUN -> [FAIL][16] ([i915#2842]) +1 similar issue
   [16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-iclb6/igt@gem_exec_fair@basic-none-rrul@rcs0.html
    - shard-glk:          NOTRUN -> [FAIL][17] ([i915#2842])
   [17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-glk8/igt@gem_exec_fair@basic-none-rrul@rcs0.html
    - shard-tglb:         NOTRUN -> [FAIL][18] ([i915#2842]) +1 similar issue
   [18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-tglb5/igt@gem_exec_fair@basic-none-rrul@rcs0.html

  * igt@gem_exec_fair@basic-pace@rcs0:
    - shard-glk:          [PASS][19] -> [FAIL][20] ([i915#2842])
   [19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11440/shard-glk6/igt@gem_exec_fair@basic-pace@rcs0.html
   [20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-glk7/igt@gem_exec_fair@basic-pace@rcs0.html

  * igt@gem_exec_fair@basic-pace@vecs0:
    - shard-kbl:          NOTRUN -> [FAIL][21] ([i915#2842])
   [21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-kbl6/igt@gem_exec_fair@basic-pace@vecs0.html

  * igt@gem_exec_whisper@basic-queues-forked-all:
    - shard-glk:          [PASS][22] -> [DMESG-WARN][23] ([i915#118]) +1 similar issue
   [22]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11440/shard-glk7/igt@gem_exec_whisper@basic-queues-forked-all.html
   [23]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-glk5/igt@gem_exec_whisper@basic-queues-forked-all.html

  * igt@gem_lmem_swapping@heavy-multi:
    - shard-skl:          NOTRUN -> [SKIP][24] ([fdo#109271] / [i915#4613]) +1 similar issue
   [24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-skl4/igt@gem_lmem_swapping@heavy-multi.html

  * igt@gem_lmem_swapping@heavy-random:
    - shard-kbl:          NOTRUN -> [SKIP][25] ([fdo#109271] / [i915#4613]) +2 similar issues
   [25]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-kbl1/igt@gem_lmem_swapping@heavy-random.html

  * igt@gem_lmem_swapping@random-engines:
    - shard-tglb:         NOTRUN -> [SKIP][26] ([i915#4613]) +1 similar issue
   [26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-tglb5/igt@gem_lmem_swapping@random-engines.html

  * igt@gem_lmem_swapping@verify:
    - shard-apl:          NOTRUN -> [SKIP][27] ([fdo#109271] / [i915#4613])
   [27]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-apl4/igt@gem_lmem_swapping@verify.html

  * igt@gem_pread@exhaustion:
    - shard-tglb:         NOTRUN -> [WARN][28] ([i915#2658])
   [28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-tglb5/igt@gem_pread@exhaustion.html
    - shard-glk:          NOTRUN -> [WARN][29] ([i915#2658])
   [29]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-glk8/igt@gem_pread@exhaustion.html
    - shard-apl:          NOTRUN -> [WARN][30] ([i915#2658]) +1 similar issue
   [30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-apl6/igt@gem_pread@exhaustion.html
    - shard-iclb:         NOTRUN -> [WARN][31] ([i915#2658])
   [31]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-iclb6/igt@gem_pread@exhaustion.html
    - shard-snb:          NOTRUN -> [WARN][32] ([i915#2658])
   [32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-snb5/igt@gem_pread@exhaustion.html
    - shard-skl:          NOTRUN -> [WARN][33] ([i915#2658])
   [33]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-skl10/igt@gem_pread@exhaustion.html

  * igt@gem_pwrite@basic-exhaustion:
    - shard-kbl:          NOTRUN -> [WARN][34] ([i915#2658]) +1 similar issue
   [34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-kbl1/igt@gem_pwrite@basic-exhaustion.html

  * igt@gem_pxp@create-regular-buffer:
    - shard-iclb:         NOTRUN -> [SKIP][35] ([i915#4270])
   [35]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-iclb8/igt@gem_pxp@create-regular-buffer.html

  * igt@gem_pxp@protected-encrypted-src-copy-not-readible:
    - shard-tglb:         NOTRUN -> [SKIP][36] ([i915#4270]) +2 similar issues
   [36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-tglb3/igt@gem_pxp@protected-encrypted-src-copy-not-readible.html

  * igt@gem_render_copy@x-tiled-to-vebox-yf-tiled:
    - shard-kbl:          NOTRUN -> [SKIP][37] ([fdo#109271]) +282 similar issues
   [37]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-kbl1/igt@gem_render_copy@x-tiled-to-vebox-yf-tiled.html

  * igt@gem_render_copy@yf-tiled-mc-ccs-to-vebox-yf-tiled:
    - shard-iclb:         NOTRUN -> [SKIP][38] ([i915#768]) +1 similar issue
   [38]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-iclb4/igt@gem_render_copy@yf-tiled-mc-ccs-to-vebox-yf-tiled.html

  * igt@gem_userptr_blits@unsync-unmap:
    - shard-iclb:         NOTRUN -> [SKIP][39] ([i915#3297]) +1 similar issue
   [39]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-iclb5/igt@gem_userptr_blits@unsync-unmap.html

  * igt@gem_userptr_blits@unsync-unmap-cycles:
    - shard-tglb:         NOTRUN -> [SKIP][40] ([i915#3297]) +2 similar issues
   [40]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-tglb6/igt@gem_userptr_blits@unsync-unmap-cycles.html

  * igt@gen3_render_mixed_blits:
    - shard-tglb:         NOTRUN -> [SKIP][41] ([fdo#109289]) +3 similar issues
   [41]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-tglb2/igt@gen3_render_mixed_blits.html

  * igt@gen9_exec_parse@bb-start-param:
    - shard-tglb:         NOTRUN -> [SKIP][42] ([i915#2527] / [i915#2856]) +2 similar issues
   [42]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-tglb7/igt@gen9_exec_parse@bb-start-param.html

  * igt@gen9_exec_parse@valid-registers:
    - shard-iclb:         NOTRUN -> [SKIP][43] ([i915#2856])
   [43]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-iclb6/igt@gen9_exec_parse@valid-registers.html

  * igt@i915_pm_dc@dc3co-vpb-simulation:
    - shard-tglb:         NOTRUN -> [SKIP][44] ([i915#1904])
   [44]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-tglb7/igt@i915_pm_dc@dc3co-vpb-simulation.html
    - shard-iclb:         NOTRUN -> [SKIP][45] ([i915#658])
   [45]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-iclb3/igt@i915_pm_dc@dc3co-vpb-simulation.html

  * igt@i915_pm_lpsp@kms-lpsp@kms-lpsp-dp:
    - shard-apl:          NOTRUN -> [SKIP][46] ([fdo#109271] / [i915#1937])
   [46]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-apl2/igt@i915_pm_lpsp@kms-lpsp@kms-lpsp-dp.html

  * igt@i915_pm_lpsp@kms-lpsp@kms-lpsp-hdmi-a:
    - shard-glk:          NOTRUN -> [SKIP][47] ([fdo#109271] / [i915#1937])
   [47]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-glk3/igt@i915_pm_lpsp@kms-lpsp@kms-lpsp-hdmi-a.html

  * igt@i915_pm_rpm@pc8-residency:
    - shard-iclb:         NOTRUN -> [SKIP][48] ([fdo#109293] / [fdo#109506])
   [48]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-iclb5/igt@i915_pm_rpm@pc8-residency.html
    - shard-tglb:         NOTRUN -> [SKIP][49] ([fdo#109506] / [i915#2411])
   [49]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-tglb1/igt@i915_pm_rpm@pc8-residency.html

  * igt@i915_suspend@debugfs-reader:
    - shard-skl:          [PASS][50] -> [INCOMPLETE][51] ([i915#4939])
   [50]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11440/shard-skl1/igt@i915_suspend@debugfs-reader.html
   [51]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-skl1/igt@i915_suspend@debugfs-reader.html

  * igt@kms_atomic@plane-primary-overlay-mutable-zpos:
    - shard-tglb:         NOTRUN -> [SKIP][52] ([i915#404])
   [52]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-tglb6/igt@kms_atomic@plane-primary-overlay-mutable-zpos.html

  * igt@kms_atomic_transition@plane-all-modeset-transition-fencing:
    - shard-tglb:         NOTRUN -> [SKIP][53] ([i915#1769])
   [53]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-tglb7/igt@kms_atomic_transition@plane-all-modeset-transition-fencing.html

  * igt@kms_big_fb@4-tiled-64bpp-rotate-0:
    - shard-iclb:         NOTRUN -> [SKIP][54] ([i915#5286]) +3 similar issues
   [54]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-iclb6/igt@kms_big_fb@4-tiled-64bpp-rotate-0.html

  * igt@kms_big_fb@4-tiled-max-hw-stride-32bpp-rotate-0:
    - shard-tglb:         NOTRUN -> [SKIP][55] ([i915#5286]) +4 similar issues
   [55]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-tglb6/igt@kms_big_fb@4-tiled-max-hw-stride-32bpp-rotate-0.html

  * igt@kms_big_fb@x-tiled-16bpp-rotate-270:
    - shard-tglb:         NOTRUN -> [SKIP][56] ([fdo#111614]) +2 similar issues
   [56]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-tglb1/igt@kms_big_fb@x-tiled-16bpp-rotate-270.html

  * igt@kms_big_fb@x-tiled-max-hw-stride-32bpp-rotate-180-hflip-async-flip:
    - shard-apl:          NOTRUN -> [SKIP][57] ([fdo#109271] / [i915#3777]) +1 similar issue
   [57]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-apl6/igt@kms_big_fb@x-tiled-max-hw-stride-32bpp-rotate-180-hflip-async-flip.html

  * igt@kms_big_fb@y-tiled-max-hw-stride-32bpp-rotate-0-async-flip:
    - shard-skl:          NOTRUN -> [FAIL][58] ([i915#3743])
   [58]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-skl4/igt@kms_big_fb@y-tiled-max-hw-stride-32bpp-rotate-0-async-flip.html

  * igt@kms_big_fb@y-tiled-max-hw-stride-32bpp-rotate-0-hflip-async-flip:
    - shard-kbl:          NOTRUN -> [SKIP][59] ([fdo#109271] / [i915#3777]) +1 similar issue
   [59]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-kbl7/igt@kms_big_fb@y-tiled-max-hw-stride-32bpp-rotate-0-hflip-async-flip.html

  * igt@kms_big_fb@y-tiled-max-hw-stride-64bpp-rotate-0-async-flip:
    - shard-skl:          NOTRUN -> [FAIL][60] ([i915#3763])
   [60]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-skl6/igt@kms_big_fb@y-tiled-max-hw-stride-64bpp-rotate-0-async-flip.html

  * igt@kms_big_fb@yf-tiled-max-hw-stride-32bpp-rotate-0-hflip:
    - shard-skl:          NOTRUN -> [SKIP][61] ([fdo#109271] / [i915#3777]) +1 similar issue
   [61]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-skl1/igt@kms_big_fb@yf-tiled-max-hw-stride-32bpp-rotate-0-hflip.html

  * igt@kms_big_fb@yf-tiled-max-hw-stride-64bpp-rotate-180-async-flip:
    - shard-iclb:         NOTRUN -> [SKIP][62] ([fdo#110723])
   [62]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-iclb5/igt@kms_big_fb@yf-tiled-max-hw-stride-64bpp-rotate-180-async-flip.html

  * igt@kms_big_joiner@basic:
    - shard-tglb:         NOTRUN -> [SKIP][63] ([i915#2705]) +1 similar issue
   [63]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-tglb2/igt@kms_big_joiner@basic.html

  * igt@kms_big_joiner@invalid-modeset:
    - shard-iclb:         NOTRUN -> [SKIP][64] ([i915#2705])
   [64]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-iclb6/igt@kms_big_joiner@invalid-modeset.html

  * igt@kms_ccs@pipe-a-random-ccs-data-y_tiled_ccs:
    - shard-tglb:         NOTRUN -> [SKIP][65] ([i915#3689]) +6 similar issues
   [65]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-tglb1/igt@kms_ccs@pipe-a-random-ccs-data-y_tiled_ccs.html

  * igt@kms_ccs@pipe-b-bad-rotation-90-y_tiled_gen12_mc_ccs:
    - shard-tglb:         NOTRUN -> [SKIP][66] ([i915#3689] / [i915#3886]) +4 similar issues
   [66]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-tglb5/igt@kms_ccs@pipe-b-bad-rotation-90-y_tiled_gen12_mc_ccs.html

  * igt@kms_ccs@pipe-b-crc-primary-rotation-180-y_tiled_gen12_rc_ccs_cc:
    - shard-skl:          NOTRUN -> [SKIP][67] ([fdo#109271] / [i915#3886]) +7 similar issues
   [67]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-skl8/igt@kms_ccs@pipe-b-crc-primary-rotation-180-y_tiled_gen12_rc_ccs_cc.html
    - shard-glk:          NOTRUN -> [SKIP][68] ([fdo#109271] / [i915#3886]) +3 similar issues
   [68]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-glk4/igt@kms_ccs@pipe-b-crc-primary-rotation-180-y_tiled_gen12_rc_ccs_cc.html

  * igt@kms_ccs@pipe-b-missing-ccs-buffer-y_tiled_gen12_rc_ccs_cc:
    - shard-apl:          NOTRUN -> [SKIP][69] ([fdo#109271] / [i915#3886]) +6 similar issues
   [69]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-apl1/igt@kms_ccs@pipe-b-missing-ccs-buffer-y_tiled_gen12_rc_ccs_cc.html

  * igt@kms_ccs@pipe-b-random-ccs-data-y_tiled_gen12_mc_ccs:
    - shard-kbl:          NOTRUN -> [SKIP][70] ([fdo#109271] / [i915#3886]) +15 similar issues
   [70]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-kbl4/igt@kms_ccs@pipe-b-random-ccs-data-y_tiled_gen12_mc_ccs.html

  * igt@kms_ccs@pipe-c-crc-primary-rotation-180-y_tiled_gen12_rc_ccs_cc:
    - shard-iclb:         NOTRUN -> [SKIP][71] ([fdo#109278] / [i915#3886]) +2 similar issues
   [71]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-iclb8/igt@kms_ccs@pipe-c-crc-primary-rotation-180-y_tiled_gen12_rc_ccs_cc.html

  * igt@kms_ccs@pipe-d-missing-ccs-buffer-yf_tiled_ccs:
    - shard-tglb:         NOTRUN -> [SKIP][72] ([fdo#111615] / [i915#3689]) +5 similar issues
   [72]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-tglb7/igt@kms_ccs@pipe-d-missing-ccs-buffer-yf_tiled_ccs.html

  * igt@kms_chamelium@hdmi-hpd-fast:
    - shard-snb:          NOTRUN -> [SKIP][73] ([fdo#109271] / [fdo#111827]) +4 similar issues
   [73]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-snb4/igt@kms_chamelium@hdmi-hpd-fast.html

  * igt@kms_chamelium@hdmi-hpd-storm:
    - shard-kbl:          NOTRUN -> [SKIP][74] ([fdo#109271] / [fdo#111827]) +20 similar issues
   [74]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-kbl7/igt@kms_chamelium@hdmi-hpd-storm.html

  * igt@kms_color@pipe-d-ctm-max:
    - shard-skl:          NOTRUN -> [SKIP][75] ([fdo#109271]) +157 similar issues
   [75]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-skl10/igt@kms_color@pipe-d-ctm-max.html
    - shard-iclb:         NOTRUN -> [SKIP][76] ([fdo#109278] / [i915#1149])
   [76]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-iclb5/igt@kms_color@pipe-d-ctm-max.html

  * igt@kms_color_chamelium@pipe-a-ctm-limited-range:
    - shard-apl:          NOTRUN -> [SKIP][77] ([fdo#109271] / [fdo#111827]) +10 similar issues
   [77]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-apl7/igt@kms_color_chamelium@pipe-a-ctm-limited-range.html

  * igt@kms_color_chamelium@pipe-b-ctm-0-5:
    - shard-tglb:         NOTRUN -> [SKIP][78] ([fdo#109284] / [fdo#111827]) +12 similar issues
   [78]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-tglb3/igt@kms_color_chamelium@pipe-b-ctm-0-5.html

  * igt@kms_color_chamelium@pipe-b-ctm-max:
    - shard-skl:          NOTRUN -> [SKIP][79] ([fdo#109271] / [fdo#111827]) +9 similar issues
   [79]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-skl8/igt@kms_color_chamelium@pipe-b-ctm-max.html

  * igt@kms_color_chamelium@pipe-b-ctm-red-to-blue:
    - shard-glk:          NOTRUN -> [SKIP][80] ([fdo#109271] / [fdo#111827]) +4 similar issues
   [80]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-glk3/igt@kms_color_chamelium@pipe-b-ctm-red-to-blue.html

  * igt@kms_color_chamelium@pipe-c-ctm-limited-range:
    - shard-iclb:         NOTRUN -> [SKIP][81] ([fdo#109284] / [fdo#111827]) +3 similar issues
   [81]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-iclb7/igt@kms_color_chamelium@pipe-c-ctm-limited-range.html

  * igt@kms_content_protection@atomic:
    - shard-kbl:          NOTRUN -> [TIMEOUT][82] ([i915#1319]) +1 similar issue
   [82]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-kbl4/igt@kms_content_protection@atomic.html

  * igt@kms_content_protection@dp-mst-lic-type-0:
    - shard-tglb:         NOTRUN -> [SKIP][83] ([i915#3116] / [i915#3299])
   [83]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-tglb2/igt@kms_content_protection@dp-mst-lic-type-0.html

  * igt@kms_content_protection@srm:
    - shard-glk:          NOTRUN -> [SKIP][84] ([fdo#109271]) +65 similar issues
   [84]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-glk1/igt@kms_content_protection@srm.html
    - shard-tglb:         NOTRUN -> [SKIP][85] ([i915#1063]) +1 similar issue
   [85]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-tglb1/igt@kms_content_protection@srm.html
    - shard-iclb:         NOTRUN -> [SKIP][86] ([fdo#109300] / [fdo#111066])
   [86]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-iclb4/igt@kms_content_protection@srm.html
    - shard-apl:          NOTRUN -> [TIMEOUT][87] ([i915#1319])
   [87]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-apl6/igt@kms_content_protection@srm.html

  * igt@kms_cursor_crc@pipe-b-cursor-32x10-random:
    - shard-tglb:         NOTRUN -> [SKIP][88] ([i915#3359]) +4 similar issues
   [88]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-tglb5/igt@kms_cursor_crc@pipe-b-cursor-32x10-random.html

  * igt@kms_cursor_crc@pipe-b-cursor-32x32-rapid-movement:
    - shard-tglb:         NOTRUN -> [SKIP][89] ([i915#3319]) +3 similar issues
   [89]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-tglb6/igt@kms_cursor_crc@pipe-b-cursor-32x32-rapid-movement.html

  * igt@kms_cursor_crc@pipe-c-cursor-suspend:
    - shard-skl:          [PASS][90] -> [SKIP][91] ([fdo#109271]) +24 similar issues
   [90]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11440/shard-skl6/igt@kms_cursor_crc@pipe-c-cursor-suspend.html
   [91]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-skl1/igt@kms_cursor_crc@pipe-c-cursor-suspend.html

  * igt@kms_cursor_crc@pipe-d-cursor-512x512-rapid-movement:
    - shard-tglb:         NOTRUN -> [SKIP][92] ([fdo#109279] / [i915#3359]) +3 similar issues
   [92]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-tglb2/igt@kms_cursor_crc@pipe-d-cursor-512x512-rapid-movement.html

  * igt@kms_cursor_legacy@2x-long-cursor-vs-flip-legacy:
    - shard-iclb:         NOTRUN -> [SKIP][93] ([fdo#109274] / [fdo#109278]) +1 similar issue
   [93]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-iclb6/igt@kms_cursor_legacy@2x-long-cursor-vs-flip-legacy.html

  * igt@kms_cursor_legacy@pipe-d-torture-bo:
    - shard-apl:          NOTRUN -> [SKIP][94] ([fdo#109271] / [i915#533])
   [94]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-apl8/igt@kms_cursor_legacy@pipe-d-torture-bo.html
    - shard-glk:          NOTRUN -> [SKIP][95] ([fdo#109271] / [i915#533])
   [95]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-glk9/igt@kms_cursor_legacy@pipe-d-torture-bo.html
    - shard-skl:          NOTRUN -> [SKIP][96] ([fdo#109271] / [i915#533])
   [96]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-skl1/igt@kms_cursor_legacy@pipe-d-torture-bo.html

  * igt@kms_display_modes@extended-mode-basic:
    - shard-tglb:         NOTRUN -> [SKIP][97] ([fdo#109274])
   [97]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-tglb3/igt@kms_display_modes@extended-mode-basic.html

  * igt@kms_dp_tiled_display@basic-test-pattern:
    - shard-iclb:         NOTRUN -> [SKIP][98] ([i915#426])
   [98]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-iclb6/igt@kms_dp_tiled_display@basic-test-pattern.html
    - shard-tglb:         NOTRUN -> [SKIP][99] ([i915#426])
   [99]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-tglb5/igt@kms_dp_tiled_display@basic-test-pattern.html

  * igt@kms_draw_crc@draw-method-rgb565-pwrite-4tiled:
    - shard-tglb:         NOTRUN -> [SKIP][100] ([i915#5287])
   [100]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-tglb2/igt@kms_draw_crc@draw-method-rgb565-pwrite-4tiled.html
    - shard-iclb:         NOTRUN -> [SKIP][101] ([i915#5287])
   [101]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-iclb8/igt@kms_draw_crc@draw-method-rgb565-pwrite-4tiled.html

  * igt@kms_fbcon_fbt@fbc-suspend:
    - shard-apl:          [PASS][102] -> [INCOMPLETE][103] ([i915#180] / [i915#1982])
   [102]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11440/shard-apl6/igt@kms_fbcon_fbt@fbc-suspend.html
   [103]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-apl6/igt@kms_fbcon_fbt@fbc-suspend.html
    - shard-kbl:          [PASS][104] -> [INCOMPLETE][105] ([i915#180] / [i915#636])
   [104]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11440/shard-kbl3/igt@kms_fbcon_fbt@fbc-suspend.html
   [105]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-kbl4/igt@kms_fbcon_fbt@fbc-suspend.html

  * igt@kms_flip@2x-blocking-absolute-wf_vblank-interruptible:
    - shard-tglb:         NOTRUN -> [SKIP][106] ([fdo#109274] / [fdo#111825]) +10 similar issues
   [106]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-tglb5/igt@kms_flip@2x-blocking-absolute-wf_vblank-interruptible.html
    - shard-iclb:         NOTRUN -> [SKIP][107] ([fdo#109274])
   [107]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/shard-iclb4/igt@kms_flip@2x-blocking-absolute-wf_vblank-interruptible.html

  * igt@kms_flip@2x-flip-vs-expired-vblank-interruptible

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22761/index.html

[-- Attachment #2: Type: text/html, Size: 34966 bytes --]

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [Intel-gfx] [CI 8/8] drm/i915: Expose client engine utilisation via fdinfo
  2022-04-01 14:22   ` [Intel-gfx] " Tvrtko Ursulin
  (?)
@ 2022-04-04  9:12   ` Tvrtko Ursulin
  2022-04-04  9:23     ` Tvrtko Ursulin
  -1 siblings, 1 reply; 35+ messages in thread
From: Tvrtko Ursulin @ 2022-04-04  9:12 UTC (permalink / raw)
  To: Intel-gfx; +Cc: dri-devel


On 01/04/2022 15:22, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> 
> Similar to AMD commit
> 874442541133 ("drm/amdgpu: Add show_fdinfo() interface"), using the
> infrastructure added in previous patches, we add basic client info
> and GPU engine utilisation for i915.
> 
> Example of the output:
> 
>    pos:    0
>    flags:  0100002
>    mnt_id: 21
>    drm-driver: i915
>    drm-pdev:   0000:00:02.0
>    drm-client-id:      7
>    drm-engine-render:  9288864723 ns
>    drm-engine-copy:    2035071108 ns
>    drm-engine-video:   0 ns
>    drm-engine-video-enhance:   0 ns
> 
> v2:
>   * Update for removal of name and pid.
> 
> v3:
>   * Use drm_driver.name.
> 
> v4:
>   * Added drm-engine-capacity- tag.
>   * Fix typo. (Umesh)
> 
> v5:
>   * Don't output engine data before Gen8.
> 
> 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: Chris Healy <cphealy@gmail.com>
> Acked-by: Christian König <christian.koenig@amd.com>
> Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>

Forgot to apply an earlier:

Acked-by: Rob Clark <robdclark@gmail.com>

Regards,

Tvrtko

> ---
>   Documentation/gpu/drm-usage-stats.rst  |  6 ++
>   Documentation/gpu/i915.rst             | 28 +++++++++
>   drivers/gpu/drm/i915/i915_driver.c     |  3 +
>   drivers/gpu/drm/i915/i915_drm_client.c | 84 ++++++++++++++++++++++++++
>   drivers/gpu/drm/i915/i915_drm_client.h |  4 ++
>   5 files changed, 125 insertions(+)
> 
> diff --git a/Documentation/gpu/drm-usage-stats.rst b/Documentation/gpu/drm-usage-stats.rst
> index b8cc28f4da6f..6c9f166a8d6f 100644
> --- a/Documentation/gpu/drm-usage-stats.rst
> +++ b/Documentation/gpu/drm-usage-stats.rst
> @@ -104,3 +104,9 @@ 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.
> +
> +===============================
> +Driver specific implementations
> +===============================
> +
> +:ref:`i915-usage-stats`
> diff --git a/Documentation/gpu/i915.rst b/Documentation/gpu/i915.rst
> index 0f08693d05cd..54060cd6c419 100644
> --- a/Documentation/gpu/i915.rst
> +++ b/Documentation/gpu/i915.rst
> @@ -697,3 +697,31 @@ The style guide for ``i915_reg.h``.
>   
>   .. kernel-doc:: drivers/gpu/drm/i915/i915_reg.h
>      :doc: The i915 register macro definition style guide
> +
> +.. _i915-usage-stats:
> +
> +i915 DRM client usage stats implementation
> +==========================================
> +
> +The drm/i915 driver implements the DRM client usage stats specification as
> +documented in :ref:`drm-client-usage-stats`.
> +
> +Example of the output showing the implemented key value pairs and entirety of
> +the currently possible format options:
> +
> +::
> +
> +      pos:    0
> +      flags:  0100002
> +      mnt_id: 21
> +      drm-driver: i915
> +      drm-pdev:   0000:00:02.0
> +      drm-client-id:      7
> +      drm-engine-render:  9288864723 ns
> +      drm-engine-copy:    2035071108 ns
> +      drm-engine-video:   0 ns
> +      drm-engine-capacity-video:   2
> +      drm-engine-video-enhance:   0 ns
> +
> +Possible `drm-engine-` key names are: `render`, `copy`, `video` and
> +`video-enhance`.
> diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
> index b2df273e6d7b..3ffb617d75c9 100644
> --- a/drivers/gpu/drm/i915/i915_driver.c
> +++ b/drivers/gpu/drm/i915/i915_driver.c
> @@ -1745,6 +1745,9 @@ static const struct file_operations i915_driver_fops = {
>   	.read = drm_read,
>   	.compat_ioctl = i915_ioc32_compat_ioctl,
>   	.llseek = noop_llseek,
> +#ifdef CONFIG_PROC_FS
> +	.show_fdinfo = i915_drm_client_fdinfo,
> +#endif
>   };
>   
>   static int
> diff --git a/drivers/gpu/drm/i915/i915_drm_client.c b/drivers/gpu/drm/i915/i915_drm_client.c
> index 91a8559bebf7..e539f6b23060 100644
> --- a/drivers/gpu/drm/i915/i915_drm_client.c
> +++ b/drivers/gpu/drm/i915/i915_drm_client.c
> @@ -7,7 +7,13 @@
>   #include <linux/slab.h>
>   #include <linux/types.h>
>   
> +#include <uapi/drm/i915_drm.h>
> +
> +#include <drm/drm_print.h>
> +
> +#include "gem/i915_gem_context.h"
>   #include "i915_drm_client.h"
> +#include "i915_file_private.h"
>   #include "i915_gem.h"
>   #include "i915_utils.h"
>   
> @@ -68,3 +74,81 @@ void i915_drm_clients_fini(struct i915_drm_clients *clients)
>   	GEM_BUG_ON(!xa_empty(&clients->xarray));
>   	xa_destroy(&clients->xarray);
>   }
> +
> +#ifdef CONFIG_PROC_FS
> +static const char * const uabi_class_names[] = {
> +	[I915_ENGINE_CLASS_RENDER] = "render",
> +	[I915_ENGINE_CLASS_COPY] = "copy",
> +	[I915_ENGINE_CLASS_VIDEO] = "video",
> +	[I915_ENGINE_CLASS_VIDEO_ENHANCE] = "video-enhance",
> +};
> +
> +static u64 busy_add(struct i915_gem_context *ctx, unsigned int class)
> +{
> +	struct i915_gem_engines_iter it;
> +	struct intel_context *ce;
> +	u64 total = 0;
> +
> +	for_each_gem_engine(ce, rcu_dereference(ctx->engines), it) {
> +		if (ce->engine->uabi_class != class)
> +			continue;
> +
> +		total += intel_context_get_total_runtime_ns(ce);
> +	}
> +
> +	return total;
> +}
> +
> +static void
> +show_client_class(struct seq_file *m,
> +		  struct i915_drm_client *client,
> +		  unsigned int class)
> +{
> +	const struct list_head *list = &client->ctx_list;
> +	u64 total = atomic64_read(&client->past_runtime[class]);
> +	const unsigned int capacity =
> +		client->clients->i915->engine_uabi_class_count[class];
> +	struct i915_gem_context *ctx;
> +
> +	rcu_read_lock();
> +	list_for_each_entry_rcu(ctx, list, client_link)
> +		total += busy_add(ctx, class);
> +	rcu_read_unlock();
> +
> +	seq_printf(m, "drm-engine-%s:\t%llu ns\n",
> +		   uabi_class_names[class], total);
> +
> +	if (capacity > 1)
> +		seq_printf(m, "drm-engine-capacity-%s:\t%u\n",
> +			   uabi_class_names[class],
> +			   capacity);
> +}
> +
> +void i915_drm_client_fdinfo(struct seq_file *m, struct file *f)
> +{
> +	struct drm_file *file = f->private_data;
> +	struct drm_i915_file_private *file_priv = file->driver_priv;
> +	struct drm_i915_private *i915 = file_priv->dev_priv;
> +	struct i915_drm_client *client = file_priv->client;
> +	struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
> +	unsigned int i;
> +
> +	/*
> +	 * ******************************************************************
> +	 * For text output format description please see drm-usage-stats.rst!
> +	 * ******************************************************************
> +	 */
> +
> +	seq_printf(m, "drm-driver:\t%s\n", i915->drm.driver->name);
> +	seq_printf(m, "drm-pdev:\t%04x:%02x:%02x.%d\n",
> +		   pci_domain_nr(pdev->bus), pdev->bus->number,
> +		   PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
> +	seq_printf(m, "drm-client-id:\t%u\n", client->id);
> +
> +	if (GRAPHICS_VER(i915) < 8)
> +		return;
> +
> +	for (i = 0; i < ARRAY_SIZE(uabi_class_names); i++)
> +		show_client_class(m, client, i);
> +}
> +#endif
> diff --git a/drivers/gpu/drm/i915/i915_drm_client.h b/drivers/gpu/drm/i915/i915_drm_client.h
> index 191368386ace..5f5b02b01ba0 100644
> --- a/drivers/gpu/drm/i915/i915_drm_client.h
> +++ b/drivers/gpu/drm/i915/i915_drm_client.h
> @@ -59,6 +59,10 @@ static inline void i915_drm_client_put(struct i915_drm_client *client)
>   
>   struct i915_drm_client *i915_drm_client_add(struct i915_drm_clients *clients);
>   
> +#ifdef CONFIG_PROC_FS
> +void i915_drm_client_fdinfo(struct seq_file *m, struct file *f);
> +#endif
> +
>   void i915_drm_clients_fini(struct i915_drm_clients *clients);
>   
>   #endif /* !__I915_DRM_CLIENT_H__ */

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [Intel-gfx] [CI 8/8] drm/i915: Expose client engine utilisation via fdinfo
  2022-04-04  9:12   ` Tvrtko Ursulin
@ 2022-04-04  9:23     ` Tvrtko Ursulin
  2022-04-04 15:36         ` Daniel Vetter
  0 siblings, 1 reply; 35+ messages in thread
From: Tvrtko Ursulin @ 2022-04-04  9:23 UTC (permalink / raw)
  To: Intel-gfx, Dave Airlie, Daniel Vetter; +Cc: Christian König, dri-devel


+ Dave and Daniel

Guys, are you okay with merging this via drm-intel-gt-next? It is one 
new file at Documentation/gpu/drm-usage-stats.rst only which is outside 
i915. It has acks from Christian and Rob.

Daniel, series is also fully reviewed and IGT reviewed and ready. Rob 
also demonstrated the approach works for msm when using the vendor 
agnosstic gputop tool I sketched out (see 
20220225202614.225197-3-robdclark@gmail.com).

My plan is to merge the i915 support with the common spec and 
intel_gpu_top on the IGT side. Then follow-up with vendor agnostic 
gputop and later yet potentially re-visit the AMD side by re-sending the 
patch which tweaks the fdinfo format there and adds support for relative 
engine utilisation as provided by amdgpu.

Regards,

Tvrtko

On 04/04/2022 10:12, Tvrtko Ursulin wrote:
> 
> On 01/04/2022 15:22, Tvrtko Ursulin wrote:
>> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>>
>> Similar to AMD commit
>> 874442541133 ("drm/amdgpu: Add show_fdinfo() interface"), using the
>> infrastructure added in previous patches, we add basic client info
>> and GPU engine utilisation for i915.
>>
>> Example of the output:
>>
>>    pos:    0
>>    flags:  0100002
>>    mnt_id: 21
>>    drm-driver: i915
>>    drm-pdev:   0000:00:02.0
>>    drm-client-id:      7
>>    drm-engine-render:  9288864723 ns
>>    drm-engine-copy:    2035071108 ns
>>    drm-engine-video:   0 ns
>>    drm-engine-video-enhance:   0 ns
>>
>> v2:
>>   * Update for removal of name and pid.
>>
>> v3:
>>   * Use drm_driver.name.
>>
>> v4:
>>   * Added drm-engine-capacity- tag.
>>   * Fix typo. (Umesh)
>>
>> v5:
>>   * Don't output engine data before Gen8.
>>
>> 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: Chris Healy <cphealy@gmail.com>
>> Acked-by: Christian König <christian.koenig@amd.com>
>> Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
> 
> Forgot to apply an earlier:
> 
> Acked-by: Rob Clark <robdclark@gmail.com>
> 
> Regards,
> 
> Tvrtko
> 
>> ---
>>   Documentation/gpu/drm-usage-stats.rst  |  6 ++
>>   Documentation/gpu/i915.rst             | 28 +++++++++
>>   drivers/gpu/drm/i915/i915_driver.c     |  3 +
>>   drivers/gpu/drm/i915/i915_drm_client.c | 84 ++++++++++++++++++++++++++
>>   drivers/gpu/drm/i915/i915_drm_client.h |  4 ++
>>   5 files changed, 125 insertions(+)
>>
>> diff --git a/Documentation/gpu/drm-usage-stats.rst 
>> b/Documentation/gpu/drm-usage-stats.rst
>> index b8cc28f4da6f..6c9f166a8d6f 100644
>> --- a/Documentation/gpu/drm-usage-stats.rst
>> +++ b/Documentation/gpu/drm-usage-stats.rst
>> @@ -104,3 +104,9 @@ 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.
>> +
>> +===============================
>> +Driver specific implementations
>> +===============================
>> +
>> +:ref:`i915-usage-stats`
>> diff --git a/Documentation/gpu/i915.rst b/Documentation/gpu/i915.rst
>> index 0f08693d05cd..54060cd6c419 100644
>> --- a/Documentation/gpu/i915.rst
>> +++ b/Documentation/gpu/i915.rst
>> @@ -697,3 +697,31 @@ The style guide for ``i915_reg.h``.
>>   .. kernel-doc:: drivers/gpu/drm/i915/i915_reg.h
>>      :doc: The i915 register macro definition style guide
>> +
>> +.. _i915-usage-stats:
>> +
>> +i915 DRM client usage stats implementation
>> +==========================================
>> +
>> +The drm/i915 driver implements the DRM client usage stats 
>> specification as
>> +documented in :ref:`drm-client-usage-stats`.
>> +
>> +Example of the output showing the implemented key value pairs and 
>> entirety of
>> +the currently possible format options:
>> +
>> +::
>> +
>> +      pos:    0
>> +      flags:  0100002
>> +      mnt_id: 21
>> +      drm-driver: i915
>> +      drm-pdev:   0000:00:02.0
>> +      drm-client-id:      7
>> +      drm-engine-render:  9288864723 ns
>> +      drm-engine-copy:    2035071108 ns
>> +      drm-engine-video:   0 ns
>> +      drm-engine-capacity-video:   2
>> +      drm-engine-video-enhance:   0 ns
>> +
>> +Possible `drm-engine-` key names are: `render`, `copy`, `video` and
>> +`video-enhance`.
>> diff --git a/drivers/gpu/drm/i915/i915_driver.c 
>> b/drivers/gpu/drm/i915/i915_driver.c
>> index b2df273e6d7b..3ffb617d75c9 100644
>> --- a/drivers/gpu/drm/i915/i915_driver.c
>> +++ b/drivers/gpu/drm/i915/i915_driver.c
>> @@ -1745,6 +1745,9 @@ static const struct file_operations 
>> i915_driver_fops = {
>>       .read = drm_read,
>>       .compat_ioctl = i915_ioc32_compat_ioctl,
>>       .llseek = noop_llseek,
>> +#ifdef CONFIG_PROC_FS
>> +    .show_fdinfo = i915_drm_client_fdinfo,
>> +#endif
>>   };
>>   static int
>> diff --git a/drivers/gpu/drm/i915/i915_drm_client.c 
>> b/drivers/gpu/drm/i915/i915_drm_client.c
>> index 91a8559bebf7..e539f6b23060 100644
>> --- a/drivers/gpu/drm/i915/i915_drm_client.c
>> +++ b/drivers/gpu/drm/i915/i915_drm_client.c
>> @@ -7,7 +7,13 @@
>>   #include <linux/slab.h>
>>   #include <linux/types.h>
>> +#include <uapi/drm/i915_drm.h>
>> +
>> +#include <drm/drm_print.h>
>> +
>> +#include "gem/i915_gem_context.h"
>>   #include "i915_drm_client.h"
>> +#include "i915_file_private.h"
>>   #include "i915_gem.h"
>>   #include "i915_utils.h"
>> @@ -68,3 +74,81 @@ void i915_drm_clients_fini(struct i915_drm_clients 
>> *clients)
>>       GEM_BUG_ON(!xa_empty(&clients->xarray));
>>       xa_destroy(&clients->xarray);
>>   }
>> +
>> +#ifdef CONFIG_PROC_FS
>> +static const char * const uabi_class_names[] = {
>> +    [I915_ENGINE_CLASS_RENDER] = "render",
>> +    [I915_ENGINE_CLASS_COPY] = "copy",
>> +    [I915_ENGINE_CLASS_VIDEO] = "video",
>> +    [I915_ENGINE_CLASS_VIDEO_ENHANCE] = "video-enhance",
>> +};
>> +
>> +static u64 busy_add(struct i915_gem_context *ctx, unsigned int class)
>> +{
>> +    struct i915_gem_engines_iter it;
>> +    struct intel_context *ce;
>> +    u64 total = 0;
>> +
>> +    for_each_gem_engine(ce, rcu_dereference(ctx->engines), it) {
>> +        if (ce->engine->uabi_class != class)
>> +            continue;
>> +
>> +        total += intel_context_get_total_runtime_ns(ce);
>> +    }
>> +
>> +    return total;
>> +}
>> +
>> +static void
>> +show_client_class(struct seq_file *m,
>> +          struct i915_drm_client *client,
>> +          unsigned int class)
>> +{
>> +    const struct list_head *list = &client->ctx_list;
>> +    u64 total = atomic64_read(&client->past_runtime[class]);
>> +    const unsigned int capacity =
>> +        client->clients->i915->engine_uabi_class_count[class];
>> +    struct i915_gem_context *ctx;
>> +
>> +    rcu_read_lock();
>> +    list_for_each_entry_rcu(ctx, list, client_link)
>> +        total += busy_add(ctx, class);
>> +    rcu_read_unlock();
>> +
>> +    seq_printf(m, "drm-engine-%s:\t%llu ns\n",
>> +           uabi_class_names[class], total);
>> +
>> +    if (capacity > 1)
>> +        seq_printf(m, "drm-engine-capacity-%s:\t%u\n",
>> +               uabi_class_names[class],
>> +               capacity);
>> +}
>> +
>> +void i915_drm_client_fdinfo(struct seq_file *m, struct file *f)
>> +{
>> +    struct drm_file *file = f->private_data;
>> +    struct drm_i915_file_private *file_priv = file->driver_priv;
>> +    struct drm_i915_private *i915 = file_priv->dev_priv;
>> +    struct i915_drm_client *client = file_priv->client;
>> +    struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
>> +    unsigned int i;
>> +
>> +    /*
>> +     * 
>> ******************************************************************
>> +     * For text output format description please see 
>> drm-usage-stats.rst!
>> +     * 
>> ******************************************************************
>> +     */
>> +
>> +    seq_printf(m, "drm-driver:\t%s\n", i915->drm.driver->name);
>> +    seq_printf(m, "drm-pdev:\t%04x:%02x:%02x.%d\n",
>> +           pci_domain_nr(pdev->bus), pdev->bus->number,
>> +           PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
>> +    seq_printf(m, "drm-client-id:\t%u\n", client->id);
>> +
>> +    if (GRAPHICS_VER(i915) < 8)
>> +        return;
>> +
>> +    for (i = 0; i < ARRAY_SIZE(uabi_class_names); i++)
>> +        show_client_class(m, client, i);
>> +}
>> +#endif
>> diff --git a/drivers/gpu/drm/i915/i915_drm_client.h 
>> b/drivers/gpu/drm/i915/i915_drm_client.h
>> index 191368386ace..5f5b02b01ba0 100644
>> --- a/drivers/gpu/drm/i915/i915_drm_client.h
>> +++ b/drivers/gpu/drm/i915/i915_drm_client.h
>> @@ -59,6 +59,10 @@ static inline void i915_drm_client_put(struct 
>> i915_drm_client *client)
>>   struct i915_drm_client *i915_drm_client_add(struct i915_drm_clients 
>> *clients);
>> +#ifdef CONFIG_PROC_FS
>> +void i915_drm_client_fdinfo(struct seq_file *m, struct file *f);
>> +#endif
>> +
>>   void i915_drm_clients_fini(struct i915_drm_clients *clients);
>>   #endif /* !__I915_DRM_CLIENT_H__ */

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [Intel-gfx] [CI 8/8] drm/i915: Expose client engine utilisation via fdinfo
  2022-04-04  9:23     ` Tvrtko Ursulin
@ 2022-04-04 15:36         ` Daniel Vetter
  0 siblings, 0 replies; 35+ messages in thread
From: Daniel Vetter @ 2022-04-04 15:36 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: Intel-gfx, dri-devel, Christian König

On Mon, Apr 04, 2022 at 10:23:53AM +0100, Tvrtko Ursulin wrote:
> 
> + Dave and Daniel
> 
> Guys, are you okay with merging this via drm-intel-gt-next? It is one new
> file at Documentation/gpu/drm-usage-stats.rst only which is outside i915. It
> has acks from Christian and Rob.

Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> 
> Daniel, series is also fully reviewed and IGT reviewed and ready. Rob also
> demonstrated the approach works for msm when using the vendor agnosstic
> gputop tool I sketched out (see
> 20220225202614.225197-3-robdclark@gmail.com).
> 
> My plan is to merge the i915 support with the common spec and intel_gpu_top
> on the IGT side. Then follow-up with vendor agnostic gputop and later yet
> potentially re-visit the AMD side by re-sending the patch which tweaks the
> fdinfo format there and adds support for relative engine utilisation as
> provided by amdgpu.
> 
> Regards,
> 
> Tvrtko
> 
> On 04/04/2022 10:12, Tvrtko Ursulin wrote:
> > 
> > On 01/04/2022 15:22, Tvrtko Ursulin wrote:
> > > From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> > > 
> > > Similar to AMD commit
> > > 874442541133 ("drm/amdgpu: Add show_fdinfo() interface"), using the
> > > infrastructure added in previous patches, we add basic client info
> > > and GPU engine utilisation for i915.
> > > 
> > > Example of the output:
> > > 
> > >    pos:    0
> > >    flags:  0100002
> > >    mnt_id: 21
> > >    drm-driver: i915
> > >    drm-pdev:   0000:00:02.0
> > >    drm-client-id:      7
> > >    drm-engine-render:  9288864723 ns
> > >    drm-engine-copy:    2035071108 ns
> > >    drm-engine-video:   0 ns
> > >    drm-engine-video-enhance:   0 ns
> > > 
> > > v2:
> > >   * Update for removal of name and pid.
> > > 
> > > v3:
> > >   * Use drm_driver.name.
> > > 
> > > v4:
> > >   * Added drm-engine-capacity- tag.
> > >   * Fix typo. (Umesh)
> > > 
> > > v5:
> > >   * Don't output engine data before Gen8.
> > > 
> > > 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: Chris Healy <cphealy@gmail.com>
> > > Acked-by: Christian König <christian.koenig@amd.com>
> > > Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
> > 
> > Forgot to apply an earlier:
> > 
> > Acked-by: Rob Clark <robdclark@gmail.com>
> > 
> > Regards,
> > 
> > Tvrtko
> > 
> > > ---
> > >   Documentation/gpu/drm-usage-stats.rst  |  6 ++
> > >   Documentation/gpu/i915.rst             | 28 +++++++++
> > >   drivers/gpu/drm/i915/i915_driver.c     |  3 +
> > >   drivers/gpu/drm/i915/i915_drm_client.c | 84 ++++++++++++++++++++++++++
> > >   drivers/gpu/drm/i915/i915_drm_client.h |  4 ++
> > >   5 files changed, 125 insertions(+)
> > > 
> > > diff --git a/Documentation/gpu/drm-usage-stats.rst
> > > b/Documentation/gpu/drm-usage-stats.rst
> > > index b8cc28f4da6f..6c9f166a8d6f 100644
> > > --- a/Documentation/gpu/drm-usage-stats.rst
> > > +++ b/Documentation/gpu/drm-usage-stats.rst
> > > @@ -104,3 +104,9 @@ 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.
> > > +
> > > +===============================
> > > +Driver specific implementations
> > > +===============================
> > > +
> > > +:ref:`i915-usage-stats`
> > > diff --git a/Documentation/gpu/i915.rst b/Documentation/gpu/i915.rst
> > > index 0f08693d05cd..54060cd6c419 100644
> > > --- a/Documentation/gpu/i915.rst
> > > +++ b/Documentation/gpu/i915.rst
> > > @@ -697,3 +697,31 @@ The style guide for ``i915_reg.h``.
> > >   .. kernel-doc:: drivers/gpu/drm/i915/i915_reg.h
> > >      :doc: The i915 register macro definition style guide
> > > +
> > > +.. _i915-usage-stats:
> > > +
> > > +i915 DRM client usage stats implementation
> > > +==========================================
> > > +
> > > +The drm/i915 driver implements the DRM client usage stats
> > > specification as
> > > +documented in :ref:`drm-client-usage-stats`.
> > > +
> > > +Example of the output showing the implemented key value pairs and
> > > entirety of
> > > +the currently possible format options:
> > > +
> > > +::
> > > +
> > > +      pos:    0
> > > +      flags:  0100002
> > > +      mnt_id: 21
> > > +      drm-driver: i915
> > > +      drm-pdev:   0000:00:02.0
> > > +      drm-client-id:      7
> > > +      drm-engine-render:  9288864723 ns
> > > +      drm-engine-copy:    2035071108 ns
> > > +      drm-engine-video:   0 ns
> > > +      drm-engine-capacity-video:   2
> > > +      drm-engine-video-enhance:   0 ns
> > > +
> > > +Possible `drm-engine-` key names are: `render`, `copy`, `video` and
> > > +`video-enhance`.
> > > diff --git a/drivers/gpu/drm/i915/i915_driver.c
> > > b/drivers/gpu/drm/i915/i915_driver.c
> > > index b2df273e6d7b..3ffb617d75c9 100644
> > > --- a/drivers/gpu/drm/i915/i915_driver.c
> > > +++ b/drivers/gpu/drm/i915/i915_driver.c
> > > @@ -1745,6 +1745,9 @@ static const struct file_operations
> > > i915_driver_fops = {
> > >       .read = drm_read,
> > >       .compat_ioctl = i915_ioc32_compat_ioctl,
> > >       .llseek = noop_llseek,
> > > +#ifdef CONFIG_PROC_FS
> > > +    .show_fdinfo = i915_drm_client_fdinfo,
> > > +#endif
> > >   };
> > >   static int
> > > diff --git a/drivers/gpu/drm/i915/i915_drm_client.c
> > > b/drivers/gpu/drm/i915/i915_drm_client.c
> > > index 91a8559bebf7..e539f6b23060 100644
> > > --- a/drivers/gpu/drm/i915/i915_drm_client.c
> > > +++ b/drivers/gpu/drm/i915/i915_drm_client.c
> > > @@ -7,7 +7,13 @@
> > >   #include <linux/slab.h>
> > >   #include <linux/types.h>
> > > +#include <uapi/drm/i915_drm.h>
> > > +
> > > +#include <drm/drm_print.h>
> > > +
> > > +#include "gem/i915_gem_context.h"
> > >   #include "i915_drm_client.h"
> > > +#include "i915_file_private.h"
> > >   #include "i915_gem.h"
> > >   #include "i915_utils.h"
> > > @@ -68,3 +74,81 @@ void i915_drm_clients_fini(struct
> > > i915_drm_clients *clients)
> > >       GEM_BUG_ON(!xa_empty(&clients->xarray));
> > >       xa_destroy(&clients->xarray);
> > >   }
> > > +
> > > +#ifdef CONFIG_PROC_FS
> > > +static const char * const uabi_class_names[] = {
> > > +    [I915_ENGINE_CLASS_RENDER] = "render",
> > > +    [I915_ENGINE_CLASS_COPY] = "copy",
> > > +    [I915_ENGINE_CLASS_VIDEO] = "video",
> > > +    [I915_ENGINE_CLASS_VIDEO_ENHANCE] = "video-enhance",
> > > +};
> > > +
> > > +static u64 busy_add(struct i915_gem_context *ctx, unsigned int class)
> > > +{
> > > +    struct i915_gem_engines_iter it;
> > > +    struct intel_context *ce;
> > > +    u64 total = 0;
> > > +
> > > +    for_each_gem_engine(ce, rcu_dereference(ctx->engines), it) {
> > > +        if (ce->engine->uabi_class != class)
> > > +            continue;
> > > +
> > > +        total += intel_context_get_total_runtime_ns(ce);
> > > +    }
> > > +
> > > +    return total;
> > > +}
> > > +
> > > +static void
> > > +show_client_class(struct seq_file *m,
> > > +          struct i915_drm_client *client,
> > > +          unsigned int class)
> > > +{
> > > +    const struct list_head *list = &client->ctx_list;
> > > +    u64 total = atomic64_read(&client->past_runtime[class]);
> > > +    const unsigned int capacity =
> > > +        client->clients->i915->engine_uabi_class_count[class];
> > > +    struct i915_gem_context *ctx;
> > > +
> > > +    rcu_read_lock();
> > > +    list_for_each_entry_rcu(ctx, list, client_link)
> > > +        total += busy_add(ctx, class);
> > > +    rcu_read_unlock();
> > > +
> > > +    seq_printf(m, "drm-engine-%s:\t%llu ns\n",
> > > +           uabi_class_names[class], total);
> > > +
> > > +    if (capacity > 1)
> > > +        seq_printf(m, "drm-engine-capacity-%s:\t%u\n",
> > > +               uabi_class_names[class],
> > > +               capacity);
> > > +}
> > > +
> > > +void i915_drm_client_fdinfo(struct seq_file *m, struct file *f)
> > > +{
> > > +    struct drm_file *file = f->private_data;
> > > +    struct drm_i915_file_private *file_priv = file->driver_priv;
> > > +    struct drm_i915_private *i915 = file_priv->dev_priv;
> > > +    struct i915_drm_client *client = file_priv->client;
> > > +    struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
> > > +    unsigned int i;
> > > +
> > > +    /*
> > > +     *
> > > ******************************************************************
> > > +     * For text output format description please see
> > > drm-usage-stats.rst!
> > > +     *
> > > ******************************************************************
> > > +     */
> > > +
> > > +    seq_printf(m, "drm-driver:\t%s\n", i915->drm.driver->name);
> > > +    seq_printf(m, "drm-pdev:\t%04x:%02x:%02x.%d\n",
> > > +           pci_domain_nr(pdev->bus), pdev->bus->number,
> > > +           PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
> > > +    seq_printf(m, "drm-client-id:\t%u\n", client->id);
> > > +
> > > +    if (GRAPHICS_VER(i915) < 8)
> > > +        return;
> > > +
> > > +    for (i = 0; i < ARRAY_SIZE(uabi_class_names); i++)
> > > +        show_client_class(m, client, i);
> > > +}
> > > +#endif
> > > diff --git a/drivers/gpu/drm/i915/i915_drm_client.h
> > > b/drivers/gpu/drm/i915/i915_drm_client.h
> > > index 191368386ace..5f5b02b01ba0 100644
> > > --- a/drivers/gpu/drm/i915/i915_drm_client.h
> > > +++ b/drivers/gpu/drm/i915/i915_drm_client.h
> > > @@ -59,6 +59,10 @@ static inline void i915_drm_client_put(struct
> > > i915_drm_client *client)
> > >   struct i915_drm_client *i915_drm_client_add(struct
> > > i915_drm_clients *clients);
> > > +#ifdef CONFIG_PROC_FS
> > > +void i915_drm_client_fdinfo(struct seq_file *m, struct file *f);
> > > +#endif
> > > +
> > >   void i915_drm_clients_fini(struct i915_drm_clients *clients);
> > >   #endif /* !__I915_DRM_CLIENT_H__ */

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [Intel-gfx] [CI 8/8] drm/i915: Expose client engine utilisation via fdinfo
@ 2022-04-04 15:36         ` Daniel Vetter
  0 siblings, 0 replies; 35+ messages in thread
From: Daniel Vetter @ 2022-04-04 15:36 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: Intel-gfx, dri-devel, Dave Airlie, Christian König

On Mon, Apr 04, 2022 at 10:23:53AM +0100, Tvrtko Ursulin wrote:
> 
> + Dave and Daniel
> 
> Guys, are you okay with merging this via drm-intel-gt-next? It is one new
> file at Documentation/gpu/drm-usage-stats.rst only which is outside i915. It
> has acks from Christian and Rob.

Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> 
> Daniel, series is also fully reviewed and IGT reviewed and ready. Rob also
> demonstrated the approach works for msm when using the vendor agnosstic
> gputop tool I sketched out (see
> 20220225202614.225197-3-robdclark@gmail.com).
> 
> My plan is to merge the i915 support with the common spec and intel_gpu_top
> on the IGT side. Then follow-up with vendor agnostic gputop and later yet
> potentially re-visit the AMD side by re-sending the patch which tweaks the
> fdinfo format there and adds support for relative engine utilisation as
> provided by amdgpu.
> 
> Regards,
> 
> Tvrtko
> 
> On 04/04/2022 10:12, Tvrtko Ursulin wrote:
> > 
> > On 01/04/2022 15:22, Tvrtko Ursulin wrote:
> > > From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> > > 
> > > Similar to AMD commit
> > > 874442541133 ("drm/amdgpu: Add show_fdinfo() interface"), using the
> > > infrastructure added in previous patches, we add basic client info
> > > and GPU engine utilisation for i915.
> > > 
> > > Example of the output:
> > > 
> > >    pos:    0
> > >    flags:  0100002
> > >    mnt_id: 21
> > >    drm-driver: i915
> > >    drm-pdev:   0000:00:02.0
> > >    drm-client-id:      7
> > >    drm-engine-render:  9288864723 ns
> > >    drm-engine-copy:    2035071108 ns
> > >    drm-engine-video:   0 ns
> > >    drm-engine-video-enhance:   0 ns
> > > 
> > > v2:
> > >   * Update for removal of name and pid.
> > > 
> > > v3:
> > >   * Use drm_driver.name.
> > > 
> > > v4:
> > >   * Added drm-engine-capacity- tag.
> > >   * Fix typo. (Umesh)
> > > 
> > > v5:
> > >   * Don't output engine data before Gen8.
> > > 
> > > 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: Chris Healy <cphealy@gmail.com>
> > > Acked-by: Christian König <christian.koenig@amd.com>
> > > Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
> > 
> > Forgot to apply an earlier:
> > 
> > Acked-by: Rob Clark <robdclark@gmail.com>
> > 
> > Regards,
> > 
> > Tvrtko
> > 
> > > ---
> > >   Documentation/gpu/drm-usage-stats.rst  |  6 ++
> > >   Documentation/gpu/i915.rst             | 28 +++++++++
> > >   drivers/gpu/drm/i915/i915_driver.c     |  3 +
> > >   drivers/gpu/drm/i915/i915_drm_client.c | 84 ++++++++++++++++++++++++++
> > >   drivers/gpu/drm/i915/i915_drm_client.h |  4 ++
> > >   5 files changed, 125 insertions(+)
> > > 
> > > diff --git a/Documentation/gpu/drm-usage-stats.rst
> > > b/Documentation/gpu/drm-usage-stats.rst
> > > index b8cc28f4da6f..6c9f166a8d6f 100644
> > > --- a/Documentation/gpu/drm-usage-stats.rst
> > > +++ b/Documentation/gpu/drm-usage-stats.rst
> > > @@ -104,3 +104,9 @@ 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.
> > > +
> > > +===============================
> > > +Driver specific implementations
> > > +===============================
> > > +
> > > +:ref:`i915-usage-stats`
> > > diff --git a/Documentation/gpu/i915.rst b/Documentation/gpu/i915.rst
> > > index 0f08693d05cd..54060cd6c419 100644
> > > --- a/Documentation/gpu/i915.rst
> > > +++ b/Documentation/gpu/i915.rst
> > > @@ -697,3 +697,31 @@ The style guide for ``i915_reg.h``.
> > >   .. kernel-doc:: drivers/gpu/drm/i915/i915_reg.h
> > >      :doc: The i915 register macro definition style guide
> > > +
> > > +.. _i915-usage-stats:
> > > +
> > > +i915 DRM client usage stats implementation
> > > +==========================================
> > > +
> > > +The drm/i915 driver implements the DRM client usage stats
> > > specification as
> > > +documented in :ref:`drm-client-usage-stats`.
> > > +
> > > +Example of the output showing the implemented key value pairs and
> > > entirety of
> > > +the currently possible format options:
> > > +
> > > +::
> > > +
> > > +      pos:    0
> > > +      flags:  0100002
> > > +      mnt_id: 21
> > > +      drm-driver: i915
> > > +      drm-pdev:   0000:00:02.0
> > > +      drm-client-id:      7
> > > +      drm-engine-render:  9288864723 ns
> > > +      drm-engine-copy:    2035071108 ns
> > > +      drm-engine-video:   0 ns
> > > +      drm-engine-capacity-video:   2
> > > +      drm-engine-video-enhance:   0 ns
> > > +
> > > +Possible `drm-engine-` key names are: `render`, `copy`, `video` and
> > > +`video-enhance`.
> > > diff --git a/drivers/gpu/drm/i915/i915_driver.c
> > > b/drivers/gpu/drm/i915/i915_driver.c
> > > index b2df273e6d7b..3ffb617d75c9 100644
> > > --- a/drivers/gpu/drm/i915/i915_driver.c
> > > +++ b/drivers/gpu/drm/i915/i915_driver.c
> > > @@ -1745,6 +1745,9 @@ static const struct file_operations
> > > i915_driver_fops = {
> > >       .read = drm_read,
> > >       .compat_ioctl = i915_ioc32_compat_ioctl,
> > >       .llseek = noop_llseek,
> > > +#ifdef CONFIG_PROC_FS
> > > +    .show_fdinfo = i915_drm_client_fdinfo,
> > > +#endif
> > >   };
> > >   static int
> > > diff --git a/drivers/gpu/drm/i915/i915_drm_client.c
> > > b/drivers/gpu/drm/i915/i915_drm_client.c
> > > index 91a8559bebf7..e539f6b23060 100644
> > > --- a/drivers/gpu/drm/i915/i915_drm_client.c
> > > +++ b/drivers/gpu/drm/i915/i915_drm_client.c
> > > @@ -7,7 +7,13 @@
> > >   #include <linux/slab.h>
> > >   #include <linux/types.h>
> > > +#include <uapi/drm/i915_drm.h>
> > > +
> > > +#include <drm/drm_print.h>
> > > +
> > > +#include "gem/i915_gem_context.h"
> > >   #include "i915_drm_client.h"
> > > +#include "i915_file_private.h"
> > >   #include "i915_gem.h"
> > >   #include "i915_utils.h"
> > > @@ -68,3 +74,81 @@ void i915_drm_clients_fini(struct
> > > i915_drm_clients *clients)
> > >       GEM_BUG_ON(!xa_empty(&clients->xarray));
> > >       xa_destroy(&clients->xarray);
> > >   }
> > > +
> > > +#ifdef CONFIG_PROC_FS
> > > +static const char * const uabi_class_names[] = {
> > > +    [I915_ENGINE_CLASS_RENDER] = "render",
> > > +    [I915_ENGINE_CLASS_COPY] = "copy",
> > > +    [I915_ENGINE_CLASS_VIDEO] = "video",
> > > +    [I915_ENGINE_CLASS_VIDEO_ENHANCE] = "video-enhance",
> > > +};
> > > +
> > > +static u64 busy_add(struct i915_gem_context *ctx, unsigned int class)
> > > +{
> > > +    struct i915_gem_engines_iter it;
> > > +    struct intel_context *ce;
> > > +    u64 total = 0;
> > > +
> > > +    for_each_gem_engine(ce, rcu_dereference(ctx->engines), it) {
> > > +        if (ce->engine->uabi_class != class)
> > > +            continue;
> > > +
> > > +        total += intel_context_get_total_runtime_ns(ce);
> > > +    }
> > > +
> > > +    return total;
> > > +}
> > > +
> > > +static void
> > > +show_client_class(struct seq_file *m,
> > > +          struct i915_drm_client *client,
> > > +          unsigned int class)
> > > +{
> > > +    const struct list_head *list = &client->ctx_list;
> > > +    u64 total = atomic64_read(&client->past_runtime[class]);
> > > +    const unsigned int capacity =
> > > +        client->clients->i915->engine_uabi_class_count[class];
> > > +    struct i915_gem_context *ctx;
> > > +
> > > +    rcu_read_lock();
> > > +    list_for_each_entry_rcu(ctx, list, client_link)
> > > +        total += busy_add(ctx, class);
> > > +    rcu_read_unlock();
> > > +
> > > +    seq_printf(m, "drm-engine-%s:\t%llu ns\n",
> > > +           uabi_class_names[class], total);
> > > +
> > > +    if (capacity > 1)
> > > +        seq_printf(m, "drm-engine-capacity-%s:\t%u\n",
> > > +               uabi_class_names[class],
> > > +               capacity);
> > > +}
> > > +
> > > +void i915_drm_client_fdinfo(struct seq_file *m, struct file *f)
> > > +{
> > > +    struct drm_file *file = f->private_data;
> > > +    struct drm_i915_file_private *file_priv = file->driver_priv;
> > > +    struct drm_i915_private *i915 = file_priv->dev_priv;
> > > +    struct i915_drm_client *client = file_priv->client;
> > > +    struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
> > > +    unsigned int i;
> > > +
> > > +    /*
> > > +     *
> > > ******************************************************************
> > > +     * For text output format description please see
> > > drm-usage-stats.rst!
> > > +     *
> > > ******************************************************************
> > > +     */
> > > +
> > > +    seq_printf(m, "drm-driver:\t%s\n", i915->drm.driver->name);
> > > +    seq_printf(m, "drm-pdev:\t%04x:%02x:%02x.%d\n",
> > > +           pci_domain_nr(pdev->bus), pdev->bus->number,
> > > +           PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
> > > +    seq_printf(m, "drm-client-id:\t%u\n", client->id);
> > > +
> > > +    if (GRAPHICS_VER(i915) < 8)
> > > +        return;
> > > +
> > > +    for (i = 0; i < ARRAY_SIZE(uabi_class_names); i++)
> > > +        show_client_class(m, client, i);
> > > +}
> > > +#endif
> > > diff --git a/drivers/gpu/drm/i915/i915_drm_client.h
> > > b/drivers/gpu/drm/i915/i915_drm_client.h
> > > index 191368386ace..5f5b02b01ba0 100644
> > > --- a/drivers/gpu/drm/i915/i915_drm_client.h
> > > +++ b/drivers/gpu/drm/i915/i915_drm_client.h
> > > @@ -59,6 +59,10 @@ static inline void i915_drm_client_put(struct
> > > i915_drm_client *client)
> > >   struct i915_drm_client *i915_drm_client_add(struct
> > > i915_drm_clients *clients);
> > > +#ifdef CONFIG_PROC_FS
> > > +void i915_drm_client_fdinfo(struct seq_file *m, struct file *f);
> > > +#endif
> > > +
> > >   void i915_drm_clients_fini(struct i915_drm_clients *clients);
> > >   #endif /* !__I915_DRM_CLIENT_H__ */

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [Intel-gfx] [CI 8/8] drm/i915: Expose client engine utilisation via fdinfo
  2022-04-04 15:36         ` Daniel Vetter
@ 2022-04-05  8:08           ` Tvrtko Ursulin
  -1 siblings, 0 replies; 35+ messages in thread
From: Tvrtko Ursulin @ 2022-04-05  8:08 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Intel-gfx, Christian König, dri-devel


On 04/04/2022 16:36, Daniel Vetter wrote:
> On Mon, Apr 04, 2022 at 10:23:53AM +0100, Tvrtko Ursulin wrote:
>>
>> + Dave and Daniel
>>
>> Guys, are you okay with merging this via drm-intel-gt-next? It is one new
>> file at Documentation/gpu/drm-usage-stats.rst only which is outside i915. It
>> has acks from Christian and Rob.
> 
> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>

Thanks, pushed now.

Rob - you can proceed with your driver at your leisure. I will re-send 
the rebased gputop to igt-dev shortly and copy you.

Regards,

Tvrtko

>>
>> Daniel, series is also fully reviewed and IGT reviewed and ready. Rob also
>> demonstrated the approach works for msm when using the vendor agnosstic
>> gputop tool I sketched out (see
>> 20220225202614.225197-3-robdclark@gmail.com).
>>
>> My plan is to merge the i915 support with the common spec and intel_gpu_top
>> on the IGT side. Then follow-up with vendor agnostic gputop and later yet
>> potentially re-visit the AMD side by re-sending the patch which tweaks the
>> fdinfo format there and adds support for relative engine utilisation as
>> provided by amdgpu.
>>
>> Regards,
>>
>> Tvrtko
>>
>> On 04/04/2022 10:12, Tvrtko Ursulin wrote:
>>>
>>> On 01/04/2022 15:22, Tvrtko Ursulin wrote:
>>>> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>>>>
>>>> Similar to AMD commit
>>>> 874442541133 ("drm/amdgpu: Add show_fdinfo() interface"), using the
>>>> infrastructure added in previous patches, we add basic client info
>>>> and GPU engine utilisation for i915.
>>>>
>>>> Example of the output:
>>>>
>>>>     pos:    0
>>>>     flags:  0100002
>>>>     mnt_id: 21
>>>>     drm-driver: i915
>>>>     drm-pdev:   0000:00:02.0
>>>>     drm-client-id:      7
>>>>     drm-engine-render:  9288864723 ns
>>>>     drm-engine-copy:    2035071108 ns
>>>>     drm-engine-video:   0 ns
>>>>     drm-engine-video-enhance:   0 ns
>>>>
>>>> v2:
>>>>    * Update for removal of name and pid.
>>>>
>>>> v3:
>>>>    * Use drm_driver.name.
>>>>
>>>> v4:
>>>>    * Added drm-engine-capacity- tag.
>>>>    * Fix typo. (Umesh)
>>>>
>>>> v5:
>>>>    * Don't output engine data before Gen8.
>>>>
>>>> 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: Chris Healy <cphealy@gmail.com>
>>>> Acked-by: Christian König <christian.koenig@amd.com>
>>>> Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
>>>
>>> Forgot to apply an earlier:
>>>
>>> Acked-by: Rob Clark <robdclark@gmail.com>
>>>
>>> Regards,
>>>
>>> Tvrtko
>>>
>>>> ---
>>>>    Documentation/gpu/drm-usage-stats.rst  |  6 ++
>>>>    Documentation/gpu/i915.rst             | 28 +++++++++
>>>>    drivers/gpu/drm/i915/i915_driver.c     |  3 +
>>>>    drivers/gpu/drm/i915/i915_drm_client.c | 84 ++++++++++++++++++++++++++
>>>>    drivers/gpu/drm/i915/i915_drm_client.h |  4 ++
>>>>    5 files changed, 125 insertions(+)
>>>>
>>>> diff --git a/Documentation/gpu/drm-usage-stats.rst
>>>> b/Documentation/gpu/drm-usage-stats.rst
>>>> index b8cc28f4da6f..6c9f166a8d6f 100644
>>>> --- a/Documentation/gpu/drm-usage-stats.rst
>>>> +++ b/Documentation/gpu/drm-usage-stats.rst
>>>> @@ -104,3 +104,9 @@ 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.
>>>> +
>>>> +===============================
>>>> +Driver specific implementations
>>>> +===============================
>>>> +
>>>> +:ref:`i915-usage-stats`
>>>> diff --git a/Documentation/gpu/i915.rst b/Documentation/gpu/i915.rst
>>>> index 0f08693d05cd..54060cd6c419 100644
>>>> --- a/Documentation/gpu/i915.rst
>>>> +++ b/Documentation/gpu/i915.rst
>>>> @@ -697,3 +697,31 @@ The style guide for ``i915_reg.h``.
>>>>    .. kernel-doc:: drivers/gpu/drm/i915/i915_reg.h
>>>>       :doc: The i915 register macro definition style guide
>>>> +
>>>> +.. _i915-usage-stats:
>>>> +
>>>> +i915 DRM client usage stats implementation
>>>> +==========================================
>>>> +
>>>> +The drm/i915 driver implements the DRM client usage stats
>>>> specification as
>>>> +documented in :ref:`drm-client-usage-stats`.
>>>> +
>>>> +Example of the output showing the implemented key value pairs and
>>>> entirety of
>>>> +the currently possible format options:
>>>> +
>>>> +::
>>>> +
>>>> +      pos:    0
>>>> +      flags:  0100002
>>>> +      mnt_id: 21
>>>> +      drm-driver: i915
>>>> +      drm-pdev:   0000:00:02.0
>>>> +      drm-client-id:      7
>>>> +      drm-engine-render:  9288864723 ns
>>>> +      drm-engine-copy:    2035071108 ns
>>>> +      drm-engine-video:   0 ns
>>>> +      drm-engine-capacity-video:   2
>>>> +      drm-engine-video-enhance:   0 ns
>>>> +
>>>> +Possible `drm-engine-` key names are: `render`, `copy`, `video` and
>>>> +`video-enhance`.
>>>> diff --git a/drivers/gpu/drm/i915/i915_driver.c
>>>> b/drivers/gpu/drm/i915/i915_driver.c
>>>> index b2df273e6d7b..3ffb617d75c9 100644
>>>> --- a/drivers/gpu/drm/i915/i915_driver.c
>>>> +++ b/drivers/gpu/drm/i915/i915_driver.c
>>>> @@ -1745,6 +1745,9 @@ static const struct file_operations
>>>> i915_driver_fops = {
>>>>        .read = drm_read,
>>>>        .compat_ioctl = i915_ioc32_compat_ioctl,
>>>>        .llseek = noop_llseek,
>>>> +#ifdef CONFIG_PROC_FS
>>>> +    .show_fdinfo = i915_drm_client_fdinfo,
>>>> +#endif
>>>>    };
>>>>    static int
>>>> diff --git a/drivers/gpu/drm/i915/i915_drm_client.c
>>>> b/drivers/gpu/drm/i915/i915_drm_client.c
>>>> index 91a8559bebf7..e539f6b23060 100644
>>>> --- a/drivers/gpu/drm/i915/i915_drm_client.c
>>>> +++ b/drivers/gpu/drm/i915/i915_drm_client.c
>>>> @@ -7,7 +7,13 @@
>>>>    #include <linux/slab.h>
>>>>    #include <linux/types.h>
>>>> +#include <uapi/drm/i915_drm.h>
>>>> +
>>>> +#include <drm/drm_print.h>
>>>> +
>>>> +#include "gem/i915_gem_context.h"
>>>>    #include "i915_drm_client.h"
>>>> +#include "i915_file_private.h"
>>>>    #include "i915_gem.h"
>>>>    #include "i915_utils.h"
>>>> @@ -68,3 +74,81 @@ void i915_drm_clients_fini(struct
>>>> i915_drm_clients *clients)
>>>>        GEM_BUG_ON(!xa_empty(&clients->xarray));
>>>>        xa_destroy(&clients->xarray);
>>>>    }
>>>> +
>>>> +#ifdef CONFIG_PROC_FS
>>>> +static const char * const uabi_class_names[] = {
>>>> +    [I915_ENGINE_CLASS_RENDER] = "render",
>>>> +    [I915_ENGINE_CLASS_COPY] = "copy",
>>>> +    [I915_ENGINE_CLASS_VIDEO] = "video",
>>>> +    [I915_ENGINE_CLASS_VIDEO_ENHANCE] = "video-enhance",
>>>> +};
>>>> +
>>>> +static u64 busy_add(struct i915_gem_context *ctx, unsigned int class)
>>>> +{
>>>> +    struct i915_gem_engines_iter it;
>>>> +    struct intel_context *ce;
>>>> +    u64 total = 0;
>>>> +
>>>> +    for_each_gem_engine(ce, rcu_dereference(ctx->engines), it) {
>>>> +        if (ce->engine->uabi_class != class)
>>>> +            continue;
>>>> +
>>>> +        total += intel_context_get_total_runtime_ns(ce);
>>>> +    }
>>>> +
>>>> +    return total;
>>>> +}
>>>> +
>>>> +static void
>>>> +show_client_class(struct seq_file *m,
>>>> +          struct i915_drm_client *client,
>>>> +          unsigned int class)
>>>> +{
>>>> +    const struct list_head *list = &client->ctx_list;
>>>> +    u64 total = atomic64_read(&client->past_runtime[class]);
>>>> +    const unsigned int capacity =
>>>> +        client->clients->i915->engine_uabi_class_count[class];
>>>> +    struct i915_gem_context *ctx;
>>>> +
>>>> +    rcu_read_lock();
>>>> +    list_for_each_entry_rcu(ctx, list, client_link)
>>>> +        total += busy_add(ctx, class);
>>>> +    rcu_read_unlock();
>>>> +
>>>> +    seq_printf(m, "drm-engine-%s:\t%llu ns\n",
>>>> +           uabi_class_names[class], total);
>>>> +
>>>> +    if (capacity > 1)
>>>> +        seq_printf(m, "drm-engine-capacity-%s:\t%u\n",
>>>> +               uabi_class_names[class],
>>>> +               capacity);
>>>> +}
>>>> +
>>>> +void i915_drm_client_fdinfo(struct seq_file *m, struct file *f)
>>>> +{
>>>> +    struct drm_file *file = f->private_data;
>>>> +    struct drm_i915_file_private *file_priv = file->driver_priv;
>>>> +    struct drm_i915_private *i915 = file_priv->dev_priv;
>>>> +    struct i915_drm_client *client = file_priv->client;
>>>> +    struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
>>>> +    unsigned int i;
>>>> +
>>>> +    /*
>>>> +     *
>>>> ******************************************************************
>>>> +     * For text output format description please see
>>>> drm-usage-stats.rst!
>>>> +     *
>>>> ******************************************************************
>>>> +     */
>>>> +
>>>> +    seq_printf(m, "drm-driver:\t%s\n", i915->drm.driver->name);
>>>> +    seq_printf(m, "drm-pdev:\t%04x:%02x:%02x.%d\n",
>>>> +           pci_domain_nr(pdev->bus), pdev->bus->number,
>>>> +           PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
>>>> +    seq_printf(m, "drm-client-id:\t%u\n", client->id);
>>>> +
>>>> +    if (GRAPHICS_VER(i915) < 8)
>>>> +        return;
>>>> +
>>>> +    for (i = 0; i < ARRAY_SIZE(uabi_class_names); i++)
>>>> +        show_client_class(m, client, i);
>>>> +}
>>>> +#endif
>>>> diff --git a/drivers/gpu/drm/i915/i915_drm_client.h
>>>> b/drivers/gpu/drm/i915/i915_drm_client.h
>>>> index 191368386ace..5f5b02b01ba0 100644
>>>> --- a/drivers/gpu/drm/i915/i915_drm_client.h
>>>> +++ b/drivers/gpu/drm/i915/i915_drm_client.h
>>>> @@ -59,6 +59,10 @@ static inline void i915_drm_client_put(struct
>>>> i915_drm_client *client)
>>>>    struct i915_drm_client *i915_drm_client_add(struct
>>>> i915_drm_clients *clients);
>>>> +#ifdef CONFIG_PROC_FS
>>>> +void i915_drm_client_fdinfo(struct seq_file *m, struct file *f);
>>>> +#endif
>>>> +
>>>>    void i915_drm_clients_fini(struct i915_drm_clients *clients);
>>>>    #endif /* !__I915_DRM_CLIENT_H__ */
> 

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [Intel-gfx] [CI 8/8] drm/i915: Expose client engine utilisation via fdinfo
@ 2022-04-05  8:08           ` Tvrtko Ursulin
  0 siblings, 0 replies; 35+ messages in thread
From: Tvrtko Ursulin @ 2022-04-05  8:08 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Intel-gfx, Dave Airlie, Christian König, dri-devel


On 04/04/2022 16:36, Daniel Vetter wrote:
> On Mon, Apr 04, 2022 at 10:23:53AM +0100, Tvrtko Ursulin wrote:
>>
>> + Dave and Daniel
>>
>> Guys, are you okay with merging this via drm-intel-gt-next? It is one new
>> file at Documentation/gpu/drm-usage-stats.rst only which is outside i915. It
>> has acks from Christian and Rob.
> 
> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>

Thanks, pushed now.

Rob - you can proceed with your driver at your leisure. I will re-send 
the rebased gputop to igt-dev shortly and copy you.

Regards,

Tvrtko

>>
>> Daniel, series is also fully reviewed and IGT reviewed and ready. Rob also
>> demonstrated the approach works for msm when using the vendor agnosstic
>> gputop tool I sketched out (see
>> 20220225202614.225197-3-robdclark@gmail.com).
>>
>> My plan is to merge the i915 support with the common spec and intel_gpu_top
>> on the IGT side. Then follow-up with vendor agnostic gputop and later yet
>> potentially re-visit the AMD side by re-sending the patch which tweaks the
>> fdinfo format there and adds support for relative engine utilisation as
>> provided by amdgpu.
>>
>> Regards,
>>
>> Tvrtko
>>
>> On 04/04/2022 10:12, Tvrtko Ursulin wrote:
>>>
>>> On 01/04/2022 15:22, Tvrtko Ursulin wrote:
>>>> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>>>>
>>>> Similar to AMD commit
>>>> 874442541133 ("drm/amdgpu: Add show_fdinfo() interface"), using the
>>>> infrastructure added in previous patches, we add basic client info
>>>> and GPU engine utilisation for i915.
>>>>
>>>> Example of the output:
>>>>
>>>>     pos:    0
>>>>     flags:  0100002
>>>>     mnt_id: 21
>>>>     drm-driver: i915
>>>>     drm-pdev:   0000:00:02.0
>>>>     drm-client-id:      7
>>>>     drm-engine-render:  9288864723 ns
>>>>     drm-engine-copy:    2035071108 ns
>>>>     drm-engine-video:   0 ns
>>>>     drm-engine-video-enhance:   0 ns
>>>>
>>>> v2:
>>>>    * Update for removal of name and pid.
>>>>
>>>> v3:
>>>>    * Use drm_driver.name.
>>>>
>>>> v4:
>>>>    * Added drm-engine-capacity- tag.
>>>>    * Fix typo. (Umesh)
>>>>
>>>> v5:
>>>>    * Don't output engine data before Gen8.
>>>>
>>>> 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: Chris Healy <cphealy@gmail.com>
>>>> Acked-by: Christian König <christian.koenig@amd.com>
>>>> Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
>>>
>>> Forgot to apply an earlier:
>>>
>>> Acked-by: Rob Clark <robdclark@gmail.com>
>>>
>>> Regards,
>>>
>>> Tvrtko
>>>
>>>> ---
>>>>    Documentation/gpu/drm-usage-stats.rst  |  6 ++
>>>>    Documentation/gpu/i915.rst             | 28 +++++++++
>>>>    drivers/gpu/drm/i915/i915_driver.c     |  3 +
>>>>    drivers/gpu/drm/i915/i915_drm_client.c | 84 ++++++++++++++++++++++++++
>>>>    drivers/gpu/drm/i915/i915_drm_client.h |  4 ++
>>>>    5 files changed, 125 insertions(+)
>>>>
>>>> diff --git a/Documentation/gpu/drm-usage-stats.rst
>>>> b/Documentation/gpu/drm-usage-stats.rst
>>>> index b8cc28f4da6f..6c9f166a8d6f 100644
>>>> --- a/Documentation/gpu/drm-usage-stats.rst
>>>> +++ b/Documentation/gpu/drm-usage-stats.rst
>>>> @@ -104,3 +104,9 @@ 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.
>>>> +
>>>> +===============================
>>>> +Driver specific implementations
>>>> +===============================
>>>> +
>>>> +:ref:`i915-usage-stats`
>>>> diff --git a/Documentation/gpu/i915.rst b/Documentation/gpu/i915.rst
>>>> index 0f08693d05cd..54060cd6c419 100644
>>>> --- a/Documentation/gpu/i915.rst
>>>> +++ b/Documentation/gpu/i915.rst
>>>> @@ -697,3 +697,31 @@ The style guide for ``i915_reg.h``.
>>>>    .. kernel-doc:: drivers/gpu/drm/i915/i915_reg.h
>>>>       :doc: The i915 register macro definition style guide
>>>> +
>>>> +.. _i915-usage-stats:
>>>> +
>>>> +i915 DRM client usage stats implementation
>>>> +==========================================
>>>> +
>>>> +The drm/i915 driver implements the DRM client usage stats
>>>> specification as
>>>> +documented in :ref:`drm-client-usage-stats`.
>>>> +
>>>> +Example of the output showing the implemented key value pairs and
>>>> entirety of
>>>> +the currently possible format options:
>>>> +
>>>> +::
>>>> +
>>>> +      pos:    0
>>>> +      flags:  0100002
>>>> +      mnt_id: 21
>>>> +      drm-driver: i915
>>>> +      drm-pdev:   0000:00:02.0
>>>> +      drm-client-id:      7
>>>> +      drm-engine-render:  9288864723 ns
>>>> +      drm-engine-copy:    2035071108 ns
>>>> +      drm-engine-video:   0 ns
>>>> +      drm-engine-capacity-video:   2
>>>> +      drm-engine-video-enhance:   0 ns
>>>> +
>>>> +Possible `drm-engine-` key names are: `render`, `copy`, `video` and
>>>> +`video-enhance`.
>>>> diff --git a/drivers/gpu/drm/i915/i915_driver.c
>>>> b/drivers/gpu/drm/i915/i915_driver.c
>>>> index b2df273e6d7b..3ffb617d75c9 100644
>>>> --- a/drivers/gpu/drm/i915/i915_driver.c
>>>> +++ b/drivers/gpu/drm/i915/i915_driver.c
>>>> @@ -1745,6 +1745,9 @@ static const struct file_operations
>>>> i915_driver_fops = {
>>>>        .read = drm_read,
>>>>        .compat_ioctl = i915_ioc32_compat_ioctl,
>>>>        .llseek = noop_llseek,
>>>> +#ifdef CONFIG_PROC_FS
>>>> +    .show_fdinfo = i915_drm_client_fdinfo,
>>>> +#endif
>>>>    };
>>>>    static int
>>>> diff --git a/drivers/gpu/drm/i915/i915_drm_client.c
>>>> b/drivers/gpu/drm/i915/i915_drm_client.c
>>>> index 91a8559bebf7..e539f6b23060 100644
>>>> --- a/drivers/gpu/drm/i915/i915_drm_client.c
>>>> +++ b/drivers/gpu/drm/i915/i915_drm_client.c
>>>> @@ -7,7 +7,13 @@
>>>>    #include <linux/slab.h>
>>>>    #include <linux/types.h>
>>>> +#include <uapi/drm/i915_drm.h>
>>>> +
>>>> +#include <drm/drm_print.h>
>>>> +
>>>> +#include "gem/i915_gem_context.h"
>>>>    #include "i915_drm_client.h"
>>>> +#include "i915_file_private.h"
>>>>    #include "i915_gem.h"
>>>>    #include "i915_utils.h"
>>>> @@ -68,3 +74,81 @@ void i915_drm_clients_fini(struct
>>>> i915_drm_clients *clients)
>>>>        GEM_BUG_ON(!xa_empty(&clients->xarray));
>>>>        xa_destroy(&clients->xarray);
>>>>    }
>>>> +
>>>> +#ifdef CONFIG_PROC_FS
>>>> +static const char * const uabi_class_names[] = {
>>>> +    [I915_ENGINE_CLASS_RENDER] = "render",
>>>> +    [I915_ENGINE_CLASS_COPY] = "copy",
>>>> +    [I915_ENGINE_CLASS_VIDEO] = "video",
>>>> +    [I915_ENGINE_CLASS_VIDEO_ENHANCE] = "video-enhance",
>>>> +};
>>>> +
>>>> +static u64 busy_add(struct i915_gem_context *ctx, unsigned int class)
>>>> +{
>>>> +    struct i915_gem_engines_iter it;
>>>> +    struct intel_context *ce;
>>>> +    u64 total = 0;
>>>> +
>>>> +    for_each_gem_engine(ce, rcu_dereference(ctx->engines), it) {
>>>> +        if (ce->engine->uabi_class != class)
>>>> +            continue;
>>>> +
>>>> +        total += intel_context_get_total_runtime_ns(ce);
>>>> +    }
>>>> +
>>>> +    return total;
>>>> +}
>>>> +
>>>> +static void
>>>> +show_client_class(struct seq_file *m,
>>>> +          struct i915_drm_client *client,
>>>> +          unsigned int class)
>>>> +{
>>>> +    const struct list_head *list = &client->ctx_list;
>>>> +    u64 total = atomic64_read(&client->past_runtime[class]);
>>>> +    const unsigned int capacity =
>>>> +        client->clients->i915->engine_uabi_class_count[class];
>>>> +    struct i915_gem_context *ctx;
>>>> +
>>>> +    rcu_read_lock();
>>>> +    list_for_each_entry_rcu(ctx, list, client_link)
>>>> +        total += busy_add(ctx, class);
>>>> +    rcu_read_unlock();
>>>> +
>>>> +    seq_printf(m, "drm-engine-%s:\t%llu ns\n",
>>>> +           uabi_class_names[class], total);
>>>> +
>>>> +    if (capacity > 1)
>>>> +        seq_printf(m, "drm-engine-capacity-%s:\t%u\n",
>>>> +               uabi_class_names[class],
>>>> +               capacity);
>>>> +}
>>>> +
>>>> +void i915_drm_client_fdinfo(struct seq_file *m, struct file *f)
>>>> +{
>>>> +    struct drm_file *file = f->private_data;
>>>> +    struct drm_i915_file_private *file_priv = file->driver_priv;
>>>> +    struct drm_i915_private *i915 = file_priv->dev_priv;
>>>> +    struct i915_drm_client *client = file_priv->client;
>>>> +    struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
>>>> +    unsigned int i;
>>>> +
>>>> +    /*
>>>> +     *
>>>> ******************************************************************
>>>> +     * For text output format description please see
>>>> drm-usage-stats.rst!
>>>> +     *
>>>> ******************************************************************
>>>> +     */
>>>> +
>>>> +    seq_printf(m, "drm-driver:\t%s\n", i915->drm.driver->name);
>>>> +    seq_printf(m, "drm-pdev:\t%04x:%02x:%02x.%d\n",
>>>> +           pci_domain_nr(pdev->bus), pdev->bus->number,
>>>> +           PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
>>>> +    seq_printf(m, "drm-client-id:\t%u\n", client->id);
>>>> +
>>>> +    if (GRAPHICS_VER(i915) < 8)
>>>> +        return;
>>>> +
>>>> +    for (i = 0; i < ARRAY_SIZE(uabi_class_names); i++)
>>>> +        show_client_class(m, client, i);
>>>> +}
>>>> +#endif
>>>> diff --git a/drivers/gpu/drm/i915/i915_drm_client.h
>>>> b/drivers/gpu/drm/i915/i915_drm_client.h
>>>> index 191368386ace..5f5b02b01ba0 100644
>>>> --- a/drivers/gpu/drm/i915/i915_drm_client.h
>>>> +++ b/drivers/gpu/drm/i915/i915_drm_client.h
>>>> @@ -59,6 +59,10 @@ static inline void i915_drm_client_put(struct
>>>> i915_drm_client *client)
>>>>    struct i915_drm_client *i915_drm_client_add(struct
>>>> i915_drm_clients *clients);
>>>> +#ifdef CONFIG_PROC_FS
>>>> +void i915_drm_client_fdinfo(struct seq_file *m, struct file *f);
>>>> +#endif
>>>> +
>>>>    void i915_drm_clients_fini(struct i915_drm_clients *clients);
>>>>    #endif /* !__I915_DRM_CLIENT_H__ */
> 

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [Intel-gfx] [CI 8/8] drm/i915: Expose client engine utilisation via fdinfo
  2022-04-05  8:08           ` Tvrtko Ursulin
@ 2022-04-06 18:15             ` Rob Clark
  -1 siblings, 0 replies; 35+ messages in thread
From: Rob Clark @ 2022-04-06 18:15 UTC (permalink / raw)
  To: Tvrtko Ursulin
  Cc: Intel Graphics Development, dri-devel, Christian König

On Tue, Apr 5, 2022 at 1:09 AM Tvrtko Ursulin
<tvrtko.ursulin@linux.intel.com> wrote:
>
>
> On 04/04/2022 16:36, Daniel Vetter wrote:
> > On Mon, Apr 04, 2022 at 10:23:53AM +0100, Tvrtko Ursulin wrote:
> >>
> >> + Dave and Daniel
> >>
> >> Guys, are you okay with merging this via drm-intel-gt-next? It is one new
> >> file at Documentation/gpu/drm-usage-stats.rst only which is outside i915. It
> >> has acks from Christian and Rob.
> >
> > Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
>
> Thanks, pushed now.
>
> Rob - you can proceed with your driver at your leisure. I will re-send
> the rebased gputop to igt-dev shortly and copy you.

Thx, I was planning to respin, but trying to figure out where the
drm-usage-stats.rst patch ended up (since I can't add to a file that
isn't there

BR,
-R

> Regards,
>
> Tvrtko
>
> >>
> >> Daniel, series is also fully reviewed and IGT reviewed and ready. Rob also
> >> demonstrated the approach works for msm when using the vendor agnosstic
> >> gputop tool I sketched out (see
> >> 20220225202614.225197-3-robdclark@gmail.com).
> >>
> >> My plan is to merge the i915 support with the common spec and intel_gpu_top
> >> on the IGT side. Then follow-up with vendor agnostic gputop and later yet
> >> potentially re-visit the AMD side by re-sending the patch which tweaks the
> >> fdinfo format there and adds support for relative engine utilisation as
> >> provided by amdgpu.
> >>
> >> Regards,
> >>
> >> Tvrtko
> >>
> >> On 04/04/2022 10:12, Tvrtko Ursulin wrote:
> >>>
> >>> On 01/04/2022 15:22, Tvrtko Ursulin wrote:
> >>>> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> >>>>
> >>>> Similar to AMD commit
> >>>> 874442541133 ("drm/amdgpu: Add show_fdinfo() interface"), using the
> >>>> infrastructure added in previous patches, we add basic client info
> >>>> and GPU engine utilisation for i915.
> >>>>
> >>>> Example of the output:
> >>>>
> >>>>     pos:    0
> >>>>     flags:  0100002
> >>>>     mnt_id: 21
> >>>>     drm-driver: i915
> >>>>     drm-pdev:   0000:00:02.0
> >>>>     drm-client-id:      7
> >>>>     drm-engine-render:  9288864723 ns
> >>>>     drm-engine-copy:    2035071108 ns
> >>>>     drm-engine-video:   0 ns
> >>>>     drm-engine-video-enhance:   0 ns
> >>>>
> >>>> v2:
> >>>>    * Update for removal of name and pid.
> >>>>
> >>>> v3:
> >>>>    * Use drm_driver.name.
> >>>>
> >>>> v4:
> >>>>    * Added drm-engine-capacity- tag.
> >>>>    * Fix typo. (Umesh)
> >>>>
> >>>> v5:
> >>>>    * Don't output engine data before Gen8.
> >>>>
> >>>> 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: Chris Healy <cphealy@gmail.com>
> >>>> Acked-by: Christian König <christian.koenig@amd.com>
> >>>> Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
> >>>
> >>> Forgot to apply an earlier:
> >>>
> >>> Acked-by: Rob Clark <robdclark@gmail.com>
> >>>
> >>> Regards,
> >>>
> >>> Tvrtko
> >>>
> >>>> ---
> >>>>    Documentation/gpu/drm-usage-stats.rst  |  6 ++
> >>>>    Documentation/gpu/i915.rst             | 28 +++++++++
> >>>>    drivers/gpu/drm/i915/i915_driver.c     |  3 +
> >>>>    drivers/gpu/drm/i915/i915_drm_client.c | 84 ++++++++++++++++++++++++++
> >>>>    drivers/gpu/drm/i915/i915_drm_client.h |  4 ++
> >>>>    5 files changed, 125 insertions(+)
> >>>>
> >>>> diff --git a/Documentation/gpu/drm-usage-stats.rst
> >>>> b/Documentation/gpu/drm-usage-stats.rst
> >>>> index b8cc28f4da6f..6c9f166a8d6f 100644
> >>>> --- a/Documentation/gpu/drm-usage-stats.rst
> >>>> +++ b/Documentation/gpu/drm-usage-stats.rst
> >>>> @@ -104,3 +104,9 @@ 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.
> >>>> +
> >>>> +===============================
> >>>> +Driver specific implementations
> >>>> +===============================
> >>>> +
> >>>> +:ref:`i915-usage-stats`
> >>>> diff --git a/Documentation/gpu/i915.rst b/Documentation/gpu/i915.rst
> >>>> index 0f08693d05cd..54060cd6c419 100644
> >>>> --- a/Documentation/gpu/i915.rst
> >>>> +++ b/Documentation/gpu/i915.rst
> >>>> @@ -697,3 +697,31 @@ The style guide for ``i915_reg.h``.
> >>>>    .. kernel-doc:: drivers/gpu/drm/i915/i915_reg.h
> >>>>       :doc: The i915 register macro definition style guide
> >>>> +
> >>>> +.. _i915-usage-stats:
> >>>> +
> >>>> +i915 DRM client usage stats implementation
> >>>> +==========================================
> >>>> +
> >>>> +The drm/i915 driver implements the DRM client usage stats
> >>>> specification as
> >>>> +documented in :ref:`drm-client-usage-stats`.
> >>>> +
> >>>> +Example of the output showing the implemented key value pairs and
> >>>> entirety of
> >>>> +the currently possible format options:
> >>>> +
> >>>> +::
> >>>> +
> >>>> +      pos:    0
> >>>> +      flags:  0100002
> >>>> +      mnt_id: 21
> >>>> +      drm-driver: i915
> >>>> +      drm-pdev:   0000:00:02.0
> >>>> +      drm-client-id:      7
> >>>> +      drm-engine-render:  9288864723 ns
> >>>> +      drm-engine-copy:    2035071108 ns
> >>>> +      drm-engine-video:   0 ns
> >>>> +      drm-engine-capacity-video:   2
> >>>> +      drm-engine-video-enhance:   0 ns
> >>>> +
> >>>> +Possible `drm-engine-` key names are: `render`, `copy`, `video` and
> >>>> +`video-enhance`.
> >>>> diff --git a/drivers/gpu/drm/i915/i915_driver.c
> >>>> b/drivers/gpu/drm/i915/i915_driver.c
> >>>> index b2df273e6d7b..3ffb617d75c9 100644
> >>>> --- a/drivers/gpu/drm/i915/i915_driver.c
> >>>> +++ b/drivers/gpu/drm/i915/i915_driver.c
> >>>> @@ -1745,6 +1745,9 @@ static const struct file_operations
> >>>> i915_driver_fops = {
> >>>>        .read = drm_read,
> >>>>        .compat_ioctl = i915_ioc32_compat_ioctl,
> >>>>        .llseek = noop_llseek,
> >>>> +#ifdef CONFIG_PROC_FS
> >>>> +    .show_fdinfo = i915_drm_client_fdinfo,
> >>>> +#endif
> >>>>    };
> >>>>    static int
> >>>> diff --git a/drivers/gpu/drm/i915/i915_drm_client.c
> >>>> b/drivers/gpu/drm/i915/i915_drm_client.c
> >>>> index 91a8559bebf7..e539f6b23060 100644
> >>>> --- a/drivers/gpu/drm/i915/i915_drm_client.c
> >>>> +++ b/drivers/gpu/drm/i915/i915_drm_client.c
> >>>> @@ -7,7 +7,13 @@
> >>>>    #include <linux/slab.h>
> >>>>    #include <linux/types.h>
> >>>> +#include <uapi/drm/i915_drm.h>
> >>>> +
> >>>> +#include <drm/drm_print.h>
> >>>> +
> >>>> +#include "gem/i915_gem_context.h"
> >>>>    #include "i915_drm_client.h"
> >>>> +#include "i915_file_private.h"
> >>>>    #include "i915_gem.h"
> >>>>    #include "i915_utils.h"
> >>>> @@ -68,3 +74,81 @@ void i915_drm_clients_fini(struct
> >>>> i915_drm_clients *clients)
> >>>>        GEM_BUG_ON(!xa_empty(&clients->xarray));
> >>>>        xa_destroy(&clients->xarray);
> >>>>    }
> >>>> +
> >>>> +#ifdef CONFIG_PROC_FS
> >>>> +static const char * const uabi_class_names[] = {
> >>>> +    [I915_ENGINE_CLASS_RENDER] = "render",
> >>>> +    [I915_ENGINE_CLASS_COPY] = "copy",
> >>>> +    [I915_ENGINE_CLASS_VIDEO] = "video",
> >>>> +    [I915_ENGINE_CLASS_VIDEO_ENHANCE] = "video-enhance",
> >>>> +};
> >>>> +
> >>>> +static u64 busy_add(struct i915_gem_context *ctx, unsigned int class)
> >>>> +{
> >>>> +    struct i915_gem_engines_iter it;
> >>>> +    struct intel_context *ce;
> >>>> +    u64 total = 0;
> >>>> +
> >>>> +    for_each_gem_engine(ce, rcu_dereference(ctx->engines), it) {
> >>>> +        if (ce->engine->uabi_class != class)
> >>>> +            continue;
> >>>> +
> >>>> +        total += intel_context_get_total_runtime_ns(ce);
> >>>> +    }
> >>>> +
> >>>> +    return total;
> >>>> +}
> >>>> +
> >>>> +static void
> >>>> +show_client_class(struct seq_file *m,
> >>>> +          struct i915_drm_client *client,
> >>>> +          unsigned int class)
> >>>> +{
> >>>> +    const struct list_head *list = &client->ctx_list;
> >>>> +    u64 total = atomic64_read(&client->past_runtime[class]);
> >>>> +    const unsigned int capacity =
> >>>> +        client->clients->i915->engine_uabi_class_count[class];
> >>>> +    struct i915_gem_context *ctx;
> >>>> +
> >>>> +    rcu_read_lock();
> >>>> +    list_for_each_entry_rcu(ctx, list, client_link)
> >>>> +        total += busy_add(ctx, class);
> >>>> +    rcu_read_unlock();
> >>>> +
> >>>> +    seq_printf(m, "drm-engine-%s:\t%llu ns\n",
> >>>> +           uabi_class_names[class], total);
> >>>> +
> >>>> +    if (capacity > 1)
> >>>> +        seq_printf(m, "drm-engine-capacity-%s:\t%u\n",
> >>>> +               uabi_class_names[class],
> >>>> +               capacity);
> >>>> +}
> >>>> +
> >>>> +void i915_drm_client_fdinfo(struct seq_file *m, struct file *f)
> >>>> +{
> >>>> +    struct drm_file *file = f->private_data;
> >>>> +    struct drm_i915_file_private *file_priv = file->driver_priv;
> >>>> +    struct drm_i915_private *i915 = file_priv->dev_priv;
> >>>> +    struct i915_drm_client *client = file_priv->client;
> >>>> +    struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
> >>>> +    unsigned int i;
> >>>> +
> >>>> +    /*
> >>>> +     *
> >>>> ******************************************************************
> >>>> +     * For text output format description please see
> >>>> drm-usage-stats.rst!
> >>>> +     *
> >>>> ******************************************************************
> >>>> +     */
> >>>> +
> >>>> +    seq_printf(m, "drm-driver:\t%s\n", i915->drm.driver->name);
> >>>> +    seq_printf(m, "drm-pdev:\t%04x:%02x:%02x.%d\n",
> >>>> +           pci_domain_nr(pdev->bus), pdev->bus->number,
> >>>> +           PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
> >>>> +    seq_printf(m, "drm-client-id:\t%u\n", client->id);
> >>>> +
> >>>> +    if (GRAPHICS_VER(i915) < 8)
> >>>> +        return;
> >>>> +
> >>>> +    for (i = 0; i < ARRAY_SIZE(uabi_class_names); i++)
> >>>> +        show_client_class(m, client, i);
> >>>> +}
> >>>> +#endif
> >>>> diff --git a/drivers/gpu/drm/i915/i915_drm_client.h
> >>>> b/drivers/gpu/drm/i915/i915_drm_client.h
> >>>> index 191368386ace..5f5b02b01ba0 100644
> >>>> --- a/drivers/gpu/drm/i915/i915_drm_client.h
> >>>> +++ b/drivers/gpu/drm/i915/i915_drm_client.h
> >>>> @@ -59,6 +59,10 @@ static inline void i915_drm_client_put(struct
> >>>> i915_drm_client *client)
> >>>>    struct i915_drm_client *i915_drm_client_add(struct
> >>>> i915_drm_clients *clients);
> >>>> +#ifdef CONFIG_PROC_FS
> >>>> +void i915_drm_client_fdinfo(struct seq_file *m, struct file *f);
> >>>> +#endif
> >>>> +
> >>>>    void i915_drm_clients_fini(struct i915_drm_clients *clients);
> >>>>    #endif /* !__I915_DRM_CLIENT_H__ */
> >

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [Intel-gfx] [CI 8/8] drm/i915: Expose client engine utilisation via fdinfo
@ 2022-04-06 18:15             ` Rob Clark
  0 siblings, 0 replies; 35+ messages in thread
From: Rob Clark @ 2022-04-06 18:15 UTC (permalink / raw)
  To: Tvrtko Ursulin
  Cc: Intel Graphics Development, Dave Airlie, dri-devel, Christian König

On Tue, Apr 5, 2022 at 1:09 AM Tvrtko Ursulin
<tvrtko.ursulin@linux.intel.com> wrote:
>
>
> On 04/04/2022 16:36, Daniel Vetter wrote:
> > On Mon, Apr 04, 2022 at 10:23:53AM +0100, Tvrtko Ursulin wrote:
> >>
> >> + Dave and Daniel
> >>
> >> Guys, are you okay with merging this via drm-intel-gt-next? It is one new
> >> file at Documentation/gpu/drm-usage-stats.rst only which is outside i915. It
> >> has acks from Christian and Rob.
> >
> > Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
>
> Thanks, pushed now.
>
> Rob - you can proceed with your driver at your leisure. I will re-send
> the rebased gputop to igt-dev shortly and copy you.

Thx, I was planning to respin, but trying to figure out where the
drm-usage-stats.rst patch ended up (since I can't add to a file that
isn't there

BR,
-R

> Regards,
>
> Tvrtko
>
> >>
> >> Daniel, series is also fully reviewed and IGT reviewed and ready. Rob also
> >> demonstrated the approach works for msm when using the vendor agnosstic
> >> gputop tool I sketched out (see
> >> 20220225202614.225197-3-robdclark@gmail.com).
> >>
> >> My plan is to merge the i915 support with the common spec and intel_gpu_top
> >> on the IGT side. Then follow-up with vendor agnostic gputop and later yet
> >> potentially re-visit the AMD side by re-sending the patch which tweaks the
> >> fdinfo format there and adds support for relative engine utilisation as
> >> provided by amdgpu.
> >>
> >> Regards,
> >>
> >> Tvrtko
> >>
> >> On 04/04/2022 10:12, Tvrtko Ursulin wrote:
> >>>
> >>> On 01/04/2022 15:22, Tvrtko Ursulin wrote:
> >>>> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> >>>>
> >>>> Similar to AMD commit
> >>>> 874442541133 ("drm/amdgpu: Add show_fdinfo() interface"), using the
> >>>> infrastructure added in previous patches, we add basic client info
> >>>> and GPU engine utilisation for i915.
> >>>>
> >>>> Example of the output:
> >>>>
> >>>>     pos:    0
> >>>>     flags:  0100002
> >>>>     mnt_id: 21
> >>>>     drm-driver: i915
> >>>>     drm-pdev:   0000:00:02.0
> >>>>     drm-client-id:      7
> >>>>     drm-engine-render:  9288864723 ns
> >>>>     drm-engine-copy:    2035071108 ns
> >>>>     drm-engine-video:   0 ns
> >>>>     drm-engine-video-enhance:   0 ns
> >>>>
> >>>> v2:
> >>>>    * Update for removal of name and pid.
> >>>>
> >>>> v3:
> >>>>    * Use drm_driver.name.
> >>>>
> >>>> v4:
> >>>>    * Added drm-engine-capacity- tag.
> >>>>    * Fix typo. (Umesh)
> >>>>
> >>>> v5:
> >>>>    * Don't output engine data before Gen8.
> >>>>
> >>>> 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: Chris Healy <cphealy@gmail.com>
> >>>> Acked-by: Christian König <christian.koenig@amd.com>
> >>>> Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
> >>>
> >>> Forgot to apply an earlier:
> >>>
> >>> Acked-by: Rob Clark <robdclark@gmail.com>
> >>>
> >>> Regards,
> >>>
> >>> Tvrtko
> >>>
> >>>> ---
> >>>>    Documentation/gpu/drm-usage-stats.rst  |  6 ++
> >>>>    Documentation/gpu/i915.rst             | 28 +++++++++
> >>>>    drivers/gpu/drm/i915/i915_driver.c     |  3 +
> >>>>    drivers/gpu/drm/i915/i915_drm_client.c | 84 ++++++++++++++++++++++++++
> >>>>    drivers/gpu/drm/i915/i915_drm_client.h |  4 ++
> >>>>    5 files changed, 125 insertions(+)
> >>>>
> >>>> diff --git a/Documentation/gpu/drm-usage-stats.rst
> >>>> b/Documentation/gpu/drm-usage-stats.rst
> >>>> index b8cc28f4da6f..6c9f166a8d6f 100644
> >>>> --- a/Documentation/gpu/drm-usage-stats.rst
> >>>> +++ b/Documentation/gpu/drm-usage-stats.rst
> >>>> @@ -104,3 +104,9 @@ 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.
> >>>> +
> >>>> +===============================
> >>>> +Driver specific implementations
> >>>> +===============================
> >>>> +
> >>>> +:ref:`i915-usage-stats`
> >>>> diff --git a/Documentation/gpu/i915.rst b/Documentation/gpu/i915.rst
> >>>> index 0f08693d05cd..54060cd6c419 100644
> >>>> --- a/Documentation/gpu/i915.rst
> >>>> +++ b/Documentation/gpu/i915.rst
> >>>> @@ -697,3 +697,31 @@ The style guide for ``i915_reg.h``.
> >>>>    .. kernel-doc:: drivers/gpu/drm/i915/i915_reg.h
> >>>>       :doc: The i915 register macro definition style guide
> >>>> +
> >>>> +.. _i915-usage-stats:
> >>>> +
> >>>> +i915 DRM client usage stats implementation
> >>>> +==========================================
> >>>> +
> >>>> +The drm/i915 driver implements the DRM client usage stats
> >>>> specification as
> >>>> +documented in :ref:`drm-client-usage-stats`.
> >>>> +
> >>>> +Example of the output showing the implemented key value pairs and
> >>>> entirety of
> >>>> +the currently possible format options:
> >>>> +
> >>>> +::
> >>>> +
> >>>> +      pos:    0
> >>>> +      flags:  0100002
> >>>> +      mnt_id: 21
> >>>> +      drm-driver: i915
> >>>> +      drm-pdev:   0000:00:02.0
> >>>> +      drm-client-id:      7
> >>>> +      drm-engine-render:  9288864723 ns
> >>>> +      drm-engine-copy:    2035071108 ns
> >>>> +      drm-engine-video:   0 ns
> >>>> +      drm-engine-capacity-video:   2
> >>>> +      drm-engine-video-enhance:   0 ns
> >>>> +
> >>>> +Possible `drm-engine-` key names are: `render`, `copy`, `video` and
> >>>> +`video-enhance`.
> >>>> diff --git a/drivers/gpu/drm/i915/i915_driver.c
> >>>> b/drivers/gpu/drm/i915/i915_driver.c
> >>>> index b2df273e6d7b..3ffb617d75c9 100644
> >>>> --- a/drivers/gpu/drm/i915/i915_driver.c
> >>>> +++ b/drivers/gpu/drm/i915/i915_driver.c
> >>>> @@ -1745,6 +1745,9 @@ static const struct file_operations
> >>>> i915_driver_fops = {
> >>>>        .read = drm_read,
> >>>>        .compat_ioctl = i915_ioc32_compat_ioctl,
> >>>>        .llseek = noop_llseek,
> >>>> +#ifdef CONFIG_PROC_FS
> >>>> +    .show_fdinfo = i915_drm_client_fdinfo,
> >>>> +#endif
> >>>>    };
> >>>>    static int
> >>>> diff --git a/drivers/gpu/drm/i915/i915_drm_client.c
> >>>> b/drivers/gpu/drm/i915/i915_drm_client.c
> >>>> index 91a8559bebf7..e539f6b23060 100644
> >>>> --- a/drivers/gpu/drm/i915/i915_drm_client.c
> >>>> +++ b/drivers/gpu/drm/i915/i915_drm_client.c
> >>>> @@ -7,7 +7,13 @@
> >>>>    #include <linux/slab.h>
> >>>>    #include <linux/types.h>
> >>>> +#include <uapi/drm/i915_drm.h>
> >>>> +
> >>>> +#include <drm/drm_print.h>
> >>>> +
> >>>> +#include "gem/i915_gem_context.h"
> >>>>    #include "i915_drm_client.h"
> >>>> +#include "i915_file_private.h"
> >>>>    #include "i915_gem.h"
> >>>>    #include "i915_utils.h"
> >>>> @@ -68,3 +74,81 @@ void i915_drm_clients_fini(struct
> >>>> i915_drm_clients *clients)
> >>>>        GEM_BUG_ON(!xa_empty(&clients->xarray));
> >>>>        xa_destroy(&clients->xarray);
> >>>>    }
> >>>> +
> >>>> +#ifdef CONFIG_PROC_FS
> >>>> +static const char * const uabi_class_names[] = {
> >>>> +    [I915_ENGINE_CLASS_RENDER] = "render",
> >>>> +    [I915_ENGINE_CLASS_COPY] = "copy",
> >>>> +    [I915_ENGINE_CLASS_VIDEO] = "video",
> >>>> +    [I915_ENGINE_CLASS_VIDEO_ENHANCE] = "video-enhance",
> >>>> +};
> >>>> +
> >>>> +static u64 busy_add(struct i915_gem_context *ctx, unsigned int class)
> >>>> +{
> >>>> +    struct i915_gem_engines_iter it;
> >>>> +    struct intel_context *ce;
> >>>> +    u64 total = 0;
> >>>> +
> >>>> +    for_each_gem_engine(ce, rcu_dereference(ctx->engines), it) {
> >>>> +        if (ce->engine->uabi_class != class)
> >>>> +            continue;
> >>>> +
> >>>> +        total += intel_context_get_total_runtime_ns(ce);
> >>>> +    }
> >>>> +
> >>>> +    return total;
> >>>> +}
> >>>> +
> >>>> +static void
> >>>> +show_client_class(struct seq_file *m,
> >>>> +          struct i915_drm_client *client,
> >>>> +          unsigned int class)
> >>>> +{
> >>>> +    const struct list_head *list = &client->ctx_list;
> >>>> +    u64 total = atomic64_read(&client->past_runtime[class]);
> >>>> +    const unsigned int capacity =
> >>>> +        client->clients->i915->engine_uabi_class_count[class];
> >>>> +    struct i915_gem_context *ctx;
> >>>> +
> >>>> +    rcu_read_lock();
> >>>> +    list_for_each_entry_rcu(ctx, list, client_link)
> >>>> +        total += busy_add(ctx, class);
> >>>> +    rcu_read_unlock();
> >>>> +
> >>>> +    seq_printf(m, "drm-engine-%s:\t%llu ns\n",
> >>>> +           uabi_class_names[class], total);
> >>>> +
> >>>> +    if (capacity > 1)
> >>>> +        seq_printf(m, "drm-engine-capacity-%s:\t%u\n",
> >>>> +               uabi_class_names[class],
> >>>> +               capacity);
> >>>> +}
> >>>> +
> >>>> +void i915_drm_client_fdinfo(struct seq_file *m, struct file *f)
> >>>> +{
> >>>> +    struct drm_file *file = f->private_data;
> >>>> +    struct drm_i915_file_private *file_priv = file->driver_priv;
> >>>> +    struct drm_i915_private *i915 = file_priv->dev_priv;
> >>>> +    struct i915_drm_client *client = file_priv->client;
> >>>> +    struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
> >>>> +    unsigned int i;
> >>>> +
> >>>> +    /*
> >>>> +     *
> >>>> ******************************************************************
> >>>> +     * For text output format description please see
> >>>> drm-usage-stats.rst!
> >>>> +     *
> >>>> ******************************************************************
> >>>> +     */
> >>>> +
> >>>> +    seq_printf(m, "drm-driver:\t%s\n", i915->drm.driver->name);
> >>>> +    seq_printf(m, "drm-pdev:\t%04x:%02x:%02x.%d\n",
> >>>> +           pci_domain_nr(pdev->bus), pdev->bus->number,
> >>>> +           PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
> >>>> +    seq_printf(m, "drm-client-id:\t%u\n", client->id);
> >>>> +
> >>>> +    if (GRAPHICS_VER(i915) < 8)
> >>>> +        return;
> >>>> +
> >>>> +    for (i = 0; i < ARRAY_SIZE(uabi_class_names); i++)
> >>>> +        show_client_class(m, client, i);
> >>>> +}
> >>>> +#endif
> >>>> diff --git a/drivers/gpu/drm/i915/i915_drm_client.h
> >>>> b/drivers/gpu/drm/i915/i915_drm_client.h
> >>>> index 191368386ace..5f5b02b01ba0 100644
> >>>> --- a/drivers/gpu/drm/i915/i915_drm_client.h
> >>>> +++ b/drivers/gpu/drm/i915/i915_drm_client.h
> >>>> @@ -59,6 +59,10 @@ static inline void i915_drm_client_put(struct
> >>>> i915_drm_client *client)
> >>>>    struct i915_drm_client *i915_drm_client_add(struct
> >>>> i915_drm_clients *clients);
> >>>> +#ifdef CONFIG_PROC_FS
> >>>> +void i915_drm_client_fdinfo(struct seq_file *m, struct file *f);
> >>>> +#endif
> >>>> +
> >>>>    void i915_drm_clients_fini(struct i915_drm_clients *clients);
> >>>>    #endif /* !__I915_DRM_CLIENT_H__ */
> >

^ permalink raw reply	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2022-04-06 18:15 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-01 14:21 [CI 0/8] Per client GPU utilisation Tvrtko Ursulin
2022-04-01 14:21 ` [Intel-gfx] " Tvrtko Ursulin
2022-04-01 14:21 ` [CI 1/8] drm/i915: Explicitly track DRM clients Tvrtko Ursulin
2022-04-01 14:21   ` [Intel-gfx] " Tvrtko Ursulin
2022-04-01 14:21 ` [CI 2/8] drm/i915: Make GEM contexts " Tvrtko Ursulin
2022-04-01 14:21   ` [Intel-gfx] " Tvrtko Ursulin
2022-04-01 14:22 ` [CI 3/8] drm/i915: Track runtime spent in closed and unreachable GEM contexts Tvrtko Ursulin
2022-04-01 14:22   ` [Intel-gfx] " Tvrtko Ursulin
2022-04-01 14:22 ` [CI 4/8] drm/i915: Track all user contexts per client Tvrtko Ursulin
2022-04-01 14:22   ` [Intel-gfx] " Tvrtko Ursulin
2022-04-01 14:22 ` [CI 5/8] drm/i915: Track context current active time Tvrtko Ursulin
2022-04-01 14:22   ` [Intel-gfx] " Tvrtko Ursulin
2022-04-01 14:22 ` [CI 6/8] drm: Document fdinfo format specification Tvrtko Ursulin
2022-04-01 14:22   ` [Intel-gfx] " Tvrtko Ursulin
2022-04-01 14:22 ` [CI 7/8] drm/i915: Count engine instances per uabi class Tvrtko Ursulin
2022-04-01 14:22   ` [Intel-gfx] " Tvrtko Ursulin
2022-04-01 14:22 ` [CI 8/8] drm/i915: Expose client engine utilisation via fdinfo Tvrtko Ursulin
2022-04-01 14:22   ` [Intel-gfx] " Tvrtko Ursulin
2022-04-04  9:12   ` Tvrtko Ursulin
2022-04-04  9:23     ` Tvrtko Ursulin
2022-04-04 15:36       ` Daniel Vetter
2022-04-04 15:36         ` Daniel Vetter
2022-04-05  8:08         ` Tvrtko Ursulin
2022-04-05  8:08           ` Tvrtko Ursulin
2022-04-06 18:15           ` Rob Clark
2022-04-06 18:15             ` Rob Clark
2022-04-01 15:57 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for Per client GPU utilisation (rev4) Patchwork
2022-04-01 15:59 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2022-04-01 16:03 ` [Intel-gfx] ✗ Fi.CI.DOCS: " Patchwork
2022-04-01 16:38 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
2022-04-01 20:28 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for Per client GPU utilisation (rev5) Patchwork
2022-04-01 20:29 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2022-04-01 20:33 ` [Intel-gfx] ✗ Fi.CI.DOCS: " Patchwork
2022-04-01 21:00 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2022-04-01 23:04 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork

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.