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
277 return HRTIMER_RESTART;277 return HRTIMER_RESTART;
278}278}
279 279
280static 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
280static void i915_pmu_event_destroy(struct perf_event *event)296static void i915_pmu_event_destroy(struct perf_event *event)
281{297{
282 WARN_ON(event->parent);298 WARN_ON(event->parent);
@@ -343,6 +359,8 @@ static int i915_pmu_event_init(struct perf_event *event) · 60 unmodified lines
343 if (INTEL_GEN(i915) < 6)359 if (INTEL_GEN(i915) < 6)
344 ret = -ENODEV;360 ret = -ENODEV;
345 break;361 break;
362 case I915_PMU_INTERRUPTS:
363 break;
346 default:364 default:
347 ret = -ENOENT;365 ret = -ENOENT;
348 break;366 break;
@@ -392,6 +410,9 @@ static u64 __i915_pmu_event_read(struct perf_event *event) · 43 unmodified lines
392 div_u64(i915->pmu.sample[__I915_SAMPLE_FREQ_REQ].cur,410 div_u64(i915->pmu.sample[__I915_SAMPLE_FREQ_REQ].cur,
393 FREQUENCY);411 FREQUENCY);
394 break;412 break;
413 case I915_PMU_INTERRUPTS:
414 val = count_interrupts(i915);
415 break;
395 }416 }
396 }417 }
397 418
@@ -654,6 +675,8 @@ static struct attribute *i915_pmu_events_attrs[] = { · 256 unmodified lines
654 I915_EVENT(actual-frequency, I915_PMU_ACTUAL_FREQUENCY, "MHz"),675 I915_EVENT(actual-frequency, I915_PMU_ACTUAL_FREQUENCY, "MHz"),
655 I915_EVENT(requested-frequency, I915_PMU_REQUESTED_FREQUENCY, "MHz"),676 I915_EVENT(requested-frequency, I915_PMU_REQUESTED_FREQUENCY, "MHz"),
656 677
678 I915_EVENT_ATTR(interrupts, I915_PMU_INTERRUPTS),
679
657 NULL,680 NULL,
658};681};
659 682
include/uapi/drm/i915_drm.h+3−1
@@ -139,7 +139,9 @@ enum drm_i915_pmu_engine_sample { · 138 unmodified lines
139#define I915_PMU_ACTUAL_FREQUENCY __I915_PMU_OTHER(0)139#define I915_PMU_ACTUAL_FREQUENCY __I915_PMU_OTHER(0)
140#define I915_PMU_REQUESTED_FREQUENCY __I915_PMU_OTHER(1)140#define I915_PMU_REQUESTED_FREQUENCY __I915_PMU_OTHER(1)
141 141
142#define I915_PMU_LAST I915_PMU_REQUESTED_FREQUENCY142#define I915_PMU_INTERRUPTS __I915_PMU_OTHER(2)
143
144#define I915_PMU_LAST I915_PMU_INTERRUPTS
143 145
144/* Each region is a minimum of 16k, and there are at most 255 of them.146/* Each region is a minimum of 16k, and there are at most 255 of them.
145 */147 */

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