[PATCH 2/2] xe_exec_system_allocator: Require huge pages reserved for huge page tests

Matthew Brost matthew.brost at intel.com
Tue Apr 29 19:33:26 UTC 2025


On Tue, Apr 29, 2025 at 07:29:56PM +0000, Jonathan Cavitt wrote:
> Various subtests in xe_exec_system_allocator attempt to use the
> MAP_HUGETLB flag for mmap.  Doing so will result in an ENOMEM error if
> there are no available huge pages, which can occur if none are reserved
> before boot time.  So, skip the tests if no huge pages have been
> reserved by the kernel.
> 
> Fixes: 41ee4d698fd8 ("tests/xe: Add system_allocator test")
> Signed-off-by: Jonathan Cavitt <jonathan.cavitt at intel.com>
> Cc: Matthew Brost <matthew.brost at intel.com>

Thanks Jonathan I was wondering if we could do something like this.

LGTM:
Reviewed-by: Matthew Brost <matthew.brost at intel.com>

> ---
>  tests/intel/xe_exec_system_allocator.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/tests/intel/xe_exec_system_allocator.c b/tests/intel/xe_exec_system_allocator.c
> index e1121a8627..8a55e0ff64 100644
> --- a/tests/intel/xe_exec_system_allocator.c
> +++ b/tests/intel/xe_exec_system_allocator.c
> @@ -964,6 +964,12 @@ struct test_exec_data {
>  	uint32_t expected_data;
>  };
>  
> +static void igt_require_hugepages(void)
> +{
> +	igt_skip_on_f(!igt_get_meminfo("HugePages_Total"),
> +		      "Huge pages not reserved by the kernel!\n");
> +}
> +
>  static void
>  test_exec(int fd, struct drm_xe_engine_class_instance *eci,
>  	  int n_exec_queues, int n_execs, size_t bo_size,
> @@ -1005,6 +1011,9 @@ test_exec(int fd, struct drm_xe_engine_class_instance *eci,
>  	if (flags & EVERY_OTHER_CHECK && odd(n_execs))
>  		return;
>  
> +	if (flags & HUGE_PAGE)
> +		igt_require_hugepages();
> +
>  	if (flags & EVERY_OTHER_CHECK)
>  		igt_assert(flags & MREMAP);
>  
> @@ -1439,6 +1448,9 @@ threads(int fd, int n_exec_queues, int n_execs, size_t bo_size,
>  	if ((FILE_BACKED | FORK_READ) & flags)
>  		return;
>  
> +	if (flags & HUGE_PAGE)
> +		igt_require_hugepages();
> +
>  	xe_for_each_engine(fd, hwe)
>  		++n_engines;
>  
> @@ -1550,6 +1562,9 @@ processes(int fd, int n_exec_queues, int n_execs, size_t bo_size,
>  	if (flags & FORK_READ)
>  		return;
>  
> +	if (flags & HUGE_PAGE)
> +		igt_require_hugepages();
> +
>  	map_fd = open(sync_file, O_RDWR | O_CREAT, 0x666);
>  	posix_fallocate(map_fd, 0, sizeof(*pdata));
>  	pdata = mmap(NULL, sizeof(*pdata), PROT_READ |
> -- 
> 2.43.0
> 


More information about the igt-dev mailing list