cgroup aware workqueues
Subsystems (4)
RFC PATCH 1/4 cgroup: Introduce a function to compare two tasks
In reply to Bandan DasThis function takes two tasks and iterates through all hierarchies to check if they belong to the same cgroups. It ignores the check for default hierarchies or for hierarchies with no subsystems attached.
--- include/linux/cgroup.h | 1 + kernel/cgroup.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+)
include/linux/cgroup.h +1 -0
@@ -83,6 +83,7 @@ struct cgroup_subsys_state *css_tryget_online_from_dir(struct dentry *dentry,struct cgroup *cgroup_get_from_path (const char *path); +bool cgroup_match_groups (struct task_struct *,struct task_struct *);int cgroup_attach_task_all (struct task_struct *from,struct task_struct *);int cgroup_transfer_tasks (struct cgroup *to,struct cgroup *from);
kernel/cgroup.c +36 -0
@@ -2745,6 +2745,42 @@ out_unlock_threadgroup: }/** +* cgroup_match_groups - check if tsk1 and tsk2 belong to same cgroups +* in all hierarchies +*/ +bool cgroup_match_groups (struct task_struct *tsk1,struct task_struct *tsk2) +{ +struct cgroup_root *root; +bool result = true; + +mutex_lock (&cgroup_mutex); +for_each_root (root) { +struct cgroup *cg_tsk1; +struct cgroup *cg_tsk2; + +if (root == &cgrp_dfl_root) +continue ; + +if (!root->subsys_mask) +continue ; + +spin_lock_bh (&css_set_lock); + cg_tsk1 =task_cgroup_from_root (tsk1, root); + cg_tsk2 =task_cgroup_from_root (tsk2, root); +spin_unlock_bh (&css_set_lock); + +if (cg_tsk1 != cg_tsk2) { + result = false; +break ; + } + } +mutex_unlock (&cgroup_mutex); + +return result; +} +EXPORT_SYMBOL_GPL (cgroup_match_groups); + +/** * cgroup_attach_task_all - attach task 'tsk' to all cgroups of task 'from' * @from: attach to all cgroups of a given task * @tsk: the task to be attached
Signature · 1 line
2.5.0
RFC PATCH 2/4 workqueue: introduce support for attaching to cgroups
In reply to Bandan DasIntroduce cgroup aware unbounded worker pools. Whenever a new worker thread is created, create_worker attaches itself to the cgroups of the task that called alloc_workqueue(). New worker pools are created if there's no match in the global list of cgroup aware worker pools.
--- include/linux/workqueue.h | 2 + kernel/workqueue.c | 212 +++++++++++++++++++++++++++++++++++++++++--- kernel/workqueue_internal.h | 4 + 3 files changed, 204 insertions(+), 14 deletions(-)
include/linux/workqueue.h +2 -0
@@ -131,6 +131,7 @@ struct workqueue_attrs {int nice;/* nice level */ cpumask_var_t cpumask;/* allowed CPUs */ bool no_numa;/* disable NUMA affinity */ +bool cg_enabled;/* cgroups aware */ };static inline struct delayed_work *to_delayed_work (struct work_struct *work)
@@ -308,6 +309,7 @@ enum {* http://thread.gmane.org/gmane.linux.kernel/1480396 */ WQ_POWER_EFFICIENT =1 <<7 , +WQ_CGROUPS =1 <<8 , __WQ_DRAINING =1 <<16 ,/* internal: workqueue is draining */ __WQ_ORDERED = 1 << 17, /* internal: workqueue is ordered */
kernel/workqueue.c +198 -14
462 lines not on this page · raw message
kernel/workqueue_internal.h +4 -0
@@ -52,6 +52,10 @@ struct worker {/* used only by rescuers to point to the target workqueue */ struct workqueue_struct *rescue_wq;/* I: the workqueue to rescue */ + +/* for cgroups */ +bool attach_pending; +struct task_struct *attach_to; };/**
Signature · 1 line
2.5.0
RFC PATCH 3/4 cgroup: use spin_lock_irq for cgroup match and attach fns
In reply to Bandan DasSince these functions will be called from the worker thread context, using spin_lock_bh triggers WARN_ONs.
--- kernel/cgroup.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/cgroup.c +4 -4
@@ -2764,10 +2764,10 @@ bool cgroup_match_groups(struct task_struct *tsk1, struct task_struct *tsk2)if (!root->subsys_mask)continue ; -spin_lock_bh (&css_set_lock); +spin_lock_irq (&css_set_lock); cg_tsk1 =task_cgroup_from_root (tsk1, root); cg_tsk2 =task_cgroup_from_root (tsk2, root); -spin_unlock_bh (&css_set_lock); +spin_unlock_irq (&css_set_lock);if (cg_tsk1 != cg_tsk2) { result = false;
@@ -2797,9 +2797,9 @@ int cgroup_attach_task_all(struct task_struct *from, struct task_struct *tsk)if (root == &cgrp_dfl_root)continue ; -spin_lock_bh (&css_set_lock); +spin_lock_irq (&css_set_lock); from_cgrp =task_cgroup_from_root (from, root); -spin_unlock_bh (&css_set_lock); +spin_unlock_irq (&css_set_lock); retval =cgroup_attach_task (from_cgrp, tsk, false);if (retval)
Signature · 1 line
2.5.0
RFC PATCH 4/4 vhost: use workqueues for the works
In reply to Bandan DasUse the common workqueue machanism for processing vhost work by creating a unbound workqueue/vhost device. The backend workers could still share work and are not visible to vhost.
--- drivers/vhost/vhost.c | 103 +++++++++++++++++++++++++++++++++++++++++++------- drivers/vhost/vhost.h | 2 + 2 files changed, 92 insertions(+), 13 deletions(-)
drivers/vhost/vhost.c +90 -13
@@ -30,6 +30,10 @@#include "vhost.h" +static int cmwq_worker =1 ; +module_param (cmwq_worker, int,0444 ); +MODULE_PARM_DESC (cmwq_worker,"Use cmwq for worker threads - Experimental, 1 - Enable; 0 - Disable" ); +static ushort max_mem_regions =64 ;module_param (max_mem_regions, ushort,0444 ); MODULE_PARM_DESC(max_mem_regions,
@@ -238,7 +242,10 @@ void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work)list_add_tail (&work->node, &dev->work_list); work->queue_seq++;spin_unlock_irqrestore (&dev->work_lock, flags); -wake_up_process (dev->worker); +if (cmwq_worker) +queue_work (dev->qworker, &dev->qwork); +else +wake_up_process (dev->worker); }else {spin_unlock_irqrestore (&dev->work_lock, flags); }
@@ -370,6 +377,52 @@ static void vhost_dev_free_iovecs(struct vhost_dev *dev)vhost_vq_free_iovecs (dev->vqs[i]); } +static void vhost_wq_worker (struct work_struct *qwork) +{ +struct vhost_dev *dev = + container_of(qwork, struct vhost_dev, qwork); +struct vhost_work *work =NULL ; +unsigned uninitialized_var (seq ); +struct mm_struct *prev_mm =NULL ; +mm_segment_t oldfs =get_fs (); + +set_fs (USER_DS ); + +for (;;) { +spin_lock_irq (&dev->work_lock); +if (list_empty (&dev->work_list)) { +spin_unlock (&dev->work_lock); +break ; + } + + work =list_first_entry (&dev->work_list, + struct vhost_work, node); +list_del_init (&work->node); + seq = work->queue_seq; + +if (prev_mm != dev->mm) { +if (prev_mm) +unuse_mm (prev_mm); + prev_mm = dev->mm; +use_mm (prev_mm); + } +spin_unlock (&dev->work_lock); + +if (work) { + work->fn (work); +spin_lock_irq (&dev->work_lock); + work->done_seq = seq; +if (work->flushing) +wake_up_all (&work->done); +spin_unlock_irq (&dev->work_lock); + } + } + +if (prev_mm) +unuse_mm (prev_mm); +set_fs (oldfs); +} +void vhost_dev_init (struct vhost_dev *dev,struct vhost_virtqueue **vqs,int nvqs) {
@@ -386,6 +439,10 @@ void vhost_dev_init(struct vhost_dev *dev,spin_lock_init (&dev->work_lock);INIT_LIST_HEAD (&dev->work_list); dev->worker =NULL ; + dev->qworker =NULL ; + +if (cmwq_worker) +INIT_WORK (&dev->qwork, vhost_wq_worker);for (i =0 ; i < dev->nvqs; ++i) { vq = dev->vqs[i];
@@ -445,7 +502,8 @@ EXPORT_SYMBOL_GPL(vhost_dev_has_owner);/* Caller should have device mutex */ long vhost_dev_set_owner (struct vhost_dev *dev) { -struct task_struct *worker; +struct task_struct *worker =NULL ; +struct workqueue_struct *qworker;int err;/* Is there an owner already? */
@@ -456,18 +514,31 @@ long vhost_dev_set_owner(struct vhost_dev *dev)/* No owner, become one */ dev->mm =get_task_mm (current); - worker =kthread_create (vhost_worker, dev,"vhost-%d" , current->pid); -if (IS_ERR (worker)) { - err =PTR_ERR (worker); - goto err_worker; - } +if (cmwq_worker) { + qworker =alloc_workqueue ("vhost-wq-%d" , +WQ_UNBOUND |WQ_CGROUPS , +0 , current->pid); +if (!qworker) { + err = -ENOMEM ; + goto err_worker; + } + dev->qworker = qworker; + }else { + worker =kthread_create (vhost_worker, dev, +"vhost-%d" , current->pid); +if (IS_ERR (worker)) { + err =PTR_ERR (worker); + goto err_worker; + } - dev->worker = worker; -wake_up_process (worker);/* avoid contributing to loadavg */ + dev->worker = worker; +/* avoid contributing to loadavg */ +wake_up_process (worker); - err =vhost_attach_cgroups (dev); -if (err) - goto err_cgroup; + err =vhost_attach_cgroups (dev); +if (err) + goto err_cgroup; + } err =vhost_dev_alloc_iovecs (dev);if (err)
@@ -475,7 +546,8 @@ long vhost_dev_set_owner(struct vhost_dev *dev)return 0 ; err_cgroup: -kthread_stop (worker); +if (worker) +kthread_stop (worker); dev->worker =NULL ; err_worker:if (dev->mm)
@@ -556,6 +628,11 @@ void vhost_dev_cleanup(struct vhost_dev *dev, bool locked)kthread_stop (dev->worker); dev->worker =NULL ; } +if (dev->qworker) { +/* destroy does flush */ +destroy_workqueue (dev->qworker); + dev->qworker =NULL ; + }if (dev->mm)mmput (dev->mm); dev->mm =NULL ;
drivers/vhost/vhost.h +2 -0
@@ -127,6 +127,8 @@ struct vhost_dev {spinlock_t work_lock;struct list_head work_list;struct task_struct *worker; +struct workqueue_struct *qworker; +struct work_struct qwork; };void vhost_dev_init (struct vhost_dev *,struct vhost_virtqueue **vqs,int nvqs);
Signature · 1 line
2.5.0
cover cgroup aware workqueues
At Linuxcon last year, based on our presentation "vhost: sharing is better" [1], we had briefly discussed the idea of cgroup aware workqueues with Tejun. The following patches are a result of the discussion. They are in no way complete in that the changes are for unbounded workqueues only, but I just wanted to present my unfinished work as RFC and get some feedback.
1/4 and 3/4 are simple cgroup changes and add a helper function. 2/4 is the main implementation.
4/4 changes vhost to use workqueues with support for cgroups.
Accounting:
When servicing a userspace task A attached to cgroup X, for cgroup awareness, a worker thread could attach to all cgroups of the task which it is servicing. This patch does it for unbound workqueues which means all tasks that are bound to certain cgroups could potentially be serviced by the same worker thread. However, the same technique could be applicable to bounded workqueues as well.
Example:
vhost creates a worker thread when invoked for a kvm guest. Since, the guest is a normal process, the kernel thread servicing it should be attached to the vm process' cgroups.
Design:
The fundamental addition is a cgroup aware worker pool and as stated above, for the unbounded case only.
These changes don't populate the "numa awareness" fields/attrs and unlike unbounded numa worker pools, cgroup worker pools are created on demand. Every work request could potentially have a new cgroup aware pool created for it based on the combination of cgroups it's attached to. However, workqueues themselves are incognizant of the actual cgroups - they rely on the cgroups provided helper functions either for 1. a match of all the cgroups or 2. to attach a worker thread to all cgroups of a userspace task. We do maintain a list of cgroup aware pools so that when a new request comes in and a suitable worker pool needs to be found, we search the list first before creating a new one. A worker pool also stores a a list of all "task owners" - a list of processes that we are serving currently.
Testing:
Create some qemu processes and attaching them to different cgroups. Verifying that new worker pools are created for tasks that are attached to different cgroups (and reuse for the ones that belong to the same).
Some simple performace testing using netperf below. Although, these numbers shouldn't be dependent on these patches. The cgroup attach and match functions are not in hot paths for general usage which is what this test does.
Netperf:
Two guests running netperf in parallel.
Without patches With patches
TCP_STREAM (10^6 bits/second) 975.45 978.88TCP_RR (Trans/second) 20121 18820.82UDP_STREAM (10^6 bits/second) 1287.82 1184.5UDP_RR (Trans/second) 20766.72 19667.08
Time a 4G iso download 2m 33 seconds 3m 02 seconds
Todo:
What about bounded workqueues ?
What happens when cgroups of a running process changes ? sysfs variables
Sanity check the flush and destroy path.
More extensive testing
Can we optimize the search/match/attach functions ?
Better performance numbers ? (although the onese above don't look bad)
Bandan Das (4):
cgroup: Introduce a function to compare two tasks
workqueue: introduce support for attaching to cgroups
cgroup: use spin_lock_irq for cgroup match and attach fns
vhost: use workqueues for the works
drivers/vhost/vhost.c | 103 ++++++++++++++++++--- drivers/vhost/vhost.h | 2 + include/linux/cgroup.h | 1 + include/linux/workqueue.h | 2 + kernel/cgroup.c | 40 ++++++++- kernel/workqueue.c | 212 +++++++++++++++++++++++++++++++++++++++++--- kernel/workqueue_internal.h | 4 + 7 files changed, 335 insertions(+), 29 deletions(-)
Signature · 1 line
2.5.0
Tejun Heo
maintainerHello,
Quoted 3 lines · Bandan Das
These changes don't populate the "numa awareness" fields/attrs and unlike unbounded numa worker pools, cgroup worker pools are created on demand. Every work request could potentially have a new cgroup
Hmmm... I don't get it. Why would this be exclusive with numa support? Can't cgroup be just another attribute in addition to numa?
Quoted 9 lines
aware pool created for it based on the combination of cgroups it's attached to. However, workqueues themselves are incognizant of the actual cgroups - they rely on the cgroups provided helper functions either for 1. a match of all the cgroups or 2. to attach a worker thread to all cgroups of a userspace task. We do maintain a list of cgroup aware pools so that when a new request comes in and a suitable worker pool needs to be found, we search the list first before creating a new one. A worker pool also stores a a list of all "task owners" - a list of processes that we are serving currently.
Why is this separate from the normal lookup mechanism? Can't it be hashed together?
Quoted 2 lines
Todo:
What about bounded workqueues ?
I don't think it'd matter. This is only interesting for work items which may consume a significant amount of resources, which shouldn't be served by per-cpu workers anyway.
Quoted 1 line
What happens when cgroups of a running process changes ?
Existing work items will be served with the old association. New work items will be served with the new association. This is consistent with how other attributes are handled too.
Quoted 1 line
Better performance numbers ? (although the onese above don't look bad)
Where is performance regression coming from? Why is there *any* performance penalty?
Thanks.
Signature · 1 line
tejun
Hi Bandan,
Quoted 3 lines
From: Bandan Das <[email protected]>
At Linuxcon last year, based on our presentation "vhost: sharing is
better" [1],
Quoted 1 line
we had briefly discussed the idea of cgroup aware workqueues with Tejun.
The
Quoted 1 line
following patches are a result of the discussion. They are in no way
complete in
Quoted 1 line
that the changes are for unbounded workqueues only, but I just wanted to
present my
Quoted 10 lines
unfinished work as RFC and get some feedback.
1/4 and 3/4 are simple cgroup changes and add a helper function. 2/4 is the main implementation.
4/4 changes vhost to use workqueues with support for cgroups.Example:
vhost creates a worker thread when invoked for a kvm guest. Since, the guest is a normal process, the kernel thread servicing it should be attached to the vm process' cgroups.
I did some performance evaluation of different threading models in vhost, and in most tests replacing vhost kthread's with workqueues degrades the performance. Moreover, having thread management inside the vhost provides opportunity for optimization, at least for some workloads... That said, I believe that switching vhost to use workqueues is not that good idea after all.
Quoted 3 lines
Netperf:
Two guests running netperf in parallel.
Without patches With
patches
Quoted 6 lines
TCP_STREAM(10^6 bits/second) 975.45 978.88TCP_RR(Trans/second) 20121 18820.82UDP_STREAM(10^6 bits/second) 1287.82 1184.5UDP_RR(Trans/second) 20766.72 19667.08
Time a 4G iso download 2m 33 seconds 3m 02 seconds
Hi Bandan,
Quoted 3 lines
From: Bandan Das <[email protected]>
At Linuxcon last year, based on our presentation "vhost: sharing is
better" [1],
Quoted 1 line
we had briefly discussed the idea of cgroup aware workqueues with Tejun.
The
Quoted 1 line
following patches are a result of the discussion. They are in no way
complete in
Quoted 1 line
that the changes are for unbounded workqueues only, but I just wanted to
present my
Quoted 10 lines
unfinished work as RFC and get some feedback.
1/4 and 3/4 are simple cgroup changes and add a helper function. 2/4 is the main implementation.
4/4 changes vhost to use workqueues with support for cgroups.Example:
vhost creates a worker thread when invoked for a kvm guest. Since, the guest is a normal process, the kernel thread servicing it should be attached to the vm process' cgroups.
I did some performance evaluation of different threading models in vhost, and in most tests replacing vhost kthread's with workqueues degrades the performance. Moreover, having thread management inside the vhost provides opportunity for optimization, at least for some workloads... That said, I believe that switching vhost to use workqueues is not that good idea after all.
Quoted 3 lines
Netperf:
Two guests running netperf in parallel.
Without patches With
patches
Quoted 6 lines
TCP_STREAM(10^6 bits/second) 975.45 978.88TCP_RR(Trans/second) 20121 18820.82UDP_STREAM(10^6 bits/second) 1287.82 1184.5UDP_RR(Trans/second) 20766.72 19667.08
Time a 4G iso download 2m 33 seconds 3m 02 seconds
--
Sincerely yours,
Mike.
On 03/18/2016 11:14 PM, Bandan Das wrote:
[..]
Quoted 9 lines
Netperf:
Two guests running netperf in parallel.
Without patches With patches
TCP_STREAM(10^6 bits/second) 975.45 978.88TCP_RR(Trans/second) 20121 18820.82UDP_STREAM(10^6 bits/second) 1287.82 1184.5UDP_RR(Trans/second) 20766.72 19667.08
Time a 4G iso download 2m 33 seconds 3m 02 seconds
So TCP stream stays the same everything else shows a regression? Not good. Have you an idea why this happens?
Quoted 9 lines · Tejun Heo
Hello,
Quoted 3 lines · Bandan Das
These changes don't populate the "numa awareness" fields/attrs and unlike unbounded numa worker pools, cgroup worker pools are created on demand. Every work request could potentially have a new cgroup
Hmmm... I don't get it. Why would this be exclusive with numa support? Can't cgroup be just another attribute in addition to numa?
Yes, I think it can. I am not certain what would be a good representation of the cgroup information; maybe, all cgroups could be represented by just a simple bitmap just like numa attrs ? The other thing that was on my mind is what happens when there's no intersection between the cgroups
of a task and the numa locality. For example, if node 1 with cpus 0,1,2,3 is local to task A but it's cgroups want to attach to cpus 4-5, then who wins in this case ? Or a simple logic would be to always attach to cgroups as the last step.
Quoted 13 lines
Quoted 9 lines
aware pool created for it based on the combination of cgroups it's attached to. However, workqueues themselves are incognizant of the actual cgroups - they rely on the cgroups provided helper functions either for 1. a match of all the cgroups or 2. to attach a worker thread to all cgroups of a userspace task. We do maintain a list of cgroup aware pools so that when a new request comes in and a suitable worker pool needs to be found, we search the list first before creating a new one. A worker pool also stores a a list of all "task owners" - a list of processes that we are serving currently.
Why is this separate from the normal lookup mechanism? Can't it be hashed together?
Quoted 6 lines
Quoted 2 lines
Todo:
What about bounded workqueues ?I don't think it'd matter. This is only interesting for work items which may consume a significant amount of resources, which shouldn't be served by per-cpu workers anyway.
Ok.
Quoted 5 lines
Quoted 1 line
What happens when cgroups of a running process changes ?
Existing work items will be served with the old association. New work items will be served with the new association. This is consistent with how other attributes are handled too.
In the current implementation, the cgroup info is fetched just once when alloc_workqueue is called. So, there's no way of knowing if the cgroups changed. Maybe I should rethink this too.
Quoted 4 lines
Quoted 1 line
Better performance numbers ? (although the onese above don't look bad)
Where is performance regression coming from? Why is there *any* performance penalty?
I am still investigating this but creating more worker threads could be one.
/* do we need to manage? */
if (unlikely(!may_start_working(pool)) && manage_workers(worker))
goto recheck; Since all work gets queued to the default pwq in this implementation, we do end up creating workers in the middle of a run.
Quoted 1 line
Thanks.
Quoted 18 lines · Michael Rapoport
Hi Bandan,
Quoted 3 lines
From: Bandan Das <[email protected]>
At Linuxcon last year, based on our presentation "vhost: sharing is
better" [1],
Quoted 1 line
we had briefly discussed the idea of cgroup aware workqueues with Tejun.
The
Quoted 1 line
following patches are a result of the discussion. They are in no way
complete in
Quoted 1 line
that the changes are for unbounded workqueues only, but I just wanted to
present my
Quoted 6 lines
unfinished work as RFC and get some feedback.
1/4 and 3/4 are simple cgroup changes and add a helper function. 2/4 is the main implementation.
4/4 changes vhost to use workqueues with support for cgroups.
Quoted 7 lines
Quoted 4 lines
Example:
vhost creates a worker thread when invoked for a kvm guest. Since, the guest is a normal process, the kernel thread servicing it should be attached to the vm process' cgroups.I did some performance evaluation of different threading models in vhost, and in most tests replacing vhost kthread's with workqueues degrades the
Workqueues us kthread_create internally and if calling one over the other impacts performace, I think we should investigate that. Which patches did you use ? Note that an earlier version of workqueue patches that I posted used per-cpu workqueues.
Quoted 1 line
performance. Moreover, having thread management inside the vhost provides
What exactly is the advantage doing our own thread management ? Do you have any examples ? (Besides for doing our own scheduling like in the original Elvis paper which I don't think is gonna happen). Also, note here that there is a possibility to affect how our work gets executed by using optional switches to alloc_workqueue() so all is not lost.
Quoted 23 lines
opportunity for optimization, at least for some workloads... That said, I believe that switching vhost to use workqueues is not that good idea after all.
Quoted 3 lines
Netperf:
Two guests running netperf in parallel.
Without patches Withpatches
Quoted 6 lines
TCP_STREAM(10^6 bits/second) 975.45 978.88TCP_RR(Trans/second) 20121 18820.82UDP_STREAM(10^6 bits/second) 1287.82 1184.5UDP_RR(Trans/second) 20766.72 19667.08
Time a 4G iso download 2m 33 seconds 3m 02 seconds--
Sincerely yours,
Mike.--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 6 lines · Christian Borntraeger
On 03/18/2016 11:14 PM, Bandan Das wrote:
[..]Quoted 4 lines
Netperf:
Two guests running netperf in parallel.
Without patches With patches
Quoted 8 lines
Quoted 5 lines
TCP_STREAM(10^6 bits/second) 975.45 978.88TCP_RR(Trans/second) 20121 18820.82UDP_STREAM(10^6 bits/second) 1287.82 1184.5UDP_RR(Trans/second) 20766.72 19667.08
Time a 4G iso download 2m 33 seconds 3m 02 secondsSo TCP stream stays the same everything else shows a regression? Not good. Have you an idea why this happens?
I am not sure yet but my guess is the way these patches implement cgroup support. I will run some tests just with workqueues (and without these patches) and see if the newer numbers are consistent with these.
vhost threading model (was: Re: [RFC PATCH 0/4] cgroup aware workqueues)
In reply to Bandan DasQuoted 10 lines
Bandan Das <[email protected]> wrote on 03/21/2016 07:43:41 PM:
Quoted 9 lines
"Michael Rapoport" <[email protected]> writes:
Hi Bandan,
Quoted 3 lines
From: Bandan Das <[email protected]>
At Linuxcon last year, based on our presentation "vhost: sharing is
better" [1],
Quoted 1 line
we had briefly discussed the idea of cgroup aware workqueues with
Tejun.
Quoted 4 lines
Quoted 4 lines
The
Quoted 1 line
following patches are a result of the discussion. They are in no way
complete in
Quoted 1 line
that the changes are for unbounded workqueues only, but I just wanted
to
Quoted 10 lines
Quoted 10 lines
present my
Quoted 9 lines
unfinished work as RFC and get some feedback.
1/4 and 3/4 are simple cgroup changes and add a helper function. 2/4 is the main implementation.
4/4 changes vhost to use workqueues with support for cgroups.Example:
vhost creates a worker thread when invoked for a kvm guest. Since, the guest is a normal process, the kernel thread servicing it should
be
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
attached to the vm process' cgroups.
I did some performance evaluation of different threading models in
vhost,
Quoted 1 line
Quoted 1 line
and in most tests replacing vhost kthread's with workqueues degrades
the
Quoted 3 lines
Workqueues us
kthread_createinternally and if calling one over the other impacts performace, I think we should investigate that.
Agree. Didn't have time to do it myself yet...
Quoted 1 line
Which patches did you use ? Note that an earlier version of workqueue
patches
Quoted 1 line
that I posted used per-cpu workqueues.
I've used your earlier version of workqueue patches, then I modified it to use unbound workqueues, and then I even restored to some extent original vhost workqueue usage. In all the cases I saw performance degradation relatively to the baseline.
Quoted 1 line
Quoted 1 line
performance. Moreover, having thread management inside the vhost
provides
Quoted 2 lines
What exactly is the advantage doing our own thread management ? Do you
have
Quoted 1 line
any examples ? (Besides for doing our own scheduling like in the
original Elvis
Quoted 1 line
paper which I don't think is gonna happen). Also, note here that there
is
Quoted 1 line
a possibility to affect how our work gets executed by using optional
switches to
Quoted 1 line
alloc_workqueue()so all is not lost.
Well, Elvis is a _theoretical_ example that showed that I/O scheduling in the vhost improves performance.
I'm not saying we should take Evlis and try to squeeze it into the vhost, I just want to say that we cannot switch vhost to use workqueues if it causes performance degradation.
My opinion is that we need to give it some more thought, much more performance evaluation, so that we can find the best model.
Quoted 2 lines
Quoted 2 lines
opportunity for optimization, at least for some workloads... That said, I believe that switching vhost to use workqueues is not
that
Quoted 2 lines
Quoted 2 lines
good idea after all.
vhost threading model (was: Re: [RFC PATCH 0/4] cgroup aware workqueues)
In reply to Bandan DasQuoted 10 lines
Bandan Das <[email protected]> wrote on 03/21/2016 07:43:41 PM:
Quoted 9 lines
"Michael Rapoport" <[email protected]> writes:
Hi Bandan,
Quoted 3 lines
From: Bandan Das <[email protected]>
At Linuxcon last year, based on our presentation "vhost: sharing is
better" [1],
Quoted 1 line
we had briefly discussed the idea of cgroup aware workqueues with
Tejun.
Quoted 4 lines
Quoted 4 lines
The
Quoted 1 line
following patches are a result of the discussion. They are in no way
complete in
Quoted 1 line
that the changes are for unbounded workqueues only, but I just wanted
to
Quoted 10 lines
Quoted 10 lines
present my
Quoted 9 lines
unfinished work as RFC and get some feedback.
1/4 and 3/4 are simple cgroup changes and add a helper function. 2/4 is the main implementation.
4/4 changes vhost to use workqueues with support for cgroups.Example:
vhost creates a worker thread when invoked for a kvm guest. Since, the guest is a normal process, the kernel thread servicing it should
be
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
attached to the vm process' cgroups.
I did some performance evaluation of different threading models in
vhost,
Quoted 1 line
Quoted 1 line
and in most tests replacing vhost kthread's with workqueues degrades
the
Quoted 3 lines
Workqueues us
kthread_createinternally and if calling one over the other impacts performace, I think we should investigate that.
Agree. Didn't have time to do it myself yet...
Quoted 1 line
Which patches did you use ? Note that an earlier version of workqueue
patches
Quoted 1 line
that I posted used per-cpu workqueues.
I've used your earlier version of workqueue patches, then I modified it to use unbound workqueues, and then I even restored to some extent original vhost workqueue usage. In all the cases I saw performance degradation relatively to the baseline.
Quoted 1 line
Quoted 1 line
performance. Moreover, having thread management inside the vhost
provides
Quoted 2 lines
What exactly is the advantage doing our own thread management ? Do you
have
Quoted 1 line
any examples ? (Besides for doing our own scheduling like in the
original Elvis
Quoted 1 line
paper which I don't think is gonna happen). Also, note here that there
is
Quoted 1 line
a possibility to affect how our work gets executed by using optional
switches to
Quoted 1 line
alloc_workqueue()so all is not lost.
Well, Elvis is a _theoretical_ example that showed that I/O scheduling in the vhost improves performance.
I'm not saying we should take Evlis and try to squeeze it into the vhost, I just want to say that we cannot switch vhost to use workqueues if it causes performance degradation.
My opinion is that we need to give it some more thought, much more performance evaluation, so that we can find the best model.
Quoted 2 lines
Quoted 2 lines
opportunity for optimization, at least for some workloads... That said, I believe that switching vhost to use workqueues is not
that
Quoted 2 lines
Quoted 2 lines
good idea after all.
--
Sincerely yours,
Mike.
Re: vhost threading model
"Michael Rapoport" <[email protected]> writes:
...
Quoted 9 lines
Well, Elvis is a _theoretical_ example that showed that I/O scheduling in the vhost improves performance.
I'm not saying we should take Evlis and try to squeeze it into the vhost, I just want to say that we cannot switch vhost to use workqueues if it causes performance degradation.My opinion is that we need to give it some more thought, much more performance evaluation, so that we can find the best model.
Exactly, I think we are outright discarding using workqueues even without investigating it in detail even though it would be a cleaner implementation using a common framework and thereby more chances of an acceptable solution for upstream.
Anyway, if we don't want to go the workqueues way for vhost, cgroups support for workqueues is still something worth having on its own.
Quoted 14 lines
Quoted 2 lines
Quoted 2 lines
opportunity for optimization, at least for some workloads... That said, I believe that switching vhost to use workqueues is not
that
Quoted 2 lines
Quoted 2 lines
good idea after all.
--
Sincerely yours,
Mike.--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: vhost threading model
Quoted 4 lines
Bandan Das <[email protected]> wrote on 03/22/2016 09:00:50 PM:
Quoted 3 lines
"Michael Rapoport" <[email protected]> writes:
Well, Elvis is a _theoretical_ example that showed that I/O scheduling
in
Quoted 2 lines
Quoted 2 lines
the vhost improves performance.
I'm not saying we should take Evlis and try to squeeze it into the
vhost,
Quoted 11 lines
Quoted 6 lines
I just want to say that we cannot switch vhost to use workqueues if it
causes performance degradation.
My opinion is that we need to give it some more thought, much more performance evaluation, so that we can find the best model.
Exactly, I think we are outright discarding using workqueues even without investigating it in detail even though it would be a cleaner implementation using a common framework and thereby more chances of an acceptable solution for upstream.
I'm not suggesting to discard using workqueues.
All I'm saying that among several options for vhost threading model we should find the one with best "performance/complexity" ratio :)
Quoted 2 lines
Anyway, if we don't want to go the workqueues way for vhost, cgroups support for workqueues is still something worth having on its own.
No objection to that.
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
opportunity for optimization, at least for some workloads... That said, I believe that switching vhost to use workqueues is not
that
Quoted 2 lines
Quoted 2 lines
good idea after all.
Re: vhost threading model
In reply to Bandan DasQuoted 4 lines
Bandan Das <[email protected]> wrote on 03/22/2016 09:00:50 PM:
Quoted 3 lines
"Michael Rapoport" <[email protected]> writes:
Well, Elvis is a _theoretical_ example that showed that I/O scheduling
in
Quoted 2 lines
Quoted 2 lines
the vhost improves performance.
I'm not saying we should take Evlis and try to squeeze it into the
vhost,
Quoted 11 lines
Quoted 6 lines
I just want to say that we cannot switch vhost to use workqueues if it
causes performance degradation.
My opinion is that we need to give it some more thought, much more performance evaluation, so that we can find the best model.
Exactly, I think we are outright discarding using workqueues even without investigating it in detail even though it would be a cleaner implementation using a common framework and thereby more chances of an acceptable solution for upstream.
I'm not suggesting to discard using workqueues.
All I'm saying that among several options for vhost threading model we should find the one with best "performance/complexity" ratio :)
Quoted 2 lines
Anyway, if we don't want to go the workqueues way for vhost, cgroups support for workqueues is still something worth having on its own.
No objection to that.
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
opportunity for optimization, at least for some workloads... That said, I believe that switching vhost to use workqueues is not
that
Quoted 2 lines
Quoted 2 lines
good idea after all.
Tejun Heo
maintainerHello,
Quoted 3 lines · Michael Rapoport
I did some performance evaluation of different threading models in vhost, and in most tests replacing vhost kthread's with workqueues degrades the performance. Moreover, having thread management inside the vhost provides
There really shouldn't be any difference when using unbound workqueues. workqueue becomes a convenience thing which manages worker pools and there shouldn't be any difference between workqueue workers and kthreads in terms of behavior.
Quoted 1 line
opportunity for optimization, at least for some workloads...
What sort of optimizations are we talking about?
Thanks.
Signature · 1 line
tejun
Hello,
Quoted 6 lines
Tejun Heo <[email protected]> wrote on 03/30/2016 08:04:19 PM:
Hello,
Quoted 1 line · Michael Rapoport
I did some performance evaluation of different threading models in
vhost,
Quoted 1 line
Quoted 1 line
and in most tests replacing vhost kthread's with workqueues degrades
the
Quoted 1 line
Quoted 1 line
performance. Moreover, having thread management inside the vhost
provides
Quoted 5 lines
There really shouldn't be any difference when using unbound workqueues. workqueue becomes a convenience thing which manages worker pools and there shouldn't be any difference between workqueue workers and kthreads in terms of behavior.
I agree that there really shouldn't be any performance difference, but the tests I've run show otherwise. I have no idea why and I hadn't time yet to investigate it.
Quoted 3 lines
Quoted 1 line
opportunity for optimization, at least for some workloads...
What sort of optimizations are we talking about?
Well, if we take Evlis (1) as for the theoretical base, there could be benefit of doing I/O scheduling inside the vhost.
[1] https://www.usenix.org/system/files/conference/atc13/atc13-harel.pdf
Quoted 4 lines
Thanks.
Signature · 1 line
tejun
Hello,
Quoted 6 lines
Tejun Heo <[email protected]> wrote on 03/30/2016 08:04:19 PM:
Hello,
Quoted 1 line · Michael Rapoport
I did some performance evaluation of different threading models in
vhost,
Quoted 1 line
Quoted 1 line
and in most tests replacing vhost kthread's with workqueues degrades
the
Quoted 1 line
Quoted 1 line
performance. Moreover, having thread management inside the vhost
provides
Quoted 5 lines
There really shouldn't be any difference when using unbound workqueues. workqueue becomes a convenience thing which manages worker pools and there shouldn't be any difference between workqueue workers and kthreads in terms of behavior.
I agree that there really shouldn't be any performance difference, but the tests I've run show otherwise. I have no idea why and I hadn't time yet to investigate it.
Quoted 3 lines
Quoted 1 line
opportunity for optimization, at least for some workloads...
What sort of optimizations are we talking about?
Well, if we take Evlis (1) as for the theoretical base, there could be benefit of doing I/O scheduling inside the vhost.
[1] https://www.usenix.org/system/files/conference/atc13/atc13-harel.pdf
Quoted 4 lines
Thanks.
Signature · 1 line
tejun
--
Sincerely yours,
Mike.
Tejun Heo
maintainerHello, Michael.
Quoted 8 lines · Michael Rapoport
Quoted 4 lines
There really shouldn't be any difference when using unbound workqueues. workqueue becomes a convenience thing which manages worker pools and there shouldn't be any difference between workqueue workers and kthreads in terms of behavior.
I agree that there really shouldn't be any performance difference, but the tests I've run show otherwise. I have no idea why and I hadn't time yet to investigate it.
I'd be happy to help digging into what's going on. If kvm wants full control over the worker thread, kvm can use workqueue as a pure threadpool. Schedule a work item to grab a worker thread with the matching attributes and keep using it as it'd a kthread. While that wouldn't be able to take advantage of work item flushing and so on, it'd still be a simpler way to manage worker threads and the extra stuff like cgroup membership handling doesn't have to be duplicated.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
opportunity for optimization, at least for some workloads...
What sort of optimizations are we talking about?
Well, if we take Evlis (1) as for the theoretical base, there could be benefit of doing I/O scheduling inside the vhost.
Yeah, if that actually is beneficial, take full control of the kworker thread.
Thanks.
Signature · 1 line
tejun
Quoted 22 lines · Tejun Heo
Hello, Michael.
Quoted 8 lines · Michael Rapoport
Quoted 4 lines
There really shouldn't be any difference when using unbound workqueues. workqueue becomes a convenience thing which manages worker pools and there shouldn't be any difference between workqueue workers and kthreads in terms of behavior.
I agree that there really shouldn't be any performance difference, but the tests I've run show otherwise. I have no idea why and I hadn't time yet to investigate it.
I'd be happy to help digging into what's going on. If kvm wants full control over the worker thread, kvm can use workqueue as a pure threadpool. Schedule a work item to grab a worker thread with the matching attributes and keep using it as it'd a kthread. While that wouldn't be able to take advantage of work item flushing and so on, it'd still be a simpler way to manage worker threads and the extra stuff like cgroup membership handling doesn't have to be duplicated.
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
opportunity for optimization, at least for some workloads...
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
What sort of optimizations are we talking about?
Well, if we take Evlis (1) as for the theoretical base, there could be benefit of doing I/O scheduling inside the vhost.
Yeah, if that actually is beneficial, take full control of the kworker thread.
Well, even if it actually is beneficial (which I am sure it is), it seems a little impractical to block current improvements based on a future prospect that (as far as I know), no one is working on ?
There have been discussions about this in the past and iirc, most people agree about not going the byos* route. But I am still all for such a proposal and if it's good/clean enough, I think we can definitely tear down what we have and throw it away! The I/O scheduling part is intrusive enough that even the current code base has to be changed quite a bit.
*byos = bring your own scheduling ;)
Quoted 1 line
Thanks.
Hi Tejun,
Quoted 11 lines
Tejun Heo <[email protected]> wrote on 03/31/2016 08:14:35 PM:
Hello, Michael.
Quoted 6 lines · Michael Rapoport
Quoted 4 lines
There really shouldn't be any difference when using unbound workqueues. workqueue becomes a convenience thing which manages worker pools and there shouldn't be any difference between workqueue workers and kthreads in terms of behavior.
I agree that there really shouldn't be any performance difference, but
the
Quoted 1 line
Quoted 1 line
tests I've run show otherwise. I have no idea why and I hadn't time
yet to
Quoted 9 lines
Quoted 1 line
investigate it.
I'd be happy to help digging into what's going on. If kvm wants full control over the worker thread, kvm can use workqueue as a pure threadpool. Schedule a work item to grab a worker thread with the matching attributes and keep using it as it'd a kthread. While that wouldn't be able to take advantage of work item flushing and so on, it'd still be a simpler way to manage worker threads and the extra stuff like cgroup membership handling doesn't have to be duplicated.
My concern is that we trade-off performance for simpler management of worker threads.
With the three models I've tested (current vhost models, workqueues-based
(1) and shared threads based (2)), workqueues-based ones gave the worst performance results :(
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line
opportunity for optimization, at least for some workloads...
What sort of optimizations are we talking about?
Quoted 8 lines
Quoted 3 lines
Well, if we take Evlis (1) as for the theoretical base, there could be
benefit of doing I/O scheduling inside the vhost.
Yeah, if that actually is beneficial, take full control of the kworker thread.
Thanks.
[1] http://thread.gmane.org/gmane.linux.network/286858
[2] http://thread.gmane.org/gmane.linux.kernel.cgroups/13808
Quoted 3 lines
Signature · 1 line
tejun
Hi Bandan,
Quoted 7 lines
Bandan Das <[email protected]> wrote on 03/31/2016 09:45:43 PM:
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
opportunity for optimization, at least for some workloads...
What sort of optimizations are we talking about?
Well, if we take Evlis (1) as for the theoretical base, there could
be
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
benefit of doing I/O scheduling inside the vhost.
Yeah, if that actually is beneficial, take full control of the kworker thread.
Well, even if it actually is beneficial (which I am sure it is), it
seems a
Quoted 1 line
little impractical to block current improvements based on a future
prospect
Quoted 1 line
that (as far as I know), no one is working on ?
I'm not suggesting to block current improvements based on a future prospect. But, unfortunately, there's regression rather than improvement with the results you've posted.
And, I thought you are working on comparing different approaches to vhost threading, like workqueues and shared vhost thread (1) ;-) Anyway, I'm working on this in a background, and, frankly, I cannot say I have a clear vision of the best route.
Quoted 1 line
There have been discussions about this in the past and iirc, most people
agree
Quoted 1 line
about not going the byos* route. But I am still all for such a proposal
and if
Quoted 1 line
it's good/clean enough, I think we can definitely tear down what we have
and
Quoted 1 line
throw it away! The I/O scheduling part is intrusive enough that even the
current
Quoted 1 line
code base has to be changed quite a bit.
The "byos" route seems more promising with respect to possible performance gains, but it will definitely add complexity, and I cannot say if the added complexity will be worth performance improvements.
Meanwhile, I'd suggest we better understand what causes regression with your current patches and maybe then we'll be smarter to get to the right direction. :)
Quoted 3 lines
*byos = bring your own scheduling ;)
Quoted 1 line
Thanks.
Hi Tejun,
Quoted 11 lines
Tejun Heo <[email protected]> wrote on 03/31/2016 08:14:35 PM:
Hello, Michael.
Quoted 6 lines · Michael Rapoport
Quoted 4 lines
There really shouldn't be any difference when using unbound workqueues. workqueue becomes a convenience thing which manages worker pools and there shouldn't be any difference between workqueue workers and kthreads in terms of behavior.
I agree that there really shouldn't be any performance difference, but
the
Quoted 1 line
Quoted 1 line
tests I've run show otherwise. I have no idea why and I hadn't time
yet to
Quoted 9 lines
Quoted 1 line
investigate it.
I'd be happy to help digging into what's going on. If kvm wants full control over the worker thread, kvm can use workqueue as a pure threadpool. Schedule a work item to grab a worker thread with the matching attributes and keep using it as it'd a kthread. While that wouldn't be able to take advantage of work item flushing and so on, it'd still be a simpler way to manage worker threads and the extra stuff like cgroup membership handling doesn't have to be duplicated.
My concern is that we trade-off performance for simpler management of worker threads.
With the three models I've tested (current vhost models, workqueues-based
(1) and shared threads based (2)), workqueues-based ones gave the worst performance results :(
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line
opportunity for optimization, at least for some workloads...
What sort of optimizations are we talking about?
Quoted 8 lines
Quoted 3 lines
Well, if we take Evlis (1) as for the theoretical base, there could be
benefit of doing I/O scheduling inside the vhost.
Yeah, if that actually is beneficial, take full control of the kworker thread.
Thanks.
[1] http://thread.gmane.org/gmane.linux.network/286858
[2] http://thread.gmane.org/gmane.linux.kernel.cgroups/13808
Quoted 3 lines
Signature · 1 line
tejun
Hi Bandan,
Quoted 7 lines
Bandan Das <[email protected]> wrote on 03/31/2016 09:45:43 PM:
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
opportunity for optimization, at least for some workloads...
What sort of optimizations are we talking about?
Well, if we take Evlis (1) as for the theoretical base, there could
be
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
benefit of doing I/O scheduling inside the vhost.
Yeah, if that actually is beneficial, take full control of the kworker thread.
Well, even if it actually is beneficial (which I am sure it is), it
seems a
Quoted 1 line
little impractical to block current improvements based on a future
prospect
Quoted 1 line
that (as far as I know), no one is working on ?
I'm not suggesting to block current improvements based on a future prospect. But, unfortunately, there's regression rather than improvement with the results you've posted.
And, I thought you are working on comparing different approaches to vhost threading, like workqueues and shared vhost thread (1) ;-) Anyway, I'm working on this in a background, and, frankly, I cannot say I have a clear vision of the best route.
Quoted 1 line
There have been discussions about this in the past and iirc, most people
agree
Quoted 1 line
about not going the byos* route. But I am still all for such a proposal
and if
Quoted 1 line
it's good/clean enough, I think we can definitely tear down what we have
and
Quoted 1 line
throw it away! The I/O scheduling part is intrusive enough that even the
current
Quoted 1 line
code base has to be changed quite a bit.
The "byos" route seems more promising with respect to possible performance gains, but it will definitely add complexity, and I cannot say if the added complexity will be worth performance improvements.
Meanwhile, I'd suggest we better understand what causes regression with your current patches and maybe then we'll be smarter to get to the right direction. :)
Quoted 3 lines
*byos = bring your own scheduling ;)
Quoted 1 line
Thanks.
--
Sincerely yours,
Mike.
...
Quoted 10 lines
Quoted 1 line
There have been discussions about this in the past and iirc, most people
agree
Quoted 1 line
about not going the byos* route. But I am still all for such a proposal
and if
Quoted 1 line
it's good/clean enough, I think we can definitely tear down what we have
and
Quoted 1 line
throw it away! The I/O scheduling part is intrusive enough that even the
current
Quoted 1 line
code base has to be changed quite a bit.
Quoted 8 lines
The "byos" route seems more promising with respect to possible performance gains, but it will definitely add complexity, and I cannot say if the added complexity will be worth performance improvements.
Meanwhile, I'd suggest we better understand what causes regression with your current patches and maybe then we'll be smarter to get to the right direction. :)
Agreed, let's try to understand the cause of the "underperformance" with wqs. I disabled WQ_CGROUPS that effectively disables my changes and I can still consistently reproduce the lower numbers.
Quoted 9 lines
Quoted 3 lines
*byos = bring your own scheduling ;)
Quoted 1 line
Thanks.
--
Sincerely yours,
Mike.
Quoted 11 lines
Tejun Heo <[email protected]> wrote on 03/31/2016 08:14:35 PM:
Hello, Michael.
Quoted 6 lines · Michael Rapoport
Quoted 4 lines
There really shouldn't be any difference when using unbound workqueues. workqueue becomes a convenience thing which manages worker pools and there shouldn't be any difference between workqueue workers and kthreads in terms of behavior.
I agree that there really shouldn't be any performance difference, but
the
Quoted 1 line
Quoted 1 line
tests I've run show otherwise. I have no idea why and I hadn't time
yet to
Quoted 12 lines
Quoted 1 line
investigate it.
I'd be happy to help digging into what's going on. If kvm wants full control over the worker thread, kvm can use workqueue as a pure threadpool. Schedule a work item to grab a worker thread with the matching attributes and keep using it as it'd a kthread. While that wouldn't be able to take advantage of work item flushing and so on, it'd still be a simpler way to manage worker threads and the extra stuff like cgroup membership handling doesn't have to be duplicated.
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
opportunity for optimization, at least for some workloads...
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
What sort of optimizations are we talking about?
Well, if we take Evlis (1) as for the theoretical base, there could be
benefit of doing I/O scheduling inside the vhost.
Yeah, if that actually is beneficial, take full control of the kworker thread.
It me took a while, but at last I had time to run some benchmarks. I've compared guest-to-guest netperf with 3 variants of vhost implementation:
(1) vanilla 4.4 (baseline)
(2) 4.4 + unbound workqueues based on Bandans patches [1]
(3) 4.4 + "grabbed" worker thread. This is my POC implementation that actually follows your proposal to take full control over the worker thread.
I've run two guests without any CPU pinning and without any actual interaction with cgroups
Here's the results (in MBits/sec):
size | 64 | 256 | 1024 | 4096 | 16384
-----+-------+---------+---------+---------+---------
(1) | 496.8 | 1346.31 | 6058.49 | 13736.2 | 13541.4 (2) | 493.3 | 1604.03 | 5723.68 | 10181.4 | 15572.4 (3) | 489.7 | 1437.86 | 6251.12 | 12774.2 | 12867.9
Quoted 1 line
From what I see, for different packet sizes there's different approach
that outperforms the others.
Moreover, I'd expect that in case when vhost completely takes over the worker thread there would no be difference vs. current state.
Tejun, can you help explaining these results?
Quoted 11 lines
Tejun Heo <[email protected]> wrote on 03/31/2016 08:14:35 PM:
Hello, Michael.
Quoted 6 lines · Michael Rapoport
Quoted 4 lines
There really shouldn't be any difference when using unbound workqueues. workqueue becomes a convenience thing which manages worker pools and there shouldn't be any difference between workqueue workers and kthreads in terms of behavior.
I agree that there really shouldn't be any performance difference, but
the
Quoted 1 line
Quoted 1 line
tests I've run show otherwise. I have no idea why and I hadn't time
yet to
Quoted 12 lines
Quoted 1 line
investigate it.
I'd be happy to help digging into what's going on. If kvm wants full control over the worker thread, kvm can use workqueue as a pure threadpool. Schedule a work item to grab a worker thread with the matching attributes and keep using it as it'd a kthread. While that wouldn't be able to take advantage of work item flushing and so on, it'd still be a simpler way to manage worker threads and the extra stuff like cgroup membership handling doesn't have to be duplicated.
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
opportunity for optimization, at least for some workloads...
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
What sort of optimizations are we talking about?
Well, if we take Evlis (1) as for the theoretical base, there could be
benefit of doing I/O scheduling inside the vhost.
Yeah, if that actually is beneficial, take full control of the kworker thread.
It me took a while, but at last I had time to run some benchmarks. I've compared guest-to-guest netperf with 3 variants of vhost implementation:
(1) vanilla 4.4 (baseline)
(2) 4.4 + unbound workqueues based on Bandans patches [1]
(3) 4.4 + "grabbed" worker thread. This is my POC implementation that actually follows your proposal to take full control over the worker thread.
I've run two guests without any CPU pinning and without any actual interaction with cgroups
Here's the results (in MBits/sec):
size | 64 | 256 | 1024 | 4096 | 16384
-----+-------+---------+---------+---------+---------
(1) | 496.8 | 1346.31 | 6058.49 | 13736.2 | 13541.4 (2) | 493.3 | 1604.03 | 5723.68 | 10181.4 | 15572.4 (3) | 489.7 | 1437.86 | 6251.12 | 12774.2 | 12867.9
Quoted 1 line
From what I see, for different packet sizes there's different approach
that outperforms the others.
Moreover, I'd expect that in case when vhost completely takes over the worker thread there would no be difference vs. current state.
Tejun, can you help explaining these results?
Tejun Heo
maintainerQuoted 11 lines · Michael Rapoport
I've run two guests without any CPU pinning and without any actual interaction with cgroups
Here's the results (in MBits/sec):size | 64 | 256 | 1024 | 4096 | 16384
-----+-------+---------+---------+---------+---------(1) | 496.8 | 1346.31 | 6058.49 | 13736.2 | 13541.4 (2) | 493.3 | 1604.03 | 5723.68 | 10181.4 | 15572.4 (3) | 489.7 | 1437.86 | 6251.12 | 12774.2 | 12867.9
Quoted 6 lines
From what I see, for different packet sizes there's different approach that outperforms the others.
Moreover, I'd expect that in case when vhost completely takes over the worker thread there would no be difference vs. current state.Tejun, can you help explaining these results?
Heh, the only thing I can tell is the tests seem noisy and weren't run enough times to draw any conclusion. Even if the numbers were consistent, I don't think anybody would be able to tell a lot from just the results. If the results can be made stable, perf would be a good place to start.
Thanks.
Signature · 1 line
tejun