All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: <nishit.sharma@intel.com>
Cc: <igt-dev@lists.freedesktop.org>, <pravalika.gurram@intel.com>,
	<himal.prasad.ghimiray@intel.com>
Subject: Re: [PATCH i-g-t v11 4/5] tests/intel/xe_exec_system_allocator: Add madvise-swizzle test
Date: Wed, 3 Sep 2025 11:14:39 -0700	[thread overview]
Message-ID: <aLiFjwXMmsTAvdRF@lstrano-desk.jf.intel.com> (raw)
In-Reply-To: <20250903141339.1859497-5-nishit.sharma@intel.com>

On Wed, Sep 03, 2025 at 02:13:38PM +0000, nishit.sharma@intel.com wrote:
> From: Nishit Sharma <nishit.sharma@intel.com>
> 
> madvise-swizzle test introduced which is called in combination with other
> tests as well. In this test the buffer object preferred location is
> system memory. MADVISE_SWIZZLE called in main loop to toggle between
> SYSTEM/DEVICE on each pass.
> 
> Signed-off-by: Nishit Sharma <nishit.sharma@intel.com>
> ---
>  tests/intel/xe_exec_system_allocator.c | 32 ++++++++++++++++++++++++++
>  1 file changed, 32 insertions(+)
> 
> diff --git a/tests/intel/xe_exec_system_allocator.c b/tests/intel/xe_exec_system_allocator.c
> index e7f3d423a..4a208f6d8 100644
> --- a/tests/intel/xe_exec_system_allocator.c
> +++ b/tests/intel/xe_exec_system_allocator.c
> @@ -777,6 +777,7 @@ partial(int fd, struct drm_xe_engine_class_instance *eci, unsigned int flags)
>  #define PROCESSES		(0x1 << 24)
>  #define PREFETCH_BENCHMARK	(0x1 << 25)
>  #define PREFETCH_SYS_BENCHMARK	(0x1 << 26)
> +#define MADVISE_SWIZZLE			(0x1 << 27)
>  
>  #define N_MULTI_FAULT		4
>  
> @@ -885,7 +886,9 @@ partial(int fd, struct drm_xe_engine_class_instance *eci, unsigned int flags)
>   * arg[1]:
>   *
>   * @malloc:				malloc single buffer for all execs, issue a command which will trigger multiple faults
> + * @malloc-madvise:			malloc single buffer for all execs, issue a command which will trigger multiple faults, perfoems madvise operation
>   * @malloc-prefetch:			malloc single buffer for all execs, prefetch buffer before each exec
> + * @malloc-prefetch-madvise:		malloc single buffer for all execs, prefetch buffer before each exec, performs madvise operation
>   * @malloc-multi-fault:			malloc single buffer for all execs
>   * @malloc-fork-read:			malloc single buffer for all execs, fork a process to read test output
>   * @malloc-fork-read-after:		malloc single buffer for all execs, fork a process to read test output, check again after fork returns in parent
> @@ -897,6 +900,7 @@ partial(int fd, struct drm_xe_engine_class_instance *eci, unsigned int flags)
>   * @mmap:				mmap single buffer for all execs
>   * @mmap-prefetch:			mmap single buffer for all execs, prefetch buffer before each exec
>   * @mmap-remap:				mmap and mremap a buffer for all execs
> + * @mmap-remap-madvise:			mmap and mremap a buffer for all execs, performs madvise operations
>   * @mmap-remap-dontunmap:		mmap and mremap a buffer with dontunmap flag for all execs
>   * @mmap-remap-ro:			mmap and mremap a read-only buffer for all execs
>   * @mmap-remap-ro-dontunmap:		mmap and mremap a read-only buffer with dontunmap flag for all execs
> @@ -916,8 +920,10 @@ partial(int fd, struct drm_xe_engine_class_instance *eci, unsigned int flags)
>   * @mmap-file-mlock:			mmap and mlock single buffer, with file backing, for all execs
>   * @mmap-race:				mmap single buffer for all execs with race between cpu and gpu access
>   * @free:				malloc and free buffer for each exec
> + * @free-madvise:			malloc and free buffer for each exec, performs madvise operation
>   * @free-race:				malloc and free buffer for each exec with race between cpu and gpu access
>   * @new:				malloc a new buffer for each exec
> + * @new-madvise:			malloc a new buffer for each exec, performs madvise operation

You have mismatches compare to the section names. Building the
IGTs should complain.

