From patchwork Thu Mar 23 19:25:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Bragg X-Patchwork-Id: 9641831 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3F75B601E9 for ; Thu, 23 Mar 2017 19:25:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3020026E51 for ; Thu, 23 Mar 2017 19:25:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F15B28403; Thu, 23 Mar 2017 19:25:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8687726E51 for ; Thu, 23 Mar 2017 19:25:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 11A316EB34; Thu, 23 Mar 2017 19:25:53 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wr0-x243.google.com (mail-wr0-x243.google.com [IPv6:2a00:1450:400c:c0c::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2F9166EB34 for ; Thu, 23 Mar 2017 19:25:51 +0000 (UTC) Received: by mail-wr0-x243.google.com with SMTP id u1so204659wra.3 for ; Thu, 23 Mar 2017 12:25:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=rhQmdqC8G5oAy4LC/aP4qcwSPyjx4w1h98LoOFKB/g0=; b=VwSLrlYXjkY6gP3M1ruIvSCXml4DMxYdIHo1nBcJHq0C9YxWAT7KMUAIwP379K0qnC gerfQ14tlvXuseu/LhX1cBbclGYwNnQx9QDBmrtXifbzv704hnr6tW6WIivarH1fPtUE gr9A1z3dq2Fw0XoBJp8cVRLHyfaWvBNKmBQ8E89k4eOjM/fZC4cY9OArL9aaJRONOGj7 tS5w79dXrI6xZ4VqmLMkmxSVfFSAutXelFpJ2tEaFUtJy9+PrxVz11BSBshlS515QFwi KOGWm+BX+Wndfhpj4eKy0u/CCEcJUwX7YmRJSmvDyIY3vyIJTym6wZoK9fwrNalU8NBT tKsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=rhQmdqC8G5oAy4LC/aP4qcwSPyjx4w1h98LoOFKB/g0=; b=JBOAe2ed+kEmGS/dVufYYjQO7QgkpsUZ4BXYP9QLYVOVVTxdDUR049F0HmzEc/Q5Q+ fs1wa8IByjt9d9EGea4IFf2/deCVlEqnGA63JKQz+J7r9JSwMvsYgDwlVsWiYNYD4X/L t2vntwLgcvSxz3BHnZF1gcnDWJGUlh8BnQP13WwUslsNiwTdSoyuPExbJgjjy/7QeU2I 53ACIgyryOI8P7iXu63B2MiTe7OsudtacCLM16OPC/V80exSsptNcEEtEiwc5TGIUpoN rqiV304G/5GMQwIeLsevKq4TT8VJnlweoTlddEXf5h+e6+53VmL5DU3u0pw0E4F+F73j NwXA== X-Gm-Message-State: AFeK/H0h07LIy2/yhrQ+iMq341vEyElYIAs7/lZadOY7oicZUD594sjCeoHo7FcPSBQDGA== X-Received: by 10.223.174.131 with SMTP id y3mr4148859wrc.40.1490297149592; Thu, 23 Mar 2017 12:25:49 -0700 (PDT) Received: from sixbynine.org (cpc26-heme10-2-0-cust305.9-1.cable.virginm.net. [86.3.57.50]) by smtp.gmail.com with ESMTPSA id m80sm1676955wma.14.2017.03.23.12.25.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Mar 2017 12:25:49 -0700 (PDT) From: Robert Bragg To: intel-gfx@lists.freedesktop.org Date: Thu, 23 Mar 2017 19:25:35 +0000 Message-Id: <20170323192535.3680-1-robert@sixbynine.org> X-Mailer: git-send-email 2.12.0 In-Reply-To: References: Subject: [Intel-gfx] [PATCH v2] drm/i915/perf: rate limit spurious oa report notice 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-Virus-Scanned: ClamAV using ClamSMTP This change is pre-emptively aiming to avoid a potential cause of kernel logging noise in case some condition were to result in us seeing invalid OA reports. The workaround for the OA unit's tail pointer race condition is what avoids the primary know cause of invalid reports being seen and with that in place we aren't expecting to see this notice but it can't be entirely ruled out. Just in case some condition does lead to the notice then it's likely that it will be triggered repeatedly while attempting to append a sequence of reports and depending on the configured OA sampling frequency that might be a large number of repeat notices. v2: (Chris) avoid inconsistent warning on throttle with printk_ratelimit() Signed-off-by: Robert Bragg Reviewed-by: Matthew Auld --- drivers/gpu/drm/i915/i915_drv.h | 6 ++++++ drivers/gpu/drm/i915/i915_perf.c | 17 ++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index a7b49cad6ab2..a7986c0c29ad 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -2471,6 +2471,12 @@ struct drm_i915_private { wait_queue_head_t poll_wq; bool pollin; + /** + * For rate limiting any notifications of spurious + * invalid OA reports + */ + struct ratelimit_state spurious_report_rs; + bool periodic; int period_exponent; diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c index c09a7c9b61d9..36d07ca68029 100644 --- a/drivers/gpu/drm/i915/i915_perf.c +++ b/drivers/gpu/drm/i915/i915_perf.c @@ -632,7 +632,8 @@ static int gen7_append_oa_reports(struct i915_perf_stream *stream, * copying it to userspace... */ if (report32[0] == 0) { - DRM_NOTE("Skipping spurious, invalid OA report\n"); + if (__ratelimit(&dev_priv->perf.oa.spurious_report_rs)) + DRM_NOTE("Skipping spurious, invalid OA report\n"); continue; } @@ -2144,6 +2145,15 @@ void i915_perf_init(struct drm_i915_private *dev_priv) if (!IS_HASWELL(dev_priv)) return; + /* Using the same limiting factors as printk_ratelimit() */ + ratelimit_state_init(&dev_priv->perf.oa.spurious_report_rs, + 5 * HZ, 10); + /* We use a DRM_NOTE for spurious reports so it would be + * inconsistent to print a warning for throttling. + */ + ratelimit_set_flags(&dev_priv->perf.oa.spurious_report_rs, + RATELIMIT_MSG_ON_RELEASE); + hrtimer_init(&dev_priv->perf.oa.poll_check_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); dev_priv->perf.oa.poll_check_timer.function = oa_poll_check_timer_cb; @@ -2182,6 +2192,11 @@ void i915_perf_fini(struct drm_i915_private *dev_priv) if (!dev_priv->perf.initialized) return; + if (dev_priv->perf.oa.spurious_report_rs.missed) { + DRM_NOTE("%d spurious OA report notices suppressed due to ratelimiting", + dev_priv->perf.oa.spurious_report_rs.missed); + } + unregister_sysctl_table(dev_priv->perf.sysctl_header); memset(&dev_priv->perf.oa.ops, 0, sizeof(dev_priv->perf.oa.ops));