vhost: apply cgroup to vhost workers
authorMichael S. Tsirkin <[email protected]>
Tue, 27 Jul 2010 19:56:50 +0000 (22:56 +0300)
committerMichael S. Tsirkin <[email protected]>
Wed, 28 Jul 2010 12:45:18 +0000 (15:45 +0300)
Apply the cgroup of the owner task to the created vhost worker.

Based on patches from Sridhar Samudrala's and Tejun Heo.
Later we'll need to also apply cpumask and probably priority
of the owner process.

Discussion on the best way to do this is still ongoing.

Signed-off-by: Michael S. Tsirkin <[email protected]>
Cc: Tejun Heo <[email protected]>
Cc: Sridhar Samudrala <[email protected]>
Cc: Li Zefan <[email protected]>
drivers/vhost/vhost.c

index 30d93c2b45b87419c3dc6b3907b70f84a0dd5a9f..dd2d019b889f2642a7791a1e6c9c08c103e74053 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/highmem.h>
 #include <linux/slab.h>
 #include <linux/kthread.h>
+#include <linux/cgroup.h>
 
 #include <linux/net.h>
 #include <linux/if_packet.h>
@@ -253,9 +254,14 @@ static long vhost_dev_set_owner(struct vhost_dev *dev)
        }
 
        dev->worker = worker;
+       err = cgroup_attach_task_current_cg(worker);
+       if (err)
+               goto err_cgroup;
        wake_up_process(worker);        /* avoid contributing to loadavg */
 
        return 0;
+err_cgroup:
+       kthread_stop(worker);
 err_worker:
        if (dev->mm)
                mmput(dev->mm);