All of lore.kernel.org
 help / color / mirror / Atom feed
From: Raag Jadav <raag.jadav@intel.com>
To: Sk Anirban <sk.anirban@intel.com>
Cc: igt-dev@lists.freedesktop.org, anshuman.gupta@intel.com,
	badal.nilawar@intel.com, riana.tauro@intel.com,
	karthik.poosa@intel.com, soham.purkait@intel.com,
	mallesh.koujalagi@intel.com, rodrigo.vivi@intel.com
Subject: Re: [PATCH] tests/intel/xe_gt_freq: Modify test to support new throttle reasons sysfs
Date: Wed, 26 Nov 2025 14:58:27 +0100	[thread overview]
Message-ID: <aScHgw56ElfJUFKV@black.igk.intel.com> (raw)
In-Reply-To: <20251121114947.3946699-2-sk.anirban@intel.com>

On Fri, Nov 21, 2025 at 05:19:48PM +0530, Sk Anirban wrote:
> Change throttle_basic_api to read the new atomic reasons attribute
> instead of checking status and individual reason files separately.
> This validates the kernel's TOCTOU-free throttling interface.
> 
> Signed-off-by: Sk Anirban <sk.anirban@intel.com>
> ---
>  tests/intel/xe_gt_freq.c | 45 ++++++++++++----------------------------
>  1 file changed, 13 insertions(+), 32 deletions(-)
> 
> diff --git a/tests/intel/xe_gt_freq.c b/tests/intel/xe_gt_freq.c
> index d0f35b10a..30e359a47 100644
> --- a/tests/intel/xe_gt_freq.c
> +++ b/tests/intel/xe_gt_freq.c
> @@ -47,48 +47,29 @@ static bool within_expected_range(uint32_t freq, uint32_t val)
>  		(freq >= val - FREQ_UNIT_MHZ);
>  }
>  
> -static uint32_t get_throttle(int fd, int gt_id, const char *throttle_file)
> +/**
> + * SUBTEST: throttle_basic_api
> + * Description: Test basic throttle API
> + */
> +
> +static void test_throttle_basic_api(int fd, int gt_id)
>  {
> -	uint32_t val;
> +	char reasons[1024];

A bit too optimistic? :D

Let's use only what we need.

>  	char throttle_attr[40];
>  	int gt_fd;
>  
> -	snprintf(throttle_attr, sizeof(throttle_attr),
> -		 "freq0/throttle/%s", throttle_file);
> +	snprintf(throttle_attr, sizeof(throttle_attr), "freq0/throttle/reasons");
>  	gt_fd = xe_sysfs_gt_open(fd, gt_id);
>  	igt_assert_lte(0, gt_fd);
>  
> -	igt_sysfs_scanf(gt_fd, throttle_attr, "%u", &val);
> +	igt_assert(igt_sysfs_scanf(gt_fd, throttle_attr, "%1023s", reasons) == 1);

Can this be igt_assert_eq()?

> -	igt_debug("gt%d/freq0/throttle/%s: %u\n", gt_id, throttle_file, val);
> +	igt_debug("gt%d/freq0/throttle/reasons: %s\n", gt_id, reasons);
>  
> -	close(gt_fd);
> -	return val;
> -}
> +	if (strcmp(reasons, "none") != 0)

Do you need '!= 0'?

Raag

> +		igt_info("GT %d is being throttled due to: %s\n", gt_id, reasons);
>  
> -/**
> - * SUBTEST: throttle_basic_api
> - * Description: Test basic throttle API
> - */
> -
> -static void test_throttle_basic_api(int fd, int gt_id)
> -{
> -	uint32_t status, reasons;
> -
> -	status = get_throttle(fd, gt_id, "status");
> -	reasons = get_throttle(fd, gt_id, "reason_pl1");
> -	reasons |= get_throttle(fd, gt_id, "reason_pl2");
> -	reasons |= get_throttle(fd, gt_id, "reason_pl4");
> -	reasons |= get_throttle(fd, gt_id, "reason_prochot");
> -	reasons |= get_throttle(fd, gt_id, "reason_ratl");
> -	reasons |= get_throttle(fd, gt_id, "reason_thermal");
> -	reasons |= get_throttle(fd, gt_id, "reason_vr_tdc");
> -	reasons |= get_throttle(fd, gt_id, "reason_vr_thermalert");
> -
> -	if (status)
> -		igt_assert(reasons);
> -	else
> -		igt_assert(!reasons);
> +	close(gt_fd);
>  }
>  
>  /**
> -- 
> 2.43.0
> 

      parent reply	other threads:[~2025-11-26 13:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-21 11:49 [PATCH] tests/intel/xe_gt_freq: Modify test to support new throttle reasons sysfs Sk Anirban
2025-11-25  3:53 ` ✓ Xe.CI.BAT: success for " Patchwork
2025-11-25  4:21 ` ✗ i915.CI.BAT: failure " Patchwork
2025-11-25  6:11 ` ✗ Xe.CI.Full: " Patchwork
2025-11-26 13:58 ` Raag Jadav [this message]

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=aScHgw56ElfJUFKV@black.igk.intel.com \
    --to=raag.jadav@intel.com \
    --cc=anshuman.gupta@intel.com \
    --cc=badal.nilawar@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=karthik.poosa@intel.com \
    --cc=mallesh.koujalagi@intel.com \
    --cc=riana.tauro@intel.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=sk.anirban@intel.com \
    --cc=soham.purkait@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.