Skip to content

Commit 2c507e4

Browse files
bhaktipriyagregkh
authored andcommitted
device core: Remove deprecated create_singlethread_workqueue
The workqueue "deferred_wq" queues a single work item &deferred_probe_work and hence doesn't require ordering. It is involved in probing devices and is not being used on a memory reclaim path. Hence, it has been converted to use 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. The work item has been flushed in driver_probe_done() 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 775115c commit 2c507e4

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

drivers/base/dd.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
static DEFINE_MUTEX(deferred_probe_mutex);
5252
static LIST_HEAD(deferred_probe_pending_list);
5353
static LIST_HEAD(deferred_probe_active_list);
54-
static struct workqueue_struct *deferred_wq;
5554
static atomic_t deferred_trigger_count = ATOMIC_INIT(0);
5655

5756
/*
@@ -175,7 +174,7 @@ static void driver_deferred_probe_trigger(void)
175174
* Kick the re-probe thread. It may already be scheduled, but it is
176175
* safe to kick it again.
177176
*/
178-
queue_work(deferred_wq, &deferred_probe_work);
177+
schedule_work(&deferred_probe_work);
179178
}
180179

181180
/**
@@ -211,14 +210,10 @@ void device_unblock_probing(void)
211210
*/
212211
static int deferred_probe_initcall(void)
213212
{
214-
deferred_wq = create_singlethread_workqueue("deferwq");
215-
if (WARN_ON(!deferred_wq))
216-
return -ENOMEM;
217-
218213
driver_deferred_probe_enable = true;
219214
driver_deferred_probe_trigger();
220215
/* Sort as many dependencies as possible before exiting initcalls */
221-
flush_workqueue(deferred_wq);
216+
flush_work(&deferred_probe_work);
222217
return 0;
223218
}
224219
late_initcall(deferred_probe_initcall);
@@ -481,8 +476,7 @@ int driver_probe_done(void)
481476
void wait_for_device_probe(void)
482477
{
483478
/* wait for the deferred probe workqueue to finish */
484-
if (driver_deferred_probe_enable)
485-
flush_workqueue(deferred_wq);
479+
flush_work(&deferred_probe_work);
486480

487481
/* wait for the known devices to complete their probing */
488482
wait_event(probe_waitqueue, atomic_read(&probe_count) == 0);

0 commit comments

Comments
 (0)