From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4D573C7EE26 for ; Tue, 23 May 2023 15:27:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B939B10E44F; Tue, 23 May 2023 15:27:04 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3967910E44F; Tue, 23 May 2023 15:27:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684855623; x=1716391623; h=date:message-id:from:to:cc:subject:in-reply-to: references:mime-version; bh=YJU7JpV+PTyyNxioy/4GQL6iBo0leVN1Uy9T08WT53A=; b=lU+CEC7ojYYuH5bZArcZ2hKQkeMZXl2JsQjSNYlmOfmG349KjXHqNcvR HJ8cgLQ1LqRCeHJIkFuAaMiwL7jy5PURrdgGNY6vRqMB3edN0A/s2i79T 1rcb5xEc8Jspg8szMXCLoqatKxClG3Wlz7rQ1+QoDevVHTGWfEowPhXK0 en0wgx2ZnJt4wJPLMB0khgnn63MdlEcfkQpW7kP9yqa5u5fXvoo4jsNtM FFYoWjZDn0dO1MQpOPMiUKMHdxrm0fhaucDoND9g4wYRQ/ztdd1F+a8gr vD+e3sRCOPoHY6M5WhP8n7qnjLyKLL8xW9zSx9tLFz9MRew1t+XGYzz5d g==; X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="355627672" X-IronPort-AV: E=Sophos;i="6.00,186,1681196400"; d="scan'208";a="355627672" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 May 2023 08:27:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="681456799" X-IronPort-AV: E=Sophos;i="6.00,186,1681196400"; d="scan'208";a="681456799" Received: from adixit-mobl.amr.corp.intel.com (HELO adixit-arch.intel.com) ([10.209.19.91]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 May 2023 08:27:01 -0700 Date: Tue, 23 May 2023 08:27:01 -0700 Message-ID: <87jzwzqda2.wl-ashutosh.dixit@intel.com> From: "Dixit, Ashutosh" To: Tvrtko Ursulin In-Reply-To: References: <20230512015320.2610830-1-ashutosh.dixit@intel.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Subject: Re: [Intel-gfx] [PATCH] drm/i915/pmu: Turn off the timer to sample frequencies when GT is parked X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On Fri, 12 May 2023 01:59:08 -0700, Tvrtko Ursulin wrote: > Hi Tvrtko, > On 12/05/2023 02:53, Ashutosh Dixit wrote: > > pmu_needs_timer() keeps the timer running even when GT is parked, > > ostensibly to sample requested/actual frequencies. However > > frequency_sample() has the following: > > > > /* Report 0/0 (actual/requested) frequency while parked. */ > > if (!intel_gt_pm_get_if_awake(gt)) > > return; > > > > The above code prevents frequencies to be sampled while the GT is > > parked. So we might as well turn off the sampling timer itself in this > > case and save CPU cycles/power. > > The confusing situation seems to be the consequence of b66ecd0438bf > ("drm/i915/pmu: Report frequency as zero while GPU is sleeping"). > > Before that commit we were deliberately sampling the frequencies as GPU > minimum during the parked periods and to do so leaving the timer running. > > But then some RPS changes exposed that approach as questionable (AFAIR > software tracked state stopped being reset to min freq and so created > wild PMU readings) and we went the route of reporting zero when parked. > > At which point running the timer stopped making sense, so really that > commit should/could have made the change you now propose. > > > Signed-off-by: Ashutosh Dixit > > --- > > drivers/gpu/drm/i915/i915_pmu.c | 11 +++++++---- > > 1 file changed, 7 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c > > index 7ece883a7d956..8db1d681cf4ab 100644 > > --- a/drivers/gpu/drm/i915/i915_pmu.c > > +++ b/drivers/gpu/drm/i915/i915_pmu.c > > @@ -124,11 +124,14 @@ static bool pmu_needs_timer(struct i915_pmu *pmu, bool gpu_active) > > ENGINE_SAMPLE_MASK; > > /* > > - * When the GPU is idle per-engine counters do not need to be > > - * running so clear those bits out. > > + * When GPU is idle, frequency or per-engine counters do not need > > + * to be running so clear those bits out. > > */ > > - if (!gpu_active) > > - enable &= ~ENGINE_SAMPLE_MASK; > > + if (!gpu_active) { > > + enable &= ~(config_mask(I915_PMU_ACTUAL_FREQUENCY) | > > + config_mask(I915_PMU_REQUESTED_FREQUENCY) | > > + ENGINE_SAMPLE_MASK); > > + } > > /* > > * Also there is software busyness tracking available we do not > > * need the timer for I915_SAMPLE_BUSY counter. > > LGTM. > > Reviewed-by: Tvrtko Ursulin > > Or maybe it is possible to simplify since it looks there is no way to return true if gt is parked. So that could be: > > pmu_needs_timer(..) > { > ... > > if (!gpu_active) > return false; > > ... > enable = pmu->enable; > > ... > enable &= config_mask(I915_PMU_ACTUAL_FREQUENCY) | > config_mask(I915_PMU_REQUESTED_FREQUENCY) | > ENGINE_SAMPLE_MASK; > > ... > if (i915->caps.scheduler & I915_SCHEDULER_CAP_ENGINE_BUSY_STATS) > enable &= ~BIT(I915_SAMPLE_BUSY); > > return enable; > } > > Not sure it is any better, your call. I have made this change in v2 of the patch submitted here: https://patchwork.freedesktop.org/series/118225/ And I have retained your R-b since the patch is essentially a copy of your code above. The original version of the patch was here: https://patchwork.freedesktop.org/series/117658/ Thanks. -- Ashutosh