From patchwork Wed Apr 5 15:41:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Bragg X-Patchwork-Id: 9664505 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 5726D602B8 for ; Wed, 5 Apr 2017 15:41:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 46ED828581 for ; Wed, 5 Apr 2017 15:41:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A2A127FAE; Wed, 5 Apr 2017 15:41: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 40A0227FAE for ; Wed, 5 Apr 2017 15:41:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B705189CC1; Wed, 5 Apr 2017 15:41: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 BB22989CC1 for ; Wed, 5 Apr 2017 15:41:52 +0000 (UTC) Received: by mail-wr0-x243.google.com with SMTP id w43so3771615wrb.1 for ; Wed, 05 Apr 2017 08:41:52 -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=NSy9K4KCFcuQwj+FJAKkTupr4bRYujbfbwFND4gCcn0=; b=Ji9mOmZZitwktK6zExqHWN6GYA9VCfBg3Uewd5UT4fzkukUevFDBs/yNsZOsCKVfMQ 8T3jhu750eu7cjjl92VcC5VkFFRdeQXuooHNslHxaxRKp0lZ6zOD2PaSxN+cWeJs5zIr Fo1xZXEQK0ErTx2oAEp92aoRtXCuEP4E5ispjV0U6Dk+4aaiz2t8QTD4PFUKBhqx7n81 iOSYNwEwtiVT2E8V5x2OENJxdZ3c+aMcvODH1cYhphS4TCRIGpR5Qvh4z3hT4lyzNzrm BZs/uz3CoBxqGt/WQeuwplcGY9L2RYJYBHCsi0bWrr/tBaUk0kLfwzlaFg/YoYCJVkBj UQDg== 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=NSy9K4KCFcuQwj+FJAKkTupr4bRYujbfbwFND4gCcn0=; b=kndC38laVjsgRYOdUgXn7hdcYncZqu2dS+nLC6KLSWmHQXbeWxrasyyBw86WhktwYS z69BzBCOCJOT7SVJnGqEknFoStTgZpq83edvN8T44bsP8a1XgETuq8iQv5rqiGgAL5jl LCkdyp6tWHZu+l3BBt5HNnlzDuiUU+uw9l7PUKjF+K40aJpxxCNlrhLeSAlxUeVAjUvi dq6OPErut4soCFa12HpFC5uVSZX1F8Mv918Ppn+qiXRFPl6BXwBttHDz4sDDbYx9bHXG CLa4EEVayJGD1rOVJq7Hjhx/nfgndKChuPcIrM0qPcwCmpBJZbg45y5ESKTfaZ9LY+te Ks+g== X-Gm-Message-State: AFeK/H1rzx89/4AHx+XWI5tkha5L9A4Foov1rR6GBj5fu/Rn+c4Mfc49 qp4g/qVtyvU54pnyDBM= X-Received: by 10.28.100.196 with SMTP id y187mr19540842wmb.129.1491406911057; Wed, 05 Apr 2017 08:41:51 -0700 (PDT) Received: from sixbynine.org (host-78-151-19-25.as13285.net. [78.151.19.25]) by smtp.gmail.com with ESMTPSA id 140sm22894304wmk.12.2017.04.05.08.41.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Apr 2017 08:41:50 -0700 (PDT) From: Robert Bragg To: intel-gfx@lists.freedesktop.org Date: Wed, 5 Apr 2017 16:41:40 +0100 Message-Id: <20170405154140.28581-1-robert@sixbynine.org> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170327213050.vu4qdolmqtvgmktb@mwahaha> References: <20170327213050.vu4qdolmqtvgmktb@mwahaha> Subject: [Intel-gfx] [PATCH v3] 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 Instead of initializing and summarising the number of throttled messages in the driver _init / _fini we now do this when opening / closing an OA stream. --- >8 --- 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 known 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() v3: (Matt) init and summarise with stream init/close not driver init/fini Signed-off-by: Robert Bragg Reviewed-by: Matthew Auld --- drivers/gpu/drm/i915/i915_drv.h | 6 ++++++ drivers/gpu/drm/i915/i915_perf.c | 28 +++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 51a410911d81..51bd6c6034bb 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -2454,6 +2454,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 5738b99caa5b..3277a52ce98e 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; } @@ -913,6 +914,11 @@ static void i915_oa_stream_destroy(struct i915_perf_stream *stream) oa_put_render_ctx_id(stream); dev_priv->perf.oa.exclusive_stream = NULL; + + if (dev_priv->perf.oa.spurious_report_rs.missed) { + DRM_NOTE("%d spurious OA report notices suppressed due to ratelimiting\n", + dev_priv->perf.oa.spurious_report_rs.missed); + } } static void gen7_init_oa_buffer(struct drm_i915_private *dev_priv) @@ -1268,6 +1274,26 @@ static int i915_oa_stream_init(struct i915_perf_stream *stream, return -EINVAL; } + /* We set up some ratelimit state to potentially throttle any _NOTES + * about spurious, invalid OA reports which we don't forward to + * userspace. + * + * The initialization is associated with opening the stream (not driver + * init) considering we print a _NOTE about any throttling when closing + * the stream instead of waiting until driver _fini which no one would + * ever see. + * + * Using the same limiting factors as printk_ratelimit() + */ + ratelimit_state_init(&dev_priv->perf.oa.spurious_report_rs, + 5 * HZ, 10); + /* Since we use a DRM_NOTE for spurious reports it would be + * inconsistent to let __ratelimit() automatically print a warning for + * throttling. + */ + ratelimit_set_flags(&dev_priv->perf.oa.spurious_report_rs, + RATELIMIT_MSG_ON_RELEASE); + stream->sample_size = sizeof(struct drm_i915_perf_record_header); format_size = dev_priv->perf.oa.oa_formats[props->oa_format].size;