Skip to content

Commit beda94d

Browse files
Dmitry Torokhovtorvalds
authored andcommitted
Vmware balloon: switch to using sysem-wide freezable workqueue
With the arrival of concurrency-managed workqueues there is no need for our driver to use dedicated workqueue; system-wide one should suffice just fine. [akpm@linux-foundation.org: fix comment layout & grammar] Signed-off-by: Dmitry Torokhov <dtor@vmware.com> Acked-by: Tejun Heo <tj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent f7b1371 commit beda94d

1 file changed

Lines changed: 11 additions & 20 deletions

File tree

‎drivers/misc/vmw_balloon.c‎

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
MODULE_AUTHOR("VMware, Inc.");
4747
MODULE_DESCRIPTION("VMware Memory Control (Balloon) Driver");
48-
MODULE_VERSION("1.2.1.2-k");
48+
MODULE_VERSION("1.2.1.3-k");
4949
MODULE_ALIAS("dmi:*:svnVMware*:*");
5050
MODULE_ALIAS("vmware_vmmemctl");
5151
MODULE_LICENSE("GPL");
@@ -215,7 +215,6 @@ struct vmballoon {
215215
};
216216

217217
static struct vmballoon balloon;
218-
static struct workqueue_struct *vmballoon_wq;
219218

220219
/*
221220
* Send "start" command to the host, communicating supported version
@@ -674,7 +673,12 @@ static void vmballoon_work(struct work_struct *work)
674673
vmballoon_deflate(b);
675674
}
676675

677-
queue_delayed_work(vmballoon_wq, dwork, round_jiffies_relative(HZ));
676+
/*
677+
* We are using a freezable workqueue so that balloon operations are
678+
* stopped while the system transitions to/from sleep/hibernation.
679+
*/
680+
queue_delayed_work(system_freezable_wq,
681+
dwork, round_jiffies_relative(HZ));
678682
}
679683

680684
/*
@@ -785,12 +789,6 @@ static int __init vmballoon_init(void)
785789
if (x86_hyper != &x86_hyper_vmware)
786790
return -ENODEV;
787791

788-
vmballoon_wq = create_freezable_workqueue("vmmemctl");
789-
if (!vmballoon_wq) {
790-
pr_err("failed to create workqueue\n");
791-
return -ENOMEM;
792-
}
793-
794792
INIT_LIST_HEAD(&balloon.pages);
795793
INIT_LIST_HEAD(&balloon.refused_pages);
796794

@@ -805,34 +803,27 @@ static int __init vmballoon_init(void)
805803
*/
806804
if (!vmballoon_send_start(&balloon)) {
807805
pr_err("failed to send start command to the host\n");
808-
error = -EIO;
809-
goto fail;
806+
return -EIO;
810807
}
811808

812809
if (!vmballoon_send_guest_id(&balloon)) {
813810
pr_err("failed to send guest ID to the host\n");
814-
error = -EIO;
815-
goto fail;
811+
return -EIO;
816812
}
817813

818814
error = vmballoon_debugfs_init(&balloon);
819815
if (error)
820-
goto fail;
816+
return error;
821817

822-
queue_delayed_work(vmballoon_wq, &balloon.dwork, 0);
818+
queue_delayed_work(system_freezable_wq, &balloon.dwork, 0);
823819

824820
return 0;
825-
826-
fail:
827-
destroy_workqueue(vmballoon_wq);
828-
return error;
829821
}
830822
module_init(vmballoon_init);
831823

832824
static void __exit vmballoon_exit(void)
833825
{
834826
cancel_delayed_work_sync(&balloon.dwork);
835-
destroy_workqueue(vmballoon_wq);
836827

837828
vmballoon_debugfs_exit(&balloon);
838829

0 commit comments

Comments
 (0)