All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [RFC PATCH 1/1] drm/mm: add ig_frag selftest
  2020-05-29 16:33 ` [Intel-gfx] " Nirmoy Das
@ 2020-05-29 15:40   ` Nirmoy
  -1 siblings, 0 replies; 21+ messages in thread
From: Nirmoy @ 2020-05-29 15:40 UTC (permalink / raw)
  To: Nirmoy Das, dri-devel; +Cc: intel-gfx, Nirmoy Das, christian.koenig, chris

This works correctly most of the times but sometimes

20k insertions can take more than 8 times of 10k insertion time.


Regards,

Nirmoy

On 5/29/20 6:33 PM, Nirmoy Das wrote:
> This patch introduces fragmentation in the address range
> and measures time taken by 10k and 20k insertions. ig_frag()
> will fail if time taken by 20k insertions takes more than 4 times
> of 10k insertions as we know that insertions scale quadratically.
> Also tolerate 10% error because of kernel scheduler's jitters.
>
> Output:
> <snip>
> [ 8092.653518] drm_mm: Testing DRM range manger (struct drm_mm), with random_seed=0x9bfb4117 max_iterations=8192 max_prime=128
> [ 8092.653520] drm_mm: igt_sanitycheck - ok!
> [ 8092.653525] igt_debug 0x0000000000000000-0x0000000000000200: 512: free
> [ 8092.653526] igt_debug 0x0000000000000200-0x0000000000000600: 1024: used
> [ 8092.653527] igt_debug 0x0000000000000600-0x0000000000000a00: 1024: free
> [ 8092.653528] igt_debug 0x0000000000000a00-0x0000000000000e00: 1024: used
> [ 8092.653529] igt_debug 0x0000000000000e00-0x0000000000001000: 512: free
> [ 8092.653529] igt_debug total: 4096, used 2048 free 2048
> [ 8112.569813] drm_mm: best fragmented insert of 10000 and 20000 insertions took 504 and 1996 msecs
> [ 8112.723254] drm_mm: bottom-up fragmented insert of 10000 and 20000 insertions took 44 and 108 msecs
> [ 8112.813212] drm_mm: top-down fragmented insert of 10000 and 20000 insertions took 40 and 44 msecs
> [ 8112.847733] drm_mm: evict fragmented insert of 10000 and 20000 insertions took 8 and 20 msecs
> <snip>
>
> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
> ---
>   drivers/gpu/drm/selftests/drm_mm_selftests.h |  1 +
>   drivers/gpu/drm/selftests/test-drm_mm.c      | 73 ++++++++++++++++++++
>   2 files changed, 74 insertions(+)
>
> diff --git a/drivers/gpu/drm/selftests/drm_mm_selftests.h b/drivers/gpu/drm/selftests/drm_mm_selftests.h
> index 6b943ea1c57d..8c87c964176b 100644
> --- a/drivers/gpu/drm/selftests/drm_mm_selftests.h
> +++ b/drivers/gpu/drm/selftests/drm_mm_selftests.h
> @@ -14,6 +14,7 @@ selftest(insert, igt_insert)
>   selftest(replace, igt_replace)
>   selftest(insert_range, igt_insert_range)
>   selftest(align, igt_align)
> +selftest(frag, igt_frag)
>   selftest(align32, igt_align32)
>   selftest(align64, igt_align64)
>   selftest(evict, igt_evict)
> diff --git a/drivers/gpu/drm/selftests/test-drm_mm.c b/drivers/gpu/drm/selftests/test-drm_mm.c
> index 9aabe82dcd3a..05d8f3659b4d 100644
> --- a/drivers/gpu/drm/selftests/test-drm_mm.c
> +++ b/drivers/gpu/drm/selftests/test-drm_mm.c
> @@ -1033,6 +1033,79 @@ static int igt_insert_range(void *ignored)
>   	return 0;
>   }
>   
> +static int get_insert_time(unsigned int num_insert,
> +			   const struct insert_mode *mode)
> +{
> +	struct drm_mm mm;
> +	struct drm_mm_node *nodes, *node, *next;
> +	unsigned int size = 4096, align = 8192;
> +	unsigned long start;
> +	unsigned int i;
> +	int ret = -EINVAL;
> +
> +	drm_mm_init(&mm, 1, U64_MAX - 2);
> +	nodes = vzalloc(array_size(num_insert, sizeof(*nodes)));
> +	if (!nodes)
> +		goto err;
> +
> +	start = jiffies;
> +	for (i = 0; i < num_insert; i++) {
> +		if (!expect_insert(&mm, &nodes[i], size, align, i, mode)) {
> +			pr_err("%s insert failed\n", mode->name);
> +			goto out;
> +		}
> +	}
> +
> +	ret = jiffies_to_msecs(jiffies - start);
> +out:
> +	drm_mm_for_each_node_safe(node, next, &mm)
> +		drm_mm_remove_node(node);
> +	drm_mm_takedown(&mm);
> +	vfree(nodes);
> +err:
> +	return ret;
> +
> +}
> +
> +static int igt_frag(void *ignored)
> +{
> +	const struct insert_mode *mode;
> +	unsigned int insert_time1, insert_time2;
> +	unsigned int insert_size = 10000;
> +	unsigned int scale_factor = 4;
> +	/* tolerate 10% excess insertion duration */
> +	unsigned int error_factor = 110;
> +	int ret = -EINVAL;
> +
> +	for (mode = insert_modes; mode->name; mode++) {
> +		unsigned int expected_time;
> +
> +		insert_time1 = get_insert_time(insert_size, mode);
> +		if (insert_time1 < 0)
> +			goto err;
> +
> +		insert_time2 = get_insert_time((insert_size * 2), mode);
> +		if (insert_time2 < 0)
> +			goto err;
> +
> +		expected_time = (scale_factor * insert_time1 *
> +				 error_factor)/100;
> +		if (insert_time2 > expected_time) {
> +			pr_err("%s fragmented insert took more %u msecs\n",
> +			       mode->name, insert_time2 - expected_time);
> +			goto err;
> +		}
> +
> +		pr_info("%s fragmented insert of %u and %u insertions took %u and %u msecs\n",
> +			mode->name, insert_size, insert_size * 2, insert_time1,
> +			insert_time2);
> +	}
> +
> +	ret = 0;
> +err:
> +	return ret;
> +}
> +
>   static int igt_align(void *ignored)
>   {
>   	const struct insert_mode *mode;
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Intel-gfx] [RFC PATCH 1/1] drm/mm: add ig_frag selftest
@ 2020-05-29 15:40   ` Nirmoy
  0 siblings, 0 replies; 21+ messages in thread
From: Nirmoy @ 2020-05-29 15:40 UTC (permalink / raw)
  To: Nirmoy Das, dri-devel; +Cc: intel-gfx, Nirmoy Das, christian.koenig, chris

This works correctly most of the times but sometimes

20k insertions can take more than 8 times of 10k insertion time.


Regards,

Nirmoy

On 5/29/20 6:33 PM, Nirmoy Das wrote:
> This patch introduces fragmentation in the address range
> and measures time taken by 10k and 20k insertions. ig_frag()
> will fail if time taken by 20k insertions takes more than 4 times
> of 10k insertions as we know that insertions scale quadratically.
> Also tolerate 10% error because of kernel scheduler's jitters.
>
> Output:
> <snip>
> [ 8092.653518] drm_mm: Testing DRM range manger (struct drm_mm), with random_seed=0x9bfb4117 max_iterations=8192 max_prime=128
> [ 8092.653520] drm_mm: igt_sanitycheck - ok!
> [ 8092.653525] igt_debug 0x0000000000000000-0x0000000000000200: 512: free
> [ 8092.653526] igt_debug 0x0000000000000200-0x0000000000000600: 1024: used
> [ 8092.653527] igt_debug 0x0000000000000600-0x0000000000000a00: 1024: free
> [ 8092.653528] igt_debug 0x0000000000000a00-0x0000000000000e00: 1024: used
> [ 8092.653529] igt_debug 0x0000000000000e00-0x0000000000001000: 512: free
> [ 8092.653529] igt_debug total: 4096, used 2048 free 2048
> [ 8112.569813] drm_mm: best fragmented insert of 10000 and 20000 insertions took 504 and 1996 msecs
> [ 8112.723254] drm_mm: bottom-up fragmented insert of 10000 and 20000 insertions took 44 and 108 msecs
> [ 8112.813212] drm_mm: top-down fragmented insert of 10000 and 20000 insertions took 40 and 44 msecs
> [ 8112.847733] drm_mm: evict fragmented insert of 10000 and 20000 insertions took 8 and 20 msecs
> <snip>
>
> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
> ---
>   drivers/gpu/drm/selftests/drm_mm_selftests.h |  1 +
>   drivers/gpu/drm/selftests/test-drm_mm.c      | 73 ++++++++++++++++++++
>   2 files changed, 74 insertions(+)
>
> diff --git a/drivers/gpu/drm/selftests/drm_mm_selftests.h b/drivers/gpu/drm/selftests/drm_mm_selftests.h
> index 6b943ea1c57d..8c87c964176b 100644
> --- a/drivers/gpu/drm/selftests/drm_mm_selftests.h
> +++ b/drivers/gpu/drm/selftests/drm_mm_selftests.h
> @@ -14,6 +14,7 @@ selftest(insert, igt_insert)
>   selftest(replace, igt_replace)
>   selftest(insert_range, igt_insert_range)
>   selftest(align, igt_align)
> +selftest(frag, igt_frag)
>   selftest(align32, igt_align32)
>   selftest(align64, igt_align64)
>   selftest(evict, igt_evict)
> diff --git a/drivers/gpu/drm/selftests/test-drm_mm.c b/drivers/gpu/drm/selftests/test-drm_mm.c
> index 9aabe82dcd3a..05d8f3659b4d 100644
> --- a/drivers/gpu/drm/selftests/test-drm_mm.c
> +++ b/drivers/gpu/drm/selftests/test-drm_mm.c
> @@ -1033,6 +1033,79 @@ static int igt_insert_range(void *ignored)
>   	return 0;
>   }
>   
> +static int get_insert_time(unsigned int num_insert,
> +			   const struct insert_mode *mode)
> +{
> +	struct drm_mm mm;
> +	struct drm_mm_node *nodes, *node, *next;
> +	unsigned int size = 4096, align = 8192;
> +	unsigned long start;
> +	unsigned int i;
> +	int ret = -EINVAL;
> +
> +	drm_mm_init(&mm, 1, U64_MAX - 2);
> +	nodes = vzalloc(array_size(num_insert, sizeof(*nodes)));
> +	if (!nodes)
> +		goto err;
> +
> +	start = jiffies;
> +	for (i = 0; i < num_insert; i++) {
> +		if (!expect_insert(&mm, &nodes[i], size, align, i, mode)) {
> +			pr_err("%s insert failed\n", mode->name);
> +			goto out;
> +		}
> +	}
> +
> +	ret = jiffies_to_msecs(jiffies - start);
> +out:
> +	drm_mm_for_each_node_safe(node, next, &mm)
> +		drm_mm_remove_node(node);
> +	drm_mm_takedown(&mm);
> +	vfree(nodes);
> +err:
> +	return ret;
> +
> +}
> +
> +static int igt_frag(void *ignored)
> +{
> +	const struct insert_mode *mode;
> +	unsigned int insert_time1, insert_time2;
> +	unsigned int insert_size = 10000;
> +	unsigned int scale_factor = 4;
> +	/* tolerate 10% excess insertion duration */
> +	unsigned int error_factor = 110;
> +	int ret = -EINVAL;
> +
> +	for (mode = insert_modes; mode->name; mode++) {
> +		unsigned int expected_time;
> +
> +		insert_time1 = get_insert_time(insert_size, mode);
> +		if (insert_time1 < 0)
> +			goto err;
> +
> +		insert_time2 = get_insert_time((insert_size * 2), mode);
> +		if (insert_time2 < 0)
> +			goto err;
> +
> +		expected_time = (scale_factor * insert_time1 *
> +				 error_factor)/100;
> +		if (insert_time2 > expected_time) {
> +			pr_err("%s fragmented insert took more %u msecs\n",
> +			       mode->name, insert_time2 - expected_time);
> +			goto err;
> +		}
> +
> +		pr_info("%s fragmented insert of %u and %u insertions took %u and %u msecs\n",
> +			mode->name, insert_size, insert_size * 2, insert_time1,
> +			insert_time2);
> +	}
> +
> +	ret = 0;
> +err:
> +	return ret;
> +}
> +
>   static int igt_align(void *ignored)
>   {
>   	const struct insert_mode *mode;
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC PATCH 1/1] drm/mm: add ig_frag selftest
  2020-05-29 15:40   ` [Intel-gfx] " Nirmoy
@ 2020-05-29 15:52     ` Chris Wilson
  -1 siblings, 0 replies; 21+ messages in thread
From: Chris Wilson @ 2020-05-29 15:52 UTC (permalink / raw)
  To: Nirmoy, Nirmoy Das, dri-devel; +Cc: intel-gfx, Nirmoy Das, christian.koenig

Quoting Nirmoy (2020-05-29 16:40:53)
> This works correctly most of the times but sometimes
> 
> 20k insertions can take more than 8 times of 10k insertion time.

The pressure is on to improve then :)

> Regards,
> 
> Nirmoy
> 
> On 5/29/20 6:33 PM, Nirmoy Das wrote:
> > This patch introduces fragmentation in the address range
> > and measures time taken by 10k and 20k insertions. ig_frag()
> > will fail if time taken by 20k insertions takes more than 4 times
> > of 10k insertions as we know that insertions scale quadratically.
> > Also tolerate 10% error because of kernel scheduler's jitters.
> >
> > Output:
> > <snip>
> > [ 8092.653518] drm_mm: Testing DRM range manger (struct drm_mm), with random_seed=0x9bfb4117 max_iterations=8192 max_prime=128
> > [ 8092.653520] drm_mm: igt_sanitycheck - ok!
> > [ 8092.653525] igt_debug 0x0000000000000000-0x0000000000000200: 512: free
> > [ 8092.653526] igt_debug 0x0000000000000200-0x0000000000000600: 1024: used
> > [ 8092.653527] igt_debug 0x0000000000000600-0x0000000000000a00: 1024: free
> > [ 8092.653528] igt_debug 0x0000000000000a00-0x0000000000000e00: 1024: used
> > [ 8092.653529] igt_debug 0x0000000000000e00-0x0000000000001000: 512: free
> > [ 8092.653529] igt_debug total: 4096, used 2048 free 2048
> > [ 8112.569813] drm_mm: best fragmented insert of 10000 and 20000 insertions took 504 and 1996 msecs
> > [ 8112.723254] drm_mm: bottom-up fragmented insert of 10000 and 20000 insertions took 44 and 108 msecs
> > [ 8112.813212] drm_mm: top-down fragmented insert of 10000 and 20000 insertions took 40 and 44 msecs
> > [ 8112.847733] drm_mm: evict fragmented insert of 10000 and 20000 insertions took 8 and 20 msecs
> > <snip>
> >
> > Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
> > ---
> >   drivers/gpu/drm/selftests/drm_mm_selftests.h |  1 +
> >   drivers/gpu/drm/selftests/test-drm_mm.c      | 73 ++++++++++++++++++++
> >   2 files changed, 74 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/selftests/drm_mm_selftests.h b/drivers/gpu/drm/selftests/drm_mm_selftests.h
> > index 6b943ea1c57d..8c87c964176b 100644
> > --- a/drivers/gpu/drm/selftests/drm_mm_selftests.h
> > +++ b/drivers/gpu/drm/selftests/drm_mm_selftests.h
> > @@ -14,6 +14,7 @@ selftest(insert, igt_insert)
> >   selftest(replace, igt_replace)
> >   selftest(insert_range, igt_insert_range)
> >   selftest(align, igt_align)
> > +selftest(frag, igt_frag)
> >   selftest(align32, igt_align32)
> >   selftest(align64, igt_align64)
> >   selftest(evict, igt_evict)
> > diff --git a/drivers/gpu/drm/selftests/test-drm_mm.c b/drivers/gpu/drm/selftests/test-drm_mm.c
> > index 9aabe82dcd3a..05d8f3659b4d 100644
> > --- a/drivers/gpu/drm/selftests/test-drm_mm.c
> > +++ b/drivers/gpu/drm/selftests/test-drm_mm.c
> > @@ -1033,6 +1033,79 @@ static int igt_insert_range(void *ignored)
> >       return 0;
> >   }
> >   
> > +static int get_insert_time(unsigned int num_insert,
> > +                        const struct insert_mode *mode)
> > +{
> > +     struct drm_mm mm;
> > +     struct drm_mm_node *nodes, *node, *next;
> > +     unsigned int size = 4096, align = 8192;
> > +     unsigned long start;
> > +     unsigned int i;
> > +     int ret = -EINVAL;
> > +
> > +     drm_mm_init(&mm, 1, U64_MAX - 2);
> > +     nodes = vzalloc(array_size(num_insert, sizeof(*nodes)));
> > +     if (!nodes)
> > +             goto err;
> > +
> > +     start = jiffies;

Use ktime_t start = ktime_now();

> > +     for (i = 0; i < num_insert; i++) {
> > +             if (!expect_insert(&mm, &nodes[i], size, align, i, mode)) {
> > +                     pr_err("%s insert failed\n", mode->name);
> > +                     goto out;
> > +             }
> > +     }
> > +
> > +     ret = jiffies_to_msecs(jiffies - start);

ret = ktime_sub(ktime_now(), start);

The downside to using ktime is remembering it is s64 and so requires care
and attention in doing math.

> > +out:
> > +     drm_mm_for_each_node_safe(node, next, &mm)
> > +             drm_mm_remove_node(node);
> > +     drm_mm_takedown(&mm);
> > +     vfree(nodes);
> > +err:
> > +     return ret;
> > +
> > +}
> > +
> > +static int igt_frag(void *ignored)
> > +{
> > +     const struct insert_mode *mode;
> > +     unsigned int insert_time1, insert_time2;
> > +     unsigned int insert_size = 10000;
> > +     unsigned int scale_factor = 4;
> > +     /* tolerate 10% excess insertion duration */
> > +     unsigned int error_factor = 110;
> > +     int ret = -EINVAL;
> > +
> > +     for (mode = insert_modes; mode->name; mode++) {
> > +             unsigned int expected_time;
> > +
> > +             insert_time1 = get_insert_time(insert_size, mode);
> > +             if (insert_time1 < 0)
> > +                     goto err;

Ah, can you propagate the actual error. I see you are returning EINVAL
for ENOMEM errors. Just wait until it hits and you have to debug why :)

> > +             insert_time2 = get_insert_time((insert_size * 2), mode);
> > +             if (insert_time2 < 0)
> > +                     goto err;
> > +
> > +             expected_time = (scale_factor * insert_time1 *
> > +                              error_factor)/100;
> > +             if (insert_time2 > expected_time) {
> > +                     pr_err("%s fragmented insert took more %u msecs\n",
> > +                            mode->name, insert_time2 - expected_time);
> > +                     goto err;
> > +             }
> > +
> > +             pr_info("%s fragmented insert of %u and %u insertions took %u and %u msecs\n",
> > +                     mode->name, insert_size, insert_size * 2, insert_time1,
> > +                     insert_time2);

Put the info first before the error. We always want the full details,
with the error message explaining why it's unhappy.
-Chris
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Intel-gfx] [RFC PATCH 1/1] drm/mm: add ig_frag selftest
@ 2020-05-29 15:52     ` Chris Wilson
  0 siblings, 0 replies; 21+ messages in thread
From: Chris Wilson @ 2020-05-29 15:52 UTC (permalink / raw)
  To: Nirmoy, Nirmoy Das, dri-devel; +Cc: intel-gfx, Nirmoy Das, christian.koenig

Quoting Nirmoy (2020-05-29 16:40:53)
> This works correctly most of the times but sometimes
> 
> 20k insertions can take more than 8 times of 10k insertion time.

The pressure is on to improve then :)

> Regards,
> 
> Nirmoy
> 
> On 5/29/20 6:33 PM, Nirmoy Das wrote:
> > This patch introduces fragmentation in the address range
> > and measures time taken by 10k and 20k insertions. ig_frag()
> > will fail if time taken by 20k insertions takes more than 4 times
> > of 10k insertions as we know that insertions scale quadratically.
> > Also tolerate 10% error because of kernel scheduler's jitters.
> >
> > Output:
> > <snip>
> > [ 8092.653518] drm_mm: Testing DRM range manger (struct drm_mm), with random_seed=0x9bfb4117 max_iterations=8192 max_prime=128
> > [ 8092.653520] drm_mm: igt_sanitycheck - ok!
> > [ 8092.653525] igt_debug 0x0000000000000000-0x0000000000000200: 512: free
> > [ 8092.653526] igt_debug 0x0000000000000200-0x0000000000000600: 1024: used
> > [ 8092.653527] igt_debug 0x0000000000000600-0x0000000000000a00: 1024: free
> > [ 8092.653528] igt_debug 0x0000000000000a00-0x0000000000000e00: 1024: used
> > [ 8092.653529] igt_debug 0x0000000000000e00-0x0000000000001000: 512: free
> > [ 8092.653529] igt_debug total: 4096, used 2048 free 2048
> > [ 8112.569813] drm_mm: best fragmented insert of 10000 and 20000 insertions took 504 and 1996 msecs
> > [ 8112.723254] drm_mm: bottom-up fragmented insert of 10000 and 20000 insertions took 44 and 108 msecs
> > [ 8112.813212] drm_mm: top-down fragmented insert of 10000 and 20000 insertions took 40 and 44 msecs
> > [ 8112.847733] drm_mm: evict fragmented insert of 10000 and 20000 insertions took 8 and 20 msecs
> > <snip>
> >
> > Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
> > ---
> >   drivers/gpu/drm/selftests/drm_mm_selftests.h |  1 +
> >   drivers/gpu/drm/selftests/test-drm_mm.c      | 73 ++++++++++++++++++++
> >   2 files changed, 74 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/selftests/drm_mm_selftests.h b/drivers/gpu/drm/selftests/drm_mm_selftests.h
> > index 6b943ea1c57d..8c87c964176b 100644
> > --- a/drivers/gpu/drm/selftests/drm_mm_selftests.h
> > +++ b/drivers/gpu/drm/selftests/drm_mm_selftests.h
> > @@ -14,6 +14,7 @@ selftest(insert, igt_insert)
> >   selftest(replace, igt_replace)
> >   selftest(insert_range, igt_insert_range)
> >   selftest(align, igt_align)
> > +selftest(frag, igt_frag)
> >   selftest(align32, igt_align32)
> >   selftest(align64, igt_align64)
> >   selftest(evict, igt_evict)
> > diff --git a/drivers/gpu/drm/selftests/test-drm_mm.c b/drivers/gpu/drm/selftests/test-drm_mm.c
> > index 9aabe82dcd3a..05d8f3659b4d 100644
> > --- a/drivers/gpu/drm/selftests/test-drm_mm.c
> > +++ b/drivers/gpu/drm/selftests/test-drm_mm.c
> > @@ -1033,6 +1033,79 @@ static int igt_insert_range(void *ignored)
> >       return 0;
> >   }
> >   
> > +static int get_insert_time(unsigned int num_insert,
> > +                        const struct insert_mode *mode)
> > +{
> > +     struct drm_mm mm;
> > +     struct drm_mm_node *nodes, *node, *next;
> > +     unsigned int size = 4096, align = 8192;
> > +     unsigned long start;
> > +     unsigned int i;
> > +     int ret = -EINVAL;
> > +
> > +     drm_mm_init(&mm, 1, U64_MAX - 2);
> > +     nodes = vzalloc(array_size(num_insert, sizeof(*nodes)));
> > +     if (!nodes)
> > +             goto err;
> > +
> > +     start = jiffies;

Use ktime_t start = ktime_now();

> > +     for (i = 0; i < num_insert; i++) {
> > +             if (!expect_insert(&mm, &nodes[i], size, align, i, mode)) {
> > +                     pr_err("%s insert failed\n", mode->name);
> > +                     goto out;
> > +             }
> > +     }
> > +
> > +     ret = jiffies_to_msecs(jiffies - start);

ret = ktime_sub(ktime_now(), start);

The downside to using ktime is remembering it is s64 and so requires care
and attention in doing math.

> > +out:
> > +     drm_mm_for_each_node_safe(node, next, &mm)
> > +             drm_mm_remove_node(node);
> > +     drm_mm_takedown(&mm);
> > +     vfree(nodes);
> > +err:
> > +     return ret;
> > +
> > +}
> > +
> > +static int igt_frag(void *ignored)
> > +{
> > +     const struct insert_mode *mode;
> > +     unsigned int insert_time1, insert_time2;
> > +     unsigned int insert_size = 10000;
> > +     unsigned int scale_factor = 4;
> > +     /* tolerate 10% excess insertion duration */
> > +     unsigned int error_factor = 110;
> > +     int ret = -EINVAL;
> > +
> > +     for (mode = insert_modes; mode->name; mode++) {
> > +             unsigned int expected_time;
> > +
> > +             insert_time1 = get_insert_time(insert_size, mode);
> > +             if (insert_time1 < 0)
> > +                     goto err;

Ah, can you propagate the actual error. I see you are returning EINVAL
for ENOMEM errors. Just wait until it hits and you have to debug why :)

> > +             insert_time2 = get_insert_time((insert_size * 2), mode);
> > +             if (insert_time2 < 0)
> > +                     goto err;
> > +
> > +             expected_time = (scale_factor * insert_time1 *
> > +                              error_factor)/100;
> > +             if (insert_time2 > expected_time) {
> > +                     pr_err("%s fragmented insert took more %u msecs\n",
> > +                            mode->name, insert_time2 - expected_time);
> > +                     goto err;
> > +             }
> > +
> > +             pr_info("%s fragmented insert of %u and %u insertions took %u and %u msecs\n",
> > +                     mode->name, insert_size, insert_size * 2, insert_time1,
> > +                     insert_time2);

Put the info first before the error. We always want the full details,
with the error message explaining why it's unhappy.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [RFC PATCH 1/1] drm/mm: add ig_frag selftest
@ 2020-05-29 16:33 ` Nirmoy Das
  0 siblings, 0 replies; 21+ messages in thread
From: Nirmoy Das @ 2020-05-29 16:33 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx, Nirmoy Das, christian.koenig, chris

This patch introduces fragmentation in the address range
and measures time taken by 10k and 20k insertions. ig_frag()
will fail if time taken by 20k insertions takes more than 4 times
of 10k insertions as we know that insertions scale quadratically.
Also tolerate 10% error because of kernel scheduler's jitters.

Output:
<snip>
[ 8092.653518] drm_mm: Testing DRM range manger (struct drm_mm), with random_seed=0x9bfb4117 max_iterations=8192 max_prime=128
[ 8092.653520] drm_mm: igt_sanitycheck - ok!
[ 8092.653525] igt_debug 0x0000000000000000-0x0000000000000200: 512: free
[ 8092.653526] igt_debug 0x0000000000000200-0x0000000000000600: 1024: used
[ 8092.653527] igt_debug 0x0000000000000600-0x0000000000000a00: 1024: free
[ 8092.653528] igt_debug 0x0000000000000a00-0x0000000000000e00: 1024: used
[ 8092.653529] igt_debug 0x0000000000000e00-0x0000000000001000: 512: free
[ 8092.653529] igt_debug total: 4096, used 2048 free 2048
[ 8112.569813] drm_mm: best fragmented insert of 10000 and 20000 insertions took 504 and 1996 msecs
[ 8112.723254] drm_mm: bottom-up fragmented insert of 10000 and 20000 insertions took 44 and 108 msecs
[ 8112.813212] drm_mm: top-down fragmented insert of 10000 and 20000 insertions took 40 and 44 msecs
[ 8112.847733] drm_mm: evict fragmented insert of 10000 and 20000 insertions took 8 and 20 msecs
<snip>

Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
---
 drivers/gpu/drm/selftests/drm_mm_selftests.h |  1 +
 drivers/gpu/drm/selftests/test-drm_mm.c      | 73 ++++++++++++++++++++
 2 files changed, 74 insertions(+)

diff --git a/drivers/gpu/drm/selftests/drm_mm_selftests.h b/drivers/gpu/drm/selftests/drm_mm_selftests.h
index 6b943ea1c57d..8c87c964176b 100644
--- a/drivers/gpu/drm/selftests/drm_mm_selftests.h
+++ b/drivers/gpu/drm/selftests/drm_mm_selftests.h
@@ -14,6 +14,7 @@ selftest(insert, igt_insert)
 selftest(replace, igt_replace)
 selftest(insert_range, igt_insert_range)
 selftest(align, igt_align)
+selftest(frag, igt_frag)
 selftest(align32, igt_align32)
 selftest(align64, igt_align64)
 selftest(evict, igt_evict)
diff --git a/drivers/gpu/drm/selftests/test-drm_mm.c b/drivers/gpu/drm/selftests/test-drm_mm.c
index 9aabe82dcd3a..05d8f3659b4d 100644
--- a/drivers/gpu/drm/selftests/test-drm_mm.c
+++ b/drivers/gpu/drm/selftests/test-drm_mm.c
@@ -1033,6 +1033,79 @@ static int igt_insert_range(void *ignored)
 	return 0;
 }
 
+static int get_insert_time(unsigned int num_insert,
+			   const struct insert_mode *mode)
+{
+	struct drm_mm mm;
+	struct drm_mm_node *nodes, *node, *next;
+	unsigned int size = 4096, align = 8192;
+	unsigned long start;
+	unsigned int i;
+	int ret = -EINVAL;
+
+	drm_mm_init(&mm, 1, U64_MAX - 2);
+	nodes = vzalloc(array_size(num_insert, sizeof(*nodes)));
+	if (!nodes)
+		goto err;
+
+	start = jiffies;
+	for (i = 0; i < num_insert; i++) {
+		if (!expect_insert(&mm, &nodes[i], size, align, i, mode)) {
+			pr_err("%s insert failed\n", mode->name);
+			goto out;
+		}
+	}
+
+	ret = jiffies_to_msecs(jiffies - start);
+out:
+	drm_mm_for_each_node_safe(node, next, &mm)
+		drm_mm_remove_node(node);
+	drm_mm_takedown(&mm);
+	vfree(nodes);
+err:
+	return ret;
+
+}
+
+static int igt_frag(void *ignored)
+{
+	const struct insert_mode *mode;
+	unsigned int insert_time1, insert_time2;
+	unsigned int insert_size = 10000;
+	unsigned int scale_factor = 4;
+	/* tolerate 10% excess insertion duration */
+	unsigned int error_factor = 110;
+	int ret = -EINVAL;
+
+	for (mode = insert_modes; mode->name; mode++) {
+		unsigned int expected_time;
+
+		insert_time1 = get_insert_time(insert_size, mode);
+		if (insert_time1 < 0)
+			goto err;
+
+		insert_time2 = get_insert_time((insert_size * 2), mode);
+		if (insert_time2 < 0)
+			goto err;
+
+		expected_time = (scale_factor * insert_time1 *
+				 error_factor)/100;
+		if (insert_time2 > expected_time) {
+			pr_err("%s fragmented insert took more %u msecs\n",
+			       mode->name, insert_time2 - expected_time);
+			goto err;
+		}
+
+		pr_info("%s fragmented insert of %u and %u insertions took %u and %u msecs\n",
+			mode->name, insert_size, insert_size * 2, insert_time1,
+			insert_time2);
+	}
+
+	ret = 0;
+err:
+	return ret;
+}
+
 static int igt_align(void *ignored)
 {
 	const struct insert_mode *mode;
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Intel-gfx] [RFC PATCH 1/1] drm/mm: add ig_frag selftest
@ 2020-05-29 16:33 ` Nirmoy Das
  0 siblings, 0 replies; 21+ messages in thread
From: Nirmoy Das @ 2020-05-29 16:33 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx, Nirmoy Das, christian.koenig, chris

This patch introduces fragmentation in the address range
and measures time taken by 10k and 20k insertions. ig_frag()
will fail if time taken by 20k insertions takes more than 4 times
of 10k insertions as we know that insertions scale quadratically.
Also tolerate 10% error because of kernel scheduler's jitters.

Output:
<snip>
[ 8092.653518] drm_mm: Testing DRM range manger (struct drm_mm), with random_seed=0x9bfb4117 max_iterations=8192 max_prime=128
[ 8092.653520] drm_mm: igt_sanitycheck - ok!
[ 8092.653525] igt_debug 0x0000000000000000-0x0000000000000200: 512: free
[ 8092.653526] igt_debug 0x0000000000000200-0x0000000000000600: 1024: used
[ 8092.653527] igt_debug 0x0000000000000600-0x0000000000000a00: 1024: free
[ 8092.653528] igt_debug 0x0000000000000a00-0x0000000000000e00: 1024: used
[ 8092.653529] igt_debug 0x0000000000000e00-0x0000000000001000: 512: free
[ 8092.653529] igt_debug total: 4096, used 2048 free 2048
[ 8112.569813] drm_mm: best fragmented insert of 10000 and 20000 insertions took 504 and 1996 msecs
[ 8112.723254] drm_mm: bottom-up fragmented insert of 10000 and 20000 insertions took 44 and 108 msecs
[ 8112.813212] drm_mm: top-down fragmented insert of 10000 and 20000 insertions took 40 and 44 msecs
[ 8112.847733] drm_mm: evict fragmented insert of 10000 and 20000 insertions took 8 and 20 msecs
<snip>

Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
---
 drivers/gpu/drm/selftests/drm_mm_selftests.h |  1 +
 drivers/gpu/drm/selftests/test-drm_mm.c      | 73 ++++++++++++++++++++
 2 files changed, 74 insertions(+)

diff --git a/drivers/gpu/drm/selftests/drm_mm_selftests.h b/drivers/gpu/drm/selftests/drm_mm_selftests.h
index 6b943ea1c57d..8c87c964176b 100644
--- a/drivers/gpu/drm/selftests/drm_mm_selftests.h
+++ b/drivers/gpu/drm/selftests/drm_mm_selftests.h
@@ -14,6 +14,7 @@ selftest(insert, igt_insert)
 selftest(replace, igt_replace)
 selftest(insert_range, igt_insert_range)
 selftest(align, igt_align)
+selftest(frag, igt_frag)
 selftest(align32, igt_align32)
 selftest(align64, igt_align64)
 selftest(evict, igt_evict)
diff --git a/drivers/gpu/drm/selftests/test-drm_mm.c b/drivers/gpu/drm/selftests/test-drm_mm.c
index 9aabe82dcd3a..05d8f3659b4d 100644
--- a/drivers/gpu/drm/selftests/test-drm_mm.c
+++ b/drivers/gpu/drm/selftests/test-drm_mm.c
@@ -1033,6 +1033,79 @@ static int igt_insert_range(void *ignored)
 	return 0;
 }
 
+static int get_insert_time(unsigned int num_insert,
+			   const struct insert_mode *mode)
+{
+	struct drm_mm mm;
+	struct drm_mm_node *nodes, *node, *next;
+	unsigned int size = 4096, align = 8192;
+	unsigned long start;
+	unsigned int i;
+	int ret = -EINVAL;
+
+	drm_mm_init(&mm, 1, U64_MAX - 2);
+	nodes = vzalloc(array_size(num_insert, sizeof(*nodes)));
+	if (!nodes)
+		goto err;
+
+	start = jiffies;
+	for (i = 0; i < num_insert; i++) {
+		if (!expect_insert(&mm, &nodes[i], size, align, i, mode)) {
+			pr_err("%s insert failed\n", mode->name);
+			goto out;
+		}
+	}
+
+	ret = jiffies_to_msecs(jiffies - start);
+out:
+	drm_mm_for_each_node_safe(node, next, &mm)
+		drm_mm_remove_node(node);
+	drm_mm_takedown(&mm);
+	vfree(nodes);
+err:
+	return ret;
+
+}
+
+static int igt_frag(void *ignored)
+{
+	const struct insert_mode *mode;
+	unsigned int insert_time1, insert_time2;
+	unsigned int insert_size = 10000;
+	unsigned int scale_factor = 4;
+	/* tolerate 10% excess insertion duration */
+	unsigned int error_factor = 110;
+	int ret = -EINVAL;
+
+	for (mode = insert_modes; mode->name; mode++) {
+		unsigned int expected_time;
+
+		insert_time1 = get_insert_time(insert_size, mode);
+		if (insert_time1 < 0)
+			goto err;
+
+		insert_time2 = get_insert_time((insert_size * 2), mode);
+		if (insert_time2 < 0)
+			goto err;
+
+		expected_time = (scale_factor * insert_time1 *
+				 error_factor)/100;
+		if (insert_time2 > expected_time) {
+			pr_err("%s fragmented insert took more %u msecs\n",
+			       mode->name, insert_time2 - expected_time);
+			goto err;
+		}
+
+		pr_info("%s fragmented insert of %u and %u insertions took %u and %u msecs\n",
+			mode->name, insert_size, insert_size * 2, insert_time1,
+			insert_time2);
+	}
+
+	ret = 0;
+err:
+	return ret;
+}
+
 static int igt_align(void *ignored)
 {
 	const struct insert_mode *mode;
-- 
2.26.2

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [RFC PATCH 1/1] drm/mm: add ig_frag selftest
  2020-05-29 15:52     ` [Intel-gfx] " Chris Wilson
@ 2020-05-29 21:01       ` Nirmoy
  -1 siblings, 0 replies; 21+ messages in thread
From: Nirmoy @ 2020-05-29 21:01 UTC (permalink / raw)
  To: Chris Wilson, Nirmoy Das, dri-devel
  Cc: intel-gfx, Nirmoy Das, christian.koenig


On 5/29/20 5:52 PM, Chris Wilson wrote:
> Quoting Nirmoy (2020-05-29 16:40:53)
>> This works correctly most of the times but sometimes


I have to take my word back. In another machine,  20k insertions in

best mode takes 6-9 times more than 10k insertions, all most all the time.

evict, bottom-up and top-down modes remains in 2-5 times range.


If I reduce the insertions to 1k and 2k then scaling factor for best 
mode stays  below 4 most of the time.

evict, bottom-up and top-down modes remains in 2-3 times range.


I wonder if it makes sense to test with only 1k and 2k insertions and 
tolerate more than error if the mode == best.

Regards,

Nirmoy

>>
>> 20k insertions can take more than 8 times of 10k insertion time.
> The pressure is on to improve then :)
>
>> Regards,
>>
>> Nirmoy
>>
>> On 5/29/20 6:33 PM, Nirmoy Das wrote:
>>> This patch introduces fragmentation in the address range
>>> and measures time taken by 10k and 20k insertions. ig_frag()
>>> will fail if time taken by 20k insertions takes more than 4 times
>>> of 10k insertions as we know that insertions scale quadratically.
>>> Also tolerate 10% error because of kernel scheduler's jitters.
>>>
>>> Output:
>>> <snip>
>>> [ 8092.653518] drm_mm: Testing DRM range manger (struct drm_mm), with random_seed=0x9bfb4117 max_iterations=8192 max_prime=128
>>> [ 8092.653520] drm_mm: igt_sanitycheck - ok!
>>> [ 8092.653525] igt_debug 0x0000000000000000-0x0000000000000200: 512: free
>>> [ 8092.653526] igt_debug 0x0000000000000200-0x0000000000000600: 1024: used
>>> [ 8092.653527] igt_debug 0x0000000000000600-0x0000000000000a00: 1024: free
>>> [ 8092.653528] igt_debug 0x0000000000000a00-0x0000000000000e00: 1024: used
>>> [ 8092.653529] igt_debug 0x0000000000000e00-0x0000000000001000: 512: free
>>> [ 8092.653529] igt_debug total: 4096, used 2048 free 2048
>>> [ 8112.569813] drm_mm: best fragmented insert of 10000 and 20000 insertions took 504 and 1996 msecs
>>> [ 8112.723254] drm_mm: bottom-up fragmented insert of 10000 and 20000 insertions took 44 and 108 msecs
>>> [ 8112.813212] drm_mm: top-down fragmented insert of 10000 and 20000 insertions took 40 and 44 msecs
>>> [ 8112.847733] drm_mm: evict fragmented insert of 10000 and 20000 insertions took 8 and 20 msecs
>>> <snip>
>>>
>>> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
>>> ---
>>>    drivers/gpu/drm/selftests/drm_mm_selftests.h |  1 +
>>>    drivers/gpu/drm/selftests/test-drm_mm.c      | 73 ++++++++++++++++++++
>>>    2 files changed, 74 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/selftests/drm_mm_selftests.h b/drivers/gpu/drm/selftests/drm_mm_selftests.h
>>> index 6b943ea1c57d..8c87c964176b 100644
>>> --- a/drivers/gpu/drm/selftests/drm_mm_selftests.h
>>> +++ b/drivers/gpu/drm/selftests/drm_mm_selftests.h
>>> @@ -14,6 +14,7 @@ selftest(insert, igt_insert)
>>>    selftest(replace, igt_replace)
>>>    selftest(insert_range, igt_insert_range)
>>>    selftest(align, igt_align)
>>> +selftest(frag, igt_frag)
>>>    selftest(align32, igt_align32)
>>>    selftest(align64, igt_align64)
>>>    selftest(evict, igt_evict)
>>> diff --git a/drivers/gpu/drm/selftests/test-drm_mm.c b/drivers/gpu/drm/selftests/test-drm_mm.c
>>> index 9aabe82dcd3a..05d8f3659b4d 100644
>>> --- a/drivers/gpu/drm/selftests/test-drm_mm.c
>>> +++ b/drivers/gpu/drm/selftests/test-drm_mm.c
>>> @@ -1033,6 +1033,79 @@ static int igt_insert_range(void *ignored)
>>>        return 0;
>>>    }
>>>    
>>> +static int get_insert_time(unsigned int num_insert,
>>> +                        const struct insert_mode *mode)
>>> +{
>>> +     struct drm_mm mm;
>>> +     struct drm_mm_node *nodes, *node, *next;
>>> +     unsigned int size = 4096, align = 8192;
>>> +     unsigned long start;
>>> +     unsigned int i;
>>> +     int ret = -EINVAL;
>>> +
>>> +     drm_mm_init(&mm, 1, U64_MAX - 2);
>>> +     nodes = vzalloc(array_size(num_insert, sizeof(*nodes)));
>>> +     if (!nodes)
>>> +             goto err;
>>> +
>>> +     start = jiffies;
> Use ktime_t start = ktime_now();
>
>>> +     for (i = 0; i < num_insert; i++) {
>>> +             if (!expect_insert(&mm, &nodes[i], size, align, i, mode)) {
>>> +                     pr_err("%s insert failed\n", mode->name);
>>> +                     goto out;
>>> +             }
>>> +     }
>>> +
>>> +     ret = jiffies_to_msecs(jiffies - start);
> ret = ktime_sub(ktime_now(), start);
>
> The downside to using ktime is remembering it is s64 and so requires care
> and attention in doing math.
>
>>> +out:
>>> +     drm_mm_for_each_node_safe(node, next, &mm)
>>> +             drm_mm_remove_node(node);
>>> +     drm_mm_takedown(&mm);
>>> +     vfree(nodes);
>>> +err:
>>> +     return ret;
>>> +
>>> +}
>>> +
>>> +static int igt_frag(void *ignored)
>>> +{
>>> +     const struct insert_mode *mode;
>>> +     unsigned int insert_time1, insert_time2;
>>> +     unsigned int insert_size = 10000;
>>> +     unsigned int scale_factor = 4;
>>> +     /* tolerate 10% excess insertion duration */
>>> +     unsigned int error_factor = 110;
>>> +     int ret = -EINVAL;
>>> +
>>> +     for (mode = insert_modes; mode->name; mode++) {
>>> +             unsigned int expected_time;
>>> +
>>> +             insert_time1 = get_insert_time(insert_size, mode);
>>> +             if (insert_time1 < 0)
>>> +                     goto err;
> Ah, can you propagate the actual error. I see you are returning EINVAL
> for ENOMEM errors. Just wait until it hits and you have to debug why :)
>
>>> +             insert_time2 = get_insert_time((insert_size * 2), mode);
>>> +             if (insert_time2 < 0)
>>> +                     goto err;
>>> +
>>> +             expected_time = (scale_factor * insert_time1 *
>>> +                              error_factor)/100;
>>> +             if (insert_time2 > expected_time) {
>>> +                     pr_err("%s fragmented insert took more %u msecs\n",
>>> +                            mode->name, insert_time2 - expected_time);
>>> +                     goto err;
>>> +             }
>>> +
>>> +             pr_info("%s fragmented insert of %u and %u insertions took %u and %u msecs\n",
>>> +                     mode->name, insert_size, insert_size * 2, insert_time1,
>>> +                     insert_time2);
> Put the info first before the error. We always want the full details,
> with the error message explaining why it's unhappy.
> -Chris
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Fdri-devel&amp;data=02%7C01%7Cnirmoy.das%40amd.com%7C5c7df129b9cf44b3ae4008d803e84445%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637263643415833767&amp;sdata=PrCQse4nhN0ZITT9OniuHhF7A5uxJD6ehk0PMjm7WMU%3D&amp;reserved=0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Intel-gfx] [RFC PATCH 1/1] drm/mm: add ig_frag selftest
@ 2020-05-29 21:01       ` Nirmoy
  0 siblings, 0 replies; 21+ messages in thread
From: Nirmoy @ 2020-05-29 21:01 UTC (permalink / raw)
  To: Chris Wilson, Nirmoy Das, dri-devel
  Cc: intel-gfx, Nirmoy Das, christian.koenig


On 5/29/20 5:52 PM, Chris Wilson wrote:
> Quoting Nirmoy (2020-05-29 16:40:53)
>> This works correctly most of the times but sometimes


I have to take my word back. In another machine,  20k insertions in

best mode takes 6-9 times more than 10k insertions, all most all the time.

evict, bottom-up and top-down modes remains in 2-5 times range.


If I reduce the insertions to 1k and 2k then scaling factor for best 
mode stays  below 4 most of the time.

evict, bottom-up and top-down modes remains in 2-3 times range.


I wonder if it makes sense to test with only 1k and 2k insertions and 
tolerate more than error if the mode == best.

Regards,

Nirmoy

>>
>> 20k insertions can take more than 8 times of 10k insertion time.
> The pressure is on to improve then :)
>
>> Regards,
>>
>> Nirmoy
>>
>> On 5/29/20 6:33 PM, Nirmoy Das wrote:
>>> This patch introduces fragmentation in the address range
>>> and measures time taken by 10k and 20k insertions. ig_frag()
>>> will fail if time taken by 20k insertions takes more than 4 times
>>> of 10k insertions as we know that insertions scale quadratically.
>>> Also tolerate 10% error because of kernel scheduler's jitters.
>>>
>>> Output:
>>> <snip>
>>> [ 8092.653518] drm_mm: Testing DRM range manger (struct drm_mm), with random_seed=0x9bfb4117 max_iterations=8192 max_prime=128
>>> [ 8092.653520] drm_mm: igt_sanitycheck - ok!
>>> [ 8092.653525] igt_debug 0x0000000000000000-0x0000000000000200: 512: free
>>> [ 8092.653526] igt_debug 0x0000000000000200-0x0000000000000600: 1024: used
>>> [ 8092.653527] igt_debug 0x0000000000000600-0x0000000000000a00: 1024: free
>>> [ 8092.653528] igt_debug 0x0000000000000a00-0x0000000000000e00: 1024: used
>>> [ 8092.653529] igt_debug 0x0000000000000e00-0x0000000000001000: 512: free
>>> [ 8092.653529] igt_debug total: 4096, used 2048 free 2048
>>> [ 8112.569813] drm_mm: best fragmented insert of 10000 and 20000 insertions took 504 and 1996 msecs
>>> [ 8112.723254] drm_mm: bottom-up fragmented insert of 10000 and 20000 insertions took 44 and 108 msecs
>>> [ 8112.813212] drm_mm: top-down fragmented insert of 10000 and 20000 insertions took 40 and 44 msecs
>>> [ 8112.847733] drm_mm: evict fragmented insert of 10000 and 20000 insertions took 8 and 20 msecs
>>> <snip>
>>>
>>> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
>>> ---
>>>    drivers/gpu/drm/selftests/drm_mm_selftests.h |  1 +
>>>    drivers/gpu/drm/selftests/test-drm_mm.c      | 73 ++++++++++++++++++++
>>>    2 files changed, 74 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/selftests/drm_mm_selftests.h b/drivers/gpu/drm/selftests/drm_mm_selftests.h
>>> index 6b943ea1c57d..8c87c964176b 100644
>>> --- a/drivers/gpu/drm/selftests/drm_mm_selftests.h
>>> +++ b/drivers/gpu/drm/selftests/drm_mm_selftests.h
>>> @@ -14,6 +14,7 @@ selftest(insert, igt_insert)
>>>    selftest(replace, igt_replace)
>>>    selftest(insert_range, igt_insert_range)
>>>    selftest(align, igt_align)
>>> +selftest(frag, igt_frag)
>>>    selftest(align32, igt_align32)
>>>    selftest(align64, igt_align64)
>>>    selftest(evict, igt_evict)
>>> diff --git a/drivers/gpu/drm/selftests/test-drm_mm.c b/drivers/gpu/drm/selftests/test-drm_mm.c
>>> index 9aabe82dcd3a..05d8f3659b4d 100644
>>> --- a/drivers/gpu/drm/selftests/test-drm_mm.c
>>> +++ b/drivers/gpu/drm/selftests/test-drm_mm.c
>>> @@ -1033,6 +1033,79 @@ static int igt_insert_range(void *ignored)
>>>        return 0;
>>>    }
>>>    
>>> +static int get_insert_time(unsigned int num_insert,
>>> +                        const struct insert_mode *mode)
>>> +{
>>> +     struct drm_mm mm;
>>> +     struct drm_mm_node *nodes, *node, *next;
>>> +     unsigned int size = 4096, align = 8192;
>>> +     unsigned long start;
>>> +     unsigned int i;
>>> +     int ret = -EINVAL;
>>> +
>>> +     drm_mm_init(&mm, 1, U64_MAX - 2);
>>> +     nodes = vzalloc(array_size(num_insert, sizeof(*nodes)));
>>> +     if (!nodes)
>>> +             goto err;
>>> +
>>> +     start = jiffies;
> Use ktime_t start = ktime_now();
>
>>> +     for (i = 0; i < num_insert; i++) {
>>> +             if (!expect_insert(&mm, &nodes[i], size, align, i, mode)) {
>>> +                     pr_err("%s insert failed\n", mode->name);
>>> +                     goto out;
>>> +             }
>>> +     }
>>> +
>>> +     ret = jiffies_to_msecs(jiffies - start);
> ret = ktime_sub(ktime_now(), start);
>
> The downside to using ktime is remembering it is s64 and so requires care
> and attention in doing math.
>
>>> +out:
>>> +     drm_mm_for_each_node_safe(node, next, &mm)
>>> +             drm_mm_remove_node(node);
>>> +     drm_mm_takedown(&mm);
>>> +     vfree(nodes);
>>> +err:
>>> +     return ret;
>>> +
>>> +}
>>> +
>>> +static int igt_frag(void *ignored)
>>> +{
>>> +     const struct insert_mode *mode;
>>> +     unsigned int insert_time1, insert_time2;
>>> +     unsigned int insert_size = 10000;
>>> +     unsigned int scale_factor = 4;
>>> +     /* tolerate 10% excess insertion duration */
>>> +     unsigned int error_factor = 110;
>>> +     int ret = -EINVAL;
>>> +
>>> +     for (mode = insert_modes; mode->name; mode++) {
>>> +             unsigned int expected_time;
>>> +
>>> +             insert_time1 = get_insert_time(insert_size, mode);
>>> +             if (insert_time1 < 0)
>>> +                     goto err;
> Ah, can you propagate the actual error. I see you are returning EINVAL
> for ENOMEM errors. Just wait until it hits and you have to debug why :)
>
>>> +             insert_time2 = get_insert_time((insert_size * 2), mode);
>>> +             if (insert_time2 < 0)
>>> +                     goto err;
>>> +
>>> +             expected_time = (scale_factor * insert_time1 *
>>> +                              error_factor)/100;
>>> +             if (insert_time2 > expected_time) {
>>> +                     pr_err("%s fragmented insert took more %u msecs\n",
>>> +                            mode->name, insert_time2 - expected_time);
>>> +                     goto err;
>>> +             }
>>> +
>>> +             pr_info("%s fragmented insert of %u and %u insertions took %u and %u msecs\n",
>>> +                     mode->name, insert_size, insert_size * 2, insert_time1,
>>> +                     insert_time2);
> Put the info first before the error. We always want the full details,
> with the error message explaining why it's unhappy.
> -Chris
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Fdri-devel&amp;data=02%7C01%7Cnirmoy.das%40amd.com%7C5c7df129b9cf44b3ae4008d803e84445%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637263643415833767&amp;sdata=PrCQse4nhN0ZITT9OniuHhF7A5uxJD6ehk0PMjm7WMU%3D&amp;reserved=0
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for series starting with [RFC,1/1] drm/mm: add ig_frag selftest
  2020-05-29 16:33 ` [Intel-gfx] " Nirmoy Das
  (?)
  (?)
@ 2020-05-29 22:46 ` Patchwork
  -1 siblings, 0 replies; 21+ messages in thread
From: Patchwork @ 2020-05-29 22:46 UTC (permalink / raw)
  To: Nirmoy Das; +Cc: intel-gfx

== Series Details ==

Series: series starting with [RFC,1/1] drm/mm: add ig_frag selftest
URL   : https://patchwork.freedesktop.org/series/77803/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
320cc6810801 drm/mm: add ig_frag selftest
-:82: CHECK:BRACES: Blank lines aren't necessary before a close brace '}'
#82: FILE: drivers/gpu/drm/selftests/test-drm_mm.c:1068:
+
+}

-:106: CHECK:SPACING: spaces preferred around that '/' (ctx:VxV)
#106: FILE: drivers/gpu/drm/selftests/test-drm_mm.c:1092:
+				 error_factor)/100;
 				              ^

-:125: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Nirmoy Das <nirmoy.aiemd@gmail.com>'

total: 0 errors, 1 warnings, 2 checks, 86 lines checked

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Intel-gfx] ✓ Fi.CI.BAT: success for series starting with [RFC,1/1] drm/mm: add ig_frag selftest
  2020-05-29 16:33 ` [Intel-gfx] " Nirmoy Das
                   ` (2 preceding siblings ...)
  (?)
@ 2020-05-29 23:07 ` Patchwork
  -1 siblings, 0 replies; 21+ messages in thread
From: Patchwork @ 2020-05-29 23:07 UTC (permalink / raw)
  To: Nirmoy Das; +Cc: intel-gfx

== Series Details ==

Series: series starting with [RFC,1/1] drm/mm: add ig_frag selftest
URL   : https://patchwork.freedesktop.org/series/77803/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_8556 -> Patchwork_17823
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/index.html

Known issues
------------

  Here are the changes found in Patchwork_17823 that come from known issues:

### IGT changes ###

