Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Auld <matthew.auld@intel.com>
To: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>,
	igt-dev@lists.freedesktop.org
Subject: Re: [igt-dev] [PATCH i-g-t] lib/intel_memory_region: Use separate context for probing offset and alignment
Date: Mon, 9 May 2022 10:55:52 +0100	[thread overview]
Message-ID: <55762f47-74c0-62df-4e8a-9805f15f600a@intel.com> (raw)
In-Reply-To: <20220509093533.30369-1-zbigniew.kempczynski@intel.com>

On 09/05/2022 10:35, Zbigniew Kempczyński wrote:
> Probing alignment/offset (A/O) in default context works properly only
> when there're no processes which competes on same vm space. To avoid
> risk that single probe will be called on already used offset in another
> process lets use dedicated context for this purpose.
> 
> In other words when forking occur without A/O cache filled (subject of
> COW) children will exercise A/O individually. Using same default context
> leads to risk of probing offset which is in flight in another child
> thus we can get different A/O. Such behavior is not allowed as allocator
> infrastructure requires same type, strategy and alignment on single vm.
> We expect coherent A/O in different children so use separate context
> to fill this requirement.
> 
> Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
> Cc: Matthew Auld <matthew.auld@intel.com>
> Fixes: https://gitlab.freedesktop.org/drm/intel/-/issues/5729

Possibly also related:

https://gitlab.freedesktop.org/drm/intel/-/issues/5715
https://gitlab.freedesktop.org/drm/intel/-/issues/5647
https://gitlab.freedesktop.org/drm/intel/-/issues/5709
https://gitlab.freedesktop.org/drm/intel/-/issues/5769
https://gitlab.freedesktop.org/drm/intel/-/issues/5556

?

Change makes sense to me,
Reviewed-by: Matthew Auld <matthew.auld@intel.com>

> ---
>   lib/i915/intel_memory_region.c | 14 ++++++++++++--
>   1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/i915/intel_memory_region.c b/lib/i915/intel_memory_region.c
> index 593f4bedc8..ea9717691c 100644
> --- a/lib/i915/intel_memory_region.c
> +++ b/lib/i915/intel_memory_region.c
> @@ -630,7 +630,7 @@ uint64_t gem_detect_min_start_offset_for_region(int i915, uint32_t region)
>   	struct drm_i915_gem_execbuffer2 eb;
>   	uint64_t start_offset = 0;
>   	uint64_t bb_size = PAGE_SIZE;
> -	uint32_t *batch;
> +	uint32_t *batch, ctx;
>   	uint16_t devid = intel_get_drm_devid(i915);
>   	struct cache_entry *entry, *newentry;
>   
> @@ -640,12 +640,16 @@ uint64_t gem_detect_min_start_offset_for_region(int i915, uint32_t region)
>   		goto out;
>   	pthread_mutex_unlock(&cache_mutex);
>   
> +	/* Use separate context to avoid offset overlapping */
> +	ctx = gem_context_create(i915);
> +
>   	memset(&obj, 0, sizeof(obj));
>   	memset(&eb, 0, sizeof(eb));
>   
>   	eb.buffers_ptr = to_user_pointer(&obj);
>   	eb.buffer_count = 1;
>   	eb.flags = I915_EXEC_DEFAULT;
> +	eb.rsvd1 = ctx;
>   	igt_assert(__gem_create_in_memory_regions(i915, &obj.handle, &bb_size, region) == 0);
>   	obj.flags = EXEC_OBJECT_PINNED;
>   
> @@ -670,6 +674,7 @@ uint64_t gem_detect_min_start_offset_for_region(int i915, uint32_t region)
>   		igt_assert(start_offset <= 1ull << 48);
>   	}
>   	gem_close(i915, obj.handle);
> +	gem_context_destroy(i915, ctx);
>   
>   	newentry = malloc(sizeof(*newentry));
>   	if (!newentry)
> @@ -770,7 +775,7 @@ uint64_t gem_detect_min_alignment_for_regions(int i915,
>   	struct drm_i915_gem_execbuffer2 eb;
>   	uint64_t min_alignment = PAGE_SIZE;
>   	uint64_t bb_size = PAGE_SIZE, obj_size = PAGE_SIZE;
> -	uint32_t *batch;
> +	uint32_t *batch, ctx;
>   	uint16_t devid = intel_get_drm_devid(i915);
>   	struct cache_entry *entry, *newentry;
>   
> @@ -780,6 +785,9 @@ uint64_t gem_detect_min_alignment_for_regions(int i915,
>   		goto out;
>   	pthread_mutex_unlock(&cache_mutex);
>   
> +	/* Use separate context to avoid offset overlapping */
> +	ctx = gem_context_create(i915);
> +
>   	memset(obj, 0, sizeof(obj));
>   	memset(&eb, 0, sizeof(eb));
>   
> @@ -787,6 +795,7 @@ uint64_t gem_detect_min_alignment_for_regions(int i915,
>   	eb.buffers_ptr = to_user_pointer(obj);
>   	eb.buffer_count = ARRAY_SIZE(obj);
>   	eb.flags = I915_EXEC_BATCH_FIRST | I915_EXEC_DEFAULT;
> +	eb.rsvd1 = ctx;
>   	igt_assert(__gem_create_in_memory_regions(i915, &obj[0].handle,
>   						  &bb_size, region1) == 0);
>   
> @@ -815,6 +824,7 @@ uint64_t gem_detect_min_alignment_for_regions(int i915,
>   
>   	gem_close(i915, obj[0].handle);
>   	gem_close(i915, obj[1].handle);
> +	gem_context_destroy(i915, ctx);
>   
>   	newentry = malloc(sizeof(*newentry));
>   	if (!newentry)

  reply	other threads:[~2022-05-09  9:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-09  9:35 [igt-dev] [PATCH i-g-t] lib/intel_memory_region: Use separate context for probing offset and alignment Zbigniew Kempczyński
2022-05-09  9:55 ` Matthew Auld [this message]
2022-05-09 11:03 ` [igt-dev] ✗ Fi.CI.BAT: failure for " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2022-05-09 11:30 [igt-dev] [PATCH i-g-t] " Zbigniew Kempczyński
2022-05-09 11:43 ` Matthew Auld
2022-05-09 14:52   ` Zbigniew Kempczyński
2022-05-09 14:55 Zbigniew Kempczyński

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=55762f47-74c0-62df-4e8a-9805f15f600a@intel.com \
    --to=matthew.auld@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=zbigniew.kempczynski@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