* [PATCH V3] amdgpu:optimization-- reduce no need mutex_lock area
@ 2020-04-21 6:48 ` Bernard Zhao
0 siblings, 0 replies; 8+ messages in thread
From: Bernard Zhao @ 2020-04-21 6:48 UTC (permalink / raw)
To: Felix Kuehling, Alex Deucher, Christian König,
David (ChunMing) Zhou, David Airlie, Daniel Vetter, amd-gfx,
dri-devel, linux-kernel
Cc: opensource.kernel, Bernard Zhao
Maybe we could reduce the mutex_lock(&mem->lock)`s protected code area,
and no need to protect pr_debug.
Signed-off-by: Bernard Zhao <bernard@vivo.com>
Changes since V1:
*commit message improve
Changes since V2:
*move comment along with the mutex_unlock
Link for V1:
*https://lore.kernel.org/patchwork/patch/1226588/
Link for V2:
*https://lore.kernel.org/patchwork/patch/1227907/
---
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
index 327317c54f7c..f03d9843d723 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
@@ -1285,21 +1285,21 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
struct bo_vm_reservation_context ctx;
struct ttm_validate_buffer *bo_list_entry;
int ret;
+ unsigned int mapped_to_gpu_memory;
mutex_lock(&mem->lock);
+ mapped_to_gpu_memory = mem->mapped_to_gpu_memory;
+ mutex_unlock(&mem->lock);
+ /* lock is not needed after this, since mem is unused and will
+ * be freed anyway
+ */
- if (mem->mapped_to_gpu_memory > 0) {
+ if (mapped_to_gpu_memory > 0) {
pr_debug("BO VA 0x%llx size 0x%lx is still mapped.\n",
mem->va, bo_size);
- mutex_unlock(&mem->lock);
return -EBUSY;
}
- mutex_unlock(&mem->lock);
- /* lock is not needed after this, since mem is unused and will
- * be freed anyway
- */
-
/* No more MMU notifiers */
amdgpu_mn_unregister(mem->bo);
--
2.26.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH V3] amdgpu:optimization-- reduce no need mutex_lock area
@ 2020-04-21 6:48 ` Bernard Zhao
0 siblings, 0 replies; 8+ messages in thread
From: Bernard Zhao @ 2020-04-21 6:48 UTC (permalink / raw)
To: Felix Kuehling, Alex Deucher, Christian König,
David (ChunMing) Zhou, David Airlie, Daniel Vetter, amd-gfx,
dri-devel, linux-kernel
Cc: opensource.kernel, Bernard Zhao
Maybe we could reduce the mutex_lock(&mem->lock)`s protected code area,
and no need to protect pr_debug.
Signed-off-by: Bernard Zhao <bernard@vivo.com>
Changes since V1:
*commit message improve
Changes since V2:
*move comment along with the mutex_unlock
Link for V1:
*https://lore.kernel.org/patchwork/patch/1226588/
Link for V2:
*https://lore.kernel.org/patchwork/patch/1227907/
---
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
index 327317c54f7c..f03d9843d723 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
@@ -1285,21 +1285,21 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
struct bo_vm_reservation_context ctx;
struct ttm_validate_buffer *bo_list_entry;
int ret;
+ unsigned int mapped_to_gpu_memory;
mutex_lock(&mem->lock);
+ mapped_to_gpu_memory = mem->mapped_to_gpu_memory;
+ mutex_unlock(&mem->lock);
+ /* lock is not needed after this, since mem is unused and will
+ * be freed anyway
+ */
- if (mem->mapped_to_gpu_memory > 0) {
+ if (mapped_to_gpu_memory > 0) {
pr_debug("BO VA 0x%llx size 0x%lx is still mapped.\n",
mem->va, bo_size);
- mutex_unlock(&mem->lock);
return -EBUSY;
}
- mutex_unlock(&mem->lock);
- /* lock is not needed after this, since mem is unused and will
- * be freed anyway
- */
-
/* No more MMU notifiers */
amdgpu_mn_unregister(mem->bo);
--
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] 8+ messages in thread
* [PATCH V3] amdgpu:optimization-- reduce no need mutex_lock area
@ 2020-04-21 6:48 ` Bernard Zhao
0 siblings, 0 replies; 8+ messages in thread
From: Bernard Zhao @ 2020-04-21 6:48 UTC (permalink / raw)
To: Felix Kuehling, Alex Deucher, Christian König,
David (ChunMing) Zhou, David Airlie, Daniel Vetter, amd-gfx,
dri-devel, linux-kernel
Cc: opensource.kernel, Bernard Zhao
Maybe we could reduce the mutex_lock(&mem->lock)`s protected code area,
and no need to protect pr_debug.
Signed-off-by: Bernard Zhao <bernard@vivo.com>
Changes since V1:
*commit message improve
Changes since V2:
*move comment along with the mutex_unlock
Link for V1:
*https://lore.kernel.org/patchwork/patch/1226588/
Link for V2:
*https://lore.kernel.org/patchwork/patch/1227907/
---
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
index 327317c54f7c..f03d9843d723 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
@@ -1285,21 +1285,21 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
struct bo_vm_reservation_context ctx;
struct ttm_validate_buffer *bo_list_entry;
int ret;
+ unsigned int mapped_to_gpu_memory;
mutex_lock(&mem->lock);
+ mapped_to_gpu_memory = mem->mapped_to_gpu_memory;
+ mutex_unlock(&mem->lock);
+ /* lock is not needed after this, since mem is unused and will
+ * be freed anyway
+ */
- if (mem->mapped_to_gpu_memory > 0) {
+ if (mapped_to_gpu_memory > 0) {
pr_debug("BO VA 0x%llx size 0x%lx is still mapped.\n",
mem->va, bo_size);
- mutex_unlock(&mem->lock);
return -EBUSY;
}
- mutex_unlock(&mem->lock);
- /* lock is not needed after this, since mem is unused and will
- * be freed anyway
- */
-
/* No more MMU notifiers */
amdgpu_mn_unregister(mem->bo);
--
2.26.2
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH V3] amdgpu:optimization-- reduce no need mutex_lock area
2020-04-21 6:48 ` Bernard Zhao
@ 2020-04-22 2:27 ` Felix Kuehling
-1 siblings, 0 replies; 8+ messages in thread
From: Felix Kuehling @ 2020-04-22 2:27 UTC (permalink / raw)
To: 1587181464-114215-1-git-send-email-bernard, Alex Deucher,
Christian König, David (ChunMing) Zhou, David Airlie,
Daniel Vetter, amd-gfx, dri-devel, linux-kernel
Cc: opensource.kernel, Bernard Zhao
[-- Attachment #1.1: Type: text/plain, Size: 2965 bytes --]
Thanks again for the patch. I'm going to apply this with some minor
fixes. The headline should start with "drm/amdgpu:". I'll also change
the wording of the headline and commit message:
drm/amdgpu: shrink critical section in
amdgpu_amdkfd_gpuvm_free_memory_of_gpu
Reduce the mem->lock`s protected code area, no need to protect pr_debug.
This also simplifies error handling.
There is one more cosmetic change I'm going to make, see inline. I'll
apply your patch with those updates if you're OK with that.
On 2020-04-21 2:48, Bernard Zhao wrote:
> Maybe we could reduce the mutex_lock(&mem->lock)`s protected code area,
> and no need to protect pr_debug.
>
> Signed-off-by: Bernard Zhao <bernard@vivo.com>
>
> Changes since V1:
> *commit message improve
>
> Changes since V2:
> *move comment along with the mutex_unlock
>
> Link for V1:
> *https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fpatchwork%2Fpatch%2F1226588%2F&data=02%7C01%7CFelix.Kuehling%40amd.com%7Cc715f5d02aae40846b8f08d7e5c001fd%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637230485152789682&sdata=4UdZiWMAbW8eR1BS2%2F6qMvs5K6cHWy5c8I32ReQ4uz0%3D&reserved=0
> Link for V2:
> *https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fpatchwork%2Fpatch%2F1227907%2F&data=02%7C01%7CFelix.Kuehling%40amd.com%7Cc715f5d02aae40846b8f08d7e5c001fd%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637230485152799673&sdata=Wt%2Bk7k4MtSX4zIDgmLEOB6ZKzfuqAd6GJZ3Creqf1aY%3D&reserved=0
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> index 327317c54f7c..f03d9843d723 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> @@ -1285,21 +1285,21 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
> struct bo_vm_reservation_context ctx;
> struct ttm_validate_buffer *bo_list_entry;
> int ret;
> + unsigned int mapped_to_gpu_memory;
I'll move this before the "int ret;" line. It makes the code more
readable if long declarations come before short ones.
Regards,
Felix
>
> mutex_lock(&mem->lock);
> + mapped_to_gpu_memory = mem->mapped_to_gpu_memory;
> + mutex_unlock(&mem->lock);
> + /* lock is not needed after this, since mem is unused and will
> + * be freed anyway
> + */
>
> - if (mem->mapped_to_gpu_memory > 0) {
> + if (mapped_to_gpu_memory > 0) {
> pr_debug("BO VA 0x%llx size 0x%lx is still mapped.\n",
> mem->va, bo_size);
> - mutex_unlock(&mem->lock);
> return -EBUSY;
> }
>
> - mutex_unlock(&mem->lock);
> - /* lock is not needed after this, since mem is unused and will
> - * be freed anyway
> - */
> -
> /* No more MMU notifiers */
> amdgpu_mn_unregister(mem->bo);
>
[-- Attachment #1.2: Type: text/html, Size: 4972 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH V3] amdgpu:optimization-- reduce no need mutex_lock area
@ 2020-04-22 2:27 ` Felix Kuehling
0 siblings, 0 replies; 8+ messages in thread
From: Felix Kuehling @ 2020-04-22 2:27 UTC (permalink / raw)
To: 1587181464-114215-1-git-send-email-bernard, Alex Deucher,
Christian König, David (ChunMing) Zhou, David Airlie,
Daniel Vetter, amd-gfx, dri-devel, linux-kernel
Cc: opensource.kernel, Bernard Zhao
[-- Attachment #1.1: Type: text/plain, Size: 2965 bytes --]
Thanks again for the patch. I'm going to apply this with some minor
fixes. The headline should start with "drm/amdgpu:". I'll also change
the wording of the headline and commit message:
drm/amdgpu: shrink critical section in
amdgpu_amdkfd_gpuvm_free_memory_of_gpu
Reduce the mem->lock`s protected code area, no need to protect pr_debug.
This also simplifies error handling.
There is one more cosmetic change I'm going to make, see inline. I'll
apply your patch with those updates if you're OK with that.
On 2020-04-21 2:48, Bernard Zhao wrote:
> Maybe we could reduce the mutex_lock(&mem->lock)`s protected code area,
> and no need to protect pr_debug.
>
> Signed-off-by: Bernard Zhao <bernard@vivo.com>
>
> Changes since V1:
> *commit message improve
>
> Changes since V2:
> *move comment along with the mutex_unlock
>
> Link for V1:
> *https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fpatchwork%2Fpatch%2F1226588%2F&data=02%7C01%7CFelix.Kuehling%40amd.com%7Cc715f5d02aae40846b8f08d7e5c001fd%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637230485152789682&sdata=4UdZiWMAbW8eR1BS2%2F6qMvs5K6cHWy5c8I32ReQ4uz0%3D&reserved=0
> Link for V2:
> *https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fpatchwork%2Fpatch%2F1227907%2F&data=02%7C01%7CFelix.Kuehling%40amd.com%7Cc715f5d02aae40846b8f08d7e5c001fd%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637230485152799673&sdata=Wt%2Bk7k4MtSX4zIDgmLEOB6ZKzfuqAd6GJZ3Creqf1aY%3D&reserved=0
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> index 327317c54f7c..f03d9843d723 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
> @@ -1285,21 +1285,21 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
> struct bo_vm_reservation_context ctx;
> struct ttm_validate_buffer *bo_list_entry;
> int ret;
> + unsigned int mapped_to_gpu_memory;
I'll move this before the "int ret;" line. It makes the code more
readable if long declarations come before short ones.
Regards,
Felix
>
> mutex_lock(&mem->lock);
> + mapped_to_gpu_memory = mem->mapped_to_gpu_memory;
> + mutex_unlock(&mem->lock);
> + /* lock is not needed after this, since mem is unused and will
> + * be freed anyway
> + */
>
> - if (mem->mapped_to_gpu_memory > 0) {
> + if (mapped_to_gpu_memory > 0) {
> pr_debug("BO VA 0x%llx size 0x%lx is still mapped.\n",
> mem->va, bo_size);
> - mutex_unlock(&mem->lock);
> return -EBUSY;
> }
>
> - mutex_unlock(&mem->lock);
> - /* lock is not needed after this, since mem is unused and will
> - * be freed anyway
> - */
> -
> /* No more MMU notifiers */
> amdgpu_mn_unregister(mem->bo);
>
[-- Attachment #1.2: Type: text/html, Size: 4972 bytes --]
[-- Attachment #2: Type: text/plain, Size: 154 bytes --]
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re:Re: [PATCH V3] amdgpu:optimization-- reduce no need mutex_lock area
2020-04-22 2:27 ` Felix Kuehling
(?)
@ 2020-04-22 2:50 ` 赵军奎
-1 siblings, 0 replies; 8+ messages in thread
From: 赵军奎 @ 2020-04-22 2:50 UTC (permalink / raw)
To: Felix Kuehling
Cc: Alex Deucher, Christian König, David (ChunMing) Zhou,
David Airlie, Daniel Vetter, amd-gfx, dri-devel, linux-kernel,
opensource.kernel
Sure, this seems to be a lot more professional than my previous modification.
My original intention is to make the code easier to read, and I learned a lot from
submitting these patches. Thank you very much for all your guidance!
Regards,
Bernard
发件人:Felix Kuehling <felix.kuehling@amd.com>
发送日期:2020-04-22 10:27:16
收件人:1587181464-114215-1-git-send-email-bernard@vivo.com,Alex Deucher <alexander.deucher@amd.com>,"Christian König" <christian.koenig@amd.com>,"David (ChunMing) Zhou" <David1.Zhou@amd.com>,David Airlie <airlied@linux.ie>,Daniel Vetter <daniel@ffwll.ch>,amd-gfx@lists.freedesktop.org,dri-devel@lists.freedesktop.org,linux-kernel@vger.kernel.org
抄送人:opensource.kernel@vivo.com,Bernard Zhao <bernard@vivo.com>
主题:Re: [PATCH V3] amdgpu:optimization-- reduce no need mutex_lock area
Thanks again for the patch. I'm going
to apply this with some minor fixes. The headline should start
with "drm/amdgpu:". I'll also change the wording of the headline
and commit message:
drm/amdgpu: shrink critical section
in amdgpu_amdkfd_gpuvm_free_memory_of_gpu
Reduce the mem->lock`s protected
code area, no need to protect pr_debug.
This also simplifies error handling.
There is one more cosmetic change I'm
going to make, see inline. I'll apply your patch with those
updates if you're OK with that.
On 2020-04-21 2:48, Bernard Zhao wrote:
Maybe we could reduce the mutex_lock(&mem->lock)`s protected code area,
and no need to protect pr_debug.
Signed-off-by: Bernard Zhao <bernard@vivo.com>
Changes since V1:
*commit message improve
Changes since V2:
*move comment along with the mutex_unlock
Link for V1:
*https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fpatchwork%2Fpatch%2F1226588%2F&data=02%7C01%7CFelix.Kuehling%40amd.com%7Cc715f5d02aae40846b8f08d7e5c001fd%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637230485152789682&sdata=4UdZiWMAbW8eR1BS2%2F6qMvs5K6cHWy5c8I32ReQ4uz0%3D&reserved=0
Link for V2:
*https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fpatchwork%2Fpatch%2F1227907%2F&data=02%7C01%7CFelix.Kuehling%40amd.com%7Cc715f5d02aae40846b8f08d7e5c001fd%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637230485152799673&sdata=Wt%2Bk7k4MtSX4zIDgmLEOB6ZKzfuqAd6GJZ3Creqf1aY%3D&reserved=0
---
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
index 327317c54f7c..f03d9843d723 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
@@ -1285,21 +1285,21 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
struct bo_vm_reservation_context ctx;
struct ttm_validate_buffer *bo_list_entry;
int ret;
+ unsigned int mapped_to_gpu_memory;
I'll move this before the "int ret;" line. It makes the code more
readable if long declarations come before short ones.
Regards,
Felix
mutex_lock(&mem->lock);
+ mapped_to_gpu_memory = mem->mapped_to_gpu_memory;
+ mutex_unlock(&mem->lock);
+ /* lock is not needed after this, since mem is unused and will
+ * be freed anyway
+ */
- if (mem->mapped_to_gpu_memory > 0) {
+ if (mapped_to_gpu_memory > 0) {
pr_debug("BO VA 0x%llx size 0x%lx is still mapped.\n",
mem->va, bo_size);
- mutex_unlock(&mem->lock);
return -EBUSY;
}
- mutex_unlock(&mem->lock);
- /* lock is not needed after this, since mem is unused and will
- * be freed anyway
- */
-
/* No more MMU notifiers */
amdgpu_mn_unregister(mem->bo);
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re:Re: [PATCH V3] amdgpu:optimization-- reduce no need mutex_lock area
@ 2020-04-22 2:50 ` 赵军奎
0 siblings, 0 replies; 8+ messages in thread
From: 赵军奎 @ 2020-04-22 2:50 UTC (permalink / raw)
To: Felix Kuehling
Cc: opensource.kernel, David Airlie, linux-kernel, amd-gfx,
dri-devel, Alex Deucher, Christian König
Sure, this seems to be a lot more professional than my previous modification.
My original intention is to make the code easier to read, and I learned a lot from
submitting these patches. Thank you very much for all your guidance!
Regards,
Bernard
发件人:Felix Kuehling <felix.kuehling@amd.com>
发送日期:2020-04-22 10:27:16
收件人:1587181464-114215-1-git-send-email-bernard@vivo.com,Alex Deucher <alexander.deucher@amd.com>,"Christian König" <christian.koenig@amd.com>,"David (ChunMing) Zhou" <David1.Zhou@amd.com>,David Airlie <airlied@linux.ie>,Daniel Vetter <daniel@ffwll.ch>,amd-gfx@lists.freedesktop.org,dri-devel@lists.freedesktop.org,linux-kernel@vger.kernel.org
抄送人:opensource.kernel@vivo.com,Bernard Zhao <bernard@vivo.com>
主题:Re: [PATCH V3] amdgpu:optimization-- reduce no need mutex_lock area
Thanks again for the patch. I'm going
to apply this with some minor fixes. The headline should start
with "drm/amdgpu:". I'll also change the wording of the headline
and commit message:
drm/amdgpu: shrink critical section
in amdgpu_amdkfd_gpuvm_free_memory_of_gpu
Reduce the mem->lock`s protected
code area, no need to protect pr_debug.
This also simplifies error handling.
There is one more cosmetic change I'm
going to make, see inline. I'll apply your patch with those
updates if you're OK with that.
On 2020-04-21 2:48, Bernard Zhao wrote:
Maybe we could reduce the mutex_lock(&mem->lock)`s protected code area,
and no need to protect pr_debug.
Signed-off-by: Bernard Zhao <bernard@vivo.com>
Changes since V1:
*commit message improve
Changes since V2:
*move comment along with the mutex_unlock
Link for V1:
*https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fpatchwork%2Fpatch%2F1226588%2F&data=02%7C01%7CFelix.Kuehling%40amd.com%7Cc715f5d02aae40846b8f08d7e5c001fd%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637230485152789682&sdata=4UdZiWMAbW8eR1BS2%2F6qMvs5K6cHWy5c8I32ReQ4uz0%3D&reserved=0
Link for V2:
*https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fpatchwork%2Fpatch%2F1227907%2F&data=02%7C01%7CFelix.Kuehling%40amd.com%7Cc715f5d02aae40846b8f08d7e5c001fd%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637230485152799673&sdata=Wt%2Bk7k4MtSX4zIDgmLEOB6ZKzfuqAd6GJZ3Creqf1aY%3D&reserved=0
---
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
index 327317c54f7c..f03d9843d723 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
@@ -1285,21 +1285,21 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
struct bo_vm_reservation_context ctx;
struct ttm_validate_buffer *bo_list_entry;
int ret;
+ unsigned int mapped_to_gpu_memory;
I'll move this before the "int ret;" line. It makes the code more
readable if long declarations come before short ones.
Regards,
Felix
mutex_lock(&mem->lock);
+ mapped_to_gpu_memory = mem->mapped_to_gpu_memory;
+ mutex_unlock(&mem->lock);
+ /* lock is not needed after this, since mem is unused and will
+ * be freed anyway
+ */
- if (mem->mapped_to_gpu_memory > 0) {
+ if (mapped_to_gpu_memory > 0) {
pr_debug("BO VA 0x%llx size 0x%lx is still mapped.\n",
mem->va, bo_size);
- mutex_unlock(&mem->lock);
return -EBUSY;
}
- mutex_unlock(&mem->lock);
- /* lock is not needed after this, since mem is unused and will
- * be freed anyway
- */
-
/* No more MMU notifiers */
amdgpu_mn_unregister(mem->bo);
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re:Re: [PATCH V3] amdgpu:optimization-- reduce no need mutex_lock area
@ 2020-04-22 2:50 ` 赵军奎
0 siblings, 0 replies; 8+ messages in thread
From: 赵军奎 @ 2020-04-22 2:50 UTC (permalink / raw)
To: Felix Kuehling
Cc: David (ChunMing) Zhou, opensource.kernel, David Airlie,
linux-kernel, amd-gfx, dri-devel, Daniel Vetter, Alex Deucher,
Christian König
Sure, this seems to be a lot more professional than my previous modification.
My original intention is to make the code easier to read, and I learned a lot from
submitting these patches. Thank you very much for all your guidance!
Regards,
Bernard
发件人:Felix Kuehling <felix.kuehling@amd.com>
发送日期:2020-04-22 10:27:16
收件人:1587181464-114215-1-git-send-email-bernard@vivo.com,Alex Deucher <alexander.deucher@amd.com>,"Christian König" <christian.koenig@amd.com>,"David (ChunMing) Zhou" <David1.Zhou@amd.com>,David Airlie <airlied@linux.ie>,Daniel Vetter <daniel@ffwll.ch>,amd-gfx@lists.freedesktop.org,dri-devel@lists.freedesktop.org,linux-kernel@vger.kernel.org
抄送人:opensource.kernel@vivo.com,Bernard Zhao <bernard@vivo.com>
主题:Re: [PATCH V3] amdgpu:optimization-- reduce no need mutex_lock area
Thanks again for the patch. I'm going
to apply this with some minor fixes. The headline should start
with "drm/amdgpu:". I'll also change the wording of the headline
and commit message:
drm/amdgpu: shrink critical section
in amdgpu_amdkfd_gpuvm_free_memory_of_gpu
Reduce the mem->lock`s protected
code area, no need to protect pr_debug.
This also simplifies error handling.
There is one more cosmetic change I'm
going to make, see inline. I'll apply your patch with those
updates if you're OK with that.
On 2020-04-21 2:48, Bernard Zhao wrote:
Maybe we could reduce the mutex_lock(&mem->lock)`s protected code area,
and no need to protect pr_debug.
Signed-off-by: Bernard Zhao <bernard@vivo.com>
Changes since V1:
*commit message improve
Changes since V2:
*move comment along with the mutex_unlock
Link for V1:
*https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fpatchwork%2Fpatch%2F1226588%2F&data=02%7C01%7CFelix.Kuehling%40amd.com%7Cc715f5d02aae40846b8f08d7e5c001fd%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637230485152789682&sdata=4UdZiWMAbW8eR1BS2%2F6qMvs5K6cHWy5c8I32ReQ4uz0%3D&reserved=0
Link for V2:
*https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fpatchwork%2Fpatch%2F1227907%2F&data=02%7C01%7CFelix.Kuehling%40amd.com%7Cc715f5d02aae40846b8f08d7e5c001fd%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637230485152799673&sdata=Wt%2Bk7k4MtSX4zIDgmLEOB6ZKzfuqAd6GJZ3Creqf1aY%3D&reserved=0
---
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
index 327317c54f7c..f03d9843d723 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
@@ -1285,21 +1285,21 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
struct bo_vm_reservation_context ctx;
struct ttm_validate_buffer *bo_list_entry;
int ret;
+ unsigned int mapped_to_gpu_memory;
I'll move this before the "int ret;" line. It makes the code more
readable if long declarations come before short ones.
Regards,
Felix
mutex_lock(&mem->lock);
+ mapped_to_gpu_memory = mem->mapped_to_gpu_memory;
+ mutex_unlock(&mem->lock);
+ /* lock is not needed after this, since mem is unused and will
+ * be freed anyway
+ */
- if (mem->mapped_to_gpu_memory > 0) {
+ if (mapped_to_gpu_memory > 0) {
pr_debug("BO VA 0x%llx size 0x%lx is still mapped.\n",
mem->va, bo_size);
- mutex_unlock(&mem->lock);
return -EBUSY;
}
- mutex_unlock(&mem->lock);
- /* lock is not needed after this, since mem is unused and will
- * be freed anyway
- */
-
/* No more MMU notifiers */
amdgpu_mn_unregister(mem->bo);
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-04-22 6:56 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-21 6:48 [PATCH V3] amdgpu:optimization-- reduce no need mutex_lock area Bernard Zhao
2020-04-21 6:48 ` Bernard Zhao
2020-04-21 6:48 ` Bernard Zhao
2020-04-22 2:27 ` Felix Kuehling
2020-04-22 2:27 ` Felix Kuehling
2020-04-22 2:50 ` 赵军奎
2020-04-22 2:50 ` 赵军奎
2020-04-22 2:50 ` 赵军奎
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.