From: Asias He <asias.hejun@gmail.com>
To: Sasha Levin <levinsasha928@gmail.com>
Cc: Pekka Enberg <penberg@kernel.org>,
Cyrill Gorcunov <gorcunov@gmail.com>, Ingo Molnar <mingo@elte.hu>,
kvm@vger.kernel.org
Subject: Re: [PATCH] kvm tools: Process virito blk requests in separate thread
Date: Wed, 30 Nov 2011 15:21:58 +0800 [thread overview]
Message-ID: <4ED5D996.1070408@gmail.com> (raw)
In-Reply-To: <1322577409.7003.7.camel@lappy>
On 11/29/2011 10:36 PM, Sasha Levin wrote:
> On Tue, 2011-11-29 at 22:28 +0800, Asias He wrote:
>> Currently, all blk requests are processed in notify_vq() which is in
>> the context of ioeventfd thread: ioeventfd__thread(). The processing
>> in notify_vq() may take a long time to complete.
>>
>> We should make notify_vq() return as soon as possible, since all devices
>> are sharing the single ioeventfd thread. Otherwise, it will block other
>> device's notify_vq() being called and starve other devices.
>>
>> In virtio net's notify_vq(), we simply signal the tx/rx handle thread
>> and return.
>
> Why not use the threadpool?
No.
1) In thread pool model, each job handling operation:
thread_pool__do_job() takes about 6 or 7 mutex_{lock,unlock} ops. Most
of the mutex are global (job_mutex) which are contented by the threads
in the pool. It's fine for the non performance critical virtio devices,
such as console, rng, etc. But it's not optimal for net and blk devices.
2) Using dedicated threads to handle blk requests opens the door for
user to set different IO priority for the blk threads.
3) It also reduces the contentions between net and blk devices if they
do not share the thead pool.
--->> the thread pool lock flow <<---
thread_pool__do_job() {
mutex_lock(&jobinfo->mutex);
if (jobinfo->signalcount++ == 0)
thread_pool__job_push_locked(job) {
mutex_lock(&job_mutex);
thread_pool__job_push(job);
mutex_unlock(&job_mutex);
}
mutex_unlock(&jobinfo->mutex);
mutex_lock(&job_muex);
pthread_cond_signal(&job_cond);
mutex_unlock(&job_mutex);
}
thread_pool__threadfunc()
{
for (;;) {
mutex_lock(&job_mutex);
pthread_cond_wait(&job_cond, &job_mutex);
mutex_unlock(&job_mutex);
if (curjob)
thread_pool__handle_job(curjob);
}
}
thread_pool__handle_job()
{
while (job) {
job->callback(job->kvm, job->data);
mutex_lock(&job->mutex);
thread_pool__job_push_locked(job);
mutex_unlock(&job->mutex);
job = thread_pool__job_pop_locked();
}
}
--
Asias He
next prev parent reply other threads:[~2011-11-30 7:23 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-29 14:28 [PATCH] kvm tools: Process virito blk requests in separate thread Asias He
2011-11-29 14:36 ` Sasha Levin
2011-11-30 7:21 ` Asias He [this message]
2011-12-01 8:48 ` Pekka Enberg
2011-12-01 8:58 ` Sasha Levin
2011-12-01 10:45 ` Pekka Enberg
-- strict thread matches above, loose matches on Subject: below --
2012-06-04 15:40 Asias He
2012-06-04 15:48 ` Cyrill Gorcunov
2012-06-05 0:47 ` Asias He
2012-06-05 6:10 ` Cyrill Gorcunov
2012-06-04 16:07 ` Sasha Levin
2012-06-05 1:03 ` Asias He
2012-06-05 8:14 ` Pekka Enberg
2012-06-06 12:35 ` Paolo Bonzini
2012-06-07 1:38 ` Asias He
2012-06-07 8:47 ` Paolo Bonzini
2012-06-08 3:30 ` Asias He
2012-06-05 8:15 ` Pekka Enberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4ED5D996.1070408@gmail.com \
--to=asias.hejun@gmail.com \
--cc=gorcunov@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=levinsasha928@gmail.com \
--cc=mingo@elte.hu \
--cc=penberg@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).