From patchwork Fri Sep 29 12:34:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 9977933 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 38D7A6034B for ; Fri, 29 Sep 2017 12:35:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31CE62984F for ; Fri, 29 Sep 2017 12:35:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2682D2985A; Fri, 29 Sep 2017 12:35:17 +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 D542D2984F for ; Fri, 29 Sep 2017 12:35:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 627416EB7F; Fri, 29 Sep 2017 12:35:16 +0000 (UTC) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 898006EB7F for ; Fri, 29 Sep 2017 12:35:15 +0000 (UTC) Received: by mail-wm0-x242.google.com with SMTP id t69so3092891wmt.2 for ; Fri, 29 Sep 2017 05:35:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ursulin-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/7Eqj3cAHP+hiLZZKJQ0ESlQb1U7wefFywLpIzoCEhA=; b=eIi/fIl6tNJc2dBJuEJ4UWLIV4n1LBNMWNSEDVutN58cQZFEdk2mwoyV/7Khv09RIa 0fvshZPliP6z0vUQ9tiGuy86LvZEkiMzmxmdOa8FEEV4lV/FuYqnne/LblI3CSxuGlfj djrC0o4S2lzZjH3VF1UqB50Lofq9bQFUyK3kHZf/YgOaAVn5cA8R/z+wT3ooopobO369 wFWOySWDAc1dvkH40oinJPo0sDOhvmVNHgcutuECD0MHAxMZWgHwBYYDMP/MJZSKoOKQ vvmMxrGGLuhZv8OoPycgbosAq5TTCKUdQfXtA4CjMVracm/91iHKm0XG9Kh2g5nKFcxv JXEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/7Eqj3cAHP+hiLZZKJQ0ESlQb1U7wefFywLpIzoCEhA=; b=U+p+CEHvz67uJiMwGYhYyAaLcNkwWB4xdQN8pzWxG0smuo2fYz/9qbfDUDTn41a6OU KMHBZw506sAy3sOcELNCeT9l3YI0WQ+Vh0U+1DmaX9LYaLrHXx9JR0CK0GQ0NG0O/U/P QAUKYTenFtyOVr7Wke8RUD2sOZFIPK6/EOUIeI1Yes3OKf5K/XpNkBb0dz3OGcFHEo3c TjEQBCF33I961+rS+kdbshlxUdh23KBmIC1rf7OuCgiHNi2zag/344S9KC/wNm5ckEwo zyPjWdX4cMIWXeOy5W3DHIwo4EME9iJ5OJi+WlmxmagueubCZuVyQKq4VJeKWlI/qjQm SQig== X-Gm-Message-State: AMCzsaW4nPRruG2irw4DshyADYrSnEltwGLFlgWixT0lBwKBf7jwgXnR aEr3Ue3mJIuM9tUr+A+7hBiiyTmz X-Google-Smtp-Source: AOwi7QCPD+sRF01RHoqGBbGBWcJjnWqDENnNDQ+5qCzsGVpCwwDg38ZHfhLanxspsBug8yhSYDd4sA== X-Received: by 10.28.132.141 with SMTP id g135mr3774025wmd.37.1506688514059; Fri, 29 Sep 2017 05:35:14 -0700 (PDT) Received: from t460p.intel ([95.146.151.158]) by smtp.gmail.com with ESMTPSA id j73sm8196637wmf.15.2017.09.29.05.35.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Sep 2017 05:35:13 -0700 (PDT) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org Date: Fri, 29 Sep 2017 13:34:58 +0100 Message-Id: <20170929123500.3186-9-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20170929123500.3186-1-tvrtko.ursulin@linux.intel.com> References: <20170929123500.3186-1-tvrtko.ursulin@linux.intel.com> Subject: [Intel-gfx] [PATCH 08/10] drm/i915/pmu: Add interrupt count metric 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 From: Tvrtko Ursulin For clients like intel-gpu-overlay it is easier to read the count via the perf API than having to parse /proc. Signed-off-by: Tvrtko Ursulin Reviewed-by: Chris Wilson --- drivers/gpu/drm/i915/i915_pmu.c | 23 +++++++++++++++++++++++ include/uapi/drm/i915_drm.h | 4 +++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c index 4c9b9ae09b23..4c37c8b3cc54 100644 --- a/drivers/gpu/drm/i915/i915_pmu.c +++ b/drivers/gpu/drm/i915/i915_pmu.c @@ -276,6 +276,22 @@ static enum hrtimer_restart i915_sample(struct hrtimer *hrtimer) return HRTIMER_RESTART; } +static u64 count_interrupts(struct drm_i915_private *i915) +{ + /* open-coded kstat_irqs() */ + struct irq_desc *desc = irq_to_desc(i915->drm.pdev->irq); + u64 sum = 0; + int cpu; + + if (!desc || !desc->kstat_irqs) + return 0; + + for_each_possible_cpu(cpu) + sum += *per_cpu_ptr(desc->kstat_irqs, cpu); + + return sum; +} + static void i915_pmu_event_destroy(struct perf_event *event) { WARN_ON(event->parent); @@ -342,6 +358,8 @@ static int i915_pmu_event_init(struct perf_event *event) if (INTEL_GEN(i915) < 6) ret = -ENODEV; break; + case I915_PMU_INTERRUPTS: + break; default: ret = -ENOENT; break; @@ -391,6 +409,9 @@ static u64 __i915_pmu_event_read(struct perf_event *event) div_u64(i915->pmu.sample[__I915_SAMPLE_FREQ_REQ].cur, FREQUENCY); break; + case I915_PMU_INTERRUPTS: + val = count_interrupts(i915); + break; } } @@ -643,6 +664,8 @@ static struct attribute *i915_pmu_events_attrs[] = { I915_EVENT(actual-frequency, I915_PMU_ACTUAL_FREQUENCY, "MHz"), I915_EVENT(requested-frequency, I915_PMU_REQUESTED_FREQUENCY, "MHz"), + I915_EVENT_ATTR(interrupts, I915_PMU_INTERRUPTS), + NULL, }; diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h index 9f139f8ad19a..22b3e5e5bef8 100644 --- a/include/uapi/drm/i915_drm.h +++ b/include/uapi/drm/i915_drm.h @@ -132,7 +132,9 @@ enum drm_i915_pmu_engine_sample { #define I915_PMU_ACTUAL_FREQUENCY __I915_PMU_OTHER(0) #define I915_PMU_REQUESTED_FREQUENCY __I915_PMU_OTHER(1) -#define I915_PMU_LAST I915_PMU_REQUESTED_FREQUENCY +#define I915_PMU_INTERRUPTS __I915_PMU_OTHER(2) + +#define I915_PMU_LAST I915_PMU_INTERRUPTS /* Each region is a minimum of 16k, and there are at most 255 of them. */