All of lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-gfx] [PATCH] drm/i915/pmu: Stop peeking at kernel internals for counting interrupts
@ 2020-12-10 17:35 Tvrtko Ursulin
  2020-12-10 18:29 ` Chris Wilson
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Tvrtko Ursulin @ 2020-12-10 17:35 UTC (permalink / raw)
  To: Intel-gfx; +Cc: Thomas Gleixner, Chris Wilson

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

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.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
---
 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(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 5d04b282c060..de5cdcdc46b0 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -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. */
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index b245109f73e3..a88c1da025f1 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -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);
 
diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c
index 97bb4aaa5236..0f313f4546ab 100644
--- a/drivers/gpu/drm/i915/i915_pmu.c
+++ b/drivers/gpu/drm/i915/i915_pmu.c
@@ -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);
-- 
2.25.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [Intel-gfx] [PATCH] drm/i915/pmu: Stop peeking at kernel internals for counting interrupts
  2020-12-10 17:35 [Intel-gfx] [PATCH] drm/i915/pmu: Stop peeking at kernel internals for counting interrupts Tvrtko Ursulin
@ 2020-12-10 18:29 ` Chris Wilson
  2020-12-10 18:45 ` Ville Syrjälä
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Chris Wilson @ 2020-12-10 18:29 UTC (permalink / raw)
  To: Intel-gfx, Tvrtko Ursulin; +Cc: Thomas Gleixner

Quoting Tvrtko Ursulin (2020-12-10 17:35:45)
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> 
> 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.
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Suggested-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>

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

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

* Re: [Intel-gfx] [PATCH] drm/i915/pmu: Stop peeking at kernel internals for counting interrupts
  2020-12-10 17:35 [Intel-gfx] [PATCH] drm/i915/pmu: Stop peeking at kernel internals for counting interrupts Tvrtko Ursulin
  2020-12-10 18:29 ` Chris Wilson
@ 2020-12-10 18:45 ` Ville Syrjälä
  2020-12-10 20:30 ` [Intel-gfx] ✗ Fi.CI.DOCS: warning for " Patchwork
  2020-12-10 20:56 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
  3 siblings, 0 replies; 5+ messages in thread
From: Ville Syrjälä @ 2020-12-10 18:45 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: Intel-gfx, Thomas Gleixner, Chris Wilson

On Thu, Dec 10, 2020 at 05:35:45PM +0000, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> 
> 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.
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Suggested-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>  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(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 5d04b282c060..de5cdcdc46b0 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -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. */
> diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
> index b245109f73e3..a88c1da025f1 100644
> --- a/drivers/gpu/drm/i915/i915_irq.c
> +++ b/drivers/gpu/drm/i915/i915_irq.c
> @@ -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.

-- 
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* [Intel-gfx] ✗ Fi.CI.DOCS: warning for drm/i915/pmu: Stop peeking at kernel internals for counting interrupts
  2020-12-10 17:35 [Intel-gfx] [PATCH] drm/i915/pmu: Stop peeking at kernel internals for counting interrupts Tvrtko Ursulin
  2020-12-10 18:29 ` Chris Wilson
  2020-12-10 18:45 ` Ville Syrjälä
@ 2020-12-10 20:30 ` Patchwork
  2020-12-10 20:56 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
  3 siblings, 0 replies; 5+ messages in thread
From: Patchwork @ 2020-12-10 20:30 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: intel-gfx

== 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
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* [Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915/pmu: Stop peeking at kernel internals for counting interrupts
  2020-12-10 17:35 [Intel-gfx] [PATCH] drm/i915/pmu: Stop peeking at kernel internals for counting interrupts Tvrtko Ursulin
                   ` (2 preceding siblings ...)
  2020-12-10 20:30 ` [Intel-gfx] ✗ Fi.CI.DOCS: warning for " Patchwork
@ 2020-12-10 20:56 ` Patchwork
  3 siblings, 0 replies; 5+ messages in thread
From: Patchwork @ 2020-12-10 20:56 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: intel-gfx


[-- Attachment #1.1: Type: text/plain, Size: 3410 bytes --]

== 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@live@execlists.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19114/fi-apl-guc/igt@i915_selftest@live@execlists.html

  * 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@kms_addfb_basic@addfb25-modifier-no-flag.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19114/fi-tgl-y/igt@kms_addfb_basic@addfb25-modifier-no-flag.html

  
#### 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

[-- Attachment #1.2: Type: text/html, Size: 4175 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

end of thread, other threads:[~2020-12-10 20:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-10 17:35 [Intel-gfx] [PATCH] drm/i915/pmu: Stop peeking at kernel internals for counting interrupts Tvrtko Ursulin
2020-12-10 18:29 ` Chris Wilson
2020-12-10 18:45 ` Ville Syrjälä
2020-12-10 20:30 ` [Intel-gfx] ✗ Fi.CI.DOCS: warning for " Patchwork
2020-12-10 20:56 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " 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.