aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm
diff options
context:
space:
mode:
authorPetr Mladek <pmladek@suse.com>2016-10-11 16:55:20 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-10-11 18:06:33 -0400
commit3989144f863ac576e6efba298d24b0b02a10d4bb (patch)
treed9892a66501c0ab30d583ac5e1f609d66d842156 /arch/x86/kvm
parente700591ae03896c16974d4e1ab58eb296aaa5f59 (diff)
kthread: kthread worker API cleanup
A good practice is to prefix the names of functions by the name of the subsystem. The kthread worker API is a mix of classic kthreads and workqueues. Each worker has a dedicated kthread. It runs a generic function that process queued works. It is implemented as part of the kthread subsystem. This patch renames the existing kthread worker API to use the corresponding name from the workqueues API prefixed by kthread_: __init_kthread_worker() -> __kthread_init_worker() init_kthread_worker() -> kthread_init_worker() init_kthread_work() -> kthread_init_work() insert_kthread_work() -> kthread_insert_work() queue_kthread_work() -> kthread_queue_work() flush_kthread_work() -> kthread_flush_work() flush_kthread_worker() -> kthread_flush_worker() Note that the names of DEFINE_KTHREAD_WORK*() macros stay as they are. It is common that the "DEFINE_" prefix has precedence over the subsystem names. Note that INIT() macros and init() functions use different naming scheme. There is no good solution. There are several reasons for this solution: + "init" in the function names stands for the verb "initialize" aka "initialize worker". While "INIT" in the macro names stands for the noun "INITIALIZER" aka "worker initializer". + INIT() macros are used only in DEFINE() macros + init() functions are used close to the other kthread() functions. It looks much better if all the functions use the same scheme. + There will be also kthread_destroy_worker() that will be used close to kthread_cancel_work(). It is related to the init() function. Again it looks better if all functions use the same naming scheme. + there are several precedents for such init() function names, e.g. amd_iommu_init_device(), free_area_init_node(), jump_label_init_type(), regmap_init_mmio_clk(), + It is not an argument but it was inconsistent even before. [arnd@arndb.de: fix linux-next merge conflict] Link: http://lkml.kernel.org/r/20160908135724.1311726-1-arnd@arndb.de Link: http://lkml.kernel.org/r/1470754545-17632-3-git-send-email-pmladek@suse.com Suggested-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Petr Mladek <pmladek@suse.com> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Tejun Heo <tj@kernel.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> Cc: Josh Triplett <josh@joshtriplett.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Jiri Kosina <jkosina@suse.cz> Cc: Borislav Petkov <bp@suse.de> Cc: Michal Hocko <mhocko@suse.cz> Cc: Vlastimil Babka <vbabka@suse.cz> Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r--arch/x86/kvm/i8254.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c
index 5fb6c620180e..16a7134eedac 100644
--- a/arch/x86/kvm/i8254.c
+++ b/arch/x86/kvm/i8254.c
@@ -212,7 +212,7 @@ static void kvm_pit_ack_irq(struct kvm_irq_ack_notifier *kian)
212 */ 212 */
213 smp_mb(); 213 smp_mb();
214 if (atomic_dec_if_positive(&ps->pending) > 0) 214 if (atomic_dec_if_positive(&ps->pending) > 0)
215 queue_kthread_work(&pit->worker, &pit->expired); 215 kthread_queue_work(&pit->worker, &pit->expired);
216} 216}
217 217
218void __kvm_migrate_pit_timer(struct kvm_vcpu *vcpu) 218void __kvm_migrate_pit_timer(struct kvm_vcpu *vcpu)
@@ -233,7 +233,7 @@ void __kvm_migrate_pit_timer(struct kvm_vcpu *vcpu)
233static void destroy_pit_timer(struct kvm_pit *pit) 233static void destroy_pit_timer(struct kvm_pit *pit)
234{ 234{
235 hrtimer_cancel(&pit->pit_state.timer); 235 hrtimer_cancel(&pit->pit_state.timer);
236 flush_kthread_work(&pit->expired); 236 kthread_flush_work(&pit->expired);
237} 237}
238 238
239static void pit_do_work(struct kthread_work *work) 239static void pit_do_work(struct kthread_work *work)
@@ -272,7 +272,7 @@ static enum hrtimer_restart pit_timer_fn(struct hrtimer *data)
272 if (atomic_read(&ps->reinject)) 272 if (atomic_read(&ps->reinject))
273 atomic_inc(&ps->pending); 273 atomic_inc(&ps->pending);
274 274
275 queue_kthread_work(&pt->worker, &pt->expired); 275 kthread_queue_work(&pt->worker, &pt->expired);
276 276
277 if (ps->is_periodic) { 277 if (ps->is_periodic) {
278 hrtimer_add_expires_ns(&ps->timer, ps->period); 278 hrtimer_add_expires_ns(&ps->timer, ps->period);
@@ -324,7 +324,7 @@ static void create_pit_timer(struct kvm_pit *pit, u32 val, int is_period)
324 324
325 /* TODO The new value only affected after the retriggered */ 325 /* TODO The new value only affected after the retriggered */
326 hrtimer_cancel(&ps->timer); 326 hrtimer_cancel(&ps->timer);
327 flush_kthread_work(&pit->expired); 327 kthread_flush_work(&pit->expired);
328 ps->period = interval; 328 ps->period = interval;
329 ps->is_periodic = is_period; 329 ps->is_periodic = is_period;
330 330
@@ -667,13 +667,13 @@ struct kvm_pit *kvm_create_pit(struct kvm *kvm, u32 flags)
667 pid_nr = pid_vnr(pid); 667 pid_nr = pid_vnr(pid);
668 put_pid(pid); 668 put_pid(pid);
669 669
670 init_kthread_worker(&pit->worker); 670 kthread_init_worker(&pit->worker);
671 pit->worker_task = kthread_run(kthread_worker_fn, &pit->worker, 671 pit->worker_task = kthread_run(kthread_worker_fn, &pit->worker,
672 "kvm-pit/%d", pid_nr); 672 "kvm-pit/%d", pid_nr);
673 if (IS_ERR(pit->worker_task)) 673 if (IS_ERR(pit->worker_task))
674 goto fail_kthread; 674 goto fail_kthread;
675 675
676 init_kthread_work(&pit->expired, pit_do_work); 676 kthread_init_work(&pit->expired, pit_do_work);
677 677
678 pit->kvm = kvm; 678 pit->kvm = kvm;
679 679
@@ -730,7 +730,7 @@ void kvm_free_pit(struct kvm *kvm)
730 kvm_io_bus_unregister_dev(kvm, KVM_PIO_BUS, &pit->speaker_dev); 730 kvm_io_bus_unregister_dev(kvm, KVM_PIO_BUS, &pit->speaker_dev);
731 kvm_pit_set_reinject(pit, false); 731 kvm_pit_set_reinject(pit, false);
732 hrtimer_cancel(&pit->pit_state.timer); 732 hrtimer_cancel(&pit->pit_state.timer);
733 flush_kthread_work(&pit->expired); 733 kthread_flush_work(&pit->expired);
734 kthread_stop(pit->worker_task); 734 kthread_stop(pit->worker_task);
735 kvm_free_irq_source_id(kvm, pit->irq_source_id); 735 kvm_free_irq_source_id(kvm, pit->irq_source_id);
736 kfree(pit); 736 kfree(pit);