[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1443537549-6905-7-git-send-email-robert@sixbynine.org>
Date: Tue, 29 Sep 2015 15:39:09 +0100
From: Robert Bragg <robert@...bynine.org>
To: intel-gfx@...ts.freedesktop.org
Cc: Daniel Vetter <daniel.vetter@...el.com>,
Chris Wilson <chris@...is-wilson.co.uk>,
Sourab Gupta <sourab.gupta@...el.com>,
Zhenyu Wang <zhenyuw@...ux.intel.com>,
Jani Nikula <jani.nikula@...ux.intel.com>,
David Airlie <airlied@...ux.ie>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...nel.org>,
Kan Liang <kan.liang@...el.com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Zheng Yan <zheng.z.yan@...el.com>,
Mark Rutland <mark.rutland@....com>,
Matt Fleming <matt.fleming@...el.com>,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org,
linux-api@...r.kernel.org
Subject: [RFC 6/6] drm/i915: add oa_event_min_timer_exponent sysctl
The minimal sampling period is now configurable via a
dev.i915.oa_event_min_timer_exponent sysctl parameter.
Following the precedent set by perf, the default is the minimum that
won't (on its own) exceed the default kernel.perf_event_max_sample_rate
default of 100000 samples/s.
Signed-off-by: Robert Bragg <robert@...bynine.org>
---
drivers/gpu/drm/i915/i915_perf.c | 37 ++++++++++++++++++++++++++++---------
1 file changed, 28 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
index ab82857..5ef7d92 100644
--- a/drivers/gpu/drm/i915/i915_perf.c
+++ b/drivers/gpu/drm/i915/i915_perf.c
@@ -42,6 +42,23 @@ static u32 i915_perf_event_paranoid = true;
#define OA_EXPONENT_MAX 0x3f
+/* for sysctl proc_dointvec_minmax of i915_oa_event_min_timer_exponent */
+static int zero;
+static int oa_exponent_max = OA_EXPONENT_MAX;
+
+/* Theoretically we can program the OA unit to sample every 160ns but don't
+ * allow that by default unless root...
+ *
+ * The period is derived from the exponent as:
+ *
+ * period = 80ns * 2^(exponent + 1)
+ *
+ * Referring to perf's kernel.perf_event_max_sample_rate for a precedent
+ * (100000 by default); with an OA exponent of 6 we get a period of 10.240
+ * microseconds - just under 100000Hz
+ */
+static u32 i915_oa_event_min_timer_exponent = 6;
+
static struct i915_oa_format hsw_oa_formats[I915_OA_FORMAT_MAX] = {
[I915_OA_FORMAT_A13] = { 0, 64 },
[I915_OA_FORMAT_A29] = { 1, 128 },
@@ -674,15 +691,8 @@ static int i915_oa_event_init(struct i915_perf_event *event,
if (period_exponent > OA_EXPONENT_MAX)
return -EINVAL;
- /* Theoretically we can program the OA unit to sample every
- * 160ns but don't allow that by default unless root...
- *
- * Referring to perf's kernel.perf_event_max_sample_rate for
- * a precedent (100000 by default); with an OA exponent of
- * 6 we get a period of 10.240 microseconds -just under
- * 100000Hz
- */
- if (period_exponent < 6 && !capable(CAP_SYS_ADMIN)) {
+ if (period_exponent < i915_oa_event_min_timer_exponent &&
+ !capable(CAP_SYS_ADMIN)) {
DRM_ERROR("Sampling period too high without root privileges\n");
return -EACCES;
}
@@ -1113,6 +1123,15 @@ static struct ctl_table oa_table[] = {
.mode = 0644,
.proc_handler = proc_dointvec,
},
+ {
+ .procname = "oa_event_min_timer_exponent",
+ .data = &i915_oa_event_min_timer_exponent,
+ .maxlen = sizeof(i915_oa_event_min_timer_exponent),
+ .mode = 0644,
+ .proc_handler = proc_dointvec_minmax,
+ .extra1 = &zero,
+ .extra2 = &oa_exponent_max,
+ },
{}
};
--
2.5.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists