drm/amdgpu: optimize VRAM allocation when using drm buddy
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): DM4PR12MB526136D00F81419EEFCE47579DA29@DM4PR12MB5261.namprd12.prod.outlook.com
A message that is not in the archive (sent off-list or not yet received): [email protected]
For public review
Quoted 23 lines
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, February 15, 2023 3:02 AM
To: Xiao, Shane <[email protected]>; Paneer Selvam, Arunpravin <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: optimize VRAM allocation when using drm buddyAm 14.02.23 um 15:53 schrieb Xiao, Shane:
Quoted 14 lines
Quoted 14 lines
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Tuesday, February 14, 2023 8:41 PM
To: Xiao, Shane <[email protected]>;brahma_sw_dev<[email protected]>
Cc: Paneer Selvam, Arunpravin <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: optimize VRAM allocation when using drm buddyAm 14.02.23 um 12:18 schrieb Shane Xiao:
Quoted 4 lines
Since the VRAM manager changed from drm mm to drm buddy. It's not necessary to allocate 2MB aligned VRAM for more than 2MB unaligned size, and then do trim. This method improves the allocation efficiency and reduces memory fragmentation.
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
Well that is a trade off.
Allocating the BO as one contiguous chunk and then trimming is beneficial because if we then later need it contiguous we don't need to re-allocate and copy. This can be needed to display something for
example.
Hi Christian,
This case means that you allocate BO that is unnecessary to be continuous at first time, and latter the BO should be continuous. I'm not familiar with display. Could you give me a few more specific examples ?
Quoted 10 lines
Quoted 2 lines
Yes, I agree that one contiguous chunk may get beneficial sometimes. But as far as I know, you cannot guarantee that
amdgpu_vram_mgr_newcan get one contiguous chunk if you don't set
TTM_PL_FLAG_CONTIGUOUSflags.Quoted 1 line
For example, if you want to allocate 4M+4K BO, it will allocate one 4M block
+ one 2M block which is unnecessary to be continuous, then 2M block will be trimmed.
Oh, that's indeed not something which should happen. Sounds more like a bug fix then.
Yes, I think this case should not be happened.
Actually, I'm not sure that why the allocated BO should be aligned with pages_per_block, which is set to 2MB by default. Does this help improve performance when allocating 2M or above BO?
From my point of view, the TLB may be one of reason of this. But I'm not sure about this.
Best Regards,
Shane
Quoted 48 lines
Quoted 8 lines
Quoted 6 lines
On the other hand I completely agree allocating big and then trimming creates more fragmentation than necessary.
Do you have some test case which can show the difference?
I have use rocrtst to show the difference.
The attachment is shown that after applying this patch, the order < 9 totalvram size decrease from 99MB to 43MB.
Quoted 1 line
And the latter has more higher order block memory.
Arun can you take a look? That problem here sounds important.
Thanks,
Christian.Quoted 32 lines
Quoted 4 lines
BTW: No need to discuss that on the internal mailing list, please use the public one instead.
I will send it to public. Thank you for your remind.
Best Regards,
ShaneQuoted 23 lines
Regards,
Christian.drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c static int amdgpu_vram_mgr_new(struct
Quoted 11 lines
Signed-off-by Shane Xiao <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +0
-0@@ -453,7 +453,7 @@ static int amdgpu_vram_mgr_new(struct
ttm_resource_manager*man,drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c static int amdgpu_vram_mgr_new(struct · line 457
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +1
-1/* Limit maximum size to 2GiB due to SG table limitations */ size =min (remaining_size,2ULL <<30 ); -if (size >= (u64 )pages_per_block <<PAGE_SHIFT ) +if (!(size % ((u64 )pages_per_block <<PAGE_SHIFT ))) min_block_size = (u64)pages_per_block <<
PAGE_SHIFT;Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +0
-0cur_size = size;
Am 15.02.23 um 03:51 schrieb Xiao, Shane:
Quoted 29 lines
For public review
Quoted 28 lines
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, February 15, 2023 3:02 AM
To: Xiao, Shane <[email protected]>; Paneer Selvam, Arunpravin <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: optimize VRAM allocation when using drm buddyAm 14.02.23 um 15:53 schrieb Xiao, Shane:
Quoted 19 lines
Quoted 19 lines
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Tuesday, February 14, 2023 8:41 PM
To: Xiao, Shane <[email protected]>;brahma_sw_dev<[email protected]>
Cc: Paneer Selvam, Arunpravin <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: optimize VRAM allocation when using drm buddyAm 14.02.23 um 12:18 schrieb Shane Xiao:
Quoted 4 lines
Since the VRAM manager changed from drm mm to drm buddy. It's not necessary to allocate 2MB aligned VRAM for more than 2MB unaligned size, and then do trim. This method improves the allocation efficiency and reduces memory fragmentation.
Well that is a trade off.
Allocating the BO as one contiguous chunk and then trimming is beneficial because if we then later need it contiguous we don't need to re-allocate and copy. This can be needed to display something for
Quoted 6 lines
Quoted 1 line
example.
Hi Christian,
This case means that you allocate BO that is unnecessary to be continuous at first time, and latter the BO should be continuous. I'm not familiar with display. Could you give me a few more specific examples ?
On most generations DCE/DCN hardware needs the buffer contiguous to be able to scanout from it.
Only newer APUs can use S/G to scanout from system memory pages.
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Yes, I agree that one contiguous chunk may get beneficial sometimes. But as far as I know, you cannot guarantee that
amdgpu_vram_mgr_newcan get one contiguous chunk if you don't set
TTM_PL_FLAG_CONTIGUOUSflags.Quoted 1 line
For example, if you want to allocate 4M+4K BO, it will allocate one 4M block
+ one 2M block which is unnecessary to be continuous, then 2M block will be trimmed.
Quoted 6 lines
Quoted 2 lines
Oh, that's indeed not something which should happen. Sounds more like a bug fix then.
Yes, I think this case should not be happened.
Actually, I'm not sure that why the allocated BO should be aligned withpages_per_block, which is set to 2MB by default. Does this help improve performance when allocating 2M or above BO?
From my point of view, the TLB may be one of reason of this. But I'm not sure about this.
Yes, we try to use allocations which are as contiguous as much as possible for better TLB usage.
Especially for some compute use cases this can make a >20% performance difference.
Regards,
Christian.
Quoted 48 lines
Best Regards,
ShaneQuoted 44 lines
Quoted 6 lines
Quoted 4 lines
On the other hand I completely agree allocating big and then trimming creates more fragmentation than necessary.
Do you have some test case which can show the difference?
I have use rocrtst to show the difference.
The attachment is shown that after applying this patch, the order < 9 totalvram size decrease from 99MB to 43MB.
Quoted 1 line
And the latter has more higher order block memory.
Arun can you take a look? That problem here sounds important.
Thanks,
Christian.Quoted 31 lines
Quoted 3 lines
BTW: No need to discuss that on the internal mailing list, please use the public one instead.
I will send it to public. Thank you for your remind.
Best Regards,
ShaneQuoted 23 lines
Regards,
Christian.drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c static int amdgpu_vram_mgr_new(struct
Quoted 11 lines
Signed-off-by Shane Xiao <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +0
-0@@ -453,7 +453,7 @@ static int amdgpu_vram_mgr_new(struct
ttm_resource_manager*man,drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c static int amdgpu_vram_mgr_new(struct · line 457
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +1
-1/* Limit maximum size to 2GiB due to SG table limitations */ size =min (remaining_size,2ULL <<30 ); -if (size >= (u64 )pages_per_block <<PAGE_SHIFT ) +if (!(size % ((u64 )pages_per_block <<PAGE_SHIFT ))) min_block_size = (u64)pages_per_block <<
PAGE_SHIFT;Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +0
-0cur_size = size;
Am 2023-02-15 um 05:44 schrieb Christian König:
Quoted 52 lines
Am 15.02.23 um 03:51 schrieb Xiao, Shane:
Quoted 29 lines
For public review
Quoted 28 lines
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, February 15, 2023 3:02 AM
To: Xiao, Shane <[email protected]>; Paneer Selvam, Arunpravin <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: optimize VRAM allocation when using drm buddyAm 14.02.23 um 15:53 schrieb Xiao, Shane:
Quoted 19 lines
Quoted 19 lines
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Tuesday, February 14, 2023 8:41 PM
To: Xiao, Shane <[email protected]>;brahma_sw_dev<[email protected]>
Cc: Paneer Selvam, Arunpravin <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: optimize VRAM allocation when using drm buddyAm 14.02.23 um 12:18 schrieb Shane Xiao:
Quoted 4 lines
Since the VRAM manager changed from drm mm to drm buddy. It's not necessary to allocate 2MB aligned VRAM for more than 2MB unaligned size, and then do trim. This method improves the allocation efficiency and reduces memory fragmentation.
Well that is a trade off.
Allocating the BO as one contiguous chunk and then trimming is beneficial because if we then later need it contiguous we don't need to re-allocate and copy. This can be needed to display something for
Quoted 6 lines
Quoted 1 line
example.
Hi Christian,
This case means that you allocate BO that is unnecessary to be continuous at first time, and latter the BO should be continuous. I'm not familiar with display. Could you give me a few more specific examples ?
On most generations DCE/DCN hardware needs the buffer contiguous to be able to scanout from it.
Only newer APUs can use S/G to scanout from system memory pages.
Quoted 11 lines
Quoted 11 lines
Quoted 2 lines
Yes, I agree that one contiguous chunk may get beneficial sometimes. But as far as I know, you cannot guarantee that
amdgpu_vram_mgr_newcan get one contiguous chunk if you don't set
TTM_PL_FLAG_CONTIGUOUSflags.Quoted 1 line
For example, if you want to allocate 4M+4K BO, it will allocate one 4M block
+ one 2M block which is unnecessary to be continuous, then 2M block will be
trimmed.Oh, that's indeed not something which should happen. Sounds more like a bug fix then.
Quoted 8 lines
Quoted 4 lines
Yes, I think this case should not be happened.
Actually, I'm not sure that why the allocated BO should be aligned withpages_per_block, which is set to 2MB by default. Does this help improve performance when allocating 2M or above BO?
From my point of view, the TLB may be one of reason of this. But I'm not sure about this.Yes, we try to use allocations which are as contiguous as much as possible for better TLB usage.
Especially for some compute use cases this can make a >20% performance difference.
We actually found that >2MB virtual address alignment was hurting performance due to cache line aliasing. So we can't take advantage of >2MB pages in our page tables.
Regards,
Felix
Quoted 53 lines
Regards,
Christian.Quoted 48 lines
Best Regards,
ShaneQuoted 44 lines
Quoted 6 lines
Quoted 4 lines
On the other hand I completely agree allocating big and then trimming creates more fragmentation than necessary.
Do you have some test case which can show the difference?
I have use rocrtst to show the difference.
The attachment is shown that after applying this patch, the order < 9 totalvram size decrease from 99MB to 43MB.
Quoted 1 line
And the latter has more higher order block memory.
Arun can you take a look? That problem here sounds important.
Thanks,
Christian.Quoted 31 lines
Quoted 3 lines
BTW: No need to discuss that on the internal mailing list, please use the public one instead.
I will send it to public. Thank you for your remind.
Best Regards,
ShaneQuoted 23 lines
Regards,
Christian.drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c static int amdgpu_vram_mgr_new(struct
Quoted 11 lines
Signed-off-by Shane Xiao <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +0
-0@@ -453,7 +453,7 @@ static int amdgpu_vram_mgr_new(struct
ttm_resource_manager*man,Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +1
-1/* Limit maximum size to 2GiB due to SG table limitations */ size = min(remaining_size, 2ULL << 30); - if (size >= (u64)pages_per_block << PAGE_SHIFT) + if (!(size % ((u64)pages_per_block << PAGE_SHIFT)))
min_block_size= (u64)pages_per_block <<
PAGE_SHIFT;Quoted 1 line
cur_size= size;
Quoted 85 lines
-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Thursday, February 16, 2023 6:19 AM
To: Christian König <[email protected]>; Xiao, Shane <[email protected]>; Koenig, Christian <[email protected]>; Paneer Selvam, Arunpravin <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH 1/2] drm/amdgpu: optimize VRAM allocation when using drm buddyAm 2023-02-15 um 05:44 schrieb Christian König:
Quoted 17 lines
Am 15.02.23 um 03:51 schrieb Xiao, Shane:
Quoted 16 lines
For public review
Quoted 15 lines
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, February 15, 2023 3:02 AM
To: Xiao, Shane <[email protected]>; Paneer Selvam, Arunpravin <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: optimize VRAM allocation when using drm buddyAm 14.02.23 um 15:53 schrieb Xiao, Shane:
Quoted 6 lines
Quoted 6 lines
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Tuesday, February 14, 2023 8:41 PM
To: Xiao, Shane <[email protected]>;brahma_sw_dev<[email protected]>
Cc: Paneer Selvam, ArunpravinQuoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Subject: Re: [PATCH 1/2] drm/amdgpu: optimize VRAM allocation
when
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
using drm buddy
Am 14.02.23 um 12:18 schrieb Shane Xiao:
Quoted 1 line
Since the VRAM manager changed from drm mm to drm buddy. It's
not
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 9 lines
Quoted 3 lines
necessary to allocate 2MB aligned VRAM for more than 2MB unaligned size, and then do trim. This method improves the allocation efficiency and reduces memory fragmentation.
Well that is a trade off.
Allocating the BO as one contiguous chunk and then trimming is beneficial because if we then later need it contiguous we don't need to re-allocate and copy. This can be needed to display something for
example.
Quoted 8 lines
Quoted 6 lines
Hi Christian,
This case means that you allocate BO that is unnecessary to be continuous at first time, and latter the BO should be continuous. I'm not familiar with display. Could you give me a few more specific examples ?
On most generations DCE/DCN hardware needs the buffer contiguous to
be
Quoted 6 lines
able to scanout from it.
Only newer APUs can use S/G to scanout from system memory pages.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Yes, I agree that one contiguous chunk may get beneficial sometimes. But as far as I know, you cannot guarantee that
amdgpu_vram_mgr_newQuoted 20 lines
Quoted 8 lines
Quoted 8 lines
can get one contiguous chunk if you don't set
TTM_PL_FLAG_CONTIGUOUSflags.Quoted 2 lines
For example, if you want to allocate 4M+4K BO, it will allocate one 4M block
+ one 2M block which is unnecessary to be continuous, then 2M block will be
trimmed.Quoted 8 lines
Quoted 2 lines
Oh, that's indeed not something which should happen. Sounds more like a bug fix then.
Yes, I think this case should not be happened.
Actually, I'm not sure that why the allocated BO should be aligned withpages_per_block, which is set to 2MB by default.
Does this help improve performance when allocating 2M or above BO? From my point of view, the TLB may be one of reason of this. But I'm not sure about this.Yes, we try to use allocations which are as contiguous as much as possible for better TLB usage.
Quoted 8 lines
Quoted 2 lines
Especially for some compute use cases this can make a >20% performance difference.
We actually found that >2MB virtual address alignment was hurting performance due to cache line aliasing. So we can't take advantage of >2MB pages in our page tables.
Regards,
Felix
Yes, if we want to take advantage of 2M TLB usage, we should keep virtual address aligned.
As you have mentioned that cache line aliasing issue, I'm confused about this.
If 2MB aligned VA get the right PA from TLB or page table and the cache line addressing mode is not changed, the cache line aliasing issue should not happen here.
Is there something wrong with my understanding? Or maybe there are some backgrounds that I didn't know.
Best Regards,
Shane
Quoted 57 lines
Quoted 57 lines
Regards,
Christian.Quoted 50 lines
Best Regards,
ShaneQuoted 46 lines
Quoted 7 lines
Quoted 4 lines
On the other hand I completely agree allocating big and then trimming creates more fragmentation than necessary.
Do you have some test case which can show the difference?
I have use rocrtst to show the difference.
The attachment is shown that after applying this patch, the order < 9 totalvram size decrease from 99MB to 43MB.
Quoted 1 line
And the latter has more higher order block memory.
Arun can you take a look? That problem here sounds important.
Thanks,
Christian.Quoted 32 lines
Quoted 3 lines
BTW: No need to discuss that on the internal mailing list, please use the public one instead.
I will send it to public. Thank you for your remind.
Best Regards,
ShaneQuoted 24 lines
Regards,
Christian.drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c static int amdgpu_vram_mgr_new(struct
Quoted 11 lines
Signed-off-by Shane Xiao <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +0
-0@@ -453,7 +453,7 @@ static int amdgpu_vram_mgr_new(struct
ttm_resource_manager*man,Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +0
-0/* Limit maximum size to 2GiB due to SG tablelimitations */
size =min(remaining_size, 2ULL << 30);- if (size >= (u64)pages_per_block <<
PAGE_SHIFT) + if (!(size % ((u64)pages_per_block <<PAGE_SHIFT)))min_block_size= (u64)pages_per_block <<
PAGE_SHIFT;Quoted 1 line
cur_size= size;
Am 16.02.23 um 07:48 schrieb Xiao, Shane:
Quoted 87 lines
Quoted 87 lines
-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Thursday, February 16, 2023 6:19 AM
To: Christian König <[email protected]>; Xiao, Shane <[email protected]>; Koenig, Christian <[email protected]>; Paneer Selvam, Arunpravin <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH 1/2] drm/amdgpu: optimize VRAM allocation when using drm buddyAm 2023-02-15 um 05:44 schrieb Christian König:
Quoted 17 lines
Am 15.02.23 um 03:51 schrieb Xiao, Shane:
Quoted 16 lines
For public review
Quoted 15 lines
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, February 15, 2023 3:02 AM
To: Xiao, Shane <[email protected]>; Paneer Selvam, Arunpravin <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: optimize VRAM allocation when using drm buddyAm 14.02.23 um 15:53 schrieb Xiao, Shane:
Quoted 6 lines
Quoted 6 lines
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Tuesday, February 14, 2023 8:41 PM
To: Xiao, Shane <[email protected]>;brahma_sw_dev<[email protected]>
Cc: Paneer Selvam, ArunpravinQuoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Subject: Re: [PATCH 1/2] drm/amdgpu: optimize VRAM allocation
when
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
using drm buddy
Am 14.02.23 um 12:18 schrieb Shane Xiao:
Quoted 1 line
Since the VRAM manager changed from drm mm to drm buddy. It's
not
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 3 lines
necessary to allocate 2MB aligned VRAM for more than 2MB unaligned size, and then do trim. This method improves the allocation efficiency and reduces memory fragmentation.
Well that is a trade off.
Allocating the BO as one contiguous chunk and then trimming is beneficial because if we then later need it contiguous we don't need to re-allocate and copy. This can be needed to display something for
Quoted 8 lines
Quoted 7 lines
Quoted 1 line
example.
Hi Christian,
This case means that you allocate BO that is unnecessary to be continuous at first time, and latter the BO should be continuous. I'm not familiar with display. Could you give me a few more specific examples ?
On most generations DCE/DCN hardware needs the buffer contiguous to
be
Quoted 6 lines
able to scanout from it.
Only newer APUs can use S/G to scanout from system memory pages.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Yes, I agree that one contiguous chunk may get beneficial sometimes. But as far as I know, you cannot guarantee that
amdgpu_vram_mgr_newQuoted 16 lines
Quoted 8 lines
Quoted 8 lines
can get one contiguous chunk if you don't set
TTM_PL_FLAG_CONTIGUOUSflags.Quoted 2 lines
For example, if you want to allocate 4M+4K BO, it will allocate one 4M block
+ one 2M block which is unnecessary to be continuous, then 2M block will be
trimmed.Quoted 8 lines
Quoted 2 lines
Oh, that's indeed not something which should happen. Sounds more like a bug fix then.
Yes, I think this case should not be happened.
Actually, I'm not sure that why the allocated BO should be aligned withpages_per_block, which is set to 2MB by default.
Does this help improve performance when allocating 2M or above BO?
From my point of view, the TLB may be one of reason of this. But I'm
not sure about this.Quoted 5 lines
Yes, we try to use allocations which are as contiguous as much as possible for better TLB usage.
Especially for some compute use cases this can make a >20% performance difference.
We actually found that >2MB virtual address alignment was hurting performance due to cache line aliasing. So we can't take advantage of >2MB pages in our page tables.
Quoted 8 lines
Quoted 2 lines
Regards,
FelixYes, if we want to take advantage of 2M TLB usage, we should keep virtual address aligned.
As you have mentioned that cache line aliasing issue, I'm confused about this.
If 2MB aligned VA get the right PA from TLB or page table and the cache line addressing mode is not changed, the cache line aliasing issue should not happen here.
Is there something wrong with my understanding? Or maybe there are some backgrounds that I didn't know.
The problem is with virtual address alignments > 2MiB (or whatever the big cache line size is).
Let's assume an example where you have a lot of buffer each 66MiB in size. When you align those to 2MiB in the virtual address space you end up with
64MiB..2MiB..62MiB..4MiB..60MiB... etc...
In your address space. In this configuration each 2MiB cache line is equally used.
But if you align the buffers to say the next power of two (128MiB) you end up like this:
64MiB..2MiB..62MiB hole..64MiB..2MiB..62MiB hole... etc....
In this case the first 2MiB cache line of each buffer is used twice as much as all the other cache lines. This can hurt performance very badly.
Regards,
Christian.
Quoted 56 lines
Best Regards,
ShaneQuoted 53 lines
Quoted 53 lines
Regards,
Christian.Quoted 49 lines
Best Regards,
ShaneQuoted 46 lines
Quoted 7 lines
Quoted 4 lines
On the other hand I completely agree allocating big and then trimming creates more fragmentation than necessary.
Do you have some test case which can show the difference?
I have use rocrtst to show the difference.
The attachment is shown that after applying this patch, the order < 9 totalvram size decrease from 99MB to 43MB.
Quoted 1 line
And the latter has more higher order block memory.
Arun can you take a look? That problem here sounds important.
Thanks,
Christian.Quoted 32 lines
Quoted 3 lines
BTW: No need to discuss that on the internal mailing list, please use the public one instead.
I will send it to public. Thank you for your remind.
Best Regards,
ShaneQuoted 24 lines
Regards,
Christian.drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c static int amdgpu_vram_mgr_new(struct
Quoted 11 lines
Signed-off-by Shane Xiao <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +0
-0@@ -453,7 +453,7 @@ static int amdgpu_vram_mgr_new(struct
ttm_resource_manager*man,Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +0
-0/* Limit maximum size to 2GiB due to SG tablelimitations */
size =min(remaining_size, 2ULL << 30);- if (size >= (u64)pages_per_block <<
PAGE_SHIFT) + if (!(size % ((u64)pages_per_block <<PAGE_SHIFT)))
min_block_size= (u64)pages_per_block <<
PAGE_SHIFT;Quoted 1 line
cur_size= size;
Arunpravin Paneer Selvam
Reviewed-byThis patch seems to pass the rocm memory stress test case.
Quoted 170 lines · Christian König
Am 16.02.23 um 07:48 schrieb Xiao, Shane:
Quoted 87 lines
Quoted 87 lines
-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Thursday, February 16, 2023 6:19 AM
To: Christian König <[email protected]>; Xiao, Shane <[email protected]>; Koenig, Christian <[email protected]>; Paneer Selvam, Arunpravin <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH 1/2] drm/amdgpu: optimize VRAM allocation when using drm buddyAm 2023-02-15 um 05:44 schrieb Christian König:
Quoted 17 lines
Am 15.02.23 um 03:51 schrieb Xiao, Shane:
Quoted 16 lines
For public review
Quoted 15 lines
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, February 15, 2023 3:02 AM
To: Xiao, Shane <[email protected]>; Paneer Selvam, Arunpravin <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: optimize VRAM allocation when using drm buddyAm 14.02.23 um 15:53 schrieb Xiao, Shane:
Quoted 6 lines
Quoted 6 lines
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Tuesday, February 14, 2023 8:41 PM
To: Xiao, Shane <[email protected]>;brahma_sw_dev<[email protected]>
Cc: Paneer Selvam, ArunpravinQuoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Subject: Re: [PATCH 1/2] drm/amdgpu: optimize VRAM allocation
when
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
using drm buddy
Am 14.02.23 um 12:18 schrieb Shane Xiao:
Quoted 1 line
Since the VRAM manager changed from drm mm to drm buddy. It's
not
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 3 lines
necessary to allocate 2MB aligned VRAM for more than 2MB unaligned size, and then do trim. This method improves the allocation efficiency and reduces memory fragmentation.
Well that is a trade off.
Allocating the BO as one contiguous chunk and then trimming is beneficial because if we then later need it contiguous we don't need to re-allocate and copy. This can be needed to display something for
Quoted 8 lines
Quoted 7 lines
Quoted 1 line
example.
Hi Christian,
This case means that you allocate BO that is unnecessary to be continuous at first time, and latter the BO should be continuous. I'm not familiar with display. Could you give me a few more specific examples ?
On most generations DCE/DCN hardware needs the buffer contiguous to
be
Quoted 6 lines
able to scanout from it.
Only newer APUs can use S/G to scanout from system memory pages.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Yes, I agree that one contiguous chunk may get beneficial sometimes. But as far as I know, you cannot guarantee that
amdgpu_vram_mgr_newQuoted 16 lines
Quoted 8 lines
Quoted 8 lines
can get one contiguous chunk if you don't set
TTM_PL_FLAG_CONTIGUOUSflags.Quoted 2 lines
For example, if you want to allocate 4M+4K BO, it will allocate one 4M block
+ one 2M block which is unnecessary to be continuous, then 2M block will be
trimmed.Quoted 8 lines
Quoted 2 lines
Oh, that's indeed not something which should happen. Sounds more like a bug fix then.
Yes, I think this case should not be happened.
Actually, I'm not sure that why the allocated BO should be aligned withpages_per_block, which is set to 2MB by default.
Does this help improve performance when allocating 2M or above BO? From my point of view, the TLB may be one of reason of this. But I'm not sure about this.Quoted 5 lines
Yes, we try to use allocations which are as contiguous as much as possible for better TLB usage.
Especially for some compute use cases this can make a >20% performance difference.
We actually found that >2MB virtual address alignment was hurting performance due to cache line aliasing. So we can't take advantage of >2MB pages in our page tables.
Quoted 8 lines
Quoted 2 lines
Regards,
FelixYes, if we want to take advantage of 2M TLB usage, we should keep virtual address aligned.
As you have mentioned that cache line aliasing issue, I'm confused about this.
If 2MB aligned VA get the right PA from TLB or page table and the cache line addressing mode is not changed, the cache line aliasing issue should not happen here.
Is there something wrong with my understanding? Or maybe there are some backgrounds that I didn't know.The problem is with virtual address alignments > 2MiB (or whatever the big cache line size is).
Let's assume an example where you have a lot of buffer each 66MiB in size. When you align those to 2MiB in the virtual address space you end up with
64MiB..2MiB..62MiB..4MiB..60MiB... etc...
In your address space. In this configuration each 2MiB cache line is equally used.
But if you align the buffers to say the next power of two (128MiB) you end up like this:
64MiB..2MiB..62MiB hole..64MiB..2MiB..62MiB hole... etc....
In this case the first 2MiB cache line of each buffer is used twice as much as all the other cache lines. This can hurt performance very badly.
Regards,
Christian.Quoted 55 lines
Best Regards,
ShaneQuoted 53 lines
Quoted 53 lines
Regards,
Christian.Quoted 49 lines
Best Regards,
ShaneQuoted 46 lines
Quoted 7 lines
Quoted 4 lines
On the other hand I completely agree allocating big and then trimming creates more fragmentation than necessary.
Do you have some test case which can show the difference?
I have use rocrtst to show the difference.
The attachment is shown that after applying this patch, the order < 9 totalvram size decrease from 99MB to 43MB.
Quoted 1 line
And the latter has more higher order block memory.
Arun can you take a look? That problem here sounds important.
Thanks,
Christian.Quoted 32 lines
Quoted 3 lines
BTW: No need to discuss that on the internal mailing list, please use the public one instead.
I will send it to public. Thank you for your remind.
Best Regards,
ShaneQuoted 24 lines
Regards,
Christian.drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c static int amdgpu_vram_mgr_new(struct
Quoted 11 lines
Signed-off-by Shane Xiao <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +0
-0@@ -453,7 +453,7 @@ static int amdgpu_vram_mgr_new(struct
ttm_resource_manager*man,Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +0
-0/* Limit maximum size to 2GiB due to SG tablelimitations */
size =min(remaining_size, 2ULL << 30);- if (size >= (u64)pages_per_block <<
PAGE_SHIFT) + if (!(size % ((u64)pages_per_block <<PAGE_SHIFT)))min_block_size= (u64)pages_per_block <<
PAGE_SHIFT;Quoted 1 line
cur_size= size;
Quoted 12 lines
-----Original Message-----
From: Paneer Selvam, Arunpravin <[email protected]>
Sent: Thursday, February 16, 2023 3:24 PM
To: Koenig, Christian <[email protected]>; Xiao, Shane <[email protected]>; Kuehling, Felix <[email protected]>; Christian König <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH 1/2] drm/amdgpu: optimize VRAM allocation when using drm buddy
Quoted 3 lines
This patch seems to pass the rocm memory stress test case.
Reviewed-by: Arunpravin Paneer Selvam <[email protected]>
Hi Christian,
Do you think we should upstream this patch?
Best Regards,
Shane
Quoted 189 lines · Christian König
Quoted 6 lines
Am 16.02.23 um 07:48 schrieb Xiao, Shane:
Quoted 5 lines
Quoted 5 lines
-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Thursday, February 16, 2023 6:19 AM
To: Christian König <[email protected]>; Xiao, Shane <[email protected]>; Koenig, ChristianQuoted 6 lines
Quoted 6 lines
Quoted 6 lines
Paneer Selvam, Arunpravin <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH 1/2] drm/amdgpu: optimize VRAM allocation when using drm buddyQuoted 7 lines
Quoted 7 lines
Quoted 7 lines
Am 2023-02-15 um 05:44 schrieb Christian König:
Quoted 6 lines
Am 15.02.23 um 03:51 schrieb Xiao, Shane:
Quoted 5 lines
For public review
Quoted 4 lines
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, February 15, 2023 3:02 AM
To: Xiao, Shane <[email protected]>; Paneer Selvam,Arunpravin
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
<[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: optimize VRAM allocation when using drm buddyAm 14.02.23 um 15:53 schrieb Xiao, Shane:
Quoted 6 lines
Quoted 6 lines
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Tuesday, February 14, 2023 8:41 PM
To: Xiao, Shane <[email protected]>;brahma_sw_dev<[email protected]>
Cc: Paneer Selvam, ArunpravinQuoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Subject: Re: [PATCH 1/2] drm/amdgpu: optimize VRAM allocation
when
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
using drm buddy
Am 14.02.23 um 12:18 schrieb Shane Xiao:
Quoted 1 line
Since the VRAM manager changed from drm mm to drm buddy.
It's
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
not
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 3 lines
necessary to allocate 2MB aligned VRAM for more than 2MB unaligned size, and then do trim. This method improves the allocation efficiency and reduces memory fragmentation.
Well that is a trade off.
Allocating the BO as one contiguous chunk and then trimming is beneficial because if we then later need it contiguous we don't need to re-allocate and copy. This can be needed to display something for
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 1 line
example.
Hi Christian,
This case means that you allocate BO that is unnecessary to be continuous at first time, and latter the BO should be continuous. I'm not familiar with display. Could you give me a few more specific examples ?
On most generations DCE/DCN hardware needs the buffer contiguous
to
Quoted 128 lines
Quoted 40 lines
Quoted 29 lines
be
Quoted 7 lines
able to scanout from it.
Only newer APUs can use S/G to scanout from system memory pages.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Yes, I agree that one contiguous chunk may get beneficial sometimes.
But as far as I know, you cannot guarantee that
amdgpu_vram_mgr_newQuoted 20 lines
Quoted 9 lines
Quoted 9 lines
can get one contiguous chunk if you don't set
TTM_PL_FLAG_CONTIGUOUSflags.Quoted 2 lines
For example, if you want to allocate 4M+4K BO, it will allocate one 4M block
+ one 2M block which is unnecessary to be continuous, then 2M
+ block
will be
trimmed.Quoted 8 lines
Quoted 2 lines
Oh, that's indeed not something which should happen. Sounds more like a bug fix then.
Yes, I think this case should not be happened. Actually, I'm not sure that why the allocated BO should be aligned with
pages_per_block, which is set to 2MB by default. Does this help improve performance when allocating 2M or above BO? From my point of view, the TLB may be one of reason of this. But I'm not sure about this.Yes, we try to use allocations which are as contiguous as much as possible for better TLB usage.
Quoted 8 lines
Quoted 2 lines
Especially for some compute use cases this can make a >20% performance difference.
We actually found that >2MB virtual address alignment was hurting performance due to cache line aliasing. So we can't take advantage of >2MB pages in our page tables.
Regards,
FelixYes, if we want to take advantage of 2M TLB usage, we should keep virtual address aligned.
Quoted 7 lines
As you have mentioned that cache line aliasing issue, I'm confused about this.
If 2MB aligned VA get the right PA from TLB or page table and the cache line addressing mode is not changed, the cache line aliasing issue should not happen here.
Is there something wrong with my understanding? Or maybe there are some backgrounds that I didn't know.The problem is with virtual address alignments > 2MiB (or whatever the big cache line size is).
Let's assume an example where you have a lot of buffer each 66MiB in size. When you align those to 2MiB in the virtual address space you end up with
64MiB..2MiB..62MiB..4MiB..60MiB... etc...
In your address space. In this configuration each 2MiB cache line is equally used.
But if you align the buffers to say the next power of two (128MiB) you end up like this:
64MiB..2MiB..62MiB hole..64MiB..2MiB..62MiB hole... etc....
In this case the first 2MiB cache line of each buffer is used twice as much as all the other cache lines. This can hurt performance very badly.
Regards,
Christian.Quoted 56 lines
Best Regards,
ShaneQuoted 54 lines
Quoted 54 lines
Regards,
Christian.Quoted 50 lines
Best Regards,
ShaneQuoted 47 lines
Quoted 8 lines
Quoted 4 lines
On the other hand I completely agree allocating big and then trimming creates more fragmentation than necessary.
Do you have some test case which can show the difference?
I have use rocrtst to show the difference.
The attachment is shown that after applying this patch, the order <
9 totalvram size decrease from 99MB to 43MB.
Quoted 1 line
And the latter has more higher order block memory.
Arun can you take a look? That problem here sounds important.
Thanks,
Christian.Quoted 32 lines
Quoted 3 lines
BTW: No need to discuss that on the internal mailing list, please use the public one instead.
I will send it to public. Thank you for your remind.
Best Regards,
ShaneQuoted 24 lines
Regards,
Christian.drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c static int amdgpu_vram_mgr_new(struct
Quoted 11 lines
Signed-off-by Shane Xiao <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +0
-0@@ -453,7 +453,7 @@ static int amdgpu_vram_mgr_new(struct
ttm_resource_manager*man,Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +0
-0/* Limit maximum size to 2GiB due to SG tablelimitations */
size =min(remaining_size, 2ULL << 30);- if (size >= (u64)pages_per_block <<
PAGE_SHIFT) + if (!(size % ((u64)pages_per_block <<PAGE_SHIFT)))min_block_size= (u64)pages_per_block <<
PAGE_SHIFT;Quoted 1 line
cur_size= size;
Am 17.02.23 um 04:11 schrieb Xiao, Shane:
Quoted 11 lines
Quoted 11 lines
-----Original Message-----
From: Paneer Selvam, Arunpravin <[email protected]>
Sent: Thursday, February 16, 2023 3:24 PM
To: Koenig, Christian <[email protected]>; Xiao, Shane <[email protected]>; Kuehling, Felix <[email protected]>; Christian König <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH 1/2] drm/amdgpu: optimize VRAM allocation when using drm buddy
Quoted 6 lines
Quoted 3 lines
This patch seems to pass the rocm memory stress test case.
Reviewed-by: Arunpravin Paneer Selvam <[email protected]>Hi Christian,
Do you think we should upstream this patch?
Arun already gave his rb for this, I only see one option for further improvements and that is to avoid the "% pages_per_block".
I think pages_per_block is a power of two (but you need to double check this), so you can use something like "& (pages_per_block - 1)" instead which should have less overhead.
But that's only a minimal optimization. Either way feel free to push this to amd-staging-drm-next with Arun's rb added.
Regards,
Christian.
Quoted 190 lines
Best Regards,
ShaneQuoted 185 lines · Christian König
Quoted 6 lines
Am 16.02.23 um 07:48 schrieb Xiao, Shane:
Quoted 5 lines
Quoted 5 lines
-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Thursday, February 16, 2023 6:19 AM
To: Christian König <[email protected]>; Xiao, Shane <[email protected]>; Koenig, ChristianQuoted 6 lines
Quoted 6 lines
Quoted 6 lines
Paneer Selvam, Arunpravin <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH 1/2] drm/amdgpu: optimize VRAM allocation when using drm buddyQuoted 7 lines
Quoted 7 lines
Quoted 7 lines
Am 2023-02-15 um 05:44 schrieb Christian König:
Quoted 6 lines
Am 15.02.23 um 03:51 schrieb Xiao, Shane:
Quoted 5 lines
For public review
Quoted 4 lines
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, February 15, 2023 3:02 AM
To: Xiao, Shane <[email protected]>; Paneer Selvam,Arunpravin
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
<[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: optimize VRAM allocation when using drm buddyAm 14.02.23 um 15:53 schrieb Xiao, Shane:
Quoted 6 lines
Quoted 6 lines
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Tuesday, February 14, 2023 8:41 PM
To: Xiao, Shane <[email protected]>;brahma_sw_dev<[email protected]>
Cc: Paneer Selvam, ArunpravinQuoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Subject: Re: [PATCH 1/2] drm/amdgpu: optimize VRAM allocation
when
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
using drm buddy
Am 14.02.23 um 12:18 schrieb Shane Xiao:
Quoted 1 line
Since the VRAM manager changed from drm mm to drm buddy.
It's
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
not
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 3 lines
necessary to allocate 2MB aligned VRAM for more than 2MB unaligned size, and then do trim. This method improves the allocation efficiency and reduces memory fragmentation.
Well that is a trade off.
Allocating the BO as one contiguous chunk and then trimming is beneficial because if we then later need it contiguous we don't need to re-allocate and copy. This can be needed to display something for
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 1 line
example.
Hi Christian,
This case means that you allocate BO that is unnecessary to be continuous at first time, and latter the BO should be continuous. I'm not familiar with display. Could you give me a few more specific examples ?
On most generations DCE/DCN hardware needs the buffer contiguous
to
Quoted 125 lines
Quoted 40 lines
Quoted 29 lines
be
Quoted 7 lines
able to scanout from it.
Only newer APUs can use S/G to scanout from system memory pages.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Yes, I agree that one contiguous chunk may get beneficial sometimes.
But as far as I know, you cannot guarantee that
amdgpu_vram_mgr_newQuoted 20 lines
Quoted 9 lines
Quoted 9 lines
can get one contiguous chunk if you don't set
TTM_PL_FLAG_CONTIGUOUSflags.Quoted 2 lines
For example, if you want to allocate 4M+4K BO, it will allocate one 4M block
+ one 2M block which is unnecessary to be continuous, then 2M
+ block
will be
trimmed.Quoted 8 lines
Quoted 2 lines
Oh, that's indeed not something which should happen. Sounds more like a bug fix then.
Yes, I think this case should not be happened.
Actually, I'm not sure that why the allocated BO should be aligned withpages_per_block, which is set to 2MB by default. Does this help improve performance when allocating 2M or above BO?
From my point of view, the TLB may be one of reason of this. But
I'm not sure about this.Yes, we try to use allocations which are as contiguous as much as possible for better TLB usage.
Quoted 8 lines
Quoted 2 lines
Especially for some compute use cases this can make a >20% performance difference.
We actually found that >2MB virtual address alignment was hurting performance due to cache line aliasing. So we can't take advantage of >2MB pages in our page tables.
Regards,
FelixYes, if we want to take advantage of 2M TLB usage, we should keep virtual address aligned.
Quoted 7 lines
As you have mentioned that cache line aliasing issue, I'm confused about this.
If 2MB aligned VA get the right PA from TLB or page table and the cache line addressing mode is not changed, the cache line aliasing issue should not happen here.
Is there something wrong with my understanding? Or maybe there are some backgrounds that I didn't know.The problem is with virtual address alignments > 2MiB (or whatever the big cache line size is).
Let's assume an example where you have a lot of buffer each 66MiB in size. When you align those to 2MiB in the virtual address space you end up with
64MiB..2MiB..62MiB..4MiB..60MiB... etc...
In your address space. In this configuration each 2MiB cache line is equally used.
But if you align the buffers to say the next power of two (128MiB) you end up like this:
64MiB..2MiB..62MiB hole..64MiB..2MiB..62MiB hole... etc....
In this case the first 2MiB cache line of each buffer is used twice as much as all the other cache lines. This can hurt performance very badly.
Regards,
Christian.Quoted 55 lines
Best Regards,
ShaneQuoted 53 lines
Quoted 53 lines
Regards,
Christian.Quoted 50 lines
Best Regards,
ShaneQuoted 47 lines
Quoted 8 lines
Quoted 4 lines
On the other hand I completely agree allocating big and then trimming creates more fragmentation than necessary.
Do you have some test case which can show the difference?
I have use rocrtst to show the difference.
The attachment is shown that after applying this patch, the order <
9 totalvram size decrease from 99MB to 43MB.
Quoted 1 line
And the latter has more higher order block memory.
Arun can you take a look? That problem here sounds important.
Thanks,
Christian.Quoted 32 lines
Quoted 3 lines
BTW: No need to discuss that on the internal mailing list, please use the public one instead.
I will send it to public. Thank you for your remind.
Best Regards,
ShaneQuoted 24 lines
Regards,
Christian.drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c static int amdgpu_vram_mgr_new(struct
Quoted 11 lines
Signed-off-by Shane Xiao <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +0
-0@@ -453,7 +453,7 @@ static int amdgpu_vram_mgr_new(struct
ttm_resource_manager*man,Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +0
-0/* Limit maximum size to 2GiB due to SG tablelimitations */
size =min(remaining_size, 2ULL << 30);- if (size >= (u64)pages_per_block <<
PAGE_SHIFT) + if (!(size % ((u64)pages_per_block <<PAGE_SHIFT)))
min_block_size= (u64)pages_per_block <<
PAGE_SHIFT;Quoted 1 line
cur_size= size;