All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Matthew Auld <matthew.auld@intel.com>,
	Arunpravin <Arunpravin.PaneerSelvam@amd.com>,
	dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org,
	amd-gfx@lists.freedesktop.org
Cc: alexander.deucher@amd.com, tzimmermann@suse.de
Subject: Re: [PATCH v6 1/6] drm: move the buddy allocator from i915 into common drm
Date: Fri, 7 Jan 2022 16:57:48 +0100	[thread overview]
Message-ID: <4053214f-bbb2-b6ad-37e9-4a579792a4b3@amd.com> (raw)
In-Reply-To: <1d1a4278-5aee-20d5-b536-7ca199e85e93@intel.com>

Am 07.01.22 um 16:49 schrieb Matthew Auld:
> On 26/12/2021 22:24, Arunpravin wrote:
>> Move the base i915 buddy allocator code into drm
>> - Move i915_buddy.h to include/drm
>> - Move i915_buddy.c to drm root folder
>> - Rename "i915" string with "drm" string wherever applicable
>> - Rename "I915" string with "DRM" string wherever applicable
>> - Fix header file dependencies
>> - Fix alignment issues
>> - add Makefile support for drm buddy
>> - export functions and write kerneldoc description
>> - Remove i915 selftest config check condition as buddy selftest
>>    will be moved to drm selftest folder
>>
>> cleanup i915 buddy references in i915 driver module
>> and replace with drm buddy
>>
>> v2:
>>    - include header file in alphabetical order(Thomas)
>>    - merged changes listed in the body section into a single patch
>>      to keep the build intact(Christian, Jani)
>>
>> v3:
>>    - make drm buddy a separate module(Thomas, Christian)
>>
>> v4:
>>    - Fix build error reported by kernel test robot <lkp@intel.com>
>>    - removed i915 buddy selftest from i915_mock_selftests.h to
>>      avoid build error
>>    - removed selftests/i915_buddy.c file as we create a new set of
>>      buddy test cases in drm/selftests folder
>>
>> v5:
>>    - Fix merge conflict issue
>>
>> Signed-off-by: Arunpravin <Arunpravin.PaneerSelvam@amd.com>
>
> <snip>
>
>> +int drm_buddy_init(struct drm_buddy_mm *mm, u64 size, u64 chunk_size)
>> +{
>> +    unsigned int i;
>> +    u64 offset;
>> +
>> +    if (size < chunk_size)
>> +        return -EINVAL;
>> +
>> +    if (chunk_size < PAGE_SIZE)
>> +        return -EINVAL;
>> +
>> +    if (!is_power_of_2(chunk_size))
>> +        return -EINVAL;
>> +
>> +    size = round_down(size, chunk_size);
>> +
>> +    mm->size = size;
>> +    mm->avail = size;
>> +    mm->chunk_size = chunk_size;
>> +    mm->max_order = ilog2(size) - ilog2(chunk_size);
>> +
>> +    BUG_ON(mm->max_order > DRM_BUDDY_MAX_ORDER);
>> +
>> +    mm->slab_blocks = KMEM_CACHE(drm_buddy_block, 0);
>> +    if (!mm->slab_blocks)
>> +        return -ENOMEM;
>
> It looks like every KMEM_CACHE() also creates a debugfs entry? See the 
> error here[1]. I guess because we end with multiple instances in i915. 
> If so, is it possible to have a single KMEM_CACHE() as part of the 
> buddy module, similar to what i915 was doing previously?

Oh, that is a really good point, this code here doesn't make to much sense.

The value of a KMEM_CACHE() is to allow speeding up allocation of the 
same structure size between different drm_buddy object. If you allocate 
one cache per drm_buddy that makes the whole functionality useless.

Please fix, this is actually a bug.

Christian.

>
> [1] 
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fintel-gfx-ci.01.org%2Ftree%2Fdrm-tip%2FTrybot_8217%2Fshard-skl4%2Figt%40i915_selftest%40mock%40memory_region.html&amp;data=04%7C01%7Cchristian.koenig%40amd.com%7C56202fbe886f415c3b8308d9d1f5409c%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637771673545453215%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=ZnRmAQo%2BjX414hbqHigL4R18oBDKLIugUQIVcwhFI%2BY%3D&amp;reserved=0


WARNING: multiple messages have this Message-ID (diff)
From: "Christian König" <christian.koenig@amd.com>
To: Matthew Auld <matthew.auld@intel.com>,
	Arunpravin <Arunpravin.PaneerSelvam@amd.com>,
	dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org,
	amd-gfx@lists.freedesktop.org
Cc: alexander.deucher@amd.com, tzimmermann@suse.de
Subject: Re: [Intel-gfx] [PATCH v6 1/6] drm: move the buddy allocator from i915 into common drm
Date: Fri, 7 Jan 2022 16:57:48 +0100	[thread overview]
Message-ID: <4053214f-bbb2-b6ad-37e9-4a579792a4b3@amd.com> (raw)
In-Reply-To: <1d1a4278-5aee-20d5-b536-7ca199e85e93@intel.com>

Am 07.01.22 um 16:49 schrieb Matthew Auld:
> On 26/12/2021 22:24, Arunpravin wrote:
>> Move the base i915 buddy allocator code into drm
>> - Move i915_buddy.h to include/drm
>> - Move i915_buddy.c to drm root folder
>> - Rename "i915" string with "drm" string wherever applicable
>> - Rename "I915" string with "DRM" string wherever applicable
>> - Fix header file dependencies
>> - Fix alignment issues
>> - add Makefile support for drm buddy
>> - export functions and write kerneldoc description
>> - Remove i915 selftest config check condition as buddy selftest
>>    will be moved to drm selftest folder
>>
>> cleanup i915 buddy references in i915 driver module
>> and replace with drm buddy
>>
>> v2:
>>    - include header file in alphabetical order(Thomas)
>>    - merged changes listed in the body section into a single patch
>>      to keep the build intact(Christian, Jani)
>>
>> v3:
>>    - make drm buddy a separate module(Thomas, Christian)
>>
>> v4:
>>    - Fix build error reported by kernel test robot <lkp@intel.com>
>>    - removed i915 buddy selftest from i915_mock_selftests.h to
>>      avoid build error
>>    - removed selftests/i915_buddy.c file as we create a new set of
>>      buddy test cases in drm/selftests folder
>>
>> v5:
>>    - Fix merge conflict issue
>>
>> Signed-off-by: Arunpravin <Arunpravin.PaneerSelvam@amd.com>
>
> <snip>
>
>> +int drm_buddy_init(struct drm_buddy_mm *mm, u64 size, u64 chunk_size)
>> +{
>> +    unsigned int i;
>> +    u64 offset;
>> +
>> +    if (size < chunk_size)
>> +        return -EINVAL;
>> +
>> +    if (chunk_size < PAGE_SIZE)
>> +        return -EINVAL;
>> +
>> +    if (!is_power_of_2(chunk_size))
>> +        return -EINVAL;
>> +
>> +    size = round_down(size, chunk_size);
>> +
>> +    mm->size = size;
>> +    mm->avail = size;
>> +    mm->chunk_size = chunk_size;
>> +    mm->max_order = ilog2(size) - ilog2(chunk_size);
>> +
>> +    BUG_ON(mm->max_order > DRM_BUDDY_MAX_ORDER);
>> +
>> +    mm->slab_blocks = KMEM_CACHE(drm_buddy_block, 0);
>> +    if (!mm->slab_blocks)
>> +        return -ENOMEM;
>
> It looks like every KMEM_CACHE() also creates a debugfs entry? See the 
> error here[1]. I guess because we end with multiple instances in i915. 
> If so, is it possible to have a single KMEM_CACHE() as part of the 
> buddy module, similar to what i915 was doing previously?

Oh, that is a really good point, this code here doesn't make to much sense.

The value of a KMEM_CACHE() is to allow speeding up allocation of the 
same structure size between different drm_buddy object. If you allocate 
one cache per drm_buddy that makes the whole functionality useless.

Please fix, this is actually a bug.

Christian.

>
> [1] 
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fintel-gfx-ci.01.org%2Ftree%2Fdrm-tip%2FTrybot_8217%2Fshard-skl4%2Figt%40i915_selftest%40mock%40memory_region.html&amp;data=04%7C01%7Cchristian.koenig%40amd.com%7C56202fbe886f415c3b8308d9d1f5409c%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637771673545453215%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=ZnRmAQo%2BjX414hbqHigL4R18oBDKLIugUQIVcwhFI%2BY%3D&amp;reserved=0


WARNING: multiple messages have this Message-ID (diff)
From: "Christian König" <christian.koenig@amd.com>
To: Matthew Auld <matthew.auld@intel.com>,
	Arunpravin <Arunpravin.PaneerSelvam@amd.com>,
	dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org,
	amd-gfx@lists.freedesktop.org
Cc: alexander.deucher@amd.com, jani.nikula@linux.intel.com,
	tzimmermann@suse.de, daniel@ffwll.ch
Subject: Re: [PATCH v6 1/6] drm: move the buddy allocator from i915 into common drm
Date: Fri, 7 Jan 2022 16:57:48 +0100	[thread overview]
Message-ID: <4053214f-bbb2-b6ad-37e9-4a579792a4b3@amd.com> (raw)
In-Reply-To: <1d1a4278-5aee-20d5-b536-7ca199e85e93@intel.com>

Am 07.01.22 um 16:49 schrieb Matthew Auld:
> On 26/12/2021 22:24, Arunpravin wrote:
>> Move the base i915 buddy allocator code into drm
>> - Move i915_buddy.h to include/drm
>> - Move i915_buddy.c to drm root folder
>> - Rename "i915" string with "drm" string wherever applicable
>> - Rename "I915" string with "DRM" string wherever applicable
>> - Fix header file dependencies
>> - Fix alignment issues
>> - add Makefile support for drm buddy
>> - export functions and write kerneldoc description
>> - Remove i915 selftest config check condition as buddy selftest
>>    will be moved to drm selftest folder
>>
>> cleanup i915 buddy references in i915 driver module
>> and replace with drm buddy
>>
>> v2:
>>    - include header file in alphabetical order(Thomas)
>>    - merged changes listed in the body section into a single patch
>>      to keep the build intact(Christian, Jani)
>>
>> v3:
>>    - make drm buddy a separate module(Thomas, Christian)
>>
>> v4:
>>    - Fix build error reported by kernel test robot <lkp@intel.com>
>>    - removed i915 buddy selftest from i915_mock_selftests.h to
>>      avoid build error
>>    - removed selftests/i915_buddy.c file as we create a new set of
>>      buddy test cases in drm/selftests folder
>>
>> v5:
>>    - Fix merge conflict issue
>>
>> Signed-off-by: Arunpravin <Arunpravin.PaneerSelvam@amd.com>
>
> <snip>
>
>> +int drm_buddy_init(struct drm_buddy_mm *mm, u64 size, u64 chunk_size)
>> +{
>> +    unsigned int i;
>> +    u64 offset;
>> +
>> +    if (size < chunk_size)
>> +        return -EINVAL;
>> +
>> +    if (chunk_size < PAGE_SIZE)
>> +        return -EINVAL;
>> +
>> +    if (!is_power_of_2(chunk_size))
>> +        return -EINVAL;
>> +
>> +    size = round_down(size, chunk_size);
>> +
>> +    mm->size = size;
>> +    mm->avail = size;
>> +    mm->chunk_size = chunk_size;
>> +    mm->max_order = ilog2(size) - ilog2(chunk_size);
>> +
>> +    BUG_ON(mm->max_order > DRM_BUDDY_MAX_ORDER);
>> +
>> +    mm->slab_blocks = KMEM_CACHE(drm_buddy_block, 0);
>> +    if (!mm->slab_blocks)
>> +        return -ENOMEM;
>
> It looks like every KMEM_CACHE() also creates a debugfs entry? See the 
> error here[1]. I guess because we end with multiple instances in i915. 
> If so, is it possible to have a single KMEM_CACHE() as part of the 
> buddy module, similar to what i915 was doing previously?

Oh, that is a really good point, this code here doesn't make to much sense.

The value of a KMEM_CACHE() is to allow speeding up allocation of the 
same structure size between different drm_buddy object. If you allocate 
one cache per drm_buddy that makes the whole functionality useless.

Please fix, this is actually a bug.

Christian.

>
> [1] 
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fintel-gfx-ci.01.org%2Ftree%2Fdrm-tip%2FTrybot_8217%2Fshard-skl4%2Figt%40i915_selftest%40mock%40memory_region.html&amp;data=04%7C01%7Cchristian.koenig%40amd.com%7C56202fbe886f415c3b8308d9d1f5409c%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637771673545453215%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=ZnRmAQo%2BjX414hbqHigL4R18oBDKLIugUQIVcwhFI%2BY%3D&amp;reserved=0


  reply	other threads:[~2022-01-07 15:58 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-26 22:24 [PATCH v6 1/6] drm: move the buddy allocator from i915 into common drm Arunpravin
2021-12-26 22:24 ` Arunpravin
2021-12-26 22:24 ` [Intel-gfx] " Arunpravin
2021-12-26 22:24 ` [PATCH v6 2/6] drm: improve drm_buddy_alloc function Arunpravin
2021-12-26 22:24   ` Arunpravin
2021-12-26 22:24   ` [Intel-gfx] " Arunpravin
2022-01-04 14:01   ` Matthew Auld
2022-01-04 14:01     ` Matthew Auld
2022-01-04 14:01     ` [Intel-gfx] " Matthew Auld
     [not found]     ` <MN2PR12MB4342A3191114E4D3F2824441E44C9@MN2PR12MB4342.namprd12.prod.outlook.com>
2022-01-06 21:23       ` Arunpravin
2022-01-06 21:23         ` Arunpravin
2022-01-06 21:23         ` [Intel-gfx] " Arunpravin
2021-12-26 22:24 ` [PATCH v6 3/6] drm: implement top-down allocation method Arunpravin
2021-12-26 22:24   ` [Intel-gfx] " Arunpravin
2021-12-26 22:24   ` Arunpravin
2021-12-26 22:24 ` [PATCH v6 4/6] drm: implement a method to free unused pages Arunpravin
2021-12-26 22:24   ` [Intel-gfx] " Arunpravin
2021-12-26 22:24   ` Arunpravin
2022-01-04 14:11   ` Matthew Auld
2022-01-04 14:11     ` Matthew Auld
2022-01-04 14:11     ` [Intel-gfx] " Matthew Auld
2022-01-06 17:51     ` Arunpravin
2022-01-06 17:51       ` Arunpravin
2022-01-06 17:51       ` [Intel-gfx] " Arunpravin
2021-12-26 22:24 ` [PATCH v6 5/6] drm/amdgpu: move vram inline functions into a header Arunpravin
2021-12-26 22:24   ` Arunpravin
2021-12-26 22:24   ` [Intel-gfx] " Arunpravin
2021-12-26 22:24 ` [PATCH v6 6/6] drm/amdgpu: add drm buddy support to amdgpu Arunpravin
2021-12-26 22:24   ` Arunpravin
2021-12-26 22:24   ` [Intel-gfx] " Arunpravin
2021-12-26 22:42 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for series starting with [v6,1/6] drm: move the buddy allocator from i915 into common drm Patchwork
2021-12-26 22:45 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2021-12-26 23:15 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2021-12-27  0:38 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
2022-01-07 15:49 ` [PATCH v6 1/6] " Matthew Auld
2022-01-07 15:49   ` Matthew Auld
2022-01-07 15:49   ` [Intel-gfx] " Matthew Auld
2022-01-07 15:57   ` Christian König [this message]
2022-01-07 15:57     ` Christian König
2022-01-07 15:57     ` [Intel-gfx] " Christian König
2022-01-09 10:22     ` Arunpravin
2022-01-09 10:22       ` Arunpravin
2022-01-09 10:22       ` [Intel-gfx] " Arunpravin

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=4053214f-bbb2-b6ad-37e9-4a579792a4b3@amd.com \
    --to=christian.koenig@amd.com \
    --cc=Arunpravin.PaneerSelvam@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=matthew.auld@intel.com \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

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

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.