History

drm/i915/pmu: Add interrupt count metric

For clients like intel-gpu-overlay it is easier to read the count via the perf API than having to parse /proc.

Tvrtko Ursulin committed 8 years ago

Commit 0cd46841 parent b3add012 files · +26 −1Browse files

Unified · Split

2 files
  1. drivers/gpu/drm/i915/i915_pmu.c +23 −0
  2. include/uapi/drm/i915_drm.h +3 −1
drivers/gpu/drm/i915/i915_pmu.c+23−0
@@ -277,6 +277,22 @@ static enum hrtimer_restart i915_sample(struct hrtimer *hrtimer) · 276 unmodified lines
277277 return HRTIMER_RESTART;
278278 }
279279
280+static u64 count_interrupts(struct drm_i915_private *i915)
281+{
282+ /* open-coded kstat_irqs() */
283+ struct irq_desc *desc = irq_to_desc(i915->drm.pdev->irq);
284+ u64 sum = 0;
285+ int cpu;
286+
287+ if (!desc || !desc->kstat_irqs)
288+ return 0;
289+
290+ for_each_possible_cpu(cpu)
291+ sum += *per_cpu_ptr(desc->kstat_irqs, cpu);
292+
293+ return sum;
294+}
295+
280296 static void i915_pmu_event_destroy(struct perf_event *event)
281297 {
282298 WARN_ON(event->parent);
@@ -343,6 +359,8 @@ static int i915_pmu_event_init(struct perf_event *event) · 60 unmodified lines
343359 if (INTEL_GEN(i915) < 6)
344360 ret = -ENODEV;
345361 break;
362+ case I915_PMU_INTERRUPTS:
363+ break;
346364 default:
347365 ret = -ENOENT;
348366 break;
@@ -392,6 +410,9 @@ static u64 __i915_pmu_event_read(struct perf_event *event) · 43 unmodified lines
392410 div_u64(i915->pmu.sample[__I915_SAMPLE_FREQ_REQ].cur,
393411 FREQUENCY);
394412 break;
413+ case I915_PMU_INTERRUPTS:
414+ val = count_interrupts(i915);
415+ break;
395416 }
396417 }
397418
@@ -654,6 +675,8 @@ static struct attribute *i915_pmu_events_attrs[] = { · 256 unmodified lines
654675 I915_EVENT(actual-frequency, I915_PMU_ACTUAL_FREQUENCY, "MHz"),
655676 I915_EVENT(requested-frequency, I915_PMU_REQUESTED_FREQUENCY, "MHz"),
656677
678+ I915_EVENT_ATTR(interrupts, I915_PMU_INTERRUPTS),
679+
657680 NULL,
658681 };
659682
include/uapi/drm/i915_drm.h+3−1
@@ -139,7 +139,9 @@ enum drm_i915_pmu_engine_sample { · 138 unmodified lines
139139 #define I915_PMU_ACTUAL_FREQUENCY __I915_PMU_OTHER(0)
140140 #define I915_PMU_REQUESTED_FREQUENCY __I915_PMU_OTHER(1)
141141
142−#define I915_PMU_LAST I915_PMU_REQUESTED_FREQUENCY
142+#define I915_PMU_INTERRUPTS __I915_PMU_OTHER(2)
143+
144+#define I915_PMU_LAST I915_PMU_INTERRUPTS
143145
144146 /* Each region is a minimum of 16k, and there are at most 255 of them.
145147 */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t