Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Bernatowicz, Marcin" <marcin.bernatowicz@linux.intel.com>
To: Lucas De Marchi <lucas.demarchi@intel.com>,
	Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: intel-xe@lists.freedesktop.org,
	"Michał Winiarski" <michal.winiarski@intel.com>,
	"Umesh Nerlige Ramappa" <umesh.nerlige.ramappa@intel.com>
Subject: Re: [PATCH 3/3] drm/xe/client: Skip drm-total-cycles if unable to read timestamp
Date: Wed, 5 Feb 2025 12:29:42 +0100	[thread overview]
Message-ID: <ac682fd4-196f-40ad-be72-95730248fc95@linux.intel.com> (raw)
In-Reply-To: <dlawvvg26dolbcqdky3mkbqke4euaon4q2nvcjl4fit6jxshhb@vgzmhe6us5qt>



On 2/4/2025 9:13 PM, Lucas De Marchi wrote:
> On Tue, Feb 04, 2025 at 07:56:03PM +0100, Michal Wajdeczko wrote:
>>
>>
>> On 04.02.2025 19:05, Marcin Bernatowicz wrote:
>>> Ensure show_run_ticks() only prints drm-total-cycles when timestamp
>>> retrieval succeeds.
>>>
>>> Signed-off-by: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
>>> Cc: Lucas De Marchi <lucas.demarchi@intel.com>
>>> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
>>> Cc: Michał Winiarski <michal.winiarski@intel.com>
>>> Cc: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
>>> ---
>>>  drivers/gpu/drm/xe/xe_drm_client.c | 9 ++++++---
>>>  1 file changed, 6 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/xe/xe_drm_client.c b/drivers/gpu/drm/xe/ 
>>> xe_drm_client.c
>>> index 63f30b6df70b..e5c4f342380e 100644
>>> --- a/drivers/gpu/drm/xe/xe_drm_client.c
>>> +++ b/drivers/gpu/drm/xe/xe_drm_client.c
>>> @@ -323,6 +323,7 @@ static void show_run_ticks(struct drm_printer *p, 
>>> struct drm_file *file)
>>>      struct xe_exec_queue *q;
>>>      u64 gpu_timestamp;
>>>      unsigned int fw_ref;
>>> +    int err;
>>>
>>>      /*
>>>       * Wait for any exec queue going away: their cycles will get 
>>> updated on
>>> @@ -350,7 +351,7 @@ static void show_run_ticks(struct drm_printer *p, 
>>> struct drm_file *file)
>>>      }
>>>      mutex_unlock(&xef->exec_queue.lock);
>>>
>>> -    gpu_timestamp = xe_hw_engine_read_timestamp(hwe);
>>> +    err = xe_hw_engine_read_timestamp(hwe, &gpu_timestamp);
>>
>> can't we just check for !IS_SRIOV_VF here?
>>
>>>
>>>      xe_force_wake_put(gt_to_fw(hwe->gt), fw_ref);
>>>      xe_pm_runtime_put(xe);
>>> @@ -371,8 +372,10 @@ static void show_run_ticks(struct drm_printer 
>>> *p, struct drm_file *file)
>>>          class_name = xe_hw_engine_class_to_str(class);
>>>          drm_printf(p, "drm-cycles-%s:\t%llu\n",
>>>                 class_name, xef->run_ticks[class]);
>>> -        drm_printf(p, "drm-total-cycles-%s:\t%llu\n",
>>> -               class_name, gpu_timestamp);
>>> +
>>> +        if (!err)
>>> +            drm_printf(p, "drm-total-cycles-%s:\t%llu\n",
>>
>> are we sure we don't break any tools that might look for this?
> 
> It may break if the tool is expecting drm-total-cycles-* to exist when it
> reads a drm-cycles-*. Also there isn't much value afaik from showing just
> the total cycles. IMO we could just skip the entire function
> on IS_SRIOV_VF().

igt@xe_drm_fdinfo is passing, as its checks are immune to the lack of 
drm-total-cycles-*. However, the only information we get is that the 
engine was busy (and comparison with spin->timestamp passes), with no 
utilization visible in gputop (the tool does not break).

We could "fool" the tools by setting drm-total-cycles to a CPU-based 
timestamp:

drm-total-cycles = mul_u64_u32_div(local_clock(),
                                    hwe->gt->info.reference_clock,
                                    NSEC_PER_SEC);

However, this is a no-go, as it could introduce more problems than benefits.

I also checked qmassa, but it does not handle VF devices (for unrelated 
reasons).

I'll send a second version skipping show_run_ticks if VF.

Thanks,
marcin
> 
> Lucas De Marchi
> 
>>
>>> +                   class_name, gpu_timestamp);
>>>
>>>          if (capacity[class] > 1)
>>>              drm_printf(p, "drm-engine-capacity-%s:\t%lu\n",
>>


  reply	other threads:[~2025-02-05 11:30 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-04 18:05 [PATCH 0/3] VF: Avoid reading inaccessible RING_TIMESTAMP Marcin Bernatowicz
2025-02-04 18:05 ` [PATCH 1/3] drm/xe/vf: Return EOPNOTSUPP for DRM_XE_DEVICE_QUERY_ENGINE_CYCLES if VF Marcin Bernatowicz
2025-02-04 18:05 ` [PATCH 2/3] drm/xe/vf: Return error code from xe_hw_engine_read_timestamp() Marcin Bernatowicz
2025-02-04 18:53   ` Michal Wajdeczko
2025-02-05 11:00     ` Bernatowicz, Marcin
2025-02-04 18:05 ` [PATCH 3/3] drm/xe/client: Skip drm-total-cycles if unable to read timestamp Marcin Bernatowicz
2025-02-04 18:56   ` Michal Wajdeczko
2025-02-04 20:13     ` Lucas De Marchi
2025-02-05 11:29       ` Bernatowicz, Marcin [this message]
2025-02-04 21:55 ` ✓ CI.Patch_applied: success for VF: Avoid reading inaccessible RING_TIMESTAMP Patchwork
2025-02-04 21:55 ` ✓ CI.checkpatch: " Patchwork
2025-02-04 21:56 ` ✓ CI.KUnit: " Patchwork
2025-02-04 22:13 ` ✓ CI.Build: " Patchwork
2025-02-04 22:15 ` ✓ CI.Hooks: " Patchwork
2025-02-04 22:16 ` ✓ CI.checksparse: " Patchwork
2025-02-04 22:36 ` ✗ Xe.CI.BAT: failure " Patchwork
2025-02-05  2:50 ` ✗ Xe.CI.Full: " 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=ac682fd4-196f-40ad-be72-95730248fc95@linux.intel.com \
    --to=marcin.bernatowicz@linux.intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=lucas.demarchi@intel.com \
    --cc=michal.wajdeczko@intel.com \
    --cc=michal.winiarski@intel.com \
    --cc=umesh.nerlige.ramappa@intel.com \
    /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