From: Robert Bragg <robert@sixbynine.org>
To: intel-gfx@lists.freedesktop.org
Cc: Mark Rutland <mark.rutland@arm.com>,
Matt Fleming <matt.fleming@intel.com>,
David Airlie <airlied@linux.ie>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
Peter Zijlstra <peterz@infradead.org>,
Sourab Gupta <sourab.gupta@intel.com>,
linux-api@vger.kernel.org, Zheng Yan <zheng.z.yan@intel.com>,
Daniel Vetter <daniel.vetter@intel.com>,
Ingo Molnar <mingo@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>
Subject: [RFC 6/6] drm/i915: add oa_event_min_timer_exponent sysctl
Date: Tue, 29 Sep 2015 15:39:09 +0100 [thread overview]
Message-ID: <1443537549-6905-7-git-send-email-robert@sixbynine.org> (raw)
In-Reply-To: <1443537549-6905-1-git-send-email-robert@sixbynine.org>
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@sixbynine.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
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2015-09-29 14:39 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-29 14:39 [RFC 0/6] Non perf based Gen Graphics OA unit driver Robert Bragg
2015-09-29 14:39 ` [RFC 1/6] drm/i915: Add i915 perf infrastructure Robert Bragg
2015-09-29 14:39 ` [RFC 2/6] drm/i915: rename OACONTROL GEN7_OACONTROL Robert Bragg
2015-09-29 14:39 ` [RFC 3/6] drm/i915: Add static '3D' Haswell OA unit config Robert Bragg
2015-09-29 14:39 ` [RFC 4/6] drm/i915: Add i915 perf event for Haswell OA unit Robert Bragg
2015-09-29 14:55 ` [Intel-gfx] " kbuild test robot
2015-09-29 15:18 ` Peter Zijlstra
2015-09-29 23:19 ` [kbuild-all] " Fengguang Wu
[not found] ` <1443537549-6905-1-git-send-email-robert-St23OQVBDYPNLxjTenLetw@public.gmane.org>
2015-09-29 14:39 ` [RFC 5/6] drm/i915: Add dev.i915.perf_event_paranoid sysctl option Robert Bragg
2015-09-30 8:30 ` [RFC 0/6] Non perf based Gen Graphics OA unit driver Chris Wilson
2015-09-30 13:36 ` Robert Bragg
2015-09-29 14:39 ` Robert Bragg [this message]
2015-09-30 3:23 ` Zhenyu Wang
2015-10-16 9:43 ` Peter Zijlstra
2015-10-16 10:02 ` Ingo Molnar
2015-10-16 10:33 ` Peter Zijlstra
[not found] ` <20151016103345.GS3816-ndre7Fmf5hadTX5a5knrm8zTDFooKrT+cvkQGrU6aU0@public.gmane.org>
2015-10-16 12:08 ` Robert Bragg
2015-10-20 20:16 ` Robert Bragg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1443537549-6905-7-git-send-email-robert@sixbynine.org \
--to=robert@sixbynine.org \
--cc=airlied@linux.ie \
--cc=alexander.shishkin@linux.intel.com \
--cc=daniel.vetter@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=matt.fleming@intel.com \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=sourab.gupta@intel.com \
--cc=zheng.z.yan@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).