Skip to contentSkip to conversation

drm/i915/pmu: Stop peeking at kernel internals for counting interrupts

PATCH In review Tvrtko Ursulin 4 participants 5 messages Dec 10, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915/pmu: Stop peeking at kernel internals for counting interrupts

From: Tvrtko Ursulin <[email protected]>

Peeking at kernel internals is bad taste so instead we keep our own counter which also solves the problem of shared interrupt lines.

Additional cost should be way below noise relative to mmio reads.

---
 drivers/gpu/drm/i915/i915_drv.h |  3 +++
 drivers/gpu/drm/i915/i915_irq.c | 16 ++++++++++++++++
 drivers/gpu/drm/i915/i915_pmu.c | 19 +------------------
 3 files changed, 20 insertions(+), 18 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +3 -0
index 5d04b282c060..de5cdcdc46b0 100644
@@ -889,6 +889,9 @@ struct drm_i915_private {
 	/* protects the irq masks */
 	spinlock_t irq_lock;
 
+	/** Overall irq handler invocations. */
+	u64 irq_count;
+
 	bool display_irqs_enabled;
 
 	/* To control wakeup latency, e.g. for irq-driven dp aux transfers. */
drivers/gpu/drm/i915/i915_irq.c +16 -0
index b245109f73e3..a88c1da025f1 100644
@@ -1596,6 +1596,8 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
 	if (!intel_irqs_enabled(dev_priv))
 		return IRQ_NONE;
 
+	dev_priv->irq_count++;
+
 	/* IRQs are synced during runtime_suspend, we don't require a wakeref */
 	disable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
@@ -1681,6 +1683,8 @@ static irqreturn_t cherryview_irq_handler(int irq, void *arg)
 	if (!intel_irqs_enabled(dev_priv))
 		return IRQ_NONE;
 
+	dev_priv->irq_count++;
+
 	/* IRQs are synced during runtime_suspend, we don't require a wakeref */
 	disable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
@@ -2103,6 +2107,8 @@ static irqreturn_t ilk_irq_handler(int irq, void *arg)
 	if (unlikely(!intel_irqs_enabled(i915)))
 		return IRQ_NONE;
 
+	i915->irq_count++;
+
 	/* IRQs are synced during runtime_suspend, we don't require a wakeref */
 	disable_rpm_wakeref_asserts(&i915->runtime_pm);
 
@@ -2523,6 +2529,8 @@ static irqreturn_t gen8_irq_handler(int irq, void *arg)
 	if (!intel_irqs_enabled(dev_priv))
 		return IRQ_NONE;
 
+	dev_priv->irq_count++;
+
 	master_ctl = gen8_master_intr_disable(regs);
 	if (!master_ctl) {
 		gen8_master_intr_enable(regs);
@@ -2617,6 +2625,8 @@ __gen11_irq_handler(struct drm_i915_private * const i915,
 	if (!intel_irqs_enabled(i915))
 		return IRQ_NONE;
 
+	i915->irq_count++;
+
 	master_ctl = intr_disable(regs);
 	if (!master_ctl) {
 		intr_enable(regs);
@@ -3902,6 +3912,8 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
 	if (!intel_irqs_enabled(dev_priv))
 		return IRQ_NONE;
 
+	dev_priv->irq_count++;
+
 	/* IRQs are synced during runtime_suspend, we don't require a wakeref */
 	disable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
@@ -4003,6 +4015,8 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
 	if (!intel_irqs_enabled(dev_priv))
 		return IRQ_NONE;
 
+	dev_priv->irq_count++;
+
 	/* IRQs are synced during runtime_suspend, we don't require a wakeref */
 	disable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
@@ -4147,6 +4161,8 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
 	if (!intel_irqs_enabled(dev_priv))
 		return IRQ_NONE;
 
+	dev_priv->irq_count++;
+
 	/* IRQs are synced during runtime_suspend, we don't require a wakeref */
 	disable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
drivers/gpu/drm/i915/i915_pmu.c +1 -18
index 97bb4aaa5236..0f313f4546ab 100644
@@ -4,7 +4,6 @@
  * Copyright © 2017-2018 Intel Corporation
  */
 
-#include <linux/irq.h>
 #include <linux/pm_runtime.h>
 
 #include "gt/intel_engine.h"
@@ -452,22 +451,6 @@ static enum hrtimer_restart i915_sample(struct hrtimer *hrtimer)
 	return HRTIMER_RESTART;
 }
 
-static u64 count_interrupts(struct drm_i915_private *i915)
-{
-	/* open-coded kstat_irqs() */
-	struct irq_desc *desc = irq_to_desc(i915->drm.pdev->irq);
-	u64 sum = 0;
-	int cpu;
-
-	if (!desc || !desc->kstat_irqs)
-		return 0;
-
-	for_each_possible_cpu(cpu)
-		sum += *per_cpu_ptr(desc->kstat_irqs, cpu);
-
-	return sum;
-}
-
 static void i915_pmu_event_destroy(struct perf_event *event)
 {
 	struct drm_i915_private *i915 =
@@ -618,7 +601,7 @@ static u64 __i915_pmu_event_read(struct perf_event *event)
 				   USEC_PER_SEC /* to MHz */);
 			break;
 		case I915_PMU_INTERRUPTS:
-			val = count_interrupts(i915);
+			val = i915->irq_count;
 			break;
 		case I915_PMU_RC6_RESIDENCY:
 			val = get_rc6(&i915->gt);
Signature · 6 lines
2.25.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

Quoting Tvrtko Ursulin (2020-12-10 17:35:45)

Quoted 10 lines

From: Tvrtko Ursulin <[email protected]>

Peeking at kernel internals is bad taste so instead we keep our own counter which also solves the problem of shared interrupt lines.

Additional cost should be way below noise relative to mmio reads.

But this duplicates the same counting done by the core code. Which is also in bad taste.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw
In reply to Tvrtko Ursulin
Quoted 35 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

Peeking at kernel internals is bad taste so instead we keep our own counter which also solves the problem of shared interrupt lines.

Additional cost should be way below noise relative to mmio reads.

---
 drivers/gpu/drm/i915/i915_drv.h |  3 +++
 drivers/gpu/drm/i915/i915_irq.c | 16 ++++++++++++++++
 drivers/gpu/drm/i915/i915_pmu.c | 19 +------------------
 3 files changed, 20 insertions(+), 18 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +3 -0
index 5d04b282c060..de5cdcdc46b0 100644
@@ -889,6 +889,9 @@ struct drm_i915_private {
 	/* protects the irq masks */
 	spinlock_t irq_lock;
 
+	/** Overall irq handler invocations. */
+	u64 irq_count;
+
 	bool display_irqs_enabled;
 
 	/* To control wakeup latency, e.g. for irq-driven dp aux transfers. */
drivers/gpu/drm/i915/i915_irq.c +0 -0
index b245109f73e3..a88c1da025f1 100644

drivers/gpu/drm/i915/i915_irq.c static irqreturn_t valleyview_irq_handler(int irq, void *arg) · line 1599

Quoted 4 lines
drivers/gpu/drm/i915/i915_irq.c +1 -0
@@ -1596,6 +1596,8 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
 	if (!intel_irqs_enabled(dev_priv))
 		return IRQ_NONE;
 
+	dev_priv->irq_count++;

Would rather have to be something like
if (ret == IRQ_HANDLED)

	irq_count++;

if we really wanted to count only our interrupts when the irq line is shared.

Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

[Intel-gfx] ✗ Fi.CI.DOCS: warning for drm/i915/pmu: Stop peeking at kernel internals for counting interrupts

In reply to Tvrtko Ursulin
== Series Details ==

== Series Details ==

Series: drm/i915/pmu: Stop peeking at kernel internals for counting interrupts
URL : https://patchwork.freedesktop.org/series/84800/
State : warning

== Summary ==

$ make htmldocs 2>&1 > /dev/null | grep i915
Error: Cannot open file ./drivers/gpu/drm/i915/gt/intel_lrc.c
WARNING: kernel-doc './scripts/kernel-doc -rst -enable-lineno -sphinx-version 1.7.9 -function Logical Rings, Logical Ring Contexts and Execlists ./drivers/gpu/drm/i915/gt/intel_lrc.c' failed with return code 1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw

[Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915/pmu: Stop peeking at kernel internals for counting interrupts

In reply to Tvrtko Ursulin
== Series Details ==

== Series Details ==

Series: drm/i915/pmu: Stop peeking at kernel internals for counting interrupts
URL : https://patchwork.freedesktop.org/series/84800/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_9472 -> Patchwork_19114
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with Patchwork_19114 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in Patchwork_19114, 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_19114/index.html

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

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

### IGT changes ###

#### Possible regressions ####

* igt@i915_selftest@live@ring_submission:
- fi-apl-guc: [PASS][1] -> [DMESG-WARN][2] +13 similar issues
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9472/fi-apl-guc/igt@i915_selftest@live@ring_submission.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19114/fi-apl-guc/igt@i915_selftest@live@ring_submission.html

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

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

### IGT changes ###

#### Issues hit ####

* igt@i915_selftest@live@execlists:
- fi-apl-guc: [PASS][3] -> [DMESG-WARN][4] ([i915#1037])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9472/fi-apl-guc/igt@i915_selftest@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19114/fi-apl-guc/igt@i915_selftest@[email protected]

* igt@kms_addfb_basic@addfb25-modifier-no-flag:
- fi-tgl-y: [PASS][5] -> [DMESG-WARN][6] ([i915#402]) +1 similar issue
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9472/fi-tgl-y/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19114/fi-tgl-y/igt@[email protected]

#### Possible fixes ####

* igt@debugfs_test@read_all_entries:
- fi-tgl-y: [DMESG-WARN][7] ([i915#402]) -> [PASS][8] +2 similar issues
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9472/fi-tgl-y/igt@debugfs_test@read_all_entries.html
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19114/fi-tgl-y/igt@debugfs_test@read_all_entries.html

[i915#1037]: https://gitlab.freedesktop.org/drm/intel/issues/1037
[i915#402]: https://gitlab.freedesktop.org/drm/intel/issues/402

Participating hosts (44 -> 40)
------------------------------

Missing (4): fi-ctg-p8600 fi-ilk-m540 fi-bdw-samus fi-hsw-4200u

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

* Linux: CI_DRM_9472 -> Patchwork_19114

CI-20190529: 20190529
CI_DRM_9472: 661399b277bad4b274f9c7dc8ee8a967f5353cb5 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5888: c79d4e88f4162905da400360b6fa4940122f3a2c @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_19114: fe77a262404fb4e2128ee608bd14ac219764a669 @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

fe77a262404f drm/i915/pmu: Stop peeking at kernel internals for counting interrupts

== Logs ==

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

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx