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 6FCADCAC5AE for ; Fri, 26 Sep 2025 11:20:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 16AC410EA28; Fri, 26 Sep 2025 11:20:07 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="CTflYwO4"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0CC7510EA27 for ; Fri, 26 Sep 2025 11:20:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1758885606; x=1790421606; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qljS75dl3ofL6DGjSbIelO+EksczFPpYbXB1z85PTTQ=; b=CTflYwO4nEO6DrszZgT16jWZ34fNZAoDo+Q+Zigb8OvX7rw2rk0Gs8gQ rqADsj1IuYIAZ+IZswjUJh1R2yR1vTBcyBgCzwrEz2g6c0Yrts6NGU4Cr fSxRSTPCqhG0aGFxCYZLIqi5HluHiPfy4USj122XMseamKypgj1zdnoBY mmrhPnJgU+XphfcrzhMrwNMvJLpnKsrhpp3Op9KWa1tMi16L7pFcDbrIE UVcAHEyhhTrE2oswU9vO+WCbOjXXRhMbyhzhZvG32a7e8R3dABcmthTSq FwZk51Qd1zMzfI+3Gx2E1ThnktcbJbFwsFcA4SkUAr1LVjYVlnJxWqGR6 A==; X-CSE-ConnectionGUID: Mxaw1/5DTHSpnvU3odhjHQ== X-CSE-MsgGUID: rryd2WvrSdKJtAh7qd35EQ== X-IronPort-AV: E=McAfee;i="6800,10657,11564"; a="72314406" X-IronPort-AV: E=Sophos;i="6.18,295,1751266800"; d="scan'208";a="72314406" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2025 04:20:06 -0700 X-CSE-ConnectionGUID: voPKGEwwS5GzvYssjY2ctA== X-CSE-MsgGUID: zHk8j2eJTDSZdMjsa88wfg== X-ExtLoop1: 1 Received: from intel-s2600wft.iind.intel.com (HELO biaas-d105.iind.intel.com) ([10.223.26.161]) by fmviesa003.fm.intel.com with ESMTP; 26 Sep 2025 04:20:04 -0700 From: Aakash Deep Sarkar To: intel-xe@lists.freedesktop.org Cc: jeevaka.badrappan@intel.com, rodrigo.vivi@intel.com, matthew.brost@intel.com, carlos.santa@intel.com, matthew.auld@intel.com, Aakash Deep Sarkar Subject: [PATCH v4 4/9] drm/xe: Modify xe_exec_queue_update_run_ticks Date: Fri, 26 Sep 2025 10:45:15 +0000 Message-ID: <20250926104521.1815428-5-aakash.deep.sarkar@intel.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250926104521.1815428-1-aakash.deep.sarkar@intel.com> References: <20250926104521.1815428-1-aakash.deep.sarkar@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" For GPU work period event we need to record the run time of a context on the GPU in nanosecs. In the present xe driver code, we only record the run time in clock ticks and separately for each engine class. So, we are adding a uint64 variable |active_duration_ns| in the xe file structure where we can record the cumulative run time in ns of all the engines for this context. The intent here is to add up the |active_duration_ns| in all the xe files belonging to a given user id to derive the run time for that user id. Signed-off-by: Aakash Deep Sarkar --- drivers/gpu/drm/xe/xe_device_types.h | 3 +++ drivers/gpu/drm/xe/xe_exec_queue.c | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h index a6c361db11d9..e6ecfb3f7f38 100644 --- a/drivers/gpu/drm/xe/xe_device_types.h +++ b/drivers/gpu/drm/xe/xe_device_types.h @@ -678,6 +678,9 @@ struct xe_file { /** @run_ticks: hw engine class run time in ticks for this drm client */ u64 run_ticks[XE_ENGINE_CLASS_MAX]; + /** @active_duration_ns: total run time in ns for this xe file */ + u64 active_duration_ns; + /** @client: drm client */ struct xe_drm_client *client; diff --git a/drivers/gpu/drm/xe/xe_exec_queue.c b/drivers/gpu/drm/xe/xe_exec_queue.c index 37b2b93b73d6..6eb34c62c779 100644 --- a/drivers/gpu/drm/xe/xe_exec_queue.c +++ b/drivers/gpu/drm/xe/xe_exec_queue.c @@ -15,6 +15,7 @@ #include "xe_dep_scheduler.h" #include "xe_device.h" #include "xe_gt.h" +#include "xe_gt_clock.h" #include "xe_hw_engine_class_sysfs.h" #include "xe_hw_engine_group.h" #include "xe_hw_fence.h" @@ -887,6 +888,8 @@ void xe_exec_queue_update_run_ticks(struct xe_exec_queue *q) { struct xe_device *xe = gt_to_xe(q->gt); struct xe_lrc *lrc; + struct xe_gt *gt = q->gt; + u64 old_ts, new_ts; int idx; @@ -912,6 +915,10 @@ void xe_exec_queue_update_run_ticks(struct xe_exec_queue *q) new_ts = xe_lrc_update_timestamp(lrc, &old_ts); q->xef->run_ticks[q->class] += (new_ts - old_ts) * q->width; + // Accumulate the runtime in nanosec for this queue into the xe file. + q->xef->active_duration_ns += + xe_gt_clock_interval_to_ns(gt, (new_ts - old_ts)); + drm_dev_exit(idx); } -- 2.49.0