Skip to contentSkip to conversation

gpu: drm: amd: amdkfd: Remove create_workqueue()

PATCH Superseded Bhaktipriya Shridhar 3 participants 4 messages May 26, 2016 – May 29, 2016

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 gpu: drm: amd: amdkfd: Remove create_workqueue()

alloc_workqueue replaces deprecated create_workqueue().

create_workqueue has been replaced with alloc_workqueue with max_active as 0 since there is no need for throttling the number of active work items.

WQ_MEM_RECLAIM has not been set to because kfd_process_wq will not be used in memory reclaim path.

kfd_process_wq is used for delay destruction. A work item embedded in kfd_process gets queued to kfd_process_wq and when it executes it destroys and frees the containing kfd_process and thus itself.

This requires a dedicated workqueue because a work item once queued, may get freed at any point of time and any external entity cannot flush the work item. So, in order to wait for such a work item, it needs to be put on a dedicated workqueue.

kfd_module_exit() calls kfd_process_destroy_wq which ensures that all pending work items are finished before the module is removed.

flush_workqueue is unnecessary since destroy_workqueue() itself calls drain_workqueue() which flushes repeatedly till the workqueue becomes empty.

Hence flush_workqueue has been removed.

---
Changes in v2:
- added explanation for setting concurrency value to WQ_DFL_ACTIVE
- added explanation for dropping WQ_MEM_RECLAIM

 drivers/gpu/drm/amd/amdkfd/kfd_process.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_process.c +1 -2
index ac00579..b21d3fc8 100644
@@ -63,13 +63,12 @@ static struct kfd_process *create_process(const struct task_struct *thread);
 void kfd_process_create_wq(void)
 {
 	if (!kfd_process_wq)
-		kfd_process_wq = create_workqueue("kfd_process_wq");
+		kfd_process_wq = alloc_workqueue("kfd_process_wq",0,0);
 }
 
 void kfd_process_destroy_wq(void)
 {
 	if (kfd_process_wq) {
-		flush_workqueue(kfd_process_wq);
 		destroy_workqueue(kfd_process_wq);
 		kfd_process_wq = NULL;
 	}
Acked-by on v2 1/1
#1 lore raw
Quoted 20 lines · Bhaktipriya Shridhar

alloc_workqueue replaces deprecated create_workqueue().

create_workqueue has been replaced with alloc_workqueue with max_active as 0 since there is no need for throttling the number of active work items.

WQ_MEM_RECLAIM has not been set to because kfd_process_wq will not be used in memory reclaim path.

kfd_process_wq is used for delay destruction. A work item embedded in kfd_process gets queued to kfd_process_wq and when it executes it destroys and frees the containing kfd_process and thus itself.

This requires a dedicated workqueue because a work item once queued, may get freed at any point of time and any external entity cannot flush the work item. So, in order to wait for such a work item, it needs to be put on a dedicated workqueue.

kfd_module_exit() calls kfd_process_destroy_wq which ensures that all pending work items are finished before the module is removed.

Quoted 6 lines

flush_workqueue is unnecessary since destroy_workqueue() itself calls drain_workqueue() which flushes repeatedly till the workqueue becomes empty.

Hence flush_workqueue has been removed.

Thanks.

Signature · 5 lines
tejun
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw
In reply to Bhaktipriya Shridhar
Quoted 40 lines · Bhaktipriya Shridhar

alloc_workqueue replaces deprecated create_workqueue().

create_workqueue has been replaced with alloc_workqueue with max_active as 0 since there is no need for throttling the number of active work items.

WQ_MEM_RECLAIM has not been set to because kfd_process_wq will not be used in memory reclaim path.

kfd_process_wq is used for delay destruction. A work item embedded in kfd_process gets queued to kfd_process_wq and when it executes it destroys and frees the containing kfd_process and thus itself.

This requires a dedicated workqueue because a work item once queued, may get freed at any point of time and any external entity cannot flush the work item. So, in order to wait for such a work item, it needs to be put on a dedicated workqueue.

kfd_module_exit() calls kfd_process_destroy_wq which ensures that all pending work items are finished before the module is removed.

flush_workqueue is unnecessary since destroy_workqueue() itself calls drain_workqueue() which flushes repeatedly till the workqueue becomes empty.

Hence flush_workqueue has been removed.

---
Changes in v2:
- added explanation for setting concurrency value to WQ_DFL_ACTIVE
- added explanation for dropping WQ_MEM_RECLAIM

 drivers/gpu/drm/amd/amdkfd/kfd_process.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_process.c +0 -0
index ac00579..b21d3fc8 100644

drivers/gpu/drm/amd/amdkfd/kfd_process.c static struct kfd_process *create_process(const struct task_struct *thread); · line 66

Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_process.c +1 -1
@@ -63,13 +63,12 @@ static struct kfd_process *create_process(const struct task_struct *thread);
 void kfd_process_create_wq(void)
 {
        if (!kfd_process_wq)
-               kfd_process_wq = create_workqueue("kfd_process_wq");
+               kfd_process_wq = alloc_workqueue("kfd_process_wq",0,0);

You are missing a space between the arguments. Seem you forgot to run checkpatch.pl ;)

Send a new patch and I'll add it to amdkfd's tree.

Thanks,

Oded

Quoted 12 lines
drivers/gpu/drm/amd/amdkfd/kfd_process.c +0 -2
 }
 
 void kfd_process_destroy_wq(void)
 {
        if (kfd_process_wq) {
-               flush_workqueue(kfd_process_wq);
                destroy_workqueue(kfd_process_wq);
                kfd_process_wq = NULL;
        }
--

2.1.4

#3 lore raw

Thanks Oded. Sending v3 right away :)

Quoted 69 lines · Oded Gabbay
Quoted 40 lines · Bhaktipriya Shridhar

alloc_workqueue replaces deprecated create_workqueue().

create_workqueue has been replaced with alloc_workqueue with max_active as 0 since there is no need for throttling the number of active work items.

WQ_MEM_RECLAIM has not been set to because kfd_process_wq will not be used in memory reclaim path.

kfd_process_wq is used for delay destruction. A work item embedded in kfd_process gets queued to kfd_process_wq and when it executes it destroys and frees the containing kfd_process and thus itself.

This requires a dedicated workqueue because a work item once queued, may get freed at any point of time and any external entity cannot flush the work item. So, in order to wait for such a work item, it needs to be put on a dedicated workqueue.

kfd_module_exit() calls kfd_process_destroy_wq which ensures that all pending work items are finished before the module is removed.

flush_workqueue is unnecessary since destroy_workqueue() itself calls drain_workqueue() which flushes repeatedly till the workqueue becomes empty.

Hence flush_workqueue has been removed.

---
Changes in v2:
- added explanation for setting concurrency value to WQ_DFL_ACTIVE
- added explanation for dropping WQ_MEM_RECLAIM

 drivers/gpu/drm/amd/amdkfd/kfd_process.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_process.c +0 -0
index ac00579..b21d3fc8 100644

drivers/gpu/drm/amd/amdkfd/kfd_process.c static struct kfd_process *create_process(const struct task_struct *thread); · line 66

Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_process.c +1 -1
@@ -63,13 +63,12 @@ static struct kfd_process *create_process(const struct task_struct *thread);
 void kfd_process_create_wq(void)
 {
        if (!kfd_process_wq)
-               kfd_process_wq = create_workqueue("kfd_process_wq");
+               kfd_process_wq = alloc_workqueue("kfd_process_wq",0,0);

You are missing a space between the arguments. Seem you forgot to run checkpatch.pl ;)

Send a new patch and I'll add it to amdkfd's tree.

Thanks,

Oded

Quoted 12 lines
drivers/gpu/drm/amd/amdkfd/kfd_process.c +0 -2
 }
 
 void kfd_process_destroy_wq(void)
 {
        if (kfd_process_wq) {
-               flush_workqueue(kfd_process_wq);
                destroy_workqueue(kfd_process_wq);
                kfd_process_wq = NULL;
        }
--

2.1.4