From: Takuya Yoshikawa <takuya.yoshikawa@gmail.com>
To: Avi Kivity <avi@redhat.com>
Cc: mtosatti@redhat.com, kvm@vger.kernel.org, yoshikawa.takuya@oss.ntt.co.jp
Subject: Re: [PATCH 1/1 v2] KVM: Reduce mmu_lock contention during dirty logging by cond_resched()
Date: Sun, 29 Apr 2012 23:24:07 +0900 [thread overview]
Message-ID: <20120429232407.684da454a0862f121754a126@gmail.com> (raw)
In-Reply-To: <4F9D3B26.7090602@redhat.com>
On Sun, 29 Apr 2012 15:59:18 +0300
Avi Kivity <avi@redhat.com> wrote:
> > As we discussed before, we need to add some tricks to de-couple mmu_lock and
> > TLB flush.
>
> Ok, let's discuss them (we can apply the patch independently). Do you
> have something in mind?
>
How about your own idea?
http://www.spinics.net/lists/kvm/msg68550.html
===
> > How about something like a sequence lock:
> >
> >
> > spin_lock(mmu_lock)
> > need_flush = write_protect_stuff();
> > atomic_add(kvm->want_flush_counter, need_flush);
> > spin_unlock(mmu_lock);
> >
> > while ((done = atomic_read(kvm->done_flush_counter)) < (want =
> > atomic_read(kvm->want_flush_counter)) {
> > kvm_make_request(flush)
> > atomic_cmpxchg(kvm->done_flush_counter, done, want)
> > }
> >
> > This (or maybe a corrected and optimized version) ensures that any
> > need_flush cannot pass the while () barrier, no matter which thread
> > encounters it first. However it violates the "do not invent new locking
> > techniques" commandment. Can we map it to some existing method?
>
> There is no need to advance 'want' in the loop. So we could do
>
> /* must call with mmu_lock held */
> void kvm_mmu_defer_remote_flush(kvm, need_flush)
> {
> if (need_flush)
> ++kvm->flush_counter.want;
> }
>
> /* may call without mmu_lock */
> void kvm_mmu_commit_remote_flush(kvm)
> {
> want = ACCESS_ONCE(kvm->flush_counter.want)
> while ((done = atomic_read(kvm->flush_counter.done) < want) {
> kvm_make_request(flush)
> atomic_cmpxchg(kvm->flush_counter.done, done, want)
> }
> }
===
Takuya
next prev parent reply other threads:[~2012-04-29 14:24 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-28 10:05 [PATCH 0/1 v2] KVM: Alleviate mmu_lock contention during dirty logging Takuya Yoshikawa
2012-04-28 10:07 ` [PATCH 1/1 v2] KVM: Reduce mmu_lock contention during dirty logging by cond_resched() Takuya Yoshikawa
2012-04-29 11:27 ` Avi Kivity
2012-04-29 12:17 ` Takuya Yoshikawa
2012-04-29 12:59 ` Avi Kivity
2012-04-29 14:24 ` Takuya Yoshikawa [this message]
2012-04-29 14:39 ` Avi Kivity
2012-04-29 14:55 ` Takuya Yoshikawa
2012-04-29 15:00 ` Avi Kivity
2012-04-29 15:13 ` Takuya Yoshikawa
2012-04-29 15:20 ` Avi Kivity
2012-04-30 14:06 ` Takuya Yoshikawa
2012-05-01 3:04 ` Marcelo Tosatti
2012-05-01 13:14 ` Takuya Yoshikawa
2012-05-01 3:07 ` Marcelo Tosatti
2012-05-02 11:24 ` Heavy memory_region_get_dirty() -- Re: [PATCH 0/1 v2] KVM: Alleviate mmu_lock contention during dirty logging Takuya Yoshikawa
2012-05-02 11:33 ` Avi Kivity
2012-05-02 14:20 ` Takuya Yoshikawa
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=20120429232407.684da454a0862f121754a126@gmail.com \
--to=takuya.yoshikawa@gmail.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=yoshikawa.takuya@oss.ntt.co.jp \
/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