public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] gpu: drm: amd: amdkfd: Remove create_workqueue()
@ 2016-05-26 19:37 Bhaktipriya Shridhar
  2016-05-26 20:18 ` Tejun Heo
  2016-05-29 15:01 ` Oded Gabbay
  0 siblings, 2 replies; 4+ messages in thread
From: Bhaktipriya Shridhar @ 2016-05-26 19:37 UTC (permalink / raw)
  To: tj, oded.gabbay, alexander.deucher, christian.koenig, airlied
  Cc: dri-devel, linux-kernel

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.

Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com>
---
 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(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
index ac00579..b21d3fc8 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
@@ -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;
 	}
--
2.1.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] gpu: drm: amd: amdkfd: Remove create_workqueue()
  2016-05-26 19:37 [PATCH v2] gpu: drm: amd: amdkfd: Remove create_workqueue() Bhaktipriya Shridhar
@ 2016-05-26 20:18 ` Tejun Heo
  2016-05-29 15:01 ` Oded Gabbay
  1 sibling, 0 replies; 4+ messages in thread
From: Tejun Heo @ 2016-05-26 20:18 UTC (permalink / raw)
  To: Bhaktipriya Shridhar
  Cc: oded.gabbay, alexander.deucher, christian.koenig, airlied,
	dri-devel, linux-kernel

On Fri, May 27, 2016 at 01:07:33AM +0530, Bhaktipriya Shridhar wrote:
> 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.
> 
> Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com>

Acked-by: Tejun Heo <tj@kernel.org>

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] gpu: drm: amd: amdkfd: Remove create_workqueue()
  2016-05-26 19:37 [PATCH v2] gpu: drm: amd: amdkfd: Remove create_workqueue() Bhaktipriya Shridhar
  2016-05-26 20:18 ` Tejun Heo
@ 2016-05-29 15:01 ` Oded Gabbay
  2016-05-29 15:46   ` Bhaktipriya Shridhar
  1 sibling, 1 reply; 4+ messages in thread
From: Oded Gabbay @ 2016-05-29 15:01 UTC (permalink / raw)
  To: Bhaktipriya Shridhar
  Cc: tj, Alex Deucher, Christian König, David Airlie,
	Maling list - DRI developers, Linux-Kernel@Vger. Kernel. Org

On Thu, May 26, 2016 at 10:37 PM, Bhaktipriya Shridhar
<bhaktipriya96@gmail.com> wrote:
> 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.
>
> Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com>
> ---
>  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(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> index ac00579..b21d3fc8 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> @@ -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

>  }
>
>  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
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] gpu: drm: amd: amdkfd: Remove create_workqueue()
  2016-05-29 15:01 ` Oded Gabbay
@ 2016-05-29 15:46   ` Bhaktipriya Shridhar
  0 siblings, 0 replies; 4+ messages in thread
From: Bhaktipriya Shridhar @ 2016-05-29 15:46 UTC (permalink / raw)
  To: Oded Gabbay
  Cc: Tejun Heo, Alex Deucher, Christian König, David Airlie,
	Maling list - DRI developers, Linux-Kernel@Vger. Kernel. Org

Thanks Oded. Sending v3 right away :)

On Sun, May 29, 2016 at 8:31 PM, Oded Gabbay <oded.gabbay@gmail.com> wrote:
> On Thu, May 26, 2016 at 10:37 PM, Bhaktipriya Shridhar
> <bhaktipriya96@gmail.com> wrote:
>> 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.
>>
>> Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com>
>> ---
>>  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(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
>> index ac00579..b21d3fc8 100644
>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
>> @@ -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
>
>>  }
>>
>>  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
>>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-05-29 15:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-26 19:37 [PATCH v2] gpu: drm: amd: amdkfd: Remove create_workqueue() Bhaktipriya Shridhar
2016-05-26 20:18 ` Tejun Heo
2016-05-29 15:01 ` Oded Gabbay
2016-05-29 15:46   ` Bhaktipriya Shridhar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox