All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH 12/20] drm/i915/gt: Track the overall awake/busy time
Date: Thu, 10 Dec 2020 09:51:12 -0800	[thread overview]
Message-ID: <20201210175111.GA26573@sdutt-i7> (raw)
In-Reply-To: <20201207193824.18114-12-chris@chris-wilson.co.uk>

On Mon, Dec 07, 2020 at 07:38:16PM +0000, Chris Wilson wrote:
> Since we wake the GT up before executing a request, and go to sleep as
> soon as it is retired, the GT wake time not only represents how long the
> device is powered up, but also provides a summary, albeit an overestimate,
> of the device runtime (i.e. the rc0 time to compare against rc6 time).
> 
> v2: s/busy/awake/
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>  drivers/gpu/drm/i915/gt/debugfs_gt_pm.c  |  5 ++-
>  drivers/gpu/drm/i915/gt/intel_gt_pm.c    | 49 ++++++++++++++++++++++++
>  drivers/gpu/drm/i915/gt/intel_gt_pm.h    |  2 +
>  drivers/gpu/drm/i915/gt/intel_gt_types.h | 24 ++++++++++++
>  drivers/gpu/drm/i915/i915_debugfs.c      |  5 ++-
>  drivers/gpu/drm/i915/i915_pmu.c          |  6 +++
>  include/uapi/drm/i915_drm.h              |  1 +
>  7 files changed, 89 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gt/debugfs_gt_pm.c b/drivers/gpu/drm/i915/gt/debugfs_gt_pm.c
> index 174a24553322..8975717ace06 100644
> --- a/drivers/gpu/drm/i915/gt/debugfs_gt_pm.c
> +++ b/drivers/gpu/drm/i915/gt/debugfs_gt_pm.c
> @@ -11,6 +11,7 @@
>  #include "i915_drv.h"
>  #include "intel_gt.h"
>  #include "intel_gt_clock_utils.h"
> +#include "intel_gt_pm.h"
>  #include "intel_llc.h"
>  #include "intel_rc6.h"
>  #include "intel_rps.h"
> @@ -558,7 +559,9 @@ static int rps_boost_show(struct seq_file *m, void *data)
>  
>  	seq_printf(m, "RPS enabled? %s\n", yesno(intel_rps_is_enabled(rps)));
>  	seq_printf(m, "RPS active? %s\n", yesno(intel_rps_is_active(rps)));
> -	seq_printf(m, "GPU busy? %s\n", yesno(gt->awake));
> +	seq_printf(m, "GPU busy? %s, %llums\n",
> +		   yesno(gt->awake),
> +		   ktime_to_ms(intel_gt_get_awake_time(gt)));

I think it would be useful to print the total time the gt has been alive
too. This would give a nice comparison to total awake time which you
print here. Should be easy enough to do.

