Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Laguna, Lukasz" <lukasz.laguna@intel.com>
To: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>,
	<igt-dev@lists.freedesktop.org>
Cc: Adam Miszczak <adam.miszczak@linux.intel.com>,
	Jakub Kolakowski <jakub1.kolakowski@intel.com>,
	Michal Wajdeczko <michal.wajdeczko@intel.com>
Subject: Re: [PATCH i-g-t 5/6] tests/intel/xe_sriov_scheduling: Use safe scheduling params helpers
Date: Tue, 18 Aug 2026 16:15:50 +0200	[thread overview]
Message-ID: <2e051164-f74e-4292-ab5a-68391d3e636d@intel.com> (raw)
In-Reply-To: <62fd6c4bbb320576d774d1752d5bf2da3d1b4af3.1787056235.git.marcin.bernatowicz@linux.intel.com>


On 8/18/2026 14:39, Marcin Bernatowicz wrote:
> The test open coded provisioning as execution quantum, preemption timeout
> and then priority, and reused the same helper for cleanup by passing an
> all zero params struct. On the cleanup path that raised priority handling
> last, so a function could be left with priority above LOW while
> timeslicing was already infinite.
>
> Drop the local helpers and use xe_sriov_admin_bulk_set_sched_params() for
> provisioning and __xe_sriov_admin_bulk_restore_sched_defaults() for
> cleanup, which apply the safe order for each direction. The invalid
> combination of infinite timeslicing with priority above LOW is no longer
> representable.
>
> Assisted-by: Copilot:Claude-Opus-5
> Signed-off-by: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
> Cc: Adam Miszczak <adam.miszczak@linux.intel.com>
> Cc: Jakub Kolakowski <jakub1.kolakowski@intel.com>
> Cc: Lukasz Laguna <lukasz.laguna@intel.com>

Reviewed-by: Lukasz Laguna <lukasz.laguna@intel.com>

> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
> ---
>   tests/intel/xe_sriov_scheduling.c | 86 +++++++++----------------------
>   1 file changed, 23 insertions(+), 63 deletions(-)
>
> diff --git a/tests/intel/xe_sriov_scheduling.c b/tests/intel/xe_sriov_scheduling.c
> index 5e4001219..75f1b2322 100644
> --- a/tests/intel/xe_sriov_scheduling.c
> +++ b/tests/intel/xe_sriov_scheduling.c
> @@ -369,44 +369,6 @@ static void init_vf_ids(uint8_t *array, size_t n,
>   	}
>   }
>   
> -struct vf_sched_params {
> -	uint32_t exec_quantum_ms;
> -	uint32_t preempt_timeout_us;
> -	enum xe_sriov_sched_priority priority;
> -};
> -
> -static int __set_vfs_scheduling_params(int pf_fd, int num_vfs,
> -				       const struct vf_sched_params *p)
> -{
> -	int ret = 0;
> -
> -	ret = __xe_sriov_admin_bulk_set_exec_quantum_ms(pf_fd, p->exec_quantum_ms);
> -	if (igt_warn_on_f(ret,
> -			  "Failed to bulk set exec quantum=%u: %d\n",
> -			  p->exec_quantum_ms, ret))
> -		return ret;
> -
> -	ret = __xe_sriov_admin_bulk_set_preempt_timeout_us(pf_fd, p->preempt_timeout_us);
> -	if (igt_warn_on_f(ret,
> -			  "Failed to bulk set preempt timeout=%u: %d\n",
> -			  p->preempt_timeout_us, ret))
> -		return ret;
> -
> -	ret = __xe_sriov_admin_bulk_set_sched_priority(pf_fd, p->priority);
> -	if (igt_warn_on_f(ret,
> -			  "Failed to bulk set sched priority=%d: %d\n",
> -			  p->priority, ret))
> -		return ret;
> -
> -	return ret;
> -}
> -
> -static void set_vfs_scheduling_params(int pf_fd, int num_vfs,
> -				      const struct vf_sched_params *p)
> -{
> -	igt_assert_eq(0, __set_vfs_scheduling_params(pf_fd, num_vfs, p));
> -}
> -
>   static bool check_within_epsilon(const double x, const double ref, const double tol)
>   {
>   	return x <= (1.0 + tol) * ref && x >= (1.0 - tol) * ref;
> @@ -483,7 +445,7 @@ static void compute_common_time_frame_stats(struct subm_set *set)
>   struct job_sched_params {
>   	int duration_ms;
>   	int num_repeats;
> -	struct vf_sched_params sched_params;
> +	struct xe_sriov_sched_params sched_params;
>   };
>   
>   static uint32_t sysfs_get_job_timeout_ms(int fd, const struct drm_xe_engine_class_instance *eci)
> @@ -566,15 +528,17 @@ static unsigned int select_inflight_k(unsigned int duration_ms,
>   	return 2;
>   }
>   
> -static struct vf_sched_params prepare_vf_sched_params(int num_threads,
> -						      int min_num_repeats,
> -						      int job_timeout_ms,
> -						      const struct subm_opts *opts,
> -						      enum xe_sriov_sched_priority priority)
> +static struct xe_sriov_sched_params prepare_vf_sched_params(int num_threads,
> +							    int min_num_repeats,
> +							    int job_timeout_ms,
> +							    const struct subm_opts *opts,
> +							    enum xe_sriov_sched_priority priority)
>   {
> -	struct vf_sched_params params = { MIN_EXEC_QUANTUM_MS,
> -					  derive_preempt_timeout_us(MIN_EXEC_QUANTUM_MS),
> -						  priority };
> +	struct xe_sriov_sched_params params = {
> +		.exec_quantum_ms = MIN_EXEC_QUANTUM_MS,
> +		.preempt_timeout_us = derive_preempt_timeout_us(MIN_EXEC_QUANTUM_MS),
> +		.priority = priority,
> +	};
>   
>   	if (opts->exec_quantum_ms || opts->preempt_timeout_us) {
>   		if (opts->exec_quantum_ms)
> @@ -617,7 +581,7 @@ prepare_job_sched_params(int num_threads, int job_timeout_ms, const struct subm_
>   
>   struct vf_config {
>   	unsigned int vf_id;
> -	struct vf_sched_params sched_params;
> +	struct xe_sriov_sched_params sched_params;
>   	bool run_workload;
>   };
>   
> @@ -1154,8 +1118,8 @@ static void throughput_ratio(int pf_fd, int num_vfs, const struct subm_opts *opt
>   							     job_timeout_ms,
>   							     opts, priority);
>   		xe_sriov_disable_vfs_restore_auto_provisioning(pf_fd);
> -		set_vfs_scheduling_params(pf_fd, num_vfs,
> -					  &job_sched_params->sched_params);
> +		xe_sriov_admin_bulk_set_sched_params(pf_fd,
> +						     &job_sched_params->sched_params);
>   		igt_sriov_enable_driver_autoprobe(pf_fd);
>   		igt_sriov_enable_vfs(pf_fd, num_vfs);
>   	}
> @@ -1196,10 +1160,9 @@ static void nonpreempt_engine_resets(int pf_fd, int num_vfs,
>   	igt_assert(job_sched_params);
>   
>   	if (!job_sched_params->num_repeats) {
> -		struct vf_sched_params vf_sched_params = prepare_vf_sched_params(num_vfs, 1,
> -										 job_timeout_ms,
> -										 opts,
> -										 priority);
> +		struct xe_sriov_sched_params vf_sched_params =
> +			prepare_vf_sched_params(num_vfs, 1, job_timeout_ms,
> +						opts, priority);
>   
>   		*job_sched_params = (struct job_sched_params) {
>   			.sched_params = vf_sched_params,
> @@ -1208,8 +1171,8 @@ static void nonpreempt_engine_resets(int pf_fd, int num_vfs,
>   			.num_repeats = 1,
>   		};
>   		xe_sriov_disable_vfs_restore_auto_provisioning(pf_fd);
> -		set_vfs_scheduling_params(pf_fd, num_vfs,
> -					  &job_sched_params->sched_params);
> +		xe_sriov_admin_bulk_set_sched_params(pf_fd,
> +						     &job_sched_params->sched_params);
>   		igt_sriov_enable_driver_autoprobe(pf_fd);
>   		igt_sriov_enable_vfs(pf_fd, num_vfs);
>   	}
> @@ -1280,7 +1243,7 @@ prepare_default_enabled_job_sched_params(int pf_fd,
>   	struct job_sched_params params = { };
>   	uint32_t min_exec_quantum_ms = UINT32_MAX;
>   
> -	params.sched_params = (struct vf_sched_params) {
> +	params.sched_params = (struct xe_sriov_sched_params) {
>   		.exec_quantum_ms = xe_sriov_admin_get_exec_quantum_ms(pf_fd, vf_ids[0]),
>   		.preempt_timeout_us = xe_sriov_admin_get_preempt_timeout_us(pf_fd, vf_ids[0]),
>   		.priority = xe_sriov_admin_get_sched_priority(pf_fd, vf_ids[0], NULL),
> @@ -1566,8 +1529,7 @@ int igt_main_args("", long_opts, help_str, subm_opts_handler, NULL)
>   
>   		igt_fixture() {
>   			xe_sriov_disable_vfs_restore_auto_provisioning(pf_fd);
> -			__set_vfs_scheduling_params(pf_fd, igt_sriov_get_total_vfs(pf_fd),
> -						    &(struct vf_sched_params){});
> +			__xe_sriov_admin_bulk_restore_sched_defaults(pf_fd);
>   		}
>   	}
>   
> @@ -1618,8 +1580,7 @@ int igt_main_args("", long_opts, help_str, subm_opts_handler, NULL)
>   
>   		igt_fixture() {
>   			xe_sriov_disable_vfs_restore_auto_provisioning(pf_fd);
> -			__set_vfs_scheduling_params(pf_fd, igt_sriov_get_total_vfs(pf_fd),
> -						    &(struct vf_sched_params){});
> +			__xe_sriov_admin_bulk_restore_sched_defaults(pf_fd);
>   		}
>   	}
>   
> @@ -1627,8 +1588,7 @@ int igt_main_args("", long_opts, help_str, subm_opts_handler, NULL)
>   		int ret;
>   
>   		xe_sriov_disable_vfs_restore_auto_provisioning(pf_fd);
> -		ret = __set_vfs_scheduling_params(pf_fd, igt_sriov_get_total_vfs(pf_fd),
> -						  &(struct vf_sched_params){});
> +		ret = __xe_sriov_admin_bulk_restore_sched_defaults(pf_fd);
>   		/* abort to avoid execution of next tests with enabled VFs */
>   		igt_abort_on_f(igt_sriov_get_enabled_vfs(pf_fd) > 0,
>   			       "Failed to disable VF(s)");

  reply	other threads:[~2026-08-18 14:17 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-18 12:39 [PATCH i-g-t 0/6] Order SR-IOV scheduling provisioning safely Marcin Bernatowicz
2026-08-18 12:39 ` [PATCH i-g-t 1/6] tests/intel/xe_sriov_scheduling: Disable VFs before resetting sched params Marcin Bernatowicz
2026-08-18 14:14   ` Laguna, Lukasz
2026-08-18 12:39 ` [PATCH i-g-t 2/6] lib/xe/xe_sriov_admin: Rename restore defaults helpers Marcin Bernatowicz
2026-08-18 14:14   ` Laguna, Lukasz
2026-08-18 12:39 ` [PATCH i-g-t 3/6] lib/xe/xe_sriov_admin: Lower priority before clearing timeslicing Marcin Bernatowicz
2026-08-18 14:15   ` Laguna, Lukasz
2026-08-18 12:39 ` [PATCH i-g-t 4/6] lib/xe/xe_sriov_admin: Add bulk scheduling params setter Marcin Bernatowicz
2026-08-18 14:15   ` Laguna, Lukasz
2026-08-18 12:39 ` [PATCH i-g-t 5/6] tests/intel/xe_sriov_scheduling: Use safe scheduling params helpers Marcin Bernatowicz
2026-08-18 14:15   ` Laguna, Lukasz [this message]
2026-08-18 12:39 ` [PATCH i-g-t 6/6] tests/intel/xe_pmu: Disable VFs before restoring sched params Marcin Bernatowicz
2026-08-18 14:16   ` Laguna, Lukasz
2026-08-18 14:11 ` ✓ Xe.CI.BAT: success for Order SR-IOV scheduling provisioning safely Patchwork
2026-08-18 14:20 ` ✓ i915.CI.BAT: " Patchwork
2026-08-18 16:39 ` ✓ Xe.CI.FULL: " Patchwork
2026-08-19  1:50 ` ✓ i915.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=2e051164-f74e-4292-ab5a-68391d3e636d@intel.com \
    --to=lukasz.laguna@intel.com \
    --cc=adam.miszczak@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=jakub1.kolakowski@intel.com \
    --cc=marcin.bernatowicz@linux.intel.com \
    --cc=michal.wajdeczko@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