dri-devel Archive mirror
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 3/7] dma-buf: add dma_fence_chain_alloc/free self tests
Date: Fri, 11 Jun 2021 12:04:58 +0200	[thread overview]
Message-ID: <e1f4954e-2c7b-49ab-5782-f06d81a6304a@gmail.com> (raw)
In-Reply-To: <YMMXlF5A7uB0sORs@phenom.ffwll.local>

Am 11.06.21 um 09:58 schrieb Daniel Vetter:
> On Thu, Jun 10, 2021 at 11:17:56AM +0200, Christian König wrote:
>> Exercise the newly added functions.
>>
>> Signed-off-by: Christian König <christian.koenig@amd.com>
> I have honestly no idea what this checks. Spawning a few threads to
> validate kmalloc/kfree feels a bit silly. Now testing whether we correctly
> rcu-delay the freeing here would make some sense, but even that feels a
> bit silly.
>
> I guess if you want this explain with comments what it does and why?

This was soley to figure out if the garbage collection is working 
properly and how much overhead it generates.

No actual need to commit it.

Christian.

> -Daniel
>
>
>> ---
>>   drivers/dma-buf/st-dma-fence-chain.c | 48 ++++++++++++++++++++++++++++
>>   1 file changed, 48 insertions(+)
>>
>> diff --git a/drivers/dma-buf/st-dma-fence-chain.c b/drivers/dma-buf/st-dma-fence-chain.c
>> index 8ce1ea59d31b..855c129c6093 100644
>> --- a/drivers/dma-buf/st-dma-fence-chain.c
>> +++ b/drivers/dma-buf/st-dma-fence-chain.c
>> @@ -95,6 +95,53 @@ static int sanitycheck(void *arg)
>>   	return err;
>>   }
>>   
>> +static int __alloc_free(void *arg)
>> +{
>> +	atomic_t *counter = arg;
>> +	int i, j;
>> +
>> +	for (i = 0; i < 1024; ++i) {
>> +		struct dma_fence_chain *chains[64];
>> +
>> +		for (j = 0; j < ARRAY_SIZE(chains); ++j)
>> +			chains[j] = dma_fence_chain_alloc();
>> +
>> +		for (j = 0; j < ARRAY_SIZE(chains); ++j)
>> +			dma_fence_chain_free(chains[j]);
>> +
>> +		atomic_add(ARRAY_SIZE(chains), counter);
>> +	}
>> +	return 0;
>> +}
>> +
>> +static int alloc_free(void *arg)
>> +{
>> +	struct task_struct *threads[8];
>> +	atomic_t counter = ATOMIC_INIT(0);
>> +	int i, err = 0;
>> +
>> +	for (i = 0; i < ARRAY_SIZE(threads); i++) {
>> +		threads[i] = kthread_run(__alloc_free, &counter, "dmabuf/%d",
>> +					 i);
>> +		if (IS_ERR(threads[i])) {
>> +			err = PTR_ERR(threads[i]);
>> +			break;
>> +		}
>> +	}
>> +
>> +	while (i--) {
>> +		int ret;
>> +
>> +		ret = kthread_stop(threads[i]);
>> +		if (ret && !err)
>> +			err = ret;
>> +	}
>> +
>> +	pr_info("Completed %u cycles\n", atomic_read(&counter));
>> +
>> +	return err;
>> +}
>> +
>>   struct fence_chains {
>>   	unsigned int chain_length;
>>   	struct dma_fence **fences;
>> @@ -677,6 +724,7 @@ int dma_fence_chain(void)
>>   {
>>   	static const struct subtest tests[] = {
>>   		SUBTEST(sanitycheck),
>> +		SUBTEST(alloc_free),
>>   		SUBTEST(find_seqno),
>>   		SUBTEST(find_signaled),
>>   		SUBTEST(find_out_of_order),
>> -- 
>> 2.25.1
>>


  reply	other threads:[~2021-06-11 10:05 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-10  9:17 Change how amdgpu stores fences in dma_resv objects Christian König
2021-06-10  9:17 ` [PATCH 1/7] dma-buf: some dma_fence_chain improvements Christian König
2021-06-11  7:49   ` Daniel Vetter
2021-06-10  9:17 ` [PATCH 2/7] dma-buf: add dma_fence_chain_alloc/free Christian König
2021-06-11  7:54   ` Daniel Vetter
2021-06-11 11:48     ` Christian König
2021-06-11 14:40       ` Daniel Vetter
2021-06-10  9:17 ` [PATCH 3/7] dma-buf: add dma_fence_chain_alloc/free self tests Christian König
2021-06-11  7:58   ` Daniel Vetter
2021-06-11 10:04     ` Christian König [this message]
2021-06-10  9:17 ` [PATCH 4/7] dma-buf: add dma_fence_chain_garbage_collect Christian König
2021-06-11  8:58   ` Daniel Vetter
2021-06-11 10:07     ` Christian König
2021-06-11 15:11       ` Daniel Vetter
2021-06-16 17:29   ` kernel test robot
2021-06-16 18:50   ` kernel test robot
2021-06-10  9:17 ` [PATCH 5/7] drm/syncobj: drop the manual garbage collection Christian König
2021-06-10  9:17 ` [PATCH 6/7] drm/amdgpu: unwrap fence chains in the explicit sync fence Christian König
2021-06-11  9:07   ` Daniel Vetter
2021-06-11 10:09     ` Christian König
2021-06-11 15:18       ` Daniel Vetter
2021-06-14  7:25         ` Christian König
2021-06-17 16:51           ` Daniel Vetter
2021-06-10  9:18 ` [PATCH 7/7] drm/amdgpu: rework dma_resv handling Christian König
2021-06-11  9:17   ` Daniel Vetter
2021-06-11 10:12     ` Christian König
2021-06-11 15:21       ` Daniel Vetter
2021-06-10 16:34 ` Change how amdgpu stores fences in dma_resv objects Michel Dänzer
2021-06-10 16:44   ` Christian König

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e1f4954e-2c7b-49ab-5782-f06d81a6304a@gmail.com \
    --to=ckoenig.leichtzumerken@gmail.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).