>  	seq_printf(m, "Boosts outstanding? %d\n",
>  		   atomic_read(&rps->num_waiters));
>  	seq_printf(m, "Interactive? %d\n", READ_ONCE(rps->power.interactive));
> diff --git a/drivers/gpu/drm/i915/gt/intel_gt_pm.c b/drivers/gpu/drm/i915/gt/intel_gt_pm.c
> index 274aa0dd7050..c94e8ac884eb 100644
> --- a/drivers/gpu/drm/i915/gt/intel_gt_pm.c
> +++ b/drivers/gpu/drm/i915/gt/intel_gt_pm.c
> @@ -39,6 +39,28 @@ static void user_forcewake(struct intel_gt *gt, bool suspend)
>  	intel_gt_pm_put(gt);
>  }
>  
> +static void runtime_begin(struct intel_gt *gt)
> +{
> +	local_irq_disable();
> +	write_seqcount_begin(&gt->stats.lock);
> +	gt->stats.start = ktime_get();
> +	gt->stats.active = true;
> +	write_seqcount_end(&gt->stats.lock);
> +	local_irq_enable();
> +}
> +
> +static void runtime_end(struct intel_gt *gt)
> +{
> +	local_irq_disable();
> +	write_seqcount_begin(&gt->stats.lock);
> +	gt->stats.active = false;
> +	gt->stats.total =
> +		ktime_add(gt->stats.total,
> +			  ktime_sub(ktime_get(), gt->stats.start));
> +	write_seqcount_end(&gt->stats.lock);
> +	local_irq_enable();
> +}
> +
>  static int __gt_unpark(struct intel_wakeref *wf)
>  {
>  	struct intel_gt *gt = container_of(wf, typeof(*gt), wakeref);
> @@ -67,6 +89,7 @@ static int __gt_unpark(struct intel_wakeref *wf)
>  	i915_pmu_gt_unparked(i915);
>  
>  	intel_gt_unpark_requests(gt);
> +	runtime_begin(gt);
>  
>  	return 0;
>  }
> @@ -79,6 +102,7 @@ static int __gt_park(struct intel_wakeref *wf)
>  
>  	GT_TRACE(gt, "\n");
>  
> +	runtime_end(gt);
>  	intel_gt_park_requests(gt);
>  
>  	i915_vma_parked(gt);
> @@ -106,6 +130,7 @@ static const struct intel_wakeref_ops wf_ops = {
>  void intel_gt_pm_init_early(struct intel_gt *gt)
>  {
>  	intel_wakeref_init(&gt->wakeref, gt->uncore->rpm, &wf_ops);
> +	seqcount_mutex_init(&gt->stats.lock, &gt->wakeref.mutex);
>  }
>  
>  void intel_gt_pm_init(struct intel_gt *gt)
> @@ -339,6 +364,30 @@ int intel_gt_runtime_resume(struct intel_gt *gt)
>  	return intel_uc_runtime_resume(&gt->uc);
>  }
>  
> +static ktime_t __intel_gt_get_awake_time(const struct intel_gt *gt)
> +{
> +	ktime_t total = gt->stats.total;
> +
> +	if (gt->stats.active)
> +		total = ktime_add(total,
> +				  ktime_sub(ktime_get(), gt->stats.start));
> +
> +	return total;
> +}
> +
> +ktime_t intel_gt_get_awake_time(const struct intel_gt *gt)
> +{
> +	unsigned int seq;
> +	ktime_t total;
> +
> +	do {
> +		seq = read_seqcount_begin(&gt->stats.lock);
> +		total = __intel_gt_get_awake_time(gt);
> +	} while (read_seqcount_retry(&gt->stats.lock, seq));
> +
> +	return total;
> +}
> +
>  #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
>  #include "selftest_gt_pm.c"
>  #endif
> diff --git a/drivers/gpu/drm/i915/gt/intel_gt_pm.h b/drivers/gpu/drm/i915/gt/intel_gt_pm.h
> index 60f0e2fbe55c..63846a856e7e 100644
> --- a/drivers/gpu/drm/i915/gt/intel_gt_pm.h
> +++ b/drivers/gpu/drm/i915/gt/intel_gt_pm.h
> @@ -58,6 +58,8 @@ int intel_gt_resume(struct intel_gt *gt);
>  void intel_gt_runtime_suspend(struct intel_gt *gt);
>  int intel_gt_runtime_resume(struct intel_gt *gt);
>  
> +ktime_t intel_gt_get_awake_time(const struct intel_gt *gt);
> +
>  static inline bool is_mock_gt(const struct intel_gt *gt)
>  {
>  	return I915_SELFTEST_ONLY(gt->awake == -ENODEV);
> diff --git a/drivers/gpu/drm/i915/gt/intel_gt_types.h b/drivers/gpu/drm/i915/gt/intel_gt_types.h
> index 6d39a4a11bf3..c7bde529feab 100644
> --- a/drivers/gpu/drm/i915/gt/intel_gt_types.h
> +++ b/drivers/gpu/drm/i915/gt/intel_gt_types.h
> @@ -87,6 +87,30 @@ struct intel_gt {
>  
>  	u32 pm_guc_events;
>  
> +	struct {
> +		bool active;
> +
> +		/**
> +		 * @lock: Lock protecting the below fields.
> +		 */
> +		seqcount_mutex_t lock;
> +
> +		/**
> +		 * @total: Total time this engine was busy.
> +		 *
> +		 * Accumulated time not counting the most recent block in cases
> +		 * where engine is currently busy (active > 0).
> +		 */
> +		ktime_t total;
> +
> +		/**
> +		 * @start: Timestamp of the last idle to active transition.
> +		 *
> +		 * Idle is defined as active == 0, active is active > 0.
> +		 */
> +		ktime_t start;
> +	} stats;
> +
>  	struct intel_engine_cs *engine[I915_NUM_ENGINES];
>  	struct intel_engine_cs *engine_class[MAX_ENGINE_CLASS + 1]
>  					    [MAX_ENGINE_INSTANCE + 1];
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> index f48df3545e39..c72160e3702f 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -858,9 +858,10 @@ static int i915_engine_info(struct seq_file *m, void *unused)
>  
>  	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
>  
> -	seq_printf(m, "GT awake? %s [%d]\n",
> +	seq_printf(m, "GT awake? %s [%d], %llums\n",
>  		   yesno(i915->gt.awake),
> -		   atomic_read(&i915->gt.wakeref.count));
> +		   atomic_read(&i915->gt.wakeref.count),
> +		   ktime_to_ms(intel_gt_get_awake_time(&i915->gt)));

Same here as above.

With that nit:
Reviewed-by: Matthew Brost <matthew.brost@intel.com>

>  	seq_printf(m, "CS timestamp frequency: %u Hz\n",
>  		   RUNTIME_INFO(i915)->cs_timestamp_frequency_hz);
>  
> diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c
> index 97bb4aaa5236..fc762eec9601 100644
> --- a/drivers/gpu/drm/i915/i915_pmu.c
> +++ b/drivers/gpu/drm/i915/i915_pmu.c
> @@ -516,6 +516,8 @@ config_status(struct drm_i915_private *i915, u64 config)
>  		if (!HAS_RC6(i915))
>  			return -ENODEV;
>  		break;
> +	case I915_PMU_GT_AWAKE:
> +		break;
>  	default:
>  		return -ENOENT;
>  	}
> @@ -623,6 +625,9 @@ static u64 __i915_pmu_event_read(struct perf_event *event)
>  		case I915_PMU_RC6_RESIDENCY:
>  			val = get_rc6(&i915->gt);
>  			break;
> +		case I915_PMU_GT_AWAKE:
> +			val = ktime_to_ns(intel_gt_get_awake_time(&i915->gt));
> +			break;
>  		}
>  	}
>  
> @@ -938,6 +943,7 @@ create_event_attributes(struct i915_pmu *pmu)
>  		__event(I915_PMU_REQUESTED_FREQUENCY, "requested-frequency", "M"),
>  		__event(I915_PMU_INTERRUPTS, "interrupts", NULL),
>  		__event(I915_PMU_RC6_RESIDENCY, "rc6-residency", "ns"),
> +		__event(I915_PMU_GT_AWAKE, "awake", "ns"),
>  	};
>  	static const struct {
>  		enum drm_i915_pmu_engine_sample sample;
> diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h
> index 6edcb2b6c708..04abd1ee89bf 100644
> --- a/include/uapi/drm/i915_drm.h
> +++ b/include/uapi/drm/i915_drm.h
> @@ -177,6 +177,7 @@ enum drm_i915_pmu_engine_sample {
>  #define I915_PMU_REQUESTED_FREQUENCY	__I915_PMU_OTHER(1)
>  #define I915_PMU_INTERRUPTS		__I915_PMU_OTHER(2)
>  #define I915_PMU_RC6_RESIDENCY		__I915_PMU_OTHER(3)
> +#define I915_PMU_GT_AWAKE		__I915_PMU_OTHER(4)
>  
>  #define I915_PMU_LAST /* Deprecated - do not use */ I915_PMU_RC6_RESIDENCY
>  
> -- 
> 2.20.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2020-12-10 17:57 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-07 19:38 [Intel-gfx] [PATCH 01/20] drm/i915/gem: Drop false !i915_vma_is_closed assertion Chris Wilson
2020-12-07 19:38 ` [Intel-gfx] [PATCH 02/20] drm/i915/gt: Replace direct submit with direct call to tasklet Chris Wilson
2020-12-07 19:38 ` [Intel-gfx] [PATCH 03/20] drm/i915/gt: Use virtual_engine during execlists_dequeue Chris Wilson
2020-12-07 19:38 ` [Intel-gfx] [PATCH 04/20] drm/i915/gt: Decouple inflight virtual engines Chris Wilson
2020-12-07 19:38 ` [Intel-gfx] [PATCH 05/20] drm/i915/gt: Defer schedule_out until after the next dequeue Chris Wilson
2020-12-07 19:38 ` [Intel-gfx] [PATCH 06/20] drm/i915/gt: Remove virtual breadcrumb before transfer Chris Wilson
2020-12-10 17:28   ` Matthew Brost
2020-12-07 19:38 ` [Intel-gfx] [PATCH 07/20] drm/i915/gt: Shrink the critical section for irq signaling Chris Wilson
2020-12-10 17:37   ` Matthew Brost
2020-12-11 11:21     ` Chris Wilson
2020-12-07 19:38 ` [Intel-gfx] [PATCH 08/20] drm/i915/gt: Resubmit the virtual engine on schedule-out Chris Wilson
2020-12-07 19:38 ` [Intel-gfx] [PATCH 09/20] drm/i915/gt: Simplify virtual engine handling for execlists_hold() Chris Wilson
2020-12-07 19:38 ` [Intel-gfx] [PATCH 10/20] drm/i915/gt: ce->inflight updates are now serialised Chris Wilson
2020-12-07 19:38 ` [Intel-gfx] [PATCH 11/20] drm/i915/gem: Drop free_work for GEM contexts Chris Wilson
2020-12-07 19:38 ` [Intel-gfx] [PATCH 12/20] drm/i915/gt: Track the overall awake/busy time Chris Wilson
2020-12-10 17:51   ` Matthew Brost [this message]
2020-12-13 19:51     ` Chris Wilson
2020-12-07 19:38 ` [Intel-gfx] [PATCH 13/20] drm/i915: Encode fence specific waitqueue behaviour into the wait.flags Chris Wilson
2020-12-10 18:03   ` Matthew Brost
2020-12-07 19:38 ` [Intel-gfx] [PATCH 14/20] drm/i915/gt: Track all timelines created using the HWSP Chris Wilson
2020-12-08 11:45   ` [Intel-gfx] [PATCH] " Chris Wilson
2020-12-07 19:38 ` [Intel-gfx] [PATCH 15/20] drm/i915/gt: Wrap intel_timeline.has_initial_breadcrumb Chris Wilson
2020-12-07 19:38 ` [Intel-gfx] [PATCH 16/20] drm/i915/gt: Track timeline GGTT offset separately from subpage offset Chris Wilson
2020-12-07 19:38 ` [Intel-gfx] [PATCH 17/20] drm/i915/gt: Add timeline "mode" Chris Wilson
2020-12-07 19:38 ` [Intel-gfx] [PATCH 18/20] drm/i915/gt: Use indices for writing into relative timelines Chris Wilson
2020-12-07 19:38 ` [Intel-gfx] [PATCH 19/20] drm/i915/selftests: Exercise relative timeline modes Chris Wilson
2020-12-07 19:38 ` [Intel-gfx] [PATCH 20/20] drm/i915/gt: Use ppHWSP for unshared non-semaphore related timelines Chris Wilson
2020-12-07 19:55 ` [Intel-gfx] ✗ Fi.CI.SPARSE: warning for series starting with [01/20] drm/i915/gem: Drop false !i915_vma_is_closed assertion Patchwork
2020-12-07 20:27 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2020-12-07 21:51 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
2020-12-08 13:32 ` [Intel-gfx] ✗ Fi.CI.SPARSE: warning for series starting with [01/20] drm/i915/gem: Drop false !i915_vma_is_closed assertion (rev2) Patchwork
2020-12-08 13:49 ` [Intel-gfx] [PATCH 01/20] drm/i915/gem: Drop false !i915_vma_is_closed assertion Tvrtko Ursulin
2020-12-08 14:01 ` [Intel-gfx] ✓ Fi.CI.BAT: success for series starting with [01/20] drm/i915/gem: Drop false !i915_vma_is_closed assertion (rev2) Patchwork
2020-12-08 16:42 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201210175111.GA26573@sdutt-i7 \
    --to=matthew.brost@intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.