From: Marcelo Tosatti <mtosatti@redhat.com>
To: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Cc: avi@redhat.com, kvm@vger.kernel.org, takuya.yoshikawa@gmail.com
Subject: Re: [RFC PATCH] KVM: Fix __set_bit() race in mark_page_dirty() during dirty logging
Date: Mon, 9 Jan 2012 10:17:03 -0200 [thread overview]
Message-ID: <20120109121703.GF5255@amt.cnet> (raw)
In-Reply-To: <20120104150643.4395fe54.yoshikawa.takuya@oss.ntt.co.jp>
On Wed, Jan 04, 2012 at 03:06:43PM +0900, Takuya Yoshikawa wrote:
> It is possible that the __set_bit() in mark_page_dirty() is called
> simultaneously on the same region of memory, which may result in only
> one bit being set, because some callers do not take mmu_lock before
> mark_page_dirty().
>
> This problem is hard to produce because when we reach mark_page_dirty()
> beginning from, e.g., tdp_page_fault(), mmu_lock is being held during
> __direct_map(): making kvm-unit-tests' dirty log api test write to two
> pages concurrently was not useful for this reason.
>
> So we have confirmed that there can actually be race condition by
> checking if some callers really reach there without holding mmu_lock
> using spin_is_locked(): probably they were from kvm_write_guest_page().
>
> To fix this race, this patch changes the bit operation to the atomic
> version: note that nr_dirty_pages also suffers from the race but we do
> not need exactly correct numbers for now.
>
> Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Applied, thanks.
prev parent reply other threads:[~2012-01-09 12:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-04 6:06 [RFC PATCH] KVM: Fix __set_bit() race in mark_page_dirty() during dirty logging Takuya Yoshikawa
2012-01-05 11:48 ` Marcelo Tosatti
2012-01-05 14:11 ` Takuya Yoshikawa
2012-01-09 12:17 ` Marcelo Tosatti [this message]
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=20120109121703.GF5255@amt.cnet \
--to=mtosatti@redhat.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=takuya.yoshikawa@gmail.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