#### Possible fixes ####

  * igt@i915_selftest@live@active:
    - fi-bsw-n3050:       [DMESG-FAIL][1] ([i915#541]) -> [PASS][2]
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8556/fi-bsw-n3050/igt@i915_selftest@live@active.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/fi-bsw-n3050/igt@i915_selftest@live@active.html

  
  [i915#541]: https://gitlab.freedesktop.org/drm/intel/issues/541


Participating hosts (50 -> 43)
------------------------------

  Missing    (7): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-kbl-7560u fi-byt-clapper fi-bdw-samus 


Build changes
-------------

  * Linux: CI_DRM_8556 -> Patchwork_17823

  CI-20190529: 20190529
  CI_DRM_8556: a12abc504361cc53eeb53c2948aebbd88709a901 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5684: bd399f5eb8263bb4a84ae6a5bb1a13d329e0515d @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_17823: 320cc6810801929affc6303c2481c0d2b735414e @ git://anongit.freedesktop.org/gfx-ci/linux


== Linux commits ==

320cc6810801 drm/mm: add ig_frag selftest

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/index.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Intel-gfx] ✓ Fi.CI.IGT: success for series starting with [RFC,1/1] drm/mm: add ig_frag selftest
  2020-05-29 16:33 ` [Intel-gfx] " Nirmoy Das
                   ` (3 preceding siblings ...)
  (?)
@ 2020-05-30  3:20 ` Patchwork
  -1 siblings, 0 replies; 21+ messages in thread
From: Patchwork @ 2020-05-30  3:20 UTC (permalink / raw)
  To: Nirmoy Das; +Cc: intel-gfx

== Series Details ==

Series: series starting with [RFC,1/1] drm/mm: add ig_frag selftest
URL   : https://patchwork.freedesktop.org/series/77803/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_8556_full -> Patchwork_17823_full
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  

Possible new issues
-------------------

  Here are the unknown changes that may have been introduced in Patchwork_17823_full:

### IGT changes ###

#### Possible regressions ####

  * {igt@drm_mm@all@frag} (NEW):
    - shard-apl:          NOTRUN -> [DMESG-FAIL][1]
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-apl3/igt@drm_mm@all@frag.html
    - shard-tglb:         NOTRUN -> [DMESG-FAIL][2]
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-tglb1/igt@drm_mm@all@frag.html
    - shard-glk:          NOTRUN -> [DMESG-FAIL][3]
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-glk8/igt@drm_mm@all@frag.html

  
New tests
---------

  New tests have been introduced between CI_DRM_8556_full and Patchwork_17823_full:

### New IGT tests (1) ###

  * igt@drm_mm@all@frag:
    - Statuses : 3 dmesg-fail(s) 4 pass(s)
    - Exec time: [2.53, 33.41] s

  

Known issues
------------

  Here are the changes found in Patchwork_17823_full that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@gem_exec_suspend@basic-s3:
    - shard-kbl:          [PASS][4] -> [DMESG-WARN][5] ([i915#180]) +3 similar issues
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8556/shard-kbl7/igt@gem_exec_suspend@basic-s3.html
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-kbl6/igt@gem_exec_suspend@basic-s3.html

  * igt@gen9_exec_parse@allowed-all:
    - shard-apl:          [PASS][6] -> [DMESG-WARN][7] ([i915#1436] / [i915#716])
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8556/shard-apl3/igt@gen9_exec_parse@allowed-all.html
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-apl6/igt@gen9_exec_parse@allowed-all.html

  * igt@kms_cursor_crc@pipe-b-cursor-256x85-sliding:
    - shard-kbl:          [PASS][8] -> [FAIL][9] ([i915#54])
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8556/shard-kbl2/igt@kms_cursor_crc@pipe-b-cursor-256x85-sliding.html
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-kbl4/igt@kms_cursor_crc@pipe-b-cursor-256x85-sliding.html
    - shard-skl:          [PASS][10] -> [FAIL][11] ([i915#54])
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8556/shard-skl2/igt@kms_cursor_crc@pipe-b-cursor-256x85-sliding.html
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-skl4/igt@kms_cursor_crc@pipe-b-cursor-256x85-sliding.html
    - shard-apl:          [PASS][12] -> [FAIL][13] ([i915#54])
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8556/shard-apl7/igt@kms_cursor_crc@pipe-b-cursor-256x85-sliding.html
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-apl6/igt@kms_cursor_crc@pipe-b-cursor-256x85-sliding.html

  * igt@kms_cursor_crc@pipe-c-cursor-suspend:
    - shard-apl:          [PASS][14] -> [DMESG-WARN][15] ([i915#180]) +1 similar issue
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8556/shard-apl3/igt@kms_cursor_crc@pipe-c-cursor-suspend.html
   [15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-apl1/igt@kms_cursor_crc@pipe-c-cursor-suspend.html

  * igt@kms_cursor_legacy@flip-vs-cursor-crc-atomic:
    - shard-kbl:          [PASS][16] -> [FAIL][17] ([i915#1566] / [i915#93] / [i915#95])
   [16]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8556/shard-kbl4/igt@kms_cursor_legacy@flip-vs-cursor-crc-atomic.html
   [17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-kbl3/igt@kms_cursor_legacy@flip-vs-cursor-crc-atomic.html

  * igt@kms_cursor_legacy@pipe-d-torture-bo:
    - shard-tglb:         [PASS][18] -> [DMESG-WARN][19] ([i915#128])
   [18]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8556/shard-tglb5/igt@kms_cursor_legacy@pipe-d-torture-bo.html
   [19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-tglb7/igt@kms_cursor_legacy@pipe-d-torture-bo.html

  * igt@kms_psr@psr2_primary_page_flip:
    - shard-iclb:         [PASS][20] -> [SKIP][21] ([fdo#109441]) +3 similar issues
   [20]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8556/shard-iclb2/igt@kms_psr@psr2_primary_page_flip.html
   [21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-iclb7/igt@kms_psr@psr2_primary_page_flip.html

  
#### Possible fixes ####

  * {igt@gem_exec_reloc@basic-concurrent0}:
    - shard-glk:          [FAIL][22] ([i915#1930]) -> [PASS][23]
   [22]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8556/shard-glk6/igt@gem_exec_reloc@basic-concurrent0.html
   [23]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-glk8/igt@gem_exec_reloc@basic-concurrent0.html

  * igt@i915_pm_rpm@system-suspend-execbuf:
    - shard-tglb:         [INCOMPLETE][24] ([i915#456]) -> [PASS][25]
   [24]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8556/shard-tglb6/igt@i915_pm_rpm@system-suspend-execbuf.html
   [25]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-tglb6/igt@i915_pm_rpm@system-suspend-execbuf.html

  * igt@i915_suspend@fence-restore-untiled:
    - shard-kbl:          [DMESG-WARN][26] ([i915#180] / [i915#93] / [i915#95]) -> [PASS][27]
   [26]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8556/shard-kbl2/igt@i915_suspend@fence-restore-untiled.html
   [27]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-kbl3/igt@i915_suspend@fence-restore-untiled.html

  * igt@i915_suspend@forcewake:
    - shard-kbl:          [INCOMPLETE][28] ([i915#155]) -> [PASS][29]
   [28]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8556/shard-kbl3/igt@i915_suspend@forcewake.html
   [29]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-kbl7/igt@i915_suspend@forcewake.html

  * igt@kms_big_fb@y-tiled-64bpp-rotate-0:
    - shard-glk:          [FAIL][30] ([i915#1119] / [i915#118] / [i915#95]) -> [PASS][31]
   [30]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8556/shard-glk8/igt@kms_big_fb@y-tiled-64bpp-rotate-0.html
   [31]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-glk6/igt@kms_big_fb@y-tiled-64bpp-rotate-0.html

  * igt@kms_cursor_crc@pipe-a-cursor-256x85-random:
    - shard-skl:          [FAIL][32] ([i915#54]) -> [PASS][33]
   [32]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8556/shard-skl1/igt@kms_cursor_crc@pipe-a-cursor-256x85-random.html
   [33]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-skl5/igt@kms_cursor_crc@pipe-a-cursor-256x85-random.html

  * igt@kms_cursor_crc@pipe-a-cursor-suspend:
    - shard-kbl:          [DMESG-WARN][34] ([i915#180]) -> [PASS][35] +1 similar issue
   [34]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8556/shard-kbl7/igt@kms_cursor_crc@pipe-a-cursor-suspend.html
   [35]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-kbl6/igt@kms_cursor_crc@pipe-a-cursor-suspend.html

  * igt@kms_cursor_edge_walk@pipe-a-256x256-top-edge:
    - shard-glk:          [TIMEOUT][36] ([i915#1958]) -> [PASS][37] +2 similar issues
   [36]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8556/shard-glk7/igt@kms_cursor_edge_walk@pipe-a-256x256-top-edge.html
   [37]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-glk5/igt@kms_cursor_edge_walk@pipe-a-256x256-top-edge.html

  * igt@kms_cursor_legacy@cursora-vs-flipb-toggle:
    - shard-glk:          [DMESG-FAIL][38] ([i915#1925] / [i915#1926]) -> [PASS][39]
   [38]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8556/shard-glk2/igt@kms_cursor_legacy@cursora-vs-flipb-toggle.html
   [39]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-glk1/igt@kms_cursor_legacy@cursora-vs-flipb-toggle.html

  * {igt@kms_flip@2x-flip-vs-expired-vblank-interruptible@ab-hdmi-a1-hdmi-a2}:
    - shard-glk:          [FAIL][40] ([i915#79]) -> [PASS][41]
   [40]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8556/shard-glk1/igt@kms_flip@2x-flip-vs-expired-vblank-interruptible@ab-hdmi-a1-hdmi-a2.html
   [41]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-glk7/igt@kms_flip@2x-flip-vs-expired-vblank-interruptible@ab-hdmi-a1-hdmi-a2.html

  * {igt@kms_flip@flip-vs-suspend-interruptible@c-dp1}:
    - shard-apl:          [DMESG-WARN][42] ([i915#180]) -> [PASS][43] +3 similar issues
   [42]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8556/shard-apl2/igt@kms_flip@flip-vs-suspend-interruptible@c-dp1.html
   [43]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-apl7/igt@kms_flip@flip-vs-suspend-interruptible@c-dp1.html

  * igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-indfb-draw-blt:
    - shard-iclb:         [FAIL][44] ([i915#49]) -> [PASS][45]
   [44]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8556/shard-iclb2/igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-indfb-draw-blt.html
   [45]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-iclb1/igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-indfb-draw-blt.html

  * igt@kms_hdr@bpc-switch-dpms:
    - shard-skl:          [FAIL][46] ([i915#1188]) -> [PASS][47]
   [46]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8556/shard-skl3/igt@kms_hdr@bpc-switch-dpms.html
   [47]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-skl6/igt@kms_hdr@bpc-switch-dpms.html

  * igt@kms_plane_alpha_blend@pipe-b-coverage-7efc:
    - shard-skl:          [FAIL][48] ([fdo#108145] / [i915#265]) -> [PASS][49] +1 similar issue
   [48]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8556/shard-skl4/igt@kms_plane_alpha_blend@pipe-b-coverage-7efc.html
   [49]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-skl7/igt@kms_plane_alpha_blend@pipe-b-coverage-7efc.html

  * igt@kms_plane_multiple@atomic-pipe-b-tiling-yf:
    - shard-glk:          [INCOMPLETE][50] ([i915#1927] / [i915#58] / [k.org#198133]) -> [PASS][51]
   [50]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8556/shard-glk2/igt@kms_plane_multiple@atomic-pipe-b-tiling-yf.html
   [51]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-glk4/igt@kms_plane_multiple@atomic-pipe-b-tiling-yf.html

  * igt@kms_psr@psr2_basic:
    - shard-iclb:         [SKIP][52] ([fdo#109441]) -> [PASS][53] +1 similar issue
   [52]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8556/shard-iclb6/igt@kms_psr@psr2_basic.html
   [53]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-iclb2/igt@kms_psr@psr2_basic.html

  
#### Warnings ####

  * igt@i915_pm_dc@dc3co-vpb-simulation:
    - shard-iclb:         [SKIP][54] ([i915#658]) -> [SKIP][55] ([i915#588])
   [54]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8556/shard-iclb8/igt@i915_pm_dc@dc3co-vpb-simulation.html
   [55]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-iclb2/igt@i915_pm_dc@dc3co-vpb-simulation.html

  * igt@kms_content_protection@legacy:
    - shard-apl:          [DMESG-FAIL][56] ([fdo#110321]) -> [TIMEOUT][57] ([i915#1319] / [i915#1635])
   [56]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8556/shard-apl2/igt@kms_content_protection@legacy.html
   [57]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-apl8/igt@kms_content_protection@legacy.html

  * igt@kms_content_protection@uevent:
    - shard-kbl:          [FAIL][58] ([i915#357]) -> [FAIL][59] ([i915#357] / [i915#93] / [i915#95])
   [58]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8556/shard-kbl3/igt@kms_content_protection@uevent.html
   [59]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-kbl1/igt@kms_content_protection@uevent.html
    - shard-apl:          [FAIL][60] ([i915#357]) -> [FAIL][61] ([i915#357] / [i915#95])
   [60]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8556/shard-apl1/igt@kms_content_protection@uevent.html
   [61]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-apl2/igt@kms_content_protection@uevent.html

  * igt@kms_frontbuffer_tracking@psr-2p-scndscrn-pri-shrfb-draw-mmap-gtt:
    - shard-glk:          [TIMEOUT][62] ([i915#1958]) -> [SKIP][63] ([fdo#109271])
   [62]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8556/shard-glk7/igt@kms_frontbuffer_tracking@psr-2p-scndscrn-pri-shrfb-draw-mmap-gtt.html
   [63]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-glk5/igt@kms_frontbuffer_tracking@psr-2p-scndscrn-pri-shrfb-draw-mmap-gtt.html

  * igt@kms_plane_alpha_blend@pipe-c-alpha-basic:
    - shard-apl:          [FAIL][64] ([fdo#108145] / [i915#265] / [i915#95]) -> [FAIL][65] ([fdo#108145] / [i915#265])
   [64]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8556/shard-apl7/igt@kms_plane_alpha_blend@pipe-c-alpha-basic.html
   [65]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/shard-apl2/igt@kms_plane_alpha_blend@pipe-c-alpha-basic.html

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
  [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
  [fdo#109441]: https://bugs.freedesktop.org/show_bug.cgi?id=109441
  [fdo#110321]: https://bugs.freedesktop.org/show_bug.cgi?id=110321
  [i915#1119]: https://gitlab.freedesktop.org/drm/intel/issues/1119
  [i915#118]: https://gitlab.freedesktop.org/drm/intel/issues/118
  [i915#1188]: https://gitlab.freedesktop.org/drm/intel/issues/1188
  [i915#128]: https://gitlab.freedesktop.org/drm/intel/issues/128
  [i915#1319]: https://gitlab.freedesktop.org/drm/intel/issues/1319
  [i915#1436]: https://gitlab.freedesktop.org/drm/intel/issues/1436
  [i915#1542]: https://gitlab.freedesktop.org/drm/intel/issues/1542
  [i915#155]: https://gitlab.freedesktop.org/drm/intel/issues/155
  [i915#1566]: https://gitlab.freedesktop.org/drm/intel/issues/1566
  [i915#1635]: https://gitlab.freedesktop.org/drm/intel/issues/1635
  [i915#180]: https://gitlab.freedesktop.org/drm/intel/issues/180
  [i915#1925]: https://gitlab.freedesktop.org/drm/intel/issues/1925
  [i915#1926]: https://gitlab.freedesktop.org/drm/intel/issues/1926
  [i915#1927]: https://gitlab.freedesktop.org/drm/intel/issues/1927
  [i915#1930]: https://gitlab.freedesktop.org/drm/intel/issues/1930
  [i915#1958]: https://gitlab.freedesktop.org/drm/intel/issues/1958
  [i915#198]: https://gitlab.freedesktop.org/drm/intel/issues/198
  [i915#265]: https://gitlab.freedesktop.org/drm/intel/issues/265
  [i915#357]: https://gitlab.freedesktop.org/drm/intel/issues/357
  [i915#456]: https://gitlab.freedesktop.org/drm/intel/issues/456
  [i915#49]: https://gitlab.freedesktop.org/drm/intel/issues/49
  [i915#54]: https://gitlab.freedesktop.org/drm/intel/issues/54
  [i915#58]: https://gitlab.freedesktop.org/drm/intel/issues/58
  [i915#588]: https://gitlab.freedesktop.org/drm/intel/issues/588
  [i915#658]: https://gitlab.freedesktop.org/drm/intel/issues/658
  [i915#716]: https://gitlab.freedesktop.org/drm/intel/issues/716
  [i915#79]: https://gitlab.freedesktop.org/drm/intel/issues/79
  [i915#93]: https://gitlab.freedesktop.org/drm/intel/issues/93
  [i915#95]: https://gitlab.freedesktop.org/drm/intel/issues/95
  [k.org#198133]: https://bugzilla.kernel.org/show_bug.cgi?id=198133


Participating hosts (11 -> 11)
------------------------------

  No changes in participating hosts


Build changes
-------------

  * Linux: CI_DRM_8556 -> Patchwork_17823

  CI-20190529: 20190529
  CI_DRM_8556: a12abc504361cc53eeb53c2948aebbd88709a901 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5684: bd399f5eb8263bb4a84ae6a5bb1a13d329e0515d @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_17823: 320cc6810801929affc6303c2481c0d2b735414e @ git://anongit.freedesktop.org/gfx-ci/linux
  piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17823/index.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Intel-gfx] [RFC PATCH 1/1] drm/mm: add ig_frag selftest
  2020-05-29 16:33 ` [Intel-gfx] " Nirmoy Das
                   ` (4 preceding siblings ...)
  (?)
@ 2020-05-31 22:29 ` kbuild test robot
  -1 siblings, 0 replies; 21+ messages in thread
From: kbuild test robot @ 2020-05-31 22:29 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2615 bytes --]

Hi Nirmoy,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on drm-intel/for-linux-next]
[also build test WARNING on drm-tip/drm-tip drm-exynos/exynos-drm-next tegra-drm/drm/tegra/for-next linus/master v5.7-rc7 next-20200529]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Nirmoy-Das/drm-mm-add-ig_frag-selftest/20200601-005135
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: arc-randconfig-m031-20200531 (attached as .config)
compiler: arc-elf-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>

smatch warnings:
drivers/gpu/drm/selftests/test-drm_mm.c:1084 igt_frag() warn: unsigned 'insert_time1' is never less than zero.
drivers/gpu/drm/selftests/test-drm_mm.c:1088 igt_frag() warn: unsigned 'insert_time2' is never less than zero.

vim +/insert_time1 +1084 drivers/gpu/drm/selftests/test-drm_mm.c

  1069	
  1070	static int igt_frag(void *ignored)
  1071	{
  1072		const struct insert_mode *mode;
  1073		unsigned int insert_time1, insert_time2;
  1074		unsigned int insert_size = 10000;
  1075		unsigned int scale_factor = 4;
  1076		/* tolerate 10% excess insertion duration */
  1077		unsigned int error_factor = 110;
  1078		int ret = -EINVAL;
  1079	
  1080		for (mode = insert_modes; mode->name; mode++) {
  1081			unsigned int expected_time;
  1082	
  1083			insert_time1 = get_insert_time(insert_size, mode);
> 1084			if (insert_time1 < 0)
  1085				goto err;
  1086	
  1087			insert_time2 = get_insert_time((insert_size * 2), mode);
> 1088			if (insert_time2 < 0)
  1089				goto err;
  1090	
  1091			expected_time = (scale_factor * insert_time1 *
  1092					 error_factor)/100;
  1093			if (insert_time2 > expected_time) {
  1094				pr_err("%s fragmented insert took more %u msecs\n",
  1095				       mode->name, insert_time2 - expected_time);
  1096				goto err;
  1097			}
  1098	
  1099			pr_info("%s fragmented insert of %u and %u insertions took %u and %u msecs\n",
  1100				mode->name, insert_size, insert_size * 2, insert_time1,
  1101				insert_time2);
  1102		}
  1103	
  1104		ret = 0;
  1105	err:
  1106		return ret;
  1107	}
  1108	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 28111 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Intel-gfx] [RFC PATCH 1/1] drm/mm: add ig_frag selftest
  2020-05-29 16:33 ` [Intel-gfx] " Nirmoy Das
                   ` (5 preceding siblings ...)
  (?)
@ 2020-06-01  3:07 ` kbuild test robot
  -1 siblings, 0 replies; 21+ messages in thread
From: kbuild test robot @ 2020-06-01  3:07 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 3422 bytes --]

Hi Nirmoy,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on drm-intel/for-linux-next]
[also build test WARNING on drm-tip/drm-tip drm-exynos/exynos-drm-next tegra-drm/drm/tegra/for-next linus/master v5.7-rc7 next-20200529]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Nirmoy-Das/drm-mm-add-ig_frag-selftest/20200601-005135
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: mips-randconfig-c022-20200531 (attached as .config)
compiler: mipsel-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>

All warnings (new ones prefixed by >>, old ones prefixed by <<):

drivers/gpu/drm/selftests/test-drm_mm.c: In function 'assert_no_holes':
drivers/gpu/drm/selftests/test-drm_mm.c:56:18: warning: variable 'hole_end' set but not used [-Wunused-but-set-variable]
56 |  u64 hole_start, hole_end;
|                  ^~~~~~~~
drivers/gpu/drm/selftests/test-drm_mm.c: In function 'igt_frag':
>> drivers/gpu/drm/selftests/test-drm_mm.c:1084:20: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
1084 |   if (insert_time1 < 0)
|                    ^
drivers/gpu/drm/selftests/test-drm_mm.c:1088:20: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
1088 |   if (insert_time2 < 0)
|                    ^

coccinelle warnings: (new ones prefixed by >>)

>> drivers/gpu/drm/selftests/test-drm_mm.c:1084:6-18: WARNING: Unsigned expression compared with zero: insert_time1 < 0
>> drivers/gpu/drm/selftests/test-drm_mm.c:1088:6-18: WARNING: Unsigned expression compared with zero: insert_time2 < 0

vim +1084 drivers/gpu/drm/selftests/test-drm_mm.c

  1069	
  1070	static int igt_frag(void *ignored)
  1071	{
  1072		const struct insert_mode *mode;
  1073		unsigned int insert_time1, insert_time2;
  1074		unsigned int insert_size = 10000;
  1075		unsigned int scale_factor = 4;
  1076		/* tolerate 10% excess insertion duration */
  1077		unsigned int error_factor = 110;
  1078		int ret = -EINVAL;
  1079	
  1080		for (mode = insert_modes; mode->name; mode++) {
  1081			unsigned int expected_time;
  1082	
  1083			insert_time1 = get_insert_time(insert_size, mode);
> 1084			if (insert_time1 < 0)
  1085				goto err;
  1086	
  1087			insert_time2 = get_insert_time((insert_size * 2), mode);
> 1088			if (insert_time2 < 0)
  1089				goto err;
  1090	
  1091			expected_time = (scale_factor * insert_time1 *
  1092					 error_factor)/100;
  1093			if (insert_time2 > expected_time) {
  1094				pr_err("%s fragmented insert took more %u msecs\n",
  1095				       mode->name, insert_time2 - expected_time);
  1096				goto err;
  1097			}
  1098	
  1099			pr_info("%s fragmented insert of %u and %u insertions took %u and %u msecs\n",
  1100				mode->name, insert_size, insert_size * 2, insert_time1,
  1101				insert_time2);
  1102		}
  1103	
  1104		ret = 0;
  1105	err:
  1106		return ret;
  1107	}
  1108	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 29176 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC PATCH 1/1] drm/mm: add ig_frag selftest
  2020-05-29 21:01       ` [Intel-gfx] " Nirmoy
@ 2020-06-02 12:47         ` Christian König
  -1 siblings, 0 replies; 21+ messages in thread
From: Christian König @ 2020-06-02 12:47 UTC (permalink / raw)
  To: Nirmoy, Chris Wilson, Nirmoy Das, dri-devel; +Cc: intel-gfx, Nirmoy Das

Nirmoy please keep in mind that your current implementation doesn't 
fully solve the issue the test case is exercising.

In other words what you have implement is fast skipping of fragmented 
address space for bottom-up and top-down.

But what this test here exercises is the fast skipping of aligned 
allocations. You should probably adjust the test case a bit.

Regards,
Christian.

Am 29.05.20 um 23:01 schrieb Nirmoy:
>
> On 5/29/20 5:52 PM, Chris Wilson wrote:
>> Quoting Nirmoy (2020-05-29 16:40:53)
>>> This works correctly most of the times but sometimes
>
>
> I have to take my word back. In another machine,  20k insertions in
>
> best mode takes 6-9 times more than 10k insertions, all most all the 
> time.
>
> evict, bottom-up and top-down modes remains in 2-5 times range.
>
>
> If I reduce the insertions to 1k and 2k then scaling factor for best 
> mode stays  below 4 most of the time.
>
> evict, bottom-up and top-down modes remains in 2-3 times range.
>
>
> I wonder if it makes sense to test with only 1k and 2k insertions and 
> tolerate more than error if the mode == best.
>
> Regards,
>
> Nirmoy
>
>>>
>>> 20k insertions can take more than 8 times of 10k insertion time.
>> The pressure is on to improve then :)
>>
>>> Regards,
>>>
>>> Nirmoy
>>>
>>> On 5/29/20 6:33 PM, Nirmoy Das wrote:
>>>> This patch introduces fragmentation in the address range
>>>> and measures time taken by 10k and 20k insertions. ig_frag()
>>>> will fail if time taken by 20k insertions takes more than 4 times
>>>> of 10k insertions as we know that insertions scale quadratically.
>>>> Also tolerate 10% error because of kernel scheduler's jitters.
>>>>
>>>> Output:
>>>> <snip>
>>>> [ 8092.653518] drm_mm: Testing DRM range manger (struct drm_mm), 
>>>> with random_seed=0x9bfb4117 max_iterations=8192 max_prime=128
>>>> [ 8092.653520] drm_mm: igt_sanitycheck - ok!
>>>> [ 8092.653525] igt_debug 0x0000000000000000-0x0000000000000200: 
>>>> 512: free
>>>> [ 8092.653526] igt_debug 0x0000000000000200-0x0000000000000600: 
>>>> 1024: used
>>>> [ 8092.653527] igt_debug 0x0000000000000600-0x0000000000000a00: 
>>>> 1024: free
>>>> [ 8092.653528] igt_debug 0x0000000000000a00-0x0000000000000e00: 
>>>> 1024: used
>>>> [ 8092.653529] igt_debug 0x0000000000000e00-0x0000000000001000: 
>>>> 512: free
>>>> [ 8092.653529] igt_debug total: 4096, used 2048 free 2048
>>>> [ 8112.569813] drm_mm: best fragmented insert of 10000 and 20000 
>>>> insertions took 504 and 1996 msecs
>>>> [ 8112.723254] drm_mm: bottom-up fragmented insert of 10000 and 
>>>> 20000 insertions took 44 and 108 msecs
>>>> [ 8112.813212] drm_mm: top-down fragmented insert of 10000 and 
>>>> 20000 insertions took 40 and 44 msecs
>>>> [ 8112.847733] drm_mm: evict fragmented insert of 10000 and 20000 
>>>> insertions took 8 and 20 msecs
>>>> <snip>
>>>>
>>>> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
>>>> ---
>>>>    drivers/gpu/drm/selftests/drm_mm_selftests.h |  1 +
>>>>    drivers/gpu/drm/selftests/test-drm_mm.c      | 73 
>>>> ++++++++++++++++++++
>>>>    2 files changed, 74 insertions(+)
>>>>
>>>> diff --git a/drivers/gpu/drm/selftests/drm_mm_selftests.h 
>>>> b/drivers/gpu/drm/selftests/drm_mm_selftests.h
>>>> index 6b943ea1c57d..8c87c964176b 100644
>>>> --- a/drivers/gpu/drm/selftests/drm_mm_selftests.h
>>>> +++ b/drivers/gpu/drm/selftests/drm_mm_selftests.h
>>>> @@ -14,6 +14,7 @@ selftest(insert, igt_insert)
>>>>    selftest(replace, igt_replace)
>>>>    selftest(insert_range, igt_insert_range)
>>>>    selftest(align, igt_align)
>>>> +selftest(frag, igt_frag)
>>>>    selftest(align32, igt_align32)
>>>>    selftest(align64, igt_align64)
>>>>    selftest(evict, igt_evict)
>>>> diff --git a/drivers/gpu/drm/selftests/test-drm_mm.c 
>>>> b/drivers/gpu/drm/selftests/test-drm_mm.c
>>>> index 9aabe82dcd3a..05d8f3659b4d 100644
>>>> --- a/drivers/gpu/drm/selftests/test-drm_mm.c
>>>> +++ b/drivers/gpu/drm/selftests/test-drm_mm.c
>>>> @@ -1033,6 +1033,79 @@ static int igt_insert_range(void *ignored)
>>>>        return 0;
>>>>    }
>>>>    +static int get_insert_time(unsigned int num_insert,
>>>> +                        const struct insert_mode *mode)
>>>> +{
>>>> +     struct drm_mm mm;
>>>> +     struct drm_mm_node *nodes, *node, *next;
>>>> +     unsigned int size = 4096, align = 8192;
>>>> +     unsigned long start;
>>>> +     unsigned int i;
>>>> +     int ret = -EINVAL;
>>>> +
>>>> +     drm_mm_init(&mm, 1, U64_MAX - 2);
>>>> +     nodes = vzalloc(array_size(num_insert, sizeof(*nodes)));
>>>> +     if (!nodes)
>>>> +             goto err;
>>>> +
>>>> +     start = jiffies;
>> Use ktime_t start = ktime_now();
>>
>>>> +     for (i = 0; i < num_insert; i++) {
>>>> +             if (!expect_insert(&mm, &nodes[i], size, align, i, 
>>>> mode)) {
>>>> +                     pr_err("%s insert failed\n", mode->name);
>>>> +                     goto out;
>>>> +             }
>>>> +     }
>>>> +
>>>> +     ret = jiffies_to_msecs(jiffies - start);
>> ret = ktime_sub(ktime_now(), start);
>>
>> The downside to using ktime is remembering it is s64 and so requires 
>> care
>> and attention in doing math.
>>
>>>> +out:
>>>> +     drm_mm_for_each_node_safe(node, next, &mm)
>>>> +             drm_mm_remove_node(node);
>>>> +     drm_mm_takedown(&mm);
>>>> +     vfree(nodes);
>>>> +err:
>>>> +     return ret;
>>>> +
>>>> +}
>>>> +
>>>> +static int igt_frag(void *ignored)
>>>> +{
>>>> +     const struct insert_mode *mode;
>>>> +     unsigned int insert_time1, insert_time2;
>>>> +     unsigned int insert_size = 10000;
>>>> +     unsigned int scale_factor = 4;
>>>> +     /* tolerate 10% excess insertion duration */
>>>> +     unsigned int error_factor = 110;
>>>> +     int ret = -EINVAL;
>>>> +
>>>> +     for (mode = insert_modes; mode->name; mode++) {
>>>> +             unsigned int expected_time;
>>>> +
>>>> +             insert_time1 = get_insert_time(insert_size, mode);
>>>> +             if (insert_time1 < 0)
>>>> +                     goto err;
>> Ah, can you propagate the actual error. I see you are returning EINVAL
>> for ENOMEM errors. Just wait until it hits and you have to debug why :)
>>
>>>> +             insert_time2 = get_insert_time((insert_size * 2), mode);
>>>> +             if (insert_time2 < 0)
>>>> +                     goto err;
>>>> +
>>>> +             expected_time = (scale_factor * insert_time1 *
>>>> +                              error_factor)/100;
>>>> +             if (insert_time2 > expected_time) {
>>>> +                     pr_err("%s fragmented insert took more %u 
>>>> msecs\n",
>>>> +                            mode->name, insert_time2 - 
>>>> expected_time);
>>>> +                     goto err;
>>>> +             }
>>>> +
>>>> +             pr_info("%s fragmented insert of %u and %u insertions 
>>>> took %u and %u msecs\n",
>>>> +                     mode->name, insert_size, insert_size * 2, 
>>>> insert_time1,
>>>> +                     insert_time2);
>> Put the info first before the error. We always want the full details,
>> with the error message explaining why it's unhappy.
>> -Chris
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Fdri-devel&amp;data=02%7C01%7Cnirmoy.das%40amd.com%7C5c7df129b9cf44b3ae4008d803e84445%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637263643415833767&amp;sdata=PrCQse4nhN0ZITT9OniuHhF7A5uxJD6ehk0PMjm7WMU%3D&amp;reserved=0 
>>

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Intel-gfx] [RFC PATCH 1/1] drm/mm: add ig_frag selftest
@ 2020-06-02 12:47         ` Christian König
  0 siblings, 0 replies; 21+ messages in thread
From: Christian König @ 2020-06-02 12:47 UTC (permalink / raw)
  To: Nirmoy, Chris Wilson, Nirmoy Das, dri-devel; +Cc: intel-gfx, Nirmoy Das

Nirmoy please keep in mind that your current implementation doesn't 
fully solve the issue the test case is exercising.

In other words what you have implement is fast skipping of fragmented 
address space for bottom-up and top-down.

But what this test here exercises is the fast skipping of aligned 
allocations. You should probably adjust the test case a bit.

Regards,
Christian.

Am 29.05.20 um 23:01 schrieb Nirmoy:
>
> On 5/29/20 5:52 PM, Chris Wilson wrote:
>> Quoting Nirmoy (2020-05-29 16:40:53)
>>> This works correctly most of the times but sometimes
>
>
> I have to take my word back. In another machine,  20k insertions in
>
> best mode takes 6-9 times more than 10k insertions, all most all the 
> time.
>
> evict, bottom-up and top-down modes remains in 2-5 times range.
>
>
> If I reduce the insertions to 1k and 2k then scaling factor for best 
> mode stays  below 4 most of the time.
>
> evict, bottom-up and top-down modes remains in 2-3 times range.
>
>
> I wonder if it makes sense to test with only 1k and 2k insertions and 
> tolerate more than error if the mode == best.
>
> Regards,
>
> Nirmoy
>
>>>
>>> 20k insertions can take more than 8 times of 10k insertion time.
>> The pressure is on to improve then :)
>>
>>> Regards,
>>>
>>> Nirmoy
>>>
>>> On 5/29/20 6:33 PM, Nirmoy Das wrote:
>>>> This patch introduces fragmentation in the address range
>>>> and measures time taken by 10k and 20k insertions. ig_frag()
>>>> will fail if time taken by 20k insertions takes more than 4 times
>>>> of 10k insertions as we know that insertions scale quadratically.
>>>> Also tolerate 10% error because of kernel scheduler's jitters.
>>>>
>>>> Output:
>>>> <snip>
>>>> [ 8092.653518] drm_mm: Testing DRM range manger (struct drm_mm), 
>>>> with random_seed=0x9bfb4117 max_iterations=8192 max_prime=128
>>>> [ 8092.653520] drm_mm: igt_sanitycheck - ok!
>>>> [ 8092.653525] igt_debug 0x0000000000000000-0x0000000000000200: 
>>>> 512: free
>>>> [ 8092.653526] igt_debug 0x0000000000000200-0x0000000000000600: 
>>>> 1024: used
>>>> [ 8092.653527] igt_debug 0x0000000000000600-0x0000000000000a00: 
>>>> 1024: free
>>>> [ 8092.653528] igt_debug 0x0000000000000a00-0x0000000000000e00: 
>>>> 1024: used
>>>> [ 8092.653529] igt_debug 0x0000000000000e00-0x0000000000001000: 
>>>> 512: free
>>>> [ 8092.653529] igt_debug total: 4096, used 2048 free 2048
>>>> [ 8112.569813] drm_mm: best fragmented insert of 10000 and 20000 
>>>> insertions took 504 and 1996 msecs
>>>> [ 8112.723254] drm_mm: bottom-up fragmented insert of 10000 and 
>>>> 20000 insertions took 44 and 108 msecs
>>>> [ 8112.813212] drm_mm: top-down fragmented insert of 10000 and 
>>>> 20000 insertions took 40 and 44 msecs
>>>> [ 8112.847733] drm_mm: evict fragmented insert of 10000 and 20000 
>>>> insertions took 8 and 20 msecs
>>>> <snip>
>>>>
>>>> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
>>>> ---
>>>>    drivers/gpu/drm/selftests/drm_mm_selftests.h |  1 +
>>>>    drivers/gpu/drm/selftests/test-drm_mm.c      | 73 
>>>> ++++++++++++++++++++
>>>>    2 files changed, 74 insertions(+)
>>>>
>>>> diff --git a/drivers/gpu/drm/selftests/drm_mm_selftests.h 
>>>> b/drivers/gpu/drm/selftests/drm_mm_selftests.h
>>>> index 6b943ea1c57d..8c87c964176b 100644
>>>> --- a/drivers/gpu/drm/selftests/drm_mm_selftests.h
>>>> +++ b/drivers/gpu/drm/selftests/drm_mm_selftests.h
>>>> @@ -14,6 +14,7 @@ selftest(insert, igt_insert)
>>>>    selftest(replace, igt_replace)
>>>>    selftest(insert_range, igt_insert_range)
>>>>    selftest(align, igt_align)
>>>> +selftest(frag, igt_frag)
>>>>    selftest(align32, igt_align32)
>>>>    selftest(align64, igt_align64)
>>>>    selftest(evict, igt_evict)
>>>> diff --git a/drivers/gpu/drm/selftests/test-drm_mm.c 
>>>> b/drivers/gpu/drm/selftests/test-drm_mm.c
>>>> index 9aabe82dcd3a..05d8f3659b4d 100644
>>>> --- a/drivers/gpu/drm/selftests/test-drm_mm.c
>>>> +++ b/drivers/gpu/drm/selftests/test-drm_mm.c
>>>> @@ -1033,6 +1033,79 @@ static int igt_insert_range(void *ignored)
>>>>        return 0;
>>>>    }
>>>>    +static int get_insert_time(unsigned int num_insert,
>>>> +                        const struct insert_mode *mode)
>>>> +{
>>>> +     struct drm_mm mm;
>>>> +     struct drm_mm_node *nodes, *node, *next;
>>>> +     unsigned int size = 4096, align = 8192;
>>>> +     unsigned long start;
>>>> +     unsigned int i;
>>>> +     int ret = -EINVAL;
>>>> +
>>>> +     drm_mm_init(&mm, 1, U64_MAX - 2);
>>>> +     nodes = vzalloc(array_size(num_insert, sizeof(*nodes)));
>>>> +     if (!nodes)
>>>> +             goto err;
>>>> +
>>>> +     start = jiffies;
>> Use ktime_t start = ktime_now();
>>
>>>> +     for (i = 0; i < num_insert; i++) {
>>>> +             if (!expect_insert(&mm, &nodes[i], size, align, i, 
>>>> mode)) {
>>>> +                     pr_err("%s insert failed\n", mode->name);
>>>> +                     goto out;
>>>> +             }
>>>> +     }
>>>> +
>>>> +     ret = jiffies_to_msecs(jiffies - start);
>> ret = ktime_sub(ktime_now(), start);
>>
>> The downside to using ktime is remembering it is s64 and so requires 
>> care
>> and attention in doing math.
>>
>>>> +out:
>>>> +     drm_mm_for_each_node_safe(node, next, &mm)
>>>> +             drm_mm_remove_node(node);
>>>> +     drm_mm_takedown(&mm);
>>>> +     vfree(nodes);
>>>> +err:
>>>> +     return ret;
>>>> +
>>>> +}
>>>> +
>>>> +static int igt_frag(void *ignored)
>>>> +{
>>>> +     const struct insert_mode *mode;
>>>> +     unsigned int insert_time1, insert_time2;
>>>> +     unsigned int insert_size = 10000;
>>>> +     unsigned int scale_factor = 4;
>>>> +     /* tolerate 10% excess insertion duration */
>>>> +     unsigned int error_factor = 110;
>>>> +     int ret = -EINVAL;
>>>> +
>>>> +     for (mode = insert_modes; mode->name; mode++) {
>>>> +             unsigned int expected_time;
>>>> +
>>>> +             insert_time1 = get_insert_time(insert_size, mode);
>>>> +             if (insert_time1 < 0)
>>>> +                     goto err;
>> Ah, can you propagate the actual error. I see you are returning EINVAL
>> for ENOMEM errors. Just wait until it hits and you have to debug why :)
>>
>>>> +             insert_time2 = get_insert_time((insert_size * 2), mode);
>>>> +             if (insert_time2 < 0)
>>>> +                     goto err;
>>>> +
>>>> +             expected_time = (scale_factor * insert_time1 *
>>>> +                              error_factor)/100;
>>>> +             if (insert_time2 > expected_time) {
>>>> +                     pr_err("%s fragmented insert took more %u 
>>>> msecs\n",
>>>> +                            mode->name, insert_time2 - 
>>>> expected_time);
>>>> +                     goto err;
>>>> +             }
>>>> +
>>>> +             pr_info("%s fragmented insert of %u and %u insertions 
>>>> took %u and %u msecs\n",
>>>> +                     mode->name, insert_size, insert_size * 2, 
>>>> insert_time1,
>>>> +                     insert_time2);
>> Put the info first before the error. We always want the full details,
>> with the error message explaining why it's unhappy.
>> -Chris
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Fdri-devel&amp;data=02%7C01%7Cnirmoy.das%40amd.com%7C5c7df129b9cf44b3ae4008d803e84445%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637263643415833767&amp;sdata=PrCQse4nhN0ZITT9OniuHhF7A5uxJD6ehk0PMjm7WMU%3D&amp;reserved=0 
>>

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC PATCH 1/1] drm/mm: add ig_frag selftest
  2020-06-02 12:47         ` [Intel-gfx] " Christian König
@ 2020-06-02 14:13           ` Nirmoy
  -1 siblings, 0 replies; 21+ messages in thread
From: Nirmoy @ 2020-06-02 14:13 UTC (permalink / raw)
  To: Christian König, Chris Wilson, dri-devel; +Cc: intel-gfx

Hi Christian,

On 6/2/20 2:47 PM, Christian König wrote:
> Nirmoy please keep in mind that your current implementation doesn't 
> fully solve the issue the test case is exercising.
>
> In other words what you have implement is fast skipping of fragmented 
> address space for bottom-up and top-down.
>
> But what this test here exercises is the fast skipping of aligned 
> allocations. You should probably adjust the test case a bit.


Allocations with size=4k and aign = 8k is known to introduce 
fragmentation, do you mean I should only test bottom-up and top-down

for now ?


Regards,

Nirmoy


>
>
> Regards,
> Christian.
>
> Am 29.05.20 um 23:01 schrieb Nirmoy:
>>
>> On 5/29/20 5:52 PM, Chris Wilson wrote:
>>> Quoting Nirmoy (2020-05-29 16:40:53)
>>>> This works correctly most of the times but sometimes
>>
>>
>> I have to take my word back. In another machine,  20k insertions in
>>
>> best mode takes 6-9 times more than 10k insertions, all most all the 
>> time.
>>
>> evict, bottom-up and top-down modes remains in 2-5 times range.
>>
>>
>> If I reduce the insertions to 1k and 2k then scaling factor for best 
>> mode stays  below 4 most of the time.
>>
>> evict, bottom-up and top-down modes remains in 2-3 times range.
>>
>>
>> I wonder if it makes sense to test with only 1k and 2k insertions and 
>> tolerate more than error if the mode == best.
>>
>> Regards,
>>
>> Nirmoy
>>
>>>>
>>>> 20k insertions can take more than 8 times of 10k insertion time.
>>> The pressure is on to improve then :)
>>>
>>>> Regards,
>>>>
>>>> Nirmoy
>>>>
>>>> On 5/29/20 6:33 PM, Nirmoy Das wrote:
>>>>> This patch introduces fragmentation in the address range
>>>>> and measures time taken by 10k and 20k insertions. ig_frag()
>>>>> will fail if time taken by 20k insertions takes more than 4 times
>>>>> of 10k insertions as we know that insertions scale quadratically.
>>>>> Also tolerate 10% error because of kernel scheduler's jitters.
>>>>>
>>>>> Output:
>>>>> <snip>
>>>>> [ 8092.653518] drm_mm: Testing DRM range manger (struct drm_mm), 
>>>>> with random_seed=0x9bfb4117 max_iterations=8192 max_prime=128
>>>>> [ 8092.653520] drm_mm: igt_sanitycheck - ok!
>>>>> [ 8092.653525] igt_debug 0x0000000000000000-0x0000000000000200: 
>>>>> 512: free
>>>>> [ 8092.653526] igt_debug 0x0000000000000200-0x0000000000000600: 
>>>>> 1024: used
>>>>> [ 8092.653527] igt_debug 0x0000000000000600-0x0000000000000a00: 
>>>>> 1024: free
>>>>> [ 8092.653528] igt_debug 0x0000000000000a00-0x0000000000000e00: 
>>>>> 1024: used
>>>>> [ 8092.653529] igt_debug 0x0000000000000e00-0x0000000000001000: 
>>>>> 512: free
>>>>> [ 8092.653529] igt_debug total: 4096, used 2048 free 2048
>>>>> [ 8112.569813] drm_mm: best fragmented insert of 10000 and 20000 
>>>>> insertions took 504 and 1996 msecs
>>>>> [ 8112.723254] drm_mm: bottom-up fragmented insert of 10000 and 
>>>>> 20000 insertions took 44 and 108 msecs
>>>>> [ 8112.813212] drm_mm: top-down fragmented insert of 10000 and 
>>>>> 20000 insertions took 40 and 44 msecs
>>>>> [ 8112.847733] drm_mm: evict fragmented insert of 10000 and 20000 
>>>>> insertions took 8 and 20 msecs
>>>>> <snip>
>>>>>
>>>>> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
>>>>> ---
>>>>>    drivers/gpu/drm/selftests/drm_mm_selftests.h |  1 +
>>>>>    drivers/gpu/drm/selftests/test-drm_mm.c      | 73 
>>>>> ++++++++++++++++++++
>>>>>    2 files changed, 74 insertions(+)
>>>>>
>>>>> diff --git a/drivers/gpu/drm/selftests/drm_mm_selftests.h 
>>>>> b/drivers/gpu/drm/selftests/drm_mm_selftests.h
>>>>> index 6b943ea1c57d..8c87c964176b 100644
>>>>> --- a/drivers/gpu/drm/selftests/drm_mm_selftests.h
>>>>> +++ b/drivers/gpu/drm/selftests/drm_mm_selftests.h
>>>>> @@ -14,6 +14,7 @@ selftest(insert, igt_insert)
>>>>>    selftest(replace, igt_replace)
>>>>>    selftest(insert_range, igt_insert_range)
>>>>>    selftest(align, igt_align)
>>>>> +selftest(frag, igt_frag)
>>>>>    selftest(align32, igt_align32)
>>>>>    selftest(align64, igt_align64)
>>>>>    selftest(evict, igt_evict)
>>>>> diff --git a/drivers/gpu/drm/selftests/test-drm_mm.c 
>>>>> b/drivers/gpu/drm/selftests/test-drm_mm.c
>>>>> index 9aabe82dcd3a..05d8f3659b4d 100644
>>>>> --- a/drivers/gpu/drm/selftests/test-drm_mm.c
>>>>> +++ b/drivers/gpu/drm/selftests/test-drm_mm.c
>>>>> @@ -1033,6 +1033,79 @@ static int igt_insert_range(void *ignored)
>>>>>        return 0;
>>>>>    }
>>>>>    +static int get_insert_time(unsigned int num_insert,
>>>>> +                        const struct insert_mode *mode)
>>>>> +{
>>>>> +     struct drm_mm mm;
>>>>> +     struct drm_mm_node *nodes, *node, *next;
>>>>> +     unsigned int size = 4096, align = 8192;
>>>>> +     unsigned long start;
>>>>> +     unsigned int i;
>>>>> +     int ret = -EINVAL;
>>>>> +
>>>>> +     drm_mm_init(&mm, 1, U64_MAX - 2);
>>>>> +     nodes = vzalloc(array_size(num_insert, sizeof(*nodes)));
>>>>> +     if (!nodes)
>>>>> +             goto err;
>>>>> +
>>>>> +     start = jiffies;
>>> Use ktime_t start = ktime_now();
>>>
>>>>> +     for (i = 0; i < num_insert; i++) {
>>>>> +             if (!expect_insert(&mm, &nodes[i], size, align, i, 
>>>>> mode)) {
>>>>> +                     pr_err("%s insert failed\n", mode->name);
>>>>> +                     goto out;
>>>>> +             }
>>>>> +     }
>>>>> +
>>>>> +     ret = jiffies_to_msecs(jiffies - start);
>>> ret = ktime_sub(ktime_now(), start);
>>>
>>> The downside to using ktime is remembering it is s64 and so requires 
>>> care
>>> and attention in doing math.
>>>
>>>>> +out:
>>>>> +     drm_mm_for_each_node_safe(node, next, &mm)
>>>>> +             drm_mm_remove_node(node);
>>>>> +     drm_mm_takedown(&mm);
>>>>> +     vfree(nodes);
>>>>> +err:
>>>>> +     return ret;
>>>>> +
>>>>> +}
>>>>> +
>>>>> +static int igt_frag(void *ignored)
>>>>> +{
>>>>> +     const struct insert_mode *mode;
>>>>> +     unsigned int insert_time1, insert_time2;
>>>>> +     unsigned int insert_size = 10000;
>>>>> +     unsigned int scale_factor = 4;
>>>>> +     /* tolerate 10% excess insertion duration */
>>>>> +     unsigned int error_factor = 110;
>>>>> +     int ret = -EINVAL;
>>>>> +
>>>>> +     for (mode = insert_modes; mode->name; mode++) {
>>>>> +             unsigned int expected_time;
>>>>> +
>>>>> +             insert_time1 = get_insert_time(insert_size, mode);
>>>>> +             if (insert_time1 < 0)
>>>>> +                     goto err;
>>> Ah, can you propagate the actual error. I see you are returning EINVAL
>>> for ENOMEM errors. Just wait until it hits and you have to debug why :)
>>>
>>>>> +             insert_time2 = get_insert_time((insert_size * 2), 
>>>>> mode);
>>>>> +             if (insert_time2 < 0)
>>>>> +                     goto err;
>>>>> +
>>>>> +             expected_time = (scale_factor * insert_time1 *
>>>>> +                              error_factor)/100;
>>>>> +             if (insert_time2 > expected_time) {
>>>>> +                     pr_err("%s fragmented insert took more %u 
>>>>> msecs\n",
>>>>> +                            mode->name, insert_time2 - 
>>>>> expected_time);
>>>>> +                     goto err;
>>>>> +             }
>>>>> +
>>>>> +             pr_info("%s fragmented insert of %u and %u 
>>>>> insertions took %u and %u msecs\n",
>>>>> +                     mode->name, insert_size, insert_size * 2, 
>>>>> insert_time1,
>>>>> +                     insert_time2);
>>> Put the info first before the error. We always want the full details,
>>> with the error message explaining why it's unhappy.
>>> -Chris
>>> _______________________________________________
>>> dri-devel mailing list
>>> dri-devel@lists.freedesktop.org
>>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Fdri-devel&amp;data=02%7C01%7Cnirmoy.das%40amd.com%7C5c7df129b9cf44b3ae4008d803e84445%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637263643415833767&amp;sdata=PrCQse4nhN0ZITT9OniuHhF7A5uxJD6ehk0PMjm7WMU%3D&amp;reserved=0 
>>>
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Intel-gfx] [RFC PATCH 1/1] drm/mm: add ig_frag selftest
@ 2020-06-02 14:13           ` Nirmoy
  0 siblings, 0 replies; 21+ messages in thread
From: Nirmoy @ 2020-06-02 14:13 UTC (permalink / raw)
  To: Christian König, Chris Wilson, dri-devel; +Cc: intel-gfx

Hi Christian,

On 6/2/20 2:47 PM, Christian König wrote:
> Nirmoy please keep in mind that your current implementation doesn't 
> fully solve the issue the test case is exercising.
>
> In other words what you have implement is fast skipping of fragmented 
> address space for bottom-up and top-down.
>
> But what this test here exercises is the fast skipping of aligned 
> allocations. You should probably adjust the test case a bit.


Allocations with size=4k and aign = 8k is known to introduce 
fragmentation, do you mean I should only test bottom-up and top-down

for now ?


Regards,

Nirmoy


>
>
> Regards,
> Christian.
>
> Am 29.05.20 um 23:01 schrieb Nirmoy:
>>
>> On 5/29/20 5:52 PM, Chris Wilson wrote:
>>> Quoting Nirmoy (2020-05-29 16:40:53)
>>>> This works correctly most of the times but sometimes
>>
>>
>> I have to take my word back. In another machine,  20k insertions in
>>
>> best mode takes 6-9 times more than 10k insertions, all most all the 
>> time.
>>
>> evict, bottom-up and top-down modes remains in 2-5 times range.
>>
>>
>> If I reduce the insertions to 1k and 2k then scaling factor for best 
>> mode stays  below 4 most of the time.
>>
>> evict, bottom-up and top-down modes remains in 2-3 times range.
>>
>>
>> I wonder if it makes sense to test with only 1k and 2k insertions and 
>> tolerate more than error if the mode == best.
>>
>> Regards,
>>
>> Nirmoy
>>
>>>>
>>>> 20k insertions can take more than 8 times of 10k insertion time.
>>> The pressure is on to improve then :)
>>>
>>>> Regards,
>>>>
>>>> Nirmoy
>>>>
>>>> On 5/29/20 6:33 PM, Nirmoy Das wrote:
>>>>> This patch introduces fragmentation in the address range
>>>>> and measures time taken by 10k and 20k insertions. ig_frag()
>>>>> will fail if time taken by 20k insertions takes more than 4 times
>>>>> of 10k insertions as we know that insertions scale quadratically.
>>>>> Also tolerate 10% error because of kernel scheduler's jitters.
>>>>>
>>>>> Output:
>>>>> <snip>
>>>>> [ 8092.653518] drm_mm: Testing DRM range manger (struct drm_mm), 
>>>>> with random_seed=0x9bfb4117 max_iterations=8192 max_prime=128
>>>>> [ 8092.653520] drm_mm: igt_sanitycheck - ok!
>>>>> [ 8092.653525] igt_debug 0x0000000000000000-0x0000000000000200: 
>>>>> 512: free
>>>>> [ 8092.653526] igt_debug 0x0000000000000200-0x0000000000000600: 
>>>>> 1024: used
>>>>> [ 8092.653527] igt_debug 0x0000000000000600-0x0000000000000a00: 
>>>>> 1024: free
>>>>> [ 8092.653528] igt_debug 0x0000000000000a00-0x0000000000000e00: 
>>>>> 1024: used
>>>>> [ 8092.653529] igt_debug 0x0000000000000e00-0x0000000000001000: 
>>>>> 512: free
>>>>> [ 8092.653529] igt_debug total: 4096, used 2048 free 2048
>>>>> [ 8112.569813] drm_mm: best fragmented insert of 10000 and 20000 
>>>>> insertions took 504 and 1996 msecs
>>>>> [ 8112.723254] drm_mm: bottom-up fragmented insert of 10000 and 
>>>>> 20000 insertions took 44 and 108 msecs
>>>>> [ 8112.813212] drm_mm: top-down fragmented insert of 10000 and 
>>>>> 20000 insertions took 40 and 44 msecs
>>>>> [ 8112.847733] drm_mm: evict fragmented insert of 10000 and 20000 
>>>>> insertions took 8 and 20 msecs
>>>>> <snip>
>>>>>
>>>>> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
>>>>> ---
>>>>>    drivers/gpu/drm/selftests/drm_mm_selftests.h |  1 +
>>>>>    drivers/gpu/drm/selftests/test-drm_mm.c      | 73 
>>>>> ++++++++++++++++++++
>>>>>    2 files changed, 74 insertions(+)
>>>>>
>>>>> diff --git a/drivers/gpu/drm/selftests/drm_mm_selftests.h 
>>>>> b/drivers/gpu/drm/selftests/drm_mm_selftests.h
>>>>> index 6b943ea1c57d..8c87c964176b 100644
>>>>> --- a/drivers/gpu/drm/selftests/drm_mm_selftests.h
>>>>> +++ b/drivers/gpu/drm/selftests/drm_mm_selftests.h
>>>>> @@ -14,6 +14,7 @@ selftest(insert, igt_insert)
>>>>>    selftest(replace, igt_replace)
>>>>>    selftest(insert_range, igt_insert_range)
>>>>>    selftest(align, igt_align)
>>>>> +selftest(frag, igt_frag)
>>>>>    selftest(align32, igt_align32)
>>>>>    selftest(align64, igt_align64)
>>>>>    selftest(evict, igt_evict)
>>>>> diff --git a/drivers/gpu/drm/selftests/test-drm_mm.c 
>>>>> b/drivers/gpu/drm/selftests/test-drm_mm.c
>>>>> index 9aabe82dcd3a..05d8f3659b4d 100644
>>>>> --- a/drivers/gpu/drm/selftests/test-drm_mm.c
>>>>> +++ b/drivers/gpu/drm/selftests/test-drm_mm.c
>>>>> @@ -1033,6 +1033,79 @@ static int igt_insert_range(void *ignored)
>>>>>        return 0;
>>>>>    }
>>>>>    +static int get_insert_time(unsigned int num_insert,
>>>>> +                        const struct insert_mode *mode)
>>>>> +{
>>>>> +     struct drm_mm mm;
>>>>> +     struct drm_mm_node *nodes, *node, *next;
>>>>> +     unsigned int size = 4096, align = 8192;
>>>>> +     unsigned long start;
>>>>> +     unsigned int i;
>>>>> +     int ret = -EINVAL;
>>>>> +
>>>>> +     drm_mm_init(&mm, 1, U64_MAX - 2);
>>>>> +     nodes = vzalloc(array_size(num_insert, sizeof(*nodes)));
>>>>> +     if (!nodes)
>>>>> +             goto err;
>>>>> +
>>>>> +     start = jiffies;
>>> Use ktime_t start = ktime_now();
>>>
>>>>> +     for (i = 0; i < num_insert; i++) {
>>>>> +             if (!expect_insert(&mm, &nodes[i], size, align, i, 
>>>>> mode)) {
>>>>> +                     pr_err("%s insert failed\n", mode->name);
>>>>> +                     goto out;
>>>>> +             }
>>>>> +     }
>>>>> +
>>>>> +     ret = jiffies_to_msecs(jiffies - start);
>>> ret = ktime_sub(ktime_now(), start);
>>>
>>> The downside to using ktime is remembering it is s64 and so requires 
>>> care
>>> and attention in doing math.
>>>
>>>>> +out:
>>>>> +     drm_mm_for_each_node_safe(node, next, &mm)
>>>>> +             drm_mm_remove_node(node);
>>>>> +     drm_mm_takedown(&mm);
>>>>> +     vfree(nodes);
>>>>> +err:
>>>>> +     return ret;
>>>>> +
>>>>> +}
>>>>> +
>>>>> +static int igt_frag(void *ignored)
>>>>> +{
>>>>> +     const struct insert_mode *mode;
>>>>> +     unsigned int insert_time1, insert_time2;
>>>>> +     unsigned int insert_size = 10000;
>>>>> +     unsigned int scale_factor = 4;
>>>>> +     /* tolerate 10% excess insertion duration */
>>>>> +     unsigned int error_factor = 110;
>>>>> +     int ret = -EINVAL;
>>>>> +
>>>>> +     for (mode = insert_modes; mode->name; mode++) {
>>>>> +             unsigned int expected_time;
>>>>> +
>>>>> +             insert_time1 = get_insert_time(insert_size, mode);
>>>>> +             if (insert_time1 < 0)
>>>>> +                     goto err;
>>> Ah, can you propagate the actual error. I see you are returning EINVAL
>>> for ENOMEM errors. Just wait until it hits and you have to debug why :)
>>>
>>>>> +             insert_time2 = get_insert_time((insert_size * 2), 
>>>>> mode);
>>>>> +             if (insert_time2 < 0)
>>>>> +                     goto err;
>>>>> +
>>>>> +             expected_time = (scale_factor * insert_time1 *
>>>>> +                              error_factor)/100;
>>>>> +             if (insert_time2 > expected_time) {
>>>>> +                     pr_err("%s fragmented insert took more %u 
>>>>> msecs\n",
>>>>> +                            mode->name, insert_time2 - 
>>>>> expected_time);
>>>>> +                     goto err;
>>>>> +             }
>>>>> +
>>>>> +             pr_info("%s fragmented insert of %u and %u 
>>>>> insertions took %u and %u msecs\n",
>>>>> +                     mode->name, insert_size, insert_size * 2, 
>>>>> insert_time1,
>>>>> +                     insert_time2);
>>> Put the info first before the error. We always want the full details,
>>> with the error message explaining why it's unhappy.
>>> -Chris
>>> _______________________________________________
>>> dri-devel mailing list
>>> dri-devel@lists.freedesktop.org
>>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Fdri-devel&amp;data=02%7C01%7Cnirmoy.das%40amd.com%7C5c7df129b9cf44b3ae4008d803e84445%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637263643415833767&amp;sdata=PrCQse4nhN0ZITT9OniuHhF7A5uxJD6ehk0PMjm7WMU%3D&amp;reserved=0 
>>>
>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC PATCH 1/1] drm/mm: add ig_frag selftest
  2020-06-02 14:13           ` [Intel-gfx] " Nirmoy
@ 2020-06-02 14:25             ` Christian König
  -1 siblings, 0 replies; 21+ messages in thread
From: Christian König @ 2020-06-02 14:25 UTC (permalink / raw)
  To: Nirmoy, Chris Wilson, dri-devel; +Cc: intel-gfx

Am 02.06.20 um 16:13 schrieb Nirmoy:
> Hi Christian,
>
> On 6/2/20 2:47 PM, Christian König wrote:
>> Nirmoy please keep in mind that your current implementation doesn't 
>> fully solve the issue the test case is exercising.
>>
>> In other words what you have implement is fast skipping of fragmented 
>> address space for bottom-up and top-down.
>>
>> But what this test here exercises is the fast skipping of aligned 
>> allocations. You should probably adjust the test case a bit.
>
>
> Allocations with size=4k and aign = 8k is known to introduce 
> fragmentation,

Yes, but this fragmentation can't be avoided with what we already 
implemented. For this we would need the extension with the alignment I 
already explained.

> do you mean I should only test bottom-up and top-down
>
> for now ?

Yes and no.

What we need to test is the following:

1. Make tons of allocations with size=4k and align=0.

2. Free every other of those allocations.

3. Make tons of allocations with size=8k and align=0.

Previously bottom-up and top-down would have checked all the holes 
created in step #2.

With your change they can immediately see that this doesn't make sense 
and shortcut to the leftmost/rightmost leaf node in the tree with the 
large free block.

That we can handle the alignment as well is the next step of that.

Regards,
Christian.

>
>
> Regards,
>
> Nirmoy
>
>
>>
>>
>> Regards,
>> Christian.
>>
>> Am 29.05.20 um 23:01 schrieb Nirmoy:
>>>
>>> On 5/29/20 5:52 PM, Chris Wilson wrote:
>>>> Quoting Nirmoy (2020-05-29 16:40:53)
>>>>> This works correctly most of the times but sometimes
>>>
>>>
>>> I have to take my word back. In another machine,  20k insertions in
>>>
>>> best mode takes 6-9 times more than 10k insertions, all most all the 
>>> time.
>>>
>>> evict, bottom-up and top-down modes remains in 2-5 times range.
>>>
>>>
>>> If I reduce the insertions to 1k and 2k then scaling factor for best 
>>> mode stays  below 4 most of the time.
>>>
>>> evict, bottom-up and top-down modes remains in 2-3 times range.
>>>
>>>
>>> I wonder if it makes sense to test with only 1k and 2k insertions 
>>> and tolerate more than error if the mode == best.
>>>
>>> Regards,
>>>
>>> Nirmoy
>>>
>>>>>
>>>>> 20k insertions can take more than 8 times of 10k insertion time.
>>>> The pressure is on to improve then :)
>>>>
>>>>> Regards,
>>>>>
>>>>> Nirmoy
>>>>>
>>>>> On 5/29/20 6:33 PM, Nirmoy Das wrote:
>>>>>> This patch introduces fragmentation in the address range
>>>>>> and measures time taken by 10k and 20k insertions. ig_frag()
>>>>>> will fail if time taken by 20k insertions takes more than 4 times
>>>>>> of 10k insertions as we know that insertions scale quadratically.
>>>>>> Also tolerate 10% error because of kernel scheduler's jitters.
>>>>>>
>>>>>> Output:
>>>>>> <snip>
>>>>>> [ 8092.653518] drm_mm: Testing DRM range manger (struct drm_mm), 
>>>>>> with random_seed=0x9bfb4117 max_iterations=8192 max_prime=128
>>>>>> [ 8092.653520] drm_mm: igt_sanitycheck - ok!
>>>>>> [ 8092.653525] igt_debug 0x0000000000000000-0x0000000000000200: 
>>>>>> 512: free
>>>>>> [ 8092.653526] igt_debug 0x0000000000000200-0x0000000000000600: 
>>>>>> 1024: used
>>>>>> [ 8092.653527] igt_debug 0x0000000000000600-0x0000000000000a00: 
>>>>>> 1024: free
>>>>>> [ 8092.653528] igt_debug 0x0000000000000a00-0x0000000000000e00: 
>>>>>> 1024: used
>>>>>> [ 8092.653529] igt_debug 0x0000000000000e00-0x0000000000001000: 
>>>>>> 512: free
>>>>>> [ 8092.653529] igt_debug total: 4096, used 2048 free 2048
>>>>>> [ 8112.569813] drm_mm: best fragmented insert of 10000 and 20000 
>>>>>> insertions took 504 and 1996 msecs
>>>>>> [ 8112.723254] drm_mm: bottom-up fragmented insert of 10000 and 
>>>>>> 20000 insertions took 44 and 108 msecs
>>>>>> [ 8112.813212] drm_mm: top-down fragmented insert of 10000 and 
>>>>>> 20000 insertions took 40 and 44 msecs
>>>>>> [ 8112.847733] drm_mm: evict fragmented insert of 10000 and 20000 
>>>>>> insertions took 8 and 20 msecs
>>>>>> <snip>
>>>>>>
>>>>>> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
>>>>>> ---
>>>>>>    drivers/gpu/drm/selftests/drm_mm_selftests.h |  1 +
>>>>>>    drivers/gpu/drm/selftests/test-drm_mm.c      | 73 
>>>>>> ++++++++++++++++++++
>>>>>>    2 files changed, 74 insertions(+)
>>>>>>
>>>>>> diff --git a/drivers/gpu/drm/selftests/drm_mm_selftests.h 
>>>>>> b/drivers/gpu/drm/selftests/drm_mm_selftests.h
>>>>>> index 6b943ea1c57d..8c87c964176b 100644
>>>>>> --- a/drivers/gpu/drm/selftests/drm_mm_selftests.h
>>>>>> +++ b/drivers/gpu/drm/selftests/drm_mm_selftests.h
>>>>>> @@ -14,6 +14,7 @@ selftest(insert, igt_insert)
>>>>>>    selftest(replace, igt_replace)
>>>>>>    selftest(insert_range, igt_insert_range)
>>>>>>    selftest(align, igt_align)
>>>>>> +selftest(frag, igt_frag)
>>>>>>    selftest(align32, igt_align32)
>>>>>>    selftest(align64, igt_align64)
>>>>>>    selftest(evict, igt_evict)
>>>>>> diff --git a/drivers/gpu/drm/selftests/test-drm_mm.c 
>>>>>> b/drivers/gpu/drm/selftests/test-drm_mm.c
>>>>>> index 9aabe82dcd3a..05d8f3659b4d 100644
>>>>>> --- a/drivers/gpu/drm/selftests/test-drm_mm.c
>>>>>> +++ b/drivers/gpu/drm/selftests/test-drm_mm.c
>>>>>> @@ -1033,6 +1033,79 @@ static int igt_insert_range(void *ignored)
>>>>>>        return 0;
>>>>>>    }
>>>>>>    +static int get_insert_time(unsigned int num_insert,
>>>>>> +                        const struct insert_mode *mode)
>>>>>> +{
>>>>>> +     struct drm_mm mm;
>>>>>> +     struct drm_mm_node *nodes, *node, *next;
>>>>>> +     unsigned int size = 4096, align = 8192;
>>>>>> +     unsigned long start;
>>>>>> +     unsigned int i;
>>>>>> +     int ret = -EINVAL;
>>>>>> +
>>>>>> +     drm_mm_init(&mm, 1, U64_MAX - 2);
>>>>>> +     nodes = vzalloc(array_size(num_insert, sizeof(*nodes)));
>>>>>> +     if (!nodes)
>>>>>> +             goto err;
>>>>>> +
>>>>>> +     start = jiffies;
>>>> Use ktime_t start = ktime_now();
>>>>
>>>>>> +     for (i = 0; i < num_insert; i++) {
>>>>>> +             if (!expect_insert(&mm, &nodes[i], size, align, i, 
>>>>>> mode)) {
>>>>>> +                     pr_err("%s insert failed\n", mode->name);
>>>>>> +                     goto out;
>>>>>> +             }
>>>>>> +     }
>>>>>> +
>>>>>> +     ret = jiffies_to_msecs(jiffies - start);
>>>> ret = ktime_sub(ktime_now(), start);
>>>>
>>>> The downside to using ktime is remembering it is s64 and so 
>>>> requires care
>>>> and attention in doing math.
>>>>
>>>>>> +out:
>>>>>> +     drm_mm_for_each_node_safe(node, next, &mm)
>>>>>> +             drm_mm_remove_node(node);
>>>>>> +     drm_mm_takedown(&mm);
>>>>>> +     vfree(nodes);
>>>>>> +err:
>>>>>> +     return ret;
>>>>>> +
>>>>>> +}
>>>>>> +
>>>>>> +static int igt_frag(void *ignored)
>>>>>> +{
>>>>>> +     const struct insert_mode *mode;
>>>>>> +     unsigned int insert_time1, insert_time2;
>>>>>> +     unsigned int insert_size = 10000;
>>>>>> +     unsigned int scale_factor = 4;
>>>>>> +     /* tolerate 10% excess insertion duration */
>>>>>> +     unsigned int error_factor = 110;
>>>>>> +     int ret = -EINVAL;
>>>>>> +
>>>>>> +     for (mode = insert_modes; mode->name; mode++) {
>>>>>> +             unsigned int expected_time;
>>>>>> +
>>>>>> +             insert_time1 = get_insert_time(insert_size, mode);
>>>>>> +             if (insert_time1 < 0)
>>>>>> +                     goto err;
>>>> Ah, can you propagate the actual error. I see you are returning EINVAL
>>>> for ENOMEM errors. Just wait until it hits and you have to debug 
>>>> why :)
>>>>
>>>>>> +             insert_time2 = get_insert_time((insert_size * 2), 
>>>>>> mode);
>>>>>> +             if (insert_time2 < 0)
>>>>>> +                     goto err;
>>>>>> +
>>>>>> +             expected_time = (scale_factor * insert_time1 *
>>>>>> +                              error_factor)/100;
>>>>>> +             if (insert_time2 > expected_time) {
>>>>>> +                     pr_err("%s fragmented insert took more %u 
>>>>>> msecs\n",
>>>>>> +                            mode->name, insert_time2 - 
>>>>>> expected_time);
>>>>>> +                     goto err;
>>>>>> +             }
>>>>>> +
>>>>>> +             pr_info("%s fragmented insert of %u and %u 
>>>>>> insertions took %u and %u msecs\n",
>>>>>> +                     mode->name, insert_size, insert_size * 2, 
>>>>>> insert_time1,
>>>>>> +                     insert_time2);
>>>> Put the info first before the error. We always want the full details,
>>>> with the error message explaining why it's unhappy.
>>>> -Chris
>>>> _______________________________________________
>>>> dri-devel mailing list
>>>> dri-devel@lists.freedesktop.org
>>>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Fdri-devel&amp;data=02%7C01%7Cnirmoy.das%40amd.com%7C5c7df129b9cf44b3ae4008d803e84445%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637263643415833767&amp;sdata=PrCQse4nhN0ZITT9OniuHhF7A5uxJD6ehk0PMjm7WMU%3D&amp;reserved=0 
>>>>
>>

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Intel-gfx] [RFC PATCH 1/1] drm/mm: add ig_frag selftest
@ 2020-06-02 14:25             ` Christian König
  0 siblings, 0 replies; 21+ messages in thread
From: Christian König @ 2020-06-02 14:25 UTC (permalink / raw)
  To: Nirmoy, Chris Wilson, dri-devel; +Cc: intel-gfx

Am 02.06.20 um 16:13 schrieb Nirmoy:
> Hi Christian,
>
> On 6/2/20 2:47 PM, Christian König wrote:
>> Nirmoy please keep in mind that your current implementation doesn't 
>> fully solve the issue the test case is exercising.
>>
>> In other words what you have implement is fast skipping of fragmented 
>> address space for bottom-up and top-down.
>>
>> But what this test here exercises is the fast skipping of aligned 
>> allocations. You should probably adjust the test case a bit.
>
>
> Allocations with size=4k and aign = 8k is known to introduce 
> fragmentation,

Yes, but this fragmentation can't be avoided with what we already 
implemented. For this we would need the extension with the alignment I 
already explained.

> do you mean I should only test bottom-up and top-down
>
> for now ?

Yes and no.

What we need to test is the following:

1. Make tons of allocations with size=4k and align=0.

2. Free every other of those allocations.

3. Make tons of allocations with size=8k and align=0.

Previously bottom-up and top-down would have checked all the holes 
created in step #2.

With your change they can immediately see that this doesn't make sense 
and shortcut to the leftmost/rightmost leaf node in the tree with the 
large free block.

That we can handle the alignment as well is the next step of that.

Regards,
Christian.

>
>
> Regards,
>
> Nirmoy
>
>
>>
>>
>> Regards,
>> Christian.
>>
>> Am 29.05.20 um 23:01 schrieb Nirmoy:
>>>
>>> On 5/29/20 5:52 PM, Chris Wilson wrote:
>>>> Quoting Nirmoy (2020-05-29 16:40:53)
>>>>> This works correctly most of the times but sometimes
>>>
>>>
>>> I have to take my word back. In another machine,  20k insertions in
>>>
>>> best mode takes 6-9 times more than 10k insertions, all most all the 
>>> time.
>>>
>>> evict, bottom-up and top-down modes remains in 2-5 times range.
>>>
>>>
>>> If I reduce the insertions to 1k and 2k then scaling factor for best 
>>> mode stays  below 4 most of the time.
>>>
>>> evict, bottom-up and top-down modes remains in 2-3 times range.
>>>
>>>
>>> I wonder if it makes sense to test with only 1k and 2k insertions 
>>> and tolerate more than error if the mode == best.
>>>
>>> Regards,
>>>
>>> Nirmoy
>>>
>>>>>
>>>>> 20k insertions can take more than 8 times of 10k insertion time.
>>>> The pressure is on to improve then :)
>>>>
>>>>> Regards,
>>>>>
>>>>> Nirmoy
>>>>>
>>>>> On 5/29/20 6:33 PM, Nirmoy Das wrote:
>>>>>> This patch introduces fragmentation in the address range
>>>>>> and measures time taken by 10k and 20k insertions. ig_frag()
>>>>>> will fail if time taken by 20k insertions takes more than 4 times
>>>>>> of 10k insertions as we know that insertions scale quadratically.
>>>>>> Also tolerate 10% error because of kernel scheduler's jitters.
>>>>>>
>>>>>> Output:
>>>>>> <snip>
>>>>>> [ 8092.653518] drm_mm: Testing DRM range manger (struct drm_mm), 
>>>>>> with random_seed=0x9bfb4117 max_iterations=8192 max_prime=128
>>>>>> [ 8092.653520] drm_mm: igt_sanitycheck - ok!
>>>>>> [ 8092.653525] igt_debug 0x0000000000000000-0x0000000000000200: 
>>>>>> 512: free
>>>>>> [ 8092.653526] igt_debug 0x0000000000000200-0x0000000000000600: 
>>>>>> 1024: used
>>>>>> [ 8092.653527] igt_debug 0x0000000000000600-0x0000000000000a00: 
>>>>>> 1024: free
>>>>>> [ 8092.653528] igt_debug 0x0000000000000a00-0x0000000000000e00: 
>>>>>> 1024: used
>>>>>> [ 8092.653529] igt_debug 0x0000000000000e00-0x0000000000001000: 
>>>>>> 512: free
>>>>>> [ 8092.653529] igt_debug total: 4096, used 2048 free 2048
>>>>>> [ 8112.569813] drm_mm: best fragmented insert of 10000 and 20000 
>>>>>> insertions took 504 and 1996 msecs
>>>>>> [ 8112.723254] drm_mm: bottom-up fragmented insert of 10000 and 
>>>>>> 20000 insertions took 44 and 108 msecs
>>>>>> [ 8112.813212] drm_mm: top-down fragmented insert of 10000 and 
>>>>>> 20000 insertions took 40 and 44 msecs
>>>>>> [ 8112.847733] drm_mm: evict fragmented insert of 10000 and 20000 
>>>>>> insertions took 8 and 20 msecs
>>>>>> <snip>
>>>>>>
>>>>>> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
>>>>>> ---
>>>>>>    drivers/gpu/drm/selftests/drm_mm_selftests.h |  1 +
>>>>>>    drivers/gpu/drm/selftests/test-drm_mm.c      | 73 
>>>>>> ++++++++++++++++++++
>>>>>>    2 files changed, 74 insertions(+)
>>>>>>
>>>>>> diff --git a/drivers/gpu/drm/selftests/drm_mm_selftests.h 
>>>>>> b/drivers/gpu/drm/selftests/drm_mm_selftests.h
>>>>>> index 6b943ea1c57d..8c87c964176b 100644
>>>>>> --- a/drivers/gpu/drm/selftests/drm_mm_selftests.h
>>>>>> +++ b/drivers/gpu/drm/selftests/drm_mm_selftests.h
>>>>>> @@ -14,6 +14,7 @@ selftest(insert, igt_insert)
>>>>>>    selftest(replace, igt_replace)
>>>>>>    selftest(insert_range, igt_insert_range)
>>>>>>    selftest(align, igt_align)
>>>>>> +selftest(frag, igt_frag)
>>>>>>    selftest(align32, igt_align32)
>>>>>>    selftest(align64, igt_align64)
>>>>>>    selftest(evict, igt_evict)
>>>>>> diff --git a/drivers/gpu/drm/selftests/test-drm_mm.c 
>>>>>> b/drivers/gpu/drm/selftests/test-drm_mm.c
>>>>>> index 9aabe82dcd3a..05d8f3659b4d 100644
>>>>>> --- a/drivers/gpu/drm/selftests/test-drm_mm.c
>>>>>> +++ b/drivers/gpu/drm/selftests/test-drm_mm.c
>>>>>> @@ -1033,6 +1033,79 @@ static int igt_insert_range(void *ignored)
>>>>>>        return 0;
>>>>>>    }
>>>>>>    +static int get_insert_time(unsigned int num_insert,
>>>>>> +                        const struct insert_mode *mode)
>>>>>> +{
>>>>>> +     struct drm_mm mm;
>>>>>> +     struct drm_mm_node *nodes, *node, *next;
>>>>>> +     unsigned int size = 4096, align = 8192;
>>>>>> +     unsigned long start;
>>>>>> +     unsigned int i;
>>>>>> +     int ret = -EINVAL;
>>>>>> +
>>>>>> +     drm_mm_init(&mm, 1, U64_MAX - 2);
>>>>>> +     nodes = vzalloc(array_size(num_insert, sizeof(*nodes)));
>>>>>> +     if (!nodes)
>>>>>> +             goto err;
>>>>>> +
>>>>>> +     start = jiffies;
>>>> Use ktime_t start = ktime_now();
>>>>
>>>>>> +     for (i = 0; i < num_insert; i++) {
>>>>>> +             if (!expect_insert(&mm, &nodes[i], size, align, i, 
>>>>>> mode)) {
>>>>>> +                     pr_err("%s insert failed\n", mode->name);
>>>>>> +                     goto out;
>>>>>> +             }
>>>>>> +     }
>>>>>> +
>>>>>> +     ret = jiffies_to_msecs(jiffies - start);
>>>> ret = ktime_sub(ktime_now(), start);
>>>>
>>>> The downside to using ktime is remembering it is s64 and so 
>>>> requires care
>>>> and attention in doing math.
>>>>
>>>>>> +out:
>>>>>> +     drm_mm_for_each_node_safe(node, next, &mm)
>>>>>> +             drm_mm_remove_node(node);
>>>>>> +     drm_mm_takedown(&mm);
>>>>>> +     vfree(nodes);
>>>>>> +err:
>>>>>> +     return ret;
>>>>>> +
>>>>>> +}
>>>>>> +
>>>>>> +static int igt_frag(void *ignored)
>>>>>> +{
>>>>>> +     const struct insert_mode *mode;
>>>>>> +     unsigned int insert_time1, insert_time2;
>>>>>> +     unsigned int insert_size = 10000;
>>>>>> +     unsigned int scale_factor = 4;
>>>>>> +     /* tolerate 10% excess insertion duration */
>>>>>> +     unsigned int error_factor = 110;
>>>>>> +     int ret = -EINVAL;
>>>>>> +
>>>>>> +     for (mode = insert_modes; mode->name; mode++) {
>>>>>> +             unsigned int expected_time;
>>>>>> +
>>>>>> +             insert_time1 = get_insert_time(insert_size, mode);
>>>>>> +             if (insert_time1 < 0)
>>>>>> +                     goto err;
>>>> Ah, can you propagate the actual error. I see you are returning EINVAL
>>>> for ENOMEM errors. Just wait until it hits and you have to debug 
>>>> why :)
>>>>
>>>>>> +             insert_time2 = get_insert_time((insert_size * 2), 
>>>>>> mode);
>>>>>> +             if (insert_time2 < 0)
>>>>>> +                     goto err;
>>>>>> +
>>>>>> +             expected_time = (scale_factor * insert_time1 *
>>>>>> +                              error_factor)/100;
>>>>>> +             if (insert_time2 > expected_time) {
>>>>>> +                     pr_err("%s fragmented insert took more %u 
>>>>>> msecs\n",
>>>>>> +                            mode->name, insert_time2 - 
>>>>>> expected_time);
>>>>>> +                     goto err;
>>>>>> +             }
>>>>>> +
>>>>>> +             pr_info("%s fragmented insert of %u and %u 
>>>>>> insertions took %u and %u msecs\n",
>>>>>> +                     mode->name, insert_size, insert_size * 2, 
>>>>>> insert_time1,
>>>>>> +                     insert_time2);
>>>> Put the info first before the error. We always want the full details,
>>>> with the error message explaining why it's unhappy.
>>>> -Chris
>>>> _______________________________________________
>>>> dri-devel mailing list
>>>> dri-devel@lists.freedesktop.org
>>>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Fdri-devel&amp;data=02%7C01%7Cnirmoy.das%40amd.com%7C5c7df129b9cf44b3ae4008d803e84445%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637263643415833767&amp;sdata=PrCQse4nhN0ZITT9OniuHhF7A5uxJD6ehk0PMjm7WMU%3D&amp;reserved=0 
>>>>
>>

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC PATCH 1/1] drm/mm: add ig_frag selftest
  2020-06-02 14:25             ` [Intel-gfx] " Christian König
@ 2020-06-03  9:10               ` Nirmoy
  -1 siblings, 0 replies; 21+ messages in thread
From: Nirmoy @ 2020-06-03  9:10 UTC (permalink / raw)
  To: Christian König, Chris Wilson, dri-devel; +Cc: intel-gfx


On 6/2/20 4:25 PM, Christian König wrote:
> Am 02.06.20 um 16:13 schrieb Nirmoy:
>> Hi Christian,
>>
>> On 6/2/20 2:47 PM, Christian König wrote:
>>> Nirmoy please keep in mind that your current implementation doesn't 
>>> fully solve the issue the test case is exercising.
>>>
>>> In other words what you have implement is fast skipping of 
>>> fragmented address space for bottom-up and top-down.
>>>
>>> But what this test here exercises is the fast skipping of aligned 
>>> allocations. You should probably adjust the test case a bit.
>>
>>
>> Allocations with size=4k and aign = 8k is known to introduce 
>> fragmentation,
>
> Yes, but this fragmentation can't be avoided with what we already 
> implemented. For this we would need the extension with the alignment I 
> already explained.
>
>> do you mean I should only test bottom-up and top-down
>>
>> for now ?
>
> Yes and no.
>
> What we need to test is the following:
>
> 1. Make tons of allocations with size=4k and align=0.
>
> 2. Free every other of those allocations.
>
> 3. Make tons of allocations with size=8k and align=0.
>
> Previously bottom-up and top-down would have checked all the holes 
> created in step #2.
>
> With your change they can immediately see that this doesn't make sense 
> and shortcut to the leftmost/rightmost leaf node in the tree with the 
> large free block.
>
> That we can handle the alignment as well is the next step of that.


Thanks Christian for the detailed explanation. I have modified this as 
you suggested, will send in few minutes.


Regards,

Nirmoy

>
> Regards,
> Christian.
>
>>
>>
>> Regards,
>>
>> Nirmoy
>>
>>
>>>
>>>
>>> Regards,
>>> Christian.
>>>
>>> Am 29.05.20 um 23:01 schrieb Nirmoy:
>>>>
>>>> On 5/29/20 5:52 PM, Chris Wilson wrote:
>>>>> Quoting Nirmoy (2020-05-29 16:40:53)
>>>>>> This works correctly most of the times but sometimes
>>>>
>>>>
>>>> I have to take my word back. In another machine,  20k insertions in
>>>>
>>>> best mode takes 6-9 times more than 10k insertions, all most all 
>>>> the time.
>>>>
>>>> evict, bottom-up and top-down modes remains in 2-5 times range.
>>>>
>>>>
>>>> If I reduce the insertions to 1k and 2k then scaling factor for 
>>>> best mode stays  below 4 most of the time.
>>>>
>>>> evict, bottom-up and top-down modes remains in 2-3 times range.
>>>>
>>>>
>>>> I wonder if it makes sense to test with only 1k and 2k insertions 
>>>> and tolerate more than error if the mode == best.
>>>>
>>>> Regards,
>>>>
>>>> Nirmoy
>>>>
>>>>>>
>>>>>> 20k insertions can take more than 8 times of 10k insertion time.
>>>>> The pressure is on to improve then :)
>>>>>
>>>>>> Regards,
>>>>>>
>>>>>> Nirmoy
>>>>>>
>>>>>> On 5/29/20 6:33 PM, Nirmoy Das wrote:
>>>>>>> This patch introduces fragmentation in the address range
>>>>>>> and measures time taken by 10k and 20k insertions. ig_frag()
>>>>>>> will fail if time taken by 20k insertions takes more than 4 times
>>>>>>> of 10k insertions as we know that insertions scale quadratically.
>>>>>>> Also tolerate 10% error because of kernel scheduler's jitters.
>>>>>>>
>>>>>>> Output:
>>>>>>> <snip>
>>>>>>> [ 8092.653518] drm_mm: Testing DRM range manger (struct drm_mm), 
>>>>>>> with random_seed=0x9bfb4117 max_iterations=8192 max_prime=128
>>>>>>> [ 8092.653520] drm_mm: igt_sanitycheck - ok!
>>>>>>> [ 8092.653525] igt_debug 0x0000000000000000-0x0000000000000200: 
>>>>>>> 512: free
>>>>>>> [ 8092.653526] igt_debug 0x0000000000000200-0x0000000000000600: 
>>>>>>> 1024: used
>>>>>>> [ 8092.653527] igt_debug 0x0000000000000600-0x0000000000000a00: 
>>>>>>> 1024: free
>>>>>>> [ 8092.653528] igt_debug 0x0000000000000a00-0x0000000000000e00: 
>>>>>>> 1024: used
>>>>>>> [ 8092.653529] igt_debug 0x0000000000000e00-0x0000000000001000: 
>>>>>>> 512: free
>>>>>>> [ 8092.653529] igt_debug total: 4096, used 2048 free 2048
>>>>>>> [ 8112.569813] drm_mm: best fragmented insert of 10000 and 20000 
>>>>>>> insertions took 504 and 1996 msecs
>>>>>>> [ 8112.723254] drm_mm: bottom-up fragmented insert of 10000 and 
>>>>>>> 20000 insertions took 44 and 108 msecs
>>>>>>> [ 8112.813212] drm_mm: top-down fragmented insert of 10000 and 
>>>>>>> 20000 insertions took 40 and 44 msecs
>>>>>>> [ 8112.847733] drm_mm: evict fragmented insert of 10000 and 
>>>>>>> 20000 insertions took 8 and 20 msecs
>>>>>>> <snip>
>>>>>>>
>>>>>>> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
>>>>>>> ---
>>>>>>>    drivers/gpu/drm/selftests/drm_mm_selftests.h |  1 +
>>>>>>>    drivers/gpu/drm/selftests/test-drm_mm.c      | 73 
>>>>>>> ++++++++++++++++++++
>>>>>>>    2 files changed, 74 insertions(+)
>>>>>>>
>>>>>>> diff --git a/drivers/gpu/drm/selftests/drm_mm_selftests.h 
>>>>>>> b/drivers/gpu/drm/selftests/drm_mm_selftests.h
>>>>>>> index 6b943ea1c57d..8c87c964176b 100644
>>>>>>> --- a/drivers/gpu/drm/selftests/drm_mm_selftests.h
>>>>>>> +++ b/drivers/gpu/drm/selftests/drm_mm_selftests.h
>>>>>>> @@ -14,6 +14,7 @@ selftest(insert, igt_insert)
>>>>>>>    selftest(replace, igt_replace)
>>>>>>>    selftest(insert_range, igt_insert_range)
>>>>>>>    selftest(align, igt_align)
>>>>>>> +selftest(frag, igt_frag)
>>>>>>>    selftest(align32, igt_align32)
>>>>>>>    selftest(align64, igt_align64)
>>>>>>>    selftest(evict, igt_evict)
>>>>>>> diff --git a/drivers/gpu/drm/selftests/test-drm_mm.c 
>>>>>>> b/drivers/gpu/drm/selftests/test-drm_mm.c
>>>>>>> index 9aabe82dcd3a..05d8f3659b4d 100644
>>>>>>> --- a/drivers/gpu/drm/selftests/test-drm_mm.c
>>>>>>> +++ b/drivers/gpu/drm/selftests/test-drm_mm.c
>>>>>>> @@ -1033,6 +1033,79 @@ static int igt_insert_range(void *ignored)
>>>>>>>        return 0;
>>>>>>>    }
>>>>>>>    +static int get_insert_time(unsigned int num_insert,
>>>>>>> +                        const struct insert_mode *mode)
>>>>>>> +{
>>>>>>> +     struct drm_mm mm;
>>>>>>> +     struct drm_mm_node *nodes, *node, *next;
>>>>>>> +     unsigned int size = 4096, align = 8192;
>>>>>>> +     unsigned long start;
>>>>>>> +     unsigned int i;
>>>>>>> +     int ret = -EINVAL;
>>>>>>> +
>>>>>>> +     drm_mm_init(&mm, 1, U64_MAX - 2);
>>>>>>> +     nodes = vzalloc(array_size(num_insert, sizeof(*nodes)));
>>>>>>> +     if (!nodes)
>>>>>>> +             goto err;
>>>>>>> +
>>>>>>> +     start = jiffies;
>>>>> Use ktime_t start = ktime_now();
>>>>>
>>>>>>> +     for (i = 0; i < num_insert; i++) {
>>>>>>> +             if (!expect_insert(&mm, &nodes[i], size, align, i, 
>>>>>>> mode)) {
>>>>>>> +                     pr_err("%s insert failed\n", mode->name);
>>>>>>> +                     goto out;
>>>>>>> +             }
>>>>>>> +     }
>>>>>>> +
>>>>>>> +     ret = jiffies_to_msecs(jiffies - start);
>>>>> ret = ktime_sub(ktime_now(), start);
>>>>>
>>>>> The downside to using ktime is remembering it is s64 and so 
>>>>> requires care
>>>>> and attention in doing math.
>>>>>
>>>>>>> +out:
>>>>>>> +     drm_mm_for_each_node_safe(node, next, &mm)
>>>>>>> +             drm_mm_remove_node(node);
>>>>>>> +     drm_mm_takedown(&mm);
>>>>>>> +     vfree(nodes);
>>>>>>> +err:
>>>>>>> +     return ret;
>>>>>>> +
>>>>>>> +}
>>>>>>> +
>>>>>>> +static int igt_frag(void *ignored)
>>>>>>> +{
>>>>>>> +     const struct insert_mode *mode;
>>>>>>> +     unsigned int insert_time1, insert_time2;
>>>>>>> +     unsigned int insert_size = 10000;
>>>>>>> +     unsigned int scale_factor = 4;
>>>>>>> +     /* tolerate 10% excess insertion duration */
>>>>>>> +     unsigned int error_factor = 110;
>>>>>>> +     int ret = -EINVAL;
>>>>>>> +
>>>>>>> +     for (mode = insert_modes; mode->name; mode++) {
>>>>>>> +             unsigned int expected_time;
>>>>>>> +
>>>>>>> +             insert_time1 = get_insert_time(insert_size, mode);
>>>>>>> +             if (insert_time1 < 0)
>>>>>>> +                     goto err;
>>>>> Ah, can you propagate the actual error. I see you are returning 
>>>>> EINVAL
>>>>> for ENOMEM errors. Just wait until it hits and you have to debug 
>>>>> why :)
>>>>>
>>>>>>> +             insert_time2 = get_insert_time((insert_size * 2), 
>>>>>>> mode);
>>>>>>> +             if (insert_time2 < 0)
>>>>>>> +                     goto err;
>>>>>>> +
>>>>>>> +             expected_time = (scale_factor * insert_time1 *
>>>>>>> +                              error_factor)/100;
>>>>>>> +             if (insert_time2 > expected_time) {
>>>>>>> +                     pr_err("%s fragmented insert took more %u 
>>>>>>> msecs\n",
>>>>>>> +                            mode->name, insert_time2 - 
>>>>>>> expected_time);
>>>>>>> +                     goto err;
>>>>>>> +             }
>>>>>>> +
>>>>>>> +             pr_info("%s fragmented insert of %u and %u 
>>>>>>> insertions took %u and %u msecs\n",
>>>>>>> +                     mode->name, insert_size, insert_size * 2, 
>>>>>>> insert_time1,
>>>>>>> +                     insert_time2);
>>>>> Put the info first before the error. We always want the full details,
>>>>> with the error message explaining why it's unhappy.
>>>>> -Chris
>>>>> _______________________________________________
>>>>> dri-devel mailing list
>>>>> dri-devel@lists.freedesktop.org
>>>>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Fdri-devel&amp;data=02%7C01%7Cnirmoy.das%40amd.com%7C5c7df129b9cf44b3ae4008d803e84445%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637263643415833767&amp;sdata=PrCQse4nhN0ZITT9OniuHhF7A5uxJD6ehk0PMjm7WMU%3D&amp;reserved=0 
>>>>>
>>>
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Intel-gfx] [RFC PATCH 1/1] drm/mm: add ig_frag selftest
@ 2020-06-03  9:10               ` Nirmoy
  0 siblings, 0 replies; 21+ messages in thread
From: Nirmoy @ 2020-06-03  9:10 UTC (permalink / raw)
  To: Christian König, Chris Wilson, dri-devel; +Cc: intel-gfx


On 6/2/20 4:25 PM, Christian König wrote:
> Am 02.06.20 um 16:13 schrieb Nirmoy:
>> Hi Christian,
>>
>> On 6/2/20 2:47 PM, Christian König wrote:
>>> Nirmoy please keep in mind that your current implementation doesn't 
>>> fully solve the issue the test case is exercising.
>>>
>>> In other words what you have implement is fast skipping of 
>>> fragmented address space for bottom-up and top-down.
>>>
>>> But what this test here exercises is the fast skipping of aligned 
>>> allocations. You should probably adjust the test case a bit.
>>
>>
>> Allocations with size=4k and aign = 8k is known to introduce 
>> fragmentation,
>
> Yes, but this fragmentation can't be avoided with what we already 
> implemented. For this we would need the extension with the alignment I 
> already explained.
>
>> do you mean I should only test bottom-up and top-down
>>
>> for now ?
>
> Yes and no.
>
> What we need to test is the following:
>
> 1. Make tons of allocations with size=4k and align=0.
>
> 2. Free every other of those allocations.
>
> 3. Make tons of allocations with size=8k and align=0.
>
> Previously bottom-up and top-down would have checked all the holes 
> created in step #2.
>
> With your change they can immediately see that this doesn't make sense 
> and shortcut to the leftmost/rightmost leaf node in the tree with the 
> large free block.
>
> That we can handle the alignment as well is the next step of that.


Thanks Christian for the detailed explanation. I have modified this as 
you suggested, will send in few minutes.


Regards,

Nirmoy

>
> Regards,
> Christian.
>
>>
>>
>> Regards,
>>
>> Nirmoy
>>
>>
>>>
>>>
>>> Regards,
>>> Christian.
>>>
>>> Am 29.05.20 um 23:01 schrieb Nirmoy:
>>>>
>>>> On 5/29/20 5:52 PM, Chris Wilson wrote:
>>>>> Quoting Nirmoy (2020-05-29 16:40:53)
>>>>>> This works correctly most of the times but sometimes
>>>>
>>>>
>>>> I have to take my word back. In another machine,  20k insertions in
>>>>
>>>> best mode takes 6-9 times more than 10k insertions, all most all 
>>>> the time.
>>>>
>>>> evict, bottom-up and top-down modes remains in 2-5 times range.
>>>>
>>>>
>>>> If I reduce the insertions to 1k and 2k then scaling factor for 
>>>> best mode stays  below 4 most of the time.
>>>>
>>>> evict, bottom-up and top-down modes remains in 2-3 times range.
>>>>
>>>>
>>>> I wonder if it makes sense to test with only 1k and 2k insertions 
>>>> and tolerate more than error if the mode == best.
>>>>
>>>> Regards,
>>>>
>>>> Nirmoy
>>>>
>>>>>>
>>>>>> 20k insertions can take more than 8 times of 10k insertion time.
>>>>> The pressure is on to improve then :)
>>>>>
>>>>>> Regards,
>>>>>>
>>>>>> Nirmoy
>>>>>>
>>>>>> On 5/29/20 6:33 PM, Nirmoy Das wrote:
>>>>>>> This patch introduces fragmentation in the address range
>>>>>>> and measures time taken by 10k and 20k insertions. ig_frag()
>>>>>>> will fail if time taken by 20k insertions takes more than 4 times
>>>>>>> of 10k insertions as we know that insertions scale quadratically.
>>>>>>> Also tolerate 10% error because of kernel scheduler's jitters.
>>>>>>>
>>>>>>> Output:
>>>>>>> <snip>
>>>>>>> [ 8092.653518] drm_mm: Testing DRM range manger (struct drm_mm), 
>>>>>>> with random_seed=0x9bfb4117 max_iterations=8192 max_prime=128
>>>>>>> [ 8092.653520] drm_mm: igt_sanitycheck - ok!
>>>>>>> [ 8092.653525] igt_debug 0x0000000000000000-0x0000000000000200: 
>>>>>>> 512: free
>>>>>>> [ 8092.653526] igt_debug 0x0000000000000200-0x0000000000000600: 
>>>>>>> 1024: used
>>>>>>> [ 8092.653527] igt_debug 0x0000000000000600-0x0000000000000a00: 
>>>>>>> 1024: free
>>>>>>> [ 8092.653528] igt_debug 0x0000000000000a00-0x0000000000000e00: 
>>>>>>> 1024: used
>>>>>>> [ 8092.653529] igt_debug 0x0000000000000e00-0x0000000000001000: 
>>>>>>> 512: free
>>>>>>> [ 8092.653529] igt_debug total: 4096, used 2048 free 2048
>>>>>>> [ 8112.569813] drm_mm: best fragmented insert of 10000 and 20000 
>>>>>>> insertions took 504 and 1996 msecs
>>>>>>> [ 8112.723254] drm_mm: bottom-up fragmented insert of 10000 and 
>>>>>>> 20000 insertions took 44 and 108 msecs
>>>>>>> [ 8112.813212] drm_mm: top-down fragmented insert of 10000 and 
>>>>>>> 20000 insertions took 40 and 44 msecs
>>>>>>> [ 8112.847733] drm_mm: evict fragmented insert of 10000 and 
>>>>>>> 20000 insertions took 8 and 20 msecs
>>>>>>> <snip>
>>>>>>>
>>>>>>> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
>>>>>>> ---
>>>>>>>    drivers/gpu/drm/selftests/drm_mm_selftests.h |  1 +
>>>>>>>    drivers/gpu/drm/selftests/test-drm_mm.c      | 73 
>>>>>>> ++++++++++++++++++++
>>>>>>>    2 files changed, 74 insertions(+)
>>>>>>>
>>>>>>> diff --git a/drivers/gpu/drm/selftests/drm_mm_selftests.h 
>>>>>>> b/drivers/gpu/drm/selftests/drm_mm_selftests.h
>>>>>>> index 6b943ea1c57d..8c87c964176b 100644
>>>>>>> --- a/drivers/gpu/drm/selftests/drm_mm_selftests.h
>>>>>>> +++ b/drivers/gpu/drm/selftests/drm_mm_selftests.h
>>>>>>> @@ -14,6 +14,7 @@ selftest(insert, igt_insert)
>>>>>>>    selftest(replace, igt_replace)
>>>>>>>    selftest(insert_range, igt_insert_range)
>>>>>>>    selftest(align, igt_align)
>>>>>>> +selftest(frag, igt_frag)
>>>>>>>    selftest(align32, igt_align32)
>>>>>>>    selftest(align64, igt_align64)
>>>>>>>    selftest(evict, igt_evict)
>>>>>>> diff --git a/drivers/gpu/drm/selftests/test-drm_mm.c 
>>>>>>> b/drivers/gpu/drm/selftests/test-drm_mm.c
>>>>>>> index 9aabe82dcd3a..05d8f3659b4d 100644
>>>>>>> --- a/drivers/gpu/drm/selftests/test-drm_mm.c
>>>>>>> +++ b/drivers/gpu/drm/selftests/test-drm_mm.c
>>>>>>> @@ -1033,6 +1033,79 @@ static int igt_insert_range(void *ignored)
>>>>>>>        return 0;
>>>>>>>    }
>>>>>>>    +static int get_insert_time(unsigned int num_insert,
>>>>>>> +                        const struct insert_mode *mode)
>>>>>>> +{
>>>>>>> +     struct drm_mm mm;
>>>>>>> +     struct drm_mm_node *nodes, *node, *next;
>>>>>>> +     unsigned int size = 4096, align = 8192;
>>>>>>> +     unsigned long start;
>>>>>>> +     unsigned int i;
>>>>>>> +     int ret = -EINVAL;
>>>>>>> +
>>>>>>> +     drm_mm_init(&mm, 1, U64_MAX - 2);
>>>>>>> +     nodes = vzalloc(array_size(num_insert, sizeof(*nodes)));
>>>>>>> +     if (!nodes)
>>>>>>> +             goto err;
>>>>>>> +
>>>>>>> +     start = jiffies;
>>>>> Use ktime_t start = ktime_now();
>>>>>
>>>>>>> +     for (i = 0; i < num_insert; i++) {
>>>>>>> +             if (!expect_insert(&mm, &nodes[i], size, align, i, 
>>>>>>> mode)) {
>>>>>>> +                     pr_err("%s insert failed\n", mode->name);
>>>>>>> +                     goto out;
>>>>>>> +             }
>>>>>>> +     }
>>>>>>> +
>>>>>>> +     ret = jiffies_to_msecs(jiffies - start);
>>>>> ret = ktime_sub(ktime_now(), start);
>>>>>
>>>>> The downside to using ktime is remembering it is s64 and so 
>>>>> requires care
>>>>> and attention in doing math.
>>>>>
>>>>>>> +out:
>>>>>>> +     drm_mm_for_each_node_safe(node, next, &mm)
>>>>>>> +             drm_mm_remove_node(node);
>>>>>>> +     drm_mm_takedown(&mm);
>>>>>>> +     vfree(nodes);
>>>>>>> +err:
>>>>>>> +     return ret;
>>>>>>> +
>>>>>>> +}
>>>>>>> +
>>>>>>> +static int igt_frag(void *ignored)
>>>>>>> +{
>>>>>>> +     const struct insert_mode *mode;
>>>>>>> +     unsigned int insert_time1, insert_time2;
>>>>>>> +     unsigned int insert_size = 10000;
>>>>>>> +     unsigned int scale_factor = 4;
>>>>>>> +     /* tolerate 10% excess insertion duration */
>>>>>>> +     unsigned int error_factor = 110;
>>>>>>> +     int ret = -EINVAL;
>>>>>>> +
>>>>>>> +     for (mode = insert_modes; mode->name; mode++) {
>>>>>>> +             unsigned int expected_time;
>>>>>>> +
>>>>>>> +             insert_time1 = get_insert_time(insert_size, mode);
>>>>>>> +             if (insert_time1 < 0)
>>>>>>> +                     goto err;
>>>>> Ah, can you propagate the actual error. I see you are returning 
>>>>> EINVAL
>>>>> for ENOMEM errors. Just wait until it hits and you have to debug 
>>>>> why :)
>>>>>
>>>>>>> +             insert_time2 = get_insert_time((insert_size * 2), 
>>>>>>> mode);
>>>>>>> +             if (insert_time2 < 0)
>>>>>>> +                     goto err;
>>>>>>> +
>>>>>>> +             expected_time = (scale_factor * insert_time1 *
>>>>>>> +                              error_factor)/100;
>>>>>>> +             if (insert_time2 > expected_time) {
>>>>>>> +                     pr_err("%s fragmented insert took more %u 
>>>>>>> msecs\n",
>>>>>>> +                            mode->name, insert_time2 - 
>>>>>>> expected_time);
>>>>>>> +                     goto err;
>>>>>>> +             }
>>>>>>> +
>>>>>>> +             pr_info("%s fragmented insert of %u and %u 
>>>>>>> insertions took %u and %u msecs\n",
>>>>>>> +                     mode->name, insert_size, insert_size * 2, 
>>>>>>> insert_time1,
>>>>>>> +                     insert_time2);
>>>>> Put the info first before the error. We always want the full details,
>>>>> with the error message explaining why it's unhappy.
>>>>> -Chris
>>>>> _______________________________________________
>>>>> dri-devel mailing list
>>>>> dri-devel@lists.freedesktop.org
>>>>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Fdri-devel&amp;data=02%7C01%7Cnirmoy.das%40amd.com%7C5c7df129b9cf44b3ae4008d803e84445%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637263643415833767&amp;sdata=PrCQse4nhN0ZITT9OniuHhF7A5uxJD6ehk0PMjm7WMU%3D&amp;reserved=0 
>>>>>
>>>
>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2020-06-03 18:01 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-29 16:33 [RFC PATCH 1/1] drm/mm: add ig_frag selftest Nirmoy Das
2020-05-29 16:33 ` [Intel-gfx] " Nirmoy Das
2020-05-29 15:40 ` Nirmoy
2020-05-29 15:40   ` [Intel-gfx] " Nirmoy
2020-05-29 15:52   ` Chris Wilson
2020-05-29 15:52     ` [Intel-gfx] " Chris Wilson
2020-05-29 21:01     ` Nirmoy
2020-05-29 21:01       ` [Intel-gfx] " Nirmoy
2020-06-02 12:47       ` Christian König
2020-06-02 12:47         ` [Intel-gfx] " Christian König
2020-06-02 14:13         ` Nirmoy
2020-06-02 14:13           ` [Intel-gfx] " Nirmoy
2020-06-02 14:25           ` Christian König
2020-06-02 14:25             ` [Intel-gfx] " Christian König
2020-06-03  9:10             ` Nirmoy
2020-06-03  9:10               ` [Intel-gfx] " Nirmoy
2020-05-29 22:46 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for series starting with [RFC,1/1] " Patchwork
2020-05-29 23:07 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2020-05-30  3:20 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
2020-05-31 22:29 ` [Intel-gfx] [RFC PATCH 1/1] " kbuild test robot
2020-06-01  3:07 ` kbuild test robot

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.