From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Alan Previn <alan.previn.teres.alexis@intel.com>,
intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [Intel-gfx v2 1/1] drm/i915/guc: Don't update engine busyness stats too frequently
Date: Mon, 20 Jun 2022 09:46:30 +0100 [thread overview]
Message-ID: <ae671cd8-df50-ea8b-0a3f-bd8ec1bea049@linux.intel.com> (raw)
In-Reply-To: <20220618054345.2086300-2-alan.previn.teres.alexis@intel.com>
On 18/06/2022 06:43, Alan Previn wrote:
> Using igt's gem-create and with additional patches to track object
> creation time, it was measured that guc_update_engine_gt_clks was
> getting called over 188 thousand times in the span of 15 seconds
> (running the test three times).
>
> Get a jiffies sample on every trigger and ensure we skip sampling
> if we are being called too soon. Use half of the ping_delay as a
> safe threshold.
>
> NOTE: with this change, the number of calls went down to just 14
> over the same span of time (matching the original intent of running
> about once every 24 seconds, at 19.2Mhz GT freq, per engine).
It would be beneficial to record the root cause. Both frequency of
parking/unparking caused by <insert what> and lmem access cost.
> Signed-off-by: Alan Previn <alan.previn.teres.alexis@intel.com>
> ---
> drivers/gpu/drm/i915/gt/uc/intel_guc.h | 8 ++++++++
> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c | 12 ++++++++++++
> 2 files changed, 20 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc.h b/drivers/gpu/drm/i915/gt/uc/intel_guc.h
> index 966e69a8b1c1..26f3e4403de7 100644
> --- a/drivers/gpu/drm/i915/gt/uc/intel_guc.h
> +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc.h
> @@ -230,6 +230,14 @@ struct intel_guc {
> * @shift: Right shift value for the gpm timestamp
> */
> u32 shift;
> +
> + /**
> + * @last_jiffies: jiffies at last actual stats collection time
> + * We use this timestamp to ensure we don't oversample the
> + * stats because runtime power management events can trigger
> + * stats collection at much higher rates than required.
> + */
> + u64 last_stat_jiffs;
Why the new "jiffs" naming and not the usual jiffies?
Otherwise a good comment - just align the member name with the kerneldoc
name.
> } timestamp;
>
> #ifdef CONFIG_DRM_I915_SELFTEST
> diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
> index e62ea35513ea..05c945f14ef5 100644
> --- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
> +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
> @@ -1314,6 +1314,8 @@ static void __update_guc_busyness_stats(struct intel_guc *guc)
> unsigned long flags;
> ktime_t unused;
>
> + guc->timestamp.last_stat_jiffs = get_jiffies_64();
Why the 64 bit flavour? It's a first in i915 but it doesn't feel so special.
> +
> spin_lock_irqsave(&guc->timestamp.lock, flags);
>
> guc_update_pm_timestamp(guc, &unused);
> @@ -1386,6 +1388,16 @@ void intel_guc_busyness_park(struct intel_gt *gt)
> return;
>
> cancel_delayed_work(&guc->timestamp.work);
> +
> + /*
> + * Before parking, we should sample engine busyness stats if we need to.
> + * We can skip it if we are less than half a ping from the last time we
> + * sampled the business stats.
busyness
> + */
> + if (guc->timestamp.last_stat_jiffs && (get_jiffies_64() - guc->timestamp.last_stat_jiffs <
> + (guc->timestamp.ping_delay >> 1)))
> + return;
1)
Recommend a division instead of a shift.
2)
Is there a time_after() macro for this?
3)
Should the logic be contained/consolidated in __update_guc_busyness_stats?
There is cancel_delayed_work in there - is it okay for that to be
bypassed from here?
Regards,
Tvrtko
> +
> __update_guc_busyness_stats(guc);
> }
>
next prev parent reply other threads:[~2022-06-20 8:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-18 5:43 [Intel-gfx] [Intel-gfx v2 0/1] drm/i915/guc: Don't update engine busyness stats too frequently Alan Previn
2022-06-18 5:43 ` [Intel-gfx] [Intel-gfx v2 1/1] " Alan Previn
2022-06-20 8:46 ` Tvrtko Ursulin [this message]
2022-06-22 22:36 ` Umesh Nerlige Ramappa
2022-06-23 0:25 ` Teres Alexis, Alan Previn
2022-06-22 23:00 ` Umesh Nerlige Ramappa
2022-06-22 23:55 ` Teres Alexis, Alan Previn
2022-06-18 6:12 ` [Intel-gfx] ✗ Fi.CI.SPARSE: warning for drm/i915/guc: Don't update engine busyness stats too frequently (rev3) Patchwork
2022-06-18 6:33 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2022-06-18 20:35 ` [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=ae671cd8-df50-ea8b-0a3f-bd8ec1bea049@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=alan.previn.teres.alexis@intel.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox