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 555C8C04AA5 for ; Thu, 25 Aug 2022 07:21:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6D72BD9096; Thu, 25 Aug 2022 07:21:46 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id A1B0BD90C1 for ; Thu, 25 Aug 2022 07:21:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661412094; x=1692948094; h=date:message-id:from:to:cc:subject:in-reply-to: references:mime-version:content-transfer-encoding; bh=7DF7SytDy3VPtij5q/3ARooyabrBDCz9Tx3Lp5kXxSY=; b=L5jQEJ0E1RvQiUqggupP2iAKkl/XI8LxC4xiXhAkzUfPBB0rGRGCil9a 9sTgVlVtetdgrT2EwwBrWkm7sxJUFqbC+VYH8fxpUH7gIUKcbFnA6dWlM RqbDRomP9xFQ/t2yPa8NQWzM13AdWWlXngn+X3AJsYMZR2MSZnEHxdWQD E02uvSH1IukDevYsGqQ3zYICrQREZUyXWZkWvM777Dm2+QkAhG+7IrxGe OTIXhQtKsh+6ltmjxiFM65Hl5Ejm6+NMydckfPDXOfRJLaNkr47p3mtAU v+2Qujm2376RUBSLpHi4kNptTYOHXJZHd958TiaNShGwJKZEDENZC4zWP A==; X-IronPort-AV: E=McAfee;i="6500,9779,10449"; a="274547695" X-IronPort-AV: E=Sophos;i="5.93,262,1654585200"; d="scan'208";a="274547695" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Aug 2022 23:18:15 -0700 X-IronPort-AV: E=Sophos;i="5.93,262,1654585200"; d="scan'208";a="639452176" Received: from adixit-mobl.amr.corp.intel.com (HELO adixit-arch.intel.com) ([10.251.14.97]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Aug 2022 23:18:15 -0700 Date: Wed, 24 Aug 2022 23:18:14 -0700 Message-ID: <87mtbsyhg9.wl-ashutosh.dixit@intel.com> From: "Dixit, Ashutosh" To: Umesh Nerlige Ramappa In-Reply-To: <20220615174208.GL48807@orsosgc001.jf.intel.com> References: <20220614004616.45561-1-umesh.nerlige.ramappa@intel.com> <2d4f5fd5-a2d2-68ac-d7ae-bc81b14327bc@linux.intel.com> <20220614163257.GF48807@orsosgc001.jf.intel.com> <979dcbee-5c3e-e14f-f31e-ddcf3edd8a5f@linux.intel.com> <20220615174208.GL48807@orsosgc001.jf.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.1 (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=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Intel-gfx] [PATCH] i915/pmu: Wire GuC backend to per-client busyness 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 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On Wed, 15 Jun 2022 10:42:08 -0700, Umesh Nerlige Ramappa wrote: > > >>>> +static void __guc_context_update_clks(struct intel_context *ce) > >>>> +{ > >>>> +=A0=A0=A0 struct intel_guc *guc =3D ce_to_guc(ce); > >>>> +=A0=A0=A0 struct intel_gt *gt =3D ce->engine->gt; > >>>> +=A0=A0=A0 u32 *pphwsp, last_switch, engine_id; > >>>> +=A0=A0=A0 u64 start_gt_clk =3D 0, active =3D 0; > >>> > >>> No need to init these two. > >>> > >>>> +=A0=A0=A0 unsigned long flags; > >>>> +=A0=A0=A0 ktime_t unused; > >>>> + > >>>> +=A0=A0=A0 spin_lock_irqsave(&guc->timestamp.lock, flags); > >>>> + > >>>> +=A0=A0=A0 pphwsp =3D ((void *)ce->lrc_reg_state) - LRC_STATE_OFFSET; > >>>> +=A0=A0=A0 last_switch =3D READ_ONCE(pphwsp[PPHWSP_GUC_CONTEXT_USAGE= _STAMP_LO]); > >>>> +=A0=A0=A0 engine_id =3D READ_ONCE(pphwsp[PPHWSP_GUC_CONTEXT_USAGE_E= NGINE_ID]); > >>>> + > >>>> +=A0=A0=A0 guc_update_pm_timestamp(guc, &unused); > >>>> + > >>>> +=A0=A0=A0 if (engine_id !=3D 0xffffffff && last_switch) { > >>>> +=A0=A0=A0=A0=A0=A0=A0 start_gt_clk =3D READ_ONCE(ce->stats.runtime.= start_gt_clk); > >>>> +=A0=A0=A0=A0=A0=A0=A0 __extend_last_switch(guc, &start_gt_clk, last= _switch); > >>>> +=A0=A0=A0=A0=A0=A0=A0 active =3D intel_gt_clock_interval_to_ns(gt, > >>>> guc->timestamp.gt_stamp - start_gt_clk); > >>>> +=A0=A0=A0=A0=A0=A0=A0 WRITE_ONCE(ce->stats.runtime.start_gt_clk, st= art_gt_clk); > >>>> +=A0=A0=A0=A0=A0=A0=A0 WRITE_ONCE(ce->stats.active, active); > >>>> +=A0=A0=A0 } else { > >>>> +=A0=A0=A0=A0=A0=A0=A0 lrc_update_runtime(ce); > >>> > >>> Why is this called from here? Presumably it was called already from > >>> guc_context_unpin if here code things context is not active. Or will = be > >>> called shortly, once context save is done. > >> > >> guc_context_unpin is only called in the path of ce->sched_disable. The > >> sched_disable is implemented in GuC (H2G message). Once the > >> corresponding G2H response is received, the context is actually > >> unpinned, eventually calling guc_context_unpin. Also the context may n= ot > >> necessarily be disabled after each context exit. > > > > So if I understand correctly, lrc runtime is only updated if someone is > > reading the busyness and not as part of normal context state transition= s? > > If you mean context_in/out events (like csb interrupts), only GuC can see > those events. KMD has no visibility into that. These 3 paths call > lrc_update_runtime. > > user query: (engine_id !=3D 0xffffffff && last_switch) translates to GuC > being within context_in and context_out events, so updating it outside of > this window is one way to report the correct busyness. > > worker: guc_timestamp_ping() also updates context stats (infrequently) f= or > all contexts primarily to take care of overflows. > > context unpin: Existing code calls lrc_update_runtime only when unpinning > the context which takes care of accumulating busyness when requests are > retired. Will adding lrc_update_runtime() to lrc_unpin() work?