>   * @new-prefetch:			malloc a new buffer and prefetch for each exec
>   * @new-race:				malloc a new buffer for each exec with race between cpu and gpu access
>   * @new-bo-map:				malloc a new buffer or map BO for each exec
> @@ -999,6 +1005,23 @@ static void igt_require_hugepages(void)
>  		      "No huge pages available!\n");
>  }
>  
> +static void
> +madvise_swizzle_op_exec(int fd, uint32_t vm, struct test_exec_data *data,
> +		size_t bo_size, uint64_t addr, int index)
> +{
> +	int preferred_loc;
> +
> +	if (index % 2 == 0)
> +		preferred_loc = DRM_XE_PREFERRED_LOC_DEFAULT_SYSTEM;
> +	else
> +		preferred_loc = DRM_XE_PREFERRED_LOC_DEFAULT_DEVICE;
> +
> +	xe_vm_madvise(fd, vm, to_user_pointer(data), bo_size, 0,
> +			DRM_XE_MEM_RANGE_ATTR_PREFERRED_LOC,
> +			preferred_loc,
> +			0);
> +}
> +
>  static void
>  test_exec(int fd, struct drm_xe_engine_class_instance *eci,
>  	  int n_exec_queues, int n_execs, size_t bo_size,
> @@ -1210,6 +1233,9 @@ test_exec(int fd, struct drm_xe_engine_class_instance *eci,
>  		if (barrier)
>  			pthread_barrier_wait(barrier);
>  
> +		if (flags & MADVISE_SWIZZLE)
> +			madvise_swizzle_op_exec(fd, vm, data, bo_size, addr, i);
> +
>  		if (flags & MULTI_FAULT) {
>  			b = 0;
>  			for (j = 0; j < N_MULTI_FAULT - 1; ++j)
> @@ -1790,7 +1816,9 @@ igt_main
>  	struct drm_xe_engine_class_instance *hwe;
>  	const struct section sections[] = {
>  		{ "malloc", 0 },
> +		{ "malloc-madvise", MADVISE_SWIZZLE },
>  		{ "malloc-prefetch", PREFETCH },
> +		{ "malloc-prefetch-madvise", PREFETCH | MADVISE_SWIZZLE },
>  		{ "malloc-multi-fault", MULTI_FAULT },
>  		{ "malloc-fork-read", FORK_READ },
>  		{ "malloc-fork-read-after", FORK_READ | FORK_READ_AFTER },
> @@ -1802,6 +1830,7 @@ igt_main
>  		{ "mmap", MMAP },
>  		{ "mmap-prefetch", MMAP | PREFETCH },
>  		{ "mmap-remap", MMAP | MREMAP },
> +		{ "mmap-remap-madvise", MMAP | MREMAP | MADVISE_SWIZZLE },
>  		{ "mmap-remap-dontunmap", MMAP | MREMAP | DONTUNMAP },
>  		{ "mmap-remap-ro", MMAP | MREMAP | READ_ONLY_REMAP },
>  		{ "mmap-remap-ro-dontunmap", MMAP | MREMAP | DONTUNMAP |
> @@ -1828,13 +1857,16 @@ igt_main
>  		{ "mmap-file-mlock", MMAP | LOCK | FILE_BACKED },
>  		{ "mmap-race", MMAP | RACE },
>  		{ "free", NEW | FREE },
> +		{ "free-madvise", NEW | FREE | MADVISE_SWIZZLE },
>  		{ "free-race", NEW | FREE | RACE },
>  		{ "new", NEW },
> +		{ "new-madvise", NEW | MADVISE_SWIZZLE },
>  		{ "new-prefetch", NEW | PREFETCH },
>  		{ "new-race", NEW | RACE },
>  		{ "new-bo-map", NEW | BO_MAP },
>  		{ "new-busy", NEW | BUSY },
>  		{ "mmap-free", MMAP | NEW | FREE },
> +		{ "mmap-free", MMAP | NEW | FREE | MADVISE_SWIZZLE },

mmap-free-madvise

>  		{ "mmap-free-huge", MMAP | NEW | FREE | HUGE_PAGE },
>  		{ "mmap-free-race", MMAP | NEW | FREE | RACE },
>  		{ "mmap-new", MMAP | NEW },

Also I thought about this a bit more, 'mmap-new-madvise' would
be helpful too as malloc / free patterns are lazy (i.e.,
sometimes free doesn't call into the kernel) whereas mmap /
munmap are not lazy.

Otherwise LGTM.

Matt

> -- 
> 2.43.0
> 

  reply	other threads:[~2025-09-03 18:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-03 14:13 [PATCH i-g-t v11 0/5] Madvise Tests in IGT nishit.sharma
2025-09-03 14:13 ` [PATCH i-g-t v11 1/5] uapi/xe: Sync latest uAPI KMD header nishit.sharma
2025-09-03 14:23   ` Gurram, Pravalika
2025-09-03 14:13 ` [PATCH i-g-t v11 2/5] lib/xe: Add xe_vm_madvise ioctl support nishit.sharma
2025-09-03 14:27   ` Gurram, Pravalika
2025-09-03 14:13 ` [PATCH i-g-t v11 3/5] lib/xe: Add Helper to get memory attributes nishit.sharma
2025-09-03 14:28   ` Gurram, Pravalika
2025-09-03 14:13 ` [PATCH i-g-t v11 4/5] tests/intel/xe_exec_system_allocator: Add madvise-swizzle test nishit.sharma
2025-09-03 18:14   ` Matthew Brost [this message]
2025-09-03 14:13 ` [PATCH i-g-t v11 5/5] tests/intel/xe_exec_system_allocator: Add atomic_batch test in IGT nishit.sharma
2025-09-04  0:29 ` ✓ Xe.CI.BAT: success for Madvise Tests in IGT (rev11) Patchwork
2025-09-04  0:38 ` ✓ i915.CI.BAT: " Patchwork
2025-09-04  9:18 ` ✓ Xe.CI.Full: " Patchwork
2025-09-05  3:54 ` ✗ i915.CI.Full: failure " 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=aLiFjwXMmsTAvdRF@lstrano-desk.jf.intel.com \
    --to=matthew.brost@intel.com \
    --cc=himal.prasad.ghimiray@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=nishit.sharma@intel.com \
    --cc=pravalika.gurram@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.