Commit 9a2e03d8ed518a61154f18d83d6466628e519f94
1 parent
8db25e7891
Exists in
master
and in
20 other branches
kthread_worker: reorganize to prepare for flush_kthread_work() reimplementation
Make the following two non-functional changes. * Separate out insert_kthread_work() from queue_kthread_work(). * Relocate struct kthread_flush_work and kthread_flush_work_fn() definitions above flush_kthread_work(). v2: Added lockdep_assert_held() in insert_kthread_work() as suggested by Andy Walls. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Andy Walls <awalls@md.metrocast.net>
Showing 1 changed file with 26 additions and 16 deletions Side-by-side Diff
kernel/kthread.c
... | ... | @@ -378,6 +378,19 @@ |
378 | 378 | } |
379 | 379 | EXPORT_SYMBOL_GPL(kthread_worker_fn); |
380 | 380 | |
381 | +/* insert @work before @pos in @worker */ | |
382 | +static void insert_kthread_work(struct kthread_worker *worker, | |
383 | + struct kthread_work *work, | |
384 | + struct list_head *pos) | |
385 | +{ | |
386 | + lockdep_assert_held(&worker->lock); | |
387 | + | |
388 | + list_add_tail(&work->node, pos); | |
389 | + work->queue_seq++; | |
390 | + if (likely(worker->task)) | |
391 | + wake_up_process(worker->task); | |
392 | +} | |
393 | + | |
381 | 394 | /** |
382 | 395 | * queue_kthread_work - queue a kthread_work |
383 | 396 | * @worker: target kthread_worker |
... | ... | @@ -395,10 +408,7 @@ |
395 | 408 | |
396 | 409 | spin_lock_irqsave(&worker->lock, flags); |
397 | 410 | if (list_empty(&work->node)) { |
398 | - list_add_tail(&work->node, &worker->work_list); | |
399 | - work->queue_seq++; | |
400 | - if (likely(worker->task)) | |
401 | - wake_up_process(worker->task); | |
411 | + insert_kthread_work(worker, work, &worker->work_list); | |
402 | 412 | ret = true; |
403 | 413 | } |
404 | 414 | spin_unlock_irqrestore(&worker->lock, flags); |
... | ... | @@ -406,6 +416,18 @@ |
406 | 416 | } |
407 | 417 | EXPORT_SYMBOL_GPL(queue_kthread_work); |
408 | 418 | |
419 | +struct kthread_flush_work { | |
420 | + struct kthread_work work; | |
421 | + struct completion done; | |
422 | +}; | |
423 | + | |
424 | +static void kthread_flush_work_fn(struct kthread_work *work) | |
425 | +{ | |
426 | + struct kthread_flush_work *fwork = | |
427 | + container_of(work, struct kthread_flush_work, work); | |
428 | + complete(&fwork->done); | |
429 | +} | |
430 | + | |
409 | 431 | /** |
410 | 432 | * flush_kthread_work - flush a kthread_work |
411 | 433 | * @work: work to flush |
... | ... | @@ -435,18 +457,6 @@ |
435 | 457 | smp_mb__after_atomic_dec(); |
436 | 458 | } |
437 | 459 | EXPORT_SYMBOL_GPL(flush_kthread_work); |
438 | - | |
439 | -struct kthread_flush_work { | |
440 | - struct kthread_work work; | |
441 | - struct completion done; | |
442 | -}; | |
443 | - | |
444 | -static void kthread_flush_work_fn(struct kthread_work *work) | |
445 | -{ | |
446 | - struct kthread_flush_work *fwork = | |
447 | - container_of(work, struct kthread_flush_work, work); | |
448 | - complete(&fwork->done); | |
449 | -} | |
450 | 460 | |
451 | 461 | /** |
452 | 462 | * flush_kthread_worker - flush all current works on a kthread_worker |