* [PATCH v2] cfag12864b: Remove deprecated create_singlethread_workqueue
@ 2016-08-13 15:38 Bhaktipriya Shridhar
2016-08-15 22:55 ` Tejun Heo
0 siblings, 1 reply; 2+ messages in thread
From: Bhaktipriya Shridhar @ 2016-08-13 15:38 UTC (permalink / raw)
To: Miguel Ojeda Sandonis; +Cc: linux-kernel, Tejun Heo
The workqueue has a single workitem(&cfag12864b_work) and hence doesn't
require ordering. Also, it is not being used on a memory reclaim path.
Hence, the singlethreaded workqueue has been replaced with the use of
system_wq.
System workqueues have been able to handle high level of concurrency
for a long time now and hence it's not required to have a singlethreaded
workqueue just to gain concurrency. Unlike a dedicated per-cpu workqueue
created with create_singlethread_workqueue(), system_wq allows multiple
work items to overlap executions even on the same CPU; however, a
per-cpu workqueue doesn't have any CPU locality or global ordering
guarantee unless the target CPU is explicitly specified and thus the
increase of local concurrency shouldn't make any difference.
Work item has been sync cancelled in cfag12864b_disable() to ensure that
there are no pending tasks while disconnecting the driver.
Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com>
---
Changes in v2:
-Used cancel_delayed_work_sync instead of cancel delayed_work
to ensure that the work item is finished.
drivers/auxdisplay/cfag12864b.c | 14 ++------------
1 file changed, 2 insertions(+), 12 deletions(-)
diff --git a/drivers/auxdisplay/cfag12864b.c b/drivers/auxdisplay/cfag12864b.c
index 41ce4bd..551b902 100644
--- a/drivers/auxdisplay/cfag12864b.c
+++ b/drivers/auxdisplay/cfag12864b.c
@@ -223,12 +223,11 @@ static unsigned char *cfag12864b_cache;
static DEFINE_MUTEX(cfag12864b_mutex);
static unsigned char cfag12864b_updating;
static void cfag12864b_update(struct work_struct *delayed_work);
-static struct workqueue_struct *cfag12864b_workqueue;
static DECLARE_DELAYED_WORK(cfag12864b_work, cfag12864b_update);
static void cfag12864b_queue(void)
{
- queue_delayed_work(cfag12864b_workqueue, &cfag12864b_work,
+ schedule_delayed_work(&cfag12864b_work,
HZ / cfag12864b_rate);
}
@@ -256,8 +255,7 @@ void cfag12864b_disable(void)
if (cfag12864b_updating) {
cfag12864b_updating = 0;
- cancel_delayed_work(&cfag12864b_work);
- flush_workqueue(cfag12864b_workqueue);
+ cancel_delayed_work_sync(&cfag12864b_work);
}
mutex_unlock(&cfag12864b_mutex);
@@ -357,19 +355,12 @@ static int __init cfag12864b_init(void)
goto bufferalloced;
}
- cfag12864b_workqueue = create_singlethread_workqueue(CFAG12864B_NAME);
- if (cfag12864b_workqueue == NULL)
- goto cachealloced;
-
cfag12864b_clear();
cfag12864b_on();
cfag12864b_inited = 1;
return 0;
-cachealloced:
- kfree(cfag12864b_cache);
-
bufferalloced:
free_page((unsigned long) cfag12864b_buffer);
@@ -381,7 +372,6 @@ static void __exit cfag12864b_exit(void)
{
cfag12864b_disable();
cfag12864b_off();
- destroy_workqueue(cfag12864b_workqueue);
kfree(cfag12864b_cache);
free_page((unsigned long) cfag12864b_buffer);
}
--
2.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v2] cfag12864b: Remove deprecated create_singlethread_workqueue
2016-08-13 15:38 [PATCH v2] cfag12864b: Remove deprecated create_singlethread_workqueue Bhaktipriya Shridhar
@ 2016-08-15 22:55 ` Tejun Heo
0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2016-08-15 22:55 UTC (permalink / raw)
To: Bhaktipriya Shridhar; +Cc: Miguel Ojeda Sandonis, linux-kernel
On Sat, Aug 13, 2016 at 09:08:07PM +0530, Bhaktipriya Shridhar wrote:
> The workqueue has a single workitem(&cfag12864b_work) and hence doesn't
> require ordering. Also, it is not being used on a memory reclaim path.
> Hence, the singlethreaded workqueue has been replaced with the use of
> system_wq.
>
> System workqueues have been able to handle high level of concurrency
> for a long time now and hence it's not required to have a singlethreaded
> workqueue just to gain concurrency. Unlike a dedicated per-cpu workqueue
> created with create_singlethread_workqueue(), system_wq allows multiple
> work items to overlap executions even on the same CPU; however, a
> per-cpu workqueue doesn't have any CPU locality or global ordering
> guarantee unless the target CPU is explicitly specified and thus the
> increase of local concurrency shouldn't make any difference.
>
> Work item has been sync cancelled in cfag12864b_disable() to ensure that
> there are no pending tasks while disconnecting the driver.
>
> Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com>
Acked-by: Tejun Heo <tj@kernel.org>
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-08-15 22:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-13 15:38 [PATCH v2] cfag12864b: Remove deprecated create_singlethread_workqueue Bhaktipriya Shridhar
2016-08-15 22:55 ` Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox