From patchwork Thu Apr 5 12:39:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 10324519 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 8FB8B600CB for ; Thu, 5 Apr 2018 12:39:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F43F29181 for ; Thu, 5 Apr 2018 12:39:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 70B2D29184; Thu, 5 Apr 2018 12:39:44 +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 0A4FD29181 for ; Thu, 5 Apr 2018 12:39:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 064E86E487; Thu, 5 Apr 2018 12:39:42 +0000 (UTC) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mail-wr0-x242.google.com (mail-wr0-x242.google.com [IPv6:2a00:1450:400c:c0c::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1D7C96E762 for ; Thu, 5 Apr 2018 12:39:40 +0000 (UTC) Received: by mail-wr0-x242.google.com with SMTP id u46so28171438wrc.11 for ; Thu, 05 Apr 2018 05:39:39 -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=TGfTsWCkq6iqcAoJHNvpaHaGmascRUj7UnKyKzRt8CA=; b=pEL7xNaS9qh7lm/sJnXwIiOpYgpkS9qGBFYpq34emqJi/qpxxLcj/Jtf1DEqFZ0rJJ 3dY/RtSMc617A2te2crehHX7S1lGRfOlfSKjs5HKDhl1PZ+XsPs9yd2tGcJA3vBbCNEQ tQFQL2KkNQI7cVg6C1xRUZYYzexu6x+EXtK9GEY/CmRgButb6u2tVACKSSqVRh+r1Uky 3Bt6SBc/1cBXELj8WkwHazEJ2su02voVdabzlSN2X+4fkvnSy0rKVmrjKg2A0RVDAY/V 5lqc0X466yZJgPEz/4rC8s2MYjtEIfsdQMLaJgfgJzV5C3YiG3H7iV9MDcmAr3sasYNg /59g== 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=TGfTsWCkq6iqcAoJHNvpaHaGmascRUj7UnKyKzRt8CA=; b=lqN9tbaIUmSEAm8CDyWUBV7iQH6eFtiTO5cIq/llLdd3x9d2CpuklWibhmctgvN5+A 50GyrHWy1JByVd5X3sH/fIcyW5dVfiR+K/vs+lL0/SXdyPaMDW/6peAmSNzjmR1I9nU8 TmbR/rNmLW4uk/NAKHcPRwkvSA8nHdzyiugad5qPKOe1/bK4RhjFRH4bzJTLhHzcEI1C ihh/Ade3jAQ0Qmc7srH+Ctice0NVaj6FmWtYhUpHO2i26dJ2aare9WfYrwmes280GLVj IWNqaWtVhhO6kf7R75BbDvWJk7lX8/WpzHNZ3zRu8e94Z11hYYqETdFzlABCh9ER2DtU oquA== X-Gm-Message-State: AElRT7HCR0Go+r9AUiKRE84D+gtlcZpmiHtXzkWFYUvs8I8hDSMivigl hRdNZt2mB9hIAxWzm5+cL4Dnxqh+ X-Google-Smtp-Source: AIpwx4/vP6HNfKP8AdZKuLKBwhVrtJTuaVjXYPAbMDWNNCJGAxij85Udxdl7BlZfbhdWdEcrrih3dQ== X-Received: by 10.223.185.21 with SMTP id k21mr16867439wrf.116.1522931978438; Thu, 05 Apr 2018 05:39:38 -0700 (PDT) Received: from localhost.localdomain ([95.146.144.186]) by smtp.gmail.com with ESMTPSA id n21sm9800333wmi.37.2018.04.05.05.39.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Apr 2018 05:39:37 -0700 (PDT) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org Date: Thu, 5 Apr 2018 13:39:22 +0100 Message-Id: <20180405123923.22671-7-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180405123923.22671-1-tvrtko.ursulin@linux.intel.com> References: <20180405123923.22671-1-tvrtko.ursulin@linux.intel.com> Subject: [Intel-gfx] [PATCH 6/7] drm/i915/pmu: Add running counter X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 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 We add a PMU counter to expose the number of requests currently executing on the GPU. This is useful to analyze the overall load of the system. v2: * Rebase. * Drop floating point constant. (Chris Wilson) v3: * Change scale to 1024 for faster arithmetics. (Chris Wilson) Signed-off-by: Tvrtko Ursulin Reviewed-by: Chris Wilson --- drivers/gpu/drm/i915/i915_pmu.c | 18 ++++++++++++++++-- drivers/gpu/drm/i915/intel_ringbuffer.h | 2 +- include/uapi/drm/i915_drm.h | 5 +++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c index afc561e1aa92..bd7e695fc663 100644 --- a/drivers/gpu/drm/i915/i915_pmu.c +++ b/drivers/gpu/drm/i915/i915_pmu.c @@ -17,7 +17,8 @@ BIT(I915_SAMPLE_WAIT) | \ BIT(I915_SAMPLE_SEMA) | \ BIT(I915_SAMPLE_QUEUED) | \ - BIT(I915_SAMPLE_RUNNABLE)) + BIT(I915_SAMPLE_RUNNABLE) | \ + BIT(I915_SAMPLE_RUNNING)) #define ENGINE_SAMPLE_BITS (1 << I915_PMU_SAMPLE_BITS) @@ -211,6 +212,11 @@ static void engines_sample(struct drm_i915_private *dev_priv) update_sample(&engine->pmu.sample[I915_SAMPLE_RUNNABLE], I915_SAMPLE_RUNNABLE_DIVISOR, engine->request_stats.runnable); + + if (engine->pmu.enable & BIT(I915_SAMPLE_RUNNING)) + update_sample(&engine->pmu.sample[I915_SAMPLE_RUNNING], + I915_SAMPLE_RUNNING_DIVISOR, + last_seqno - current_seqno); } if (fw) @@ -310,6 +316,7 @@ engine_event_status(struct intel_engine_cs *engine, case I915_SAMPLE_WAIT: case I915_SAMPLE_QUEUED: case I915_SAMPLE_RUNNABLE: + case I915_SAMPLE_RUNNING: break; case I915_SAMPLE_SEMA: if (INTEL_GEN(engine->i915) < 6) @@ -513,7 +520,8 @@ static u64 __i915_pmu_event_read(struct perf_event *event) } if (sample == I915_SAMPLE_QUEUED || - sample == I915_SAMPLE_RUNNABLE) + sample == I915_SAMPLE_RUNNABLE || + sample == I915_SAMPLE_RUNNING) val = div_u64(val, FREQUENCY); } else { switch (event->attr.config) { @@ -810,6 +818,7 @@ add_pmu_attr(struct perf_pmu_events_attr *attr, const char *name, /* No brackets or quotes below please. */ #define I915_SAMPLE_QUEUED_SCALE 0.0009765625 #define I915_SAMPLE_RUNNABLE_SCALE 0.0009765625 +#define I915_SAMPLE_RUNNING_SCALE 0.0009765625 static struct attribute ** create_event_attributes(struct drm_i915_private *i915) @@ -837,6 +846,8 @@ create_event_attributes(struct drm_i915_private *i915) __stringify(I915_SAMPLE_QUEUED_SCALE)), __engine_event_scale(I915_SAMPLE_RUNNABLE, "runnable", __stringify(I915_SAMPLE_RUNNABLE_SCALE)), + __engine_event_scale(I915_SAMPLE_RUNNING, "running", + __stringify(I915_SAMPLE_RUNNING_SCALE)), }; unsigned int count = 0; struct perf_pmu_events_attr *pmu_attr = NULL, *pmu_iter; @@ -852,6 +863,9 @@ create_event_attributes(struct drm_i915_private *i915) BUILD_BUG_ON(I915_SAMPLE_RUNNABLE_DIVISOR != (1 / I915_SAMPLE_RUNNABLE_SCALE)); + BUILD_BUG_ON(I915_SAMPLE_RUNNING_DIVISOR != + (1 / I915_SAMPLE_RUNNING_SCALE)); + /* Count how many counters we will be exposing. */ for (i = 0; i < ARRAY_SIZE(events); i++) { if (!config_status(i915, events[i].config)) diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h index 5af93e88c90f..d50b31eb43a5 100644 --- a/drivers/gpu/drm/i915/intel_ringbuffer.h +++ b/drivers/gpu/drm/i915/intel_ringbuffer.h @@ -414,7 +414,7 @@ struct intel_engine_cs { * * Our internal timer stores the current counters in this field. */ -#define I915_ENGINE_SAMPLE_MAX (I915_SAMPLE_RUNNABLE + 1) +#define I915_ENGINE_SAMPLE_MAX (I915_SAMPLE_RUNNING + 1) struct i915_pmu_sample sample[I915_ENGINE_SAMPLE_MAX]; } pmu; diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h index cf0265b20e37..9a00c30e4071 100644 --- a/include/uapi/drm/i915_drm.h +++ b/include/uapi/drm/i915_drm.h @@ -113,11 +113,13 @@ enum drm_i915_pmu_engine_sample { I915_SAMPLE_SEMA = 2, I915_SAMPLE_QUEUED = 3, I915_SAMPLE_RUNNABLE = 4, + I915_SAMPLE_RUNNING = 5, }; /* Divide counter value by divisor to get the real value. */ #define I915_SAMPLE_QUEUED_DIVISOR (1024) #define I915_SAMPLE_RUNNABLE_DIVISOR (1024) +#define I915_SAMPLE_RUNNING_DIVISOR (1024) #define I915_PMU_SAMPLE_BITS (4) #define I915_PMU_SAMPLE_MASK (0xf) @@ -145,6 +147,9 @@ enum drm_i915_pmu_engine_sample { #define I915_PMU_ENGINE_RUNNABLE(class, instance) \ __I915_PMU_ENGINE(class, instance, I915_SAMPLE_RUNNABLE) +#define I915_PMU_ENGINE_RUNNING(class, instance) \ + __I915_PMU_ENGINE(class, instance, I915_SAMPLE_RUNNING) + #define __I915_PMU_OTHER(x) (__I915_PMU_ENGINE(0xff, 0xff, 0xf) + 1 + (x)) #define I915_PMU_ACTUAL_FREQUENCY __I915_PMU_OTHER(0)