drm/amdgpu: add direct ib pool
Am 26.03.2020 07:45 schrieb "Pan, Xinhui" <[email protected]>:
Quoted 15 lines
2020年3月26日 14:36,Koenig, Christian <[email protected]> 写道:
Am 26.03.2020 07:15 schrieb "Pan, Xinhui" <[email protected]>:
Quoted 7 lines
2020年3月26日 13:38,Koenig, Christian <[email protected]> 写道:
Yeah that's on my TODO list for quite a while as well.
But we even need three IB pools. One very small for the IB tests, one for direct VM updates and one for the rest.
So please make the pool a parameter to
ib_get()and not the hack you have below.
Quoted 7 lines
yep, I will make IB pool a parameter.
IB tests for gfx need many IBs,
PAGE_SIZEfor ib pool is still not enough. but the default size for ib pool is 2MB now, just one hugepage, today we have memory in TB. so no need make a different size for IB tests pool.2MB is probably a bit much and we don't have huge page optimisation for kernel allocations at the moment anyway. Keep in mind that we have only limited space in the GART.
gart table is just 512MB.
do you mean every entry in gart table just points to one 4KB page? and need 5 gart table entries for one 2M hugepage?
Yes, we need 512 * 4KB entries for a 2MB page in GART. The table for the system VM is flat because of hardware restrictions.
IIRC we tried 256MB for the GART initially and in general we try to keep that as small as possible because it eats up visible VRAM space.
Christian.
Quoted 121 lines
Maybe make this 4*PAGE_SIZE for the new IB pool for now and test if that works or not.
Christian.
Quoted 113 lines
Thanks,
Christian.Am 26.03.2020 03:02 schrieb "Pan, Xinhui" <[email protected]>:
Another ib poll for direct submit.
Any jobs schedule IBs without dependence on gpu scheduler should use this pool firstly.Signed-off-by xinhui pan <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 12 ++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 8 +++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_job.h | 3 ++- 5 files changed, 21 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -849,6 +849,7 @@ struct amdgpu_device {struct amdgpu_ring *rings[AMDGPU_MAX_RINGS ];bool ib_pool_ready;struct amdgpu_sa_manager ring_tmp_bo; +struct amdgpu_sa_manager ring_tmp_bo_direct;/* interrupts */ struct amdgpu_irq irq;drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1
-1@@ -920,7 +920,7 @@ static int amdgpu_cs_ib_fill(struct amdgpu_device *adev, parser->entity = entity; ring =to_amdgpu_ring (entity->rq->sched); - r =amdgpu_ib_get (adev, vm, ring->funcs->parse_cs ? + r =amdgpu_ib_get (adev, (unsigned long )vm|0x1 , ring->funcs->parse_cs ? chunk_ib->ib_bytes :0 , ib);if (r) {DRM_ERROR ("Failed to get ib !\n" );drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +10
-2@@ -66,7 +66,7 @@ int amdgpu_ib_get(struct amdgpu_device *adev, struct amdgpu_vm *vm,int r;if (size) { - r =amdgpu_sa_bo_new (&adev->ring_tmp_bo, + r =amdgpu_sa_bo_new (vm ? &adev->ring_tmp_bo : &adev->ring_tmp_bo_direct, &ib->sa_bo, size,256 );if (r) {dev_err (adev->dev,"failed to get a new IB (%d)\n" , r);@@ -75,7 +75,7 @@ int amdgpu_ib_get(struct amdgpu_device *adev, struct amdgpu_vm *vm, ib->ptr =amdgpu_sa_bo_cpu_addr (ib->sa_bo); -if (!vm) +if (!((unsigned long )vm & ~0x1 )) ib->gpu_addr =amdgpu_sa_bo_gpu_addr (ib->sa_bo); }@@ -310,6 +310,13 @@ int amdgpu_ib_pool_init(struct amdgpu_device *adev)return r; } + r =amdgpu_sa_bo_manager_init (adev, &adev->ring_tmp_bo_direct, +AMDGPU_IB_POOL_SIZE *64 *1024 , +AMDGPU_GPU_PAGE_SIZE , +AMDGPU_GEM_DOMAIN_GTT ); +if (r) { +return r; + } adev->ib_pool_ready = true;return 0 ;@@ -327,6 +334,7 @@ void amdgpu_ib_pool_fini(struct amdgpu_device *adev) {if (adev->ib_pool_ready) {amdgpu_sa_bo_manager_fini (adev, &adev->ring_tmp_bo); +amdgpu_sa_bo_manager_fini (adev, &adev->ring_tmp_bo_direct); adev->ib_pool_ready = false; } }drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +7
-1@@ -88,6 +88,12 @@ int amdgpu_job_alloc(struct amdgpu_device *adev, unsigned num_ibs,int amdgpu_job_alloc_with_ib (struct amdgpu_device *adev,unsigned size,struct amdgpu_job **job) +{ +return amdgpu_job_alloc_with_ib_direct (adev, size, job,0 ); +} + +int amdgpu_job_alloc_with_ib_direct (struct amdgpu_device *adev,unsigned size, +struct amdgpu_job **job,int direct) {int r;@@ -95,7 +101,7 @@ int amdgpu_job_alloc_with_ib(struct amdgpu_device *adev, unsigned size,if (r)return r; - r =amdgpu_ib_get (adev,NULL , size, &(*job)->ibs[0 ]); + r =amdgpu_ib_get (adev, direct ?NULL :0x1 , size, &(*job)->ibs[0 ]);if (r)kfree (*job);
Quoted 18 lines
Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_job.h +2
-2@@ -67,7 +67,8 @@ int amdgpu_job_alloc(struct amdgpu_device *adev, unsigned num_ibs, struct amdgpu_job **job, struct amdgpu_vm *vm);int amdgpu_job_alloc_with_ib (struct amdgpu_device *adev,unsigned size,struct amdgpu_job **job); - +int amdgpu_job_alloc_with_ib_direct (struct amdgpu_device *adev,unsigned size, +struct amdgpu_job **job,int direct);void amdgpu_job_free_resources (struct amdgpu_job *job);void amdgpu_job_free (struct amdgpu_job *job); int amdgpu_job_submit(struct amdgpu_job *job, struct drm_sched_entity *entity, --Quoted 1 line
2.17.1
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 30 lines
2020年3月26日 14:51,Koenig, Christian <[email protected]> 写道:
Am 26.03.2020 07:45 schrieb "Pan, Xinhui" <[email protected]>:
Quoted 21 lines
2020年3月26日 14:36,Koenig, Christian <[email protected]> 写道:
Am 26.03.2020 07:15 schrieb "Pan, Xinhui" <[email protected]>:
Quoted 7 lines
2020年3月26日 13:38,Koenig, Christian <[email protected]> 写道:
Yeah that's on my TODO list for quite a while as well.
But we even need three IB pools. One very small for the IB tests, one for direct VM updates and one for the rest.
So please make the pool a parameter to
ib_get()and not the hack you have below.yep, I will make IB pool a parameter.
IB tests for gfx need many IBs,
PAGE_SIZEfor ib pool is still not enough. but the default size for ib pool is 2MB now, just one hugepage, today we have memory in TB. so no need make a different size for IB tests pool.
Quoted 6 lines
Quoted 1 line
2MB is probably a bit much and we don't have huge page optimisation for kernel allocations at the moment anyway. Keep in mind that we have only limited space in the GART.
gart table is just 512MB.
do you mean every entry in gart table just points to one 4KB page? and need 5 gart table entries for one 2M hugepage?Yes, we need 512 * 4KB entries for a 2MB page in GART. The table for the system VM is flat because of hardware restrictions.
oh yes, 512 entries.
Quoted 1 line
IIRC we tried 256MB for the GART initially and in general we try to keep that as small as possible because it eats up visible VRAM space.
that is true. but our roadmap tells that we are a linux ML team.
I can not imagine that customers use small pci bar servers. well, they care the cost. but I prefer they using new products. :)
anyway, I will chosse a smallest workable default vaule for now.
Quoted 145 lines
Christian.
Quoted 139 lines
Maybe make this 4*PAGE_SIZE for the new IB pool for now and test if that works or not.
Christian.
Quoted 129 lines
Thanks,
Christian.Am 26.03.2020 03:02 schrieb "Pan, Xinhui" <[email protected]>:
Another ib poll for direct submit.
Any jobs schedule IBs without dependence on gpu scheduler should use this pool firstly.Signed-off-by xinhui pan <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 12 ++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 8 +++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_job.h | 3 ++- 5 files changed, 21 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -849,6 +849,7 @@ struct amdgpu_device {struct amdgpu_ring *rings[AMDGPU_MAX_RINGS ];bool ib_pool_ready;struct amdgpu_sa_manager ring_tmp_bo; +struct amdgpu_sa_manager ring_tmp_bo_direct;/* interrupts */ struct amdgpu_irq irq;drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1
-1@@ -920,7 +920,7 @@ static int amdgpu_cs_ib_fill(struct amdgpu_device *adev, parser->entity = entity; ring =to_amdgpu_ring (entity->rq->sched); - r =amdgpu_ib_get (adev, vm, ring->funcs->parse_cs ? + r =amdgpu_ib_get (adev, (unsigned long )vm|0x1 , ring->funcs->parse_cs ? chunk_ib->ib_bytes :0 , ib);if (r) {DRM_ERROR ("Failed to get ib !\n" );drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +10
-2@@ -66,7 +66,7 @@ int amdgpu_ib_get(struct amdgpu_device *adev, struct amdgpu_vm *vm,int r;if (size) { - r =amdgpu_sa_bo_new (&adev->ring_tmp_bo, + r =amdgpu_sa_bo_new (vm ? &adev->ring_tmp_bo : &adev->ring_tmp_bo_direct, &ib->sa_bo, size,256 );if (r) {dev_err (adev->dev,"failed to get a new IB (%d)\n" , r);@@ -75,7 +75,7 @@ int amdgpu_ib_get(struct amdgpu_device *adev, struct amdgpu_vm *vm, ib->ptr =amdgpu_sa_bo_cpu_addr (ib->sa_bo); -if (!vm) +if (!((unsigned long )vm & ~0x1 )) ib->gpu_addr =amdgpu_sa_bo_gpu_addr (ib->sa_bo); }@@ -310,6 +310,13 @@ int amdgpu_ib_pool_init(struct amdgpu_device *adev)return r; } + r =amdgpu_sa_bo_manager_init (adev, &adev->ring_tmp_bo_direct, +AMDGPU_IB_POOL_SIZE *64 *1024 , +AMDGPU_GPU_PAGE_SIZE , +AMDGPU_GEM_DOMAIN_GTT ); +if (r) { +return r; + } adev->ib_pool_ready = true;return 0 ;@@ -327,6 +334,7 @@ void amdgpu_ib_pool_fini(struct amdgpu_device *adev) {if (adev->ib_pool_ready) {amdgpu_sa_bo_manager_fini (adev, &adev->ring_tmp_bo); +amdgpu_sa_bo_manager_fini (adev, &adev->ring_tmp_bo_direct); adev->ib_pool_ready = false; } }drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +7
-1@@ -88,6 +88,12 @@ int amdgpu_job_alloc(struct amdgpu_device *adev, unsigned num_ibs,int amdgpu_job_alloc_with_ib (struct amdgpu_device *adev,unsigned size,struct amdgpu_job **job) +{ +return amdgpu_job_alloc_with_ib_direct (adev, size, job,0 ); +} + +int amdgpu_job_alloc_with_ib_direct (struct amdgpu_device *adev,unsigned size, +struct amdgpu_job **job,int direct) {int r;@@ -95,7 +101,7 @@ int amdgpu_job_alloc_with_ib(struct amdgpu_device *adev, unsigned size,if (r)return r; - r =amdgpu_ib_get (adev,NULL , size, &(*job)->ibs[0 ]); + r =amdgpu_ib_get (adev, direct ?NULL :0x1 , size, &(*job)->ibs[0 ]);if (r)kfree (*job);drivers/gpu/drm/amd/amdgpu/amdgpu_job.h +2
-1@@ -67,7 +67,8 @@ int amdgpu_job_alloc(struct amdgpu_device *adev, unsigned num_ibs, struct amdgpu_job **job, struct amdgpu_vm *vm);int amdgpu_job_alloc_with_ib (struct amdgpu_device *adev,unsigned size,struct amdgpu_job **job); - +int amdgpu_job_alloc_with_ib_direct (struct amdgpu_device *adev,unsigned size, +struct amdgpu_job **job,int direct);void amdgpu_job_free_resources (struct amdgpu_job *job);void amdgpu_job_free (struct amdgpu_job *job); int amdgpu_job_submit(struct amdgpu_job *job, struct drm_sched_entity *entity,Signature · 1 line
2.17.1
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 34 lines · Xinhui
Quoted 28 lines
2020年3月26日 14:51,Koenig, Christian <[email protected]> 写道:
Am 26.03.2020 07:45 schrieb "Pan, Xinhui" <[email protected]>:
Quoted 20 lines
2020年3月26日 14:36,Koenig, Christian <[email protected]> 写道:
Am 26.03.2020 07:15 schrieb "Pan, Xinhui" <[email protected]>:
Quoted 7 lines
2020年3月26日 13:38,Koenig, Christian <[email protected]> 写道:
Yeah that's on my TODO list for quite a while as well.
But we even need three IB pools. One very small for the IB tests, one for direct VM updates and one for the rest.
So please make the pool a parameter to
ib_get()and not the hack you have below.yep, I will make IB pool a parameter.
IB tests for gfx need many IBs,
PAGE_SIZEfor ib pool is still not enough. but the default size for ib pool is 2MB now, just one hugepage, today we have memory in TB. so no need make a different size for IB tests pool.Quoted 6 lines
Quoted 1 line
2MB is probably a bit much and we don't have huge page optimisation for kernel allocations at the moment anyway. Keep in mind that we have only limited space in the GART.
gart table is just 512MB.
do you mean every entry in gart table just points to one 4KB page? and need 5 gart table entries for one 2M hugepage?Yes, we need 512 * 4KB entries for a 2MB page in GART. The table for the system VM is flat because of hardware restrictions.
Quoted 7 lines
oh yes, 512 entries.
Quoted 1 line
IIRC we tried 256MB for the GART initially and in general we try to keep that as small as possible because it eats up visible VRAM space.
that is true. but our roadmap tells that we are a linux ML team.
I can not imagine that customers use small pci bar servers. well, they care the cost. but I prefer they using new products. :)anyway, I will chosse a smallest workable default vaule for now.
For Linux ML we want a small GART size. We used to waste lots of memory for a big GART that was unnecessary and took away valuable memory from ML applications. The GART is only used for kernel mode mappings, most of which tend to be short-lived. Statically allocating a big GART is not necessary.
The IB pools are statically allocated and long-lived. So if we need to increase the GART size to meet that demand, so be it. But we should not waste memory for IBs and associated GART space without a good reason.
Regards,
Felix
Quoted 133 lines
Quoted 133 lines
Christian.
Quoted 129 lines
Maybe make this 4*PAGE_SIZE for the new IB pool for now and test if that works or not.
Christian.
Quoted 122 lines
Thanks,
Christian.Am 26.03.2020 03:02 schrieb "Pan, Xinhui" <[email protected]>:
Another ib poll for direct submit.
Any jobs schedule IBs without dependence on gpu scheduler should use this pool firstly.Signed-off-by xinhui pan <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 12 ++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 8 +++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_job.h | 3 ++- 5 files changed, 21 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -849,6 +849,7 @@ struct amdgpu_device {struct amdgpu_ring *rings[AMDGPU_MAX_RINGS ];bool ib_pool_ready;struct amdgpu_sa_manager ring_tmp_bo; +struct amdgpu_sa_manager ring_tmp_bo_direct;/* interrupts */ struct amdgpu_irq irq;drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1
-1@@ -920,7 +920,7 @@ static int amdgpu_cs_ib_fill(struct amdgpu_device *adev, parser->entity = entity; ring =to_amdgpu_ring (entity->rq->sched); - r =amdgpu_ib_get (adev, vm, ring->funcs->parse_cs ? + r =amdgpu_ib_get (adev, (unsigned long )vm|0x1 , ring->funcs->parse_cs ? chunk_ib->ib_bytes :0 , ib);if (r) {DRM_ERROR ("Failed to get ib !\n" );drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +10
-2@@ -66,7 +66,7 @@ int amdgpu_ib_get(struct amdgpu_device *adev, struct amdgpu_vm *vm,int r;if (size) { - r =amdgpu_sa_bo_new (&adev->ring_tmp_bo, + r =amdgpu_sa_bo_new (vm ? &adev->ring_tmp_bo : &adev->ring_tmp_bo_direct, &ib->sa_bo, size,256 );if (r) {dev_err (adev->dev,"failed to get a new IB (%d)\n" , r);@@ -75,7 +75,7 @@ int amdgpu_ib_get(struct amdgpu_device *adev, struct amdgpu_vm *vm, ib->ptr =amdgpu_sa_bo_cpu_addr (ib->sa_bo); -if (!vm) +if (!((unsigned long )vm & ~0x1 )) ib->gpu_addr =amdgpu_sa_bo_gpu_addr (ib->sa_bo); }@@ -310,6 +310,13 @@ int amdgpu_ib_pool_init(struct amdgpu_device *adev)return r; } + r =amdgpu_sa_bo_manager_init (adev, &adev->ring_tmp_bo_direct, +AMDGPU_IB_POOL_SIZE *64 *1024 , +AMDGPU_GPU_PAGE_SIZE , +AMDGPU_GEM_DOMAIN_GTT ); +if (r) { +return r; + } adev->ib_pool_ready = true;return 0 ;@@ -327,6 +334,7 @@ void amdgpu_ib_pool_fini(struct amdgpu_device *adev) {if (adev->ib_pool_ready) {amdgpu_sa_bo_manager_fini (adev, &adev->ring_tmp_bo); +amdgpu_sa_bo_manager_fini (adev, &adev->ring_tmp_bo_direct); adev->ib_pool_ready = false; } }drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +7
-1@@ -88,6 +88,12 @@ int amdgpu_job_alloc(struct amdgpu_device *adev, unsigned num_ibs,int amdgpu_job_alloc_with_ib (struct amdgpu_device *adev,unsigned size,struct amdgpu_job **job) +{ +return amdgpu_job_alloc_with_ib_direct (adev, size, job,0 ); +} + +int amdgpu_job_alloc_with_ib_direct (struct amdgpu_device *adev,unsigned size, +struct amdgpu_job **job,int direct) {int r;@@ -95,7 +101,7 @@ int amdgpu_job_alloc_with_ib(struct amdgpu_device *adev, unsigned size,if (r)return r; - r =amdgpu_ib_get (adev,NULL , size, &(*job)->ibs[0 ]); + r =amdgpu_ib_get (adev, direct ?NULL :0x1 , size, &(*job)->ibs[0 ]);if (r)kfree (*job);drivers/gpu/drm/amd/amdgpu/amdgpu_job.h +1
-1@@ -67,7 +67,8 @@ int amdgpu_job_alloc(struct amdgpu_device *adev, unsigned num_ibs, struct amdgpu_job **job, struct amdgpu_vm *vm);int amdgpu_job_alloc_with_ib (struct amdgpu_device *adev,unsigned size,struct amdgpu_job **job); - +int amdgpu_job_alloc_with_ib_direct(struct amdgpu_device *adev, unsigned size,
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_job.h +1
-0+ struct amdgpu_job **job, int direct);void amdgpu_job_free_resources (struct amdgpu_job *job);void amdgpu_job_free (struct amdgpu_job *job); int amdgpu_job_submit(struct amdgpu_job *job, struct drm_sched_entity *entity,Signature · 1 line
2.17.1
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx