From patchwork Tue Sep 29 14:39:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Bragg X-Patchwork-Id: 7286661 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0342FBEEA4 for ; Tue, 29 Sep 2015 14:41:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1EAFF20747 for ; Tue, 29 Sep 2015 14:41:17 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 0638A20634 for ; Tue, 29 Sep 2015 14:41:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 564B36EB02; Tue, 29 Sep 2015 07:41:15 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pa0-f67.google.com (mail-pa0-f67.google.com [209.85.220.67]) by gabe.freedesktop.org (Postfix) with ESMTPS id EA89F6EB02; Tue, 29 Sep 2015 07:41:13 -0700 (PDT) Received: by pablk4 with SMTP id lk4so982567pab.1; Tue, 29 Sep 2015 07:41:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=2NUeePxHxJd1sfeWdoXzzavqqGI5F9davnOj3FbHVdE=; b=yCrooNQ7v6Vib0J1JVKnGh86CFnhyXYqpAaLT2EoHlu4ASFaoHkHTZoGRkMbVs6sW0 DR55As+ljxnxIoE+pltGZOZwfhNGEVbvleBq2biIiII+Feasazxf0iv9jz7roJUfRX6s ge2ub9rapkL8T5sW+2ziinf3jGNfpbJMQzCnLJp/btSRzchxUJSK/LakCxwcAK+oBoYF Dv2YVvU7gnJjubAlhR1D1p/KU8eW61Kmr4/UyhpeH+dVa7SGNvgS4W7F+MigLV3tz0/u scSAhxMmXGLbFBUYw2frU1Ycx+OP49mIkdCsy22XFejQwUcXgBDLmQZ53/ioFO39y1A6 0BFw== X-Received: by 10.68.234.167 with SMTP id uf7mr32908335pbc.51.1443537673435; Tue, 29 Sep 2015 07:41:13 -0700 (PDT) Received: from sixbynine.org (host-2-103-31-44.as13285.net. [2.103.31.44]) by smtp.gmail.com with ESMTPSA id tb9sm26154630pab.13.2015.09.29.07.41.11 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Sep 2015 07:41:13 -0700 (PDT) From: Robert Bragg To: intel-gfx@lists.freedesktop.org Date: Tue, 29 Sep 2015 15:39:09 +0100 Message-Id: <1443537549-6905-7-git-send-email-robert@sixbynine.org> X-Mailer: git-send-email 2.5.2 In-Reply-To: <1443537549-6905-1-git-send-email-robert@sixbynine.org> References: <1443537549-6905-1-git-send-email-robert@sixbynine.org> Cc: Mark Rutland , Matt Fleming , David Airlie , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Peter Zijlstra , Sourab Gupta , linux-api@vger.kernel.org, Zheng Yan , Daniel Vetter , Ingo Molnar , Alexander Shishkin Subject: [Intel-gfx] [RFC 6/6] drm/i915: add oa_event_min_timer_exponent sysctl X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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, + }, {} };