public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrea Arcangeli <andrea@qumranet.com>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Avi Kivity <avi@qumranet.com>, kvm-devel <kvm@vger.kernel.org>
Subject: Re: KVM: MMU: rmap_write_protect() hugepage iteration bug
Date: Sun, 8 Jun 2008 20:31:19 +0200	[thread overview]
Message-ID: <20080608183119.GA21835@duo.random> (raw)
In-Reply-To: <20080608044853.GA1408@dmt.cnet>

On Sun, Jun 08, 2008 at 01:48:53AM -0300, Marcelo Tosatti wrote:
> > writeable sptes (I did exactly the same mistake once).
> 
> Why not posting it at the time?

See the comments in the mail I posted a few days ago with subject
"[patch] kvm with mmu notifier v18". I posted the incompatibility with
rmap_next and rmap_remove in the same loop, the day after I fixed it
in ksm.

> This makes no difference since rmap_next() still can't handle the case
> where rmap_remove() left a single entry in the array and "spte" has been
> passed as non-NULL:

I don't see the problem, with the fixed code we never pass spte
not-NULL after any rmap_remove run.

> How bad you think restarting is? Unless there are workloads with very

It probably worth to optimize it with rmap_next_safe in the long run,
but it may not be urgent as it may be lost in the noise even if the
chains are fairly long. To be sure you could try to profile it and see
if rmap_write_protect goes up in the opreport.

> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
> index aaccc40..d01d098 100644
> --- a/arch/x86/kvm/mmu.c
> +++ b/arch/x86/kvm/mmu.c
> @@ -640,6 +640,7 @@ static void rmap_write_protect(struct kvm *kvm, u64
> gfn)
>                         rmap_remove(kvm, spte);
>                         --kvm->stat.lpages;
>                         set_shadow_pte(spte,shadow_trap_nonpresent_pte);
> +                       spte = NULL;
>                         write_protected = 1;
>                 }
>                 spte = rmap_next(kvm, rmapp, spte);

This is shorter and functionally equivalent to my proposed fix, so you
seem to agree this makes a difference by posting this patch, and I
sure agree with the above fix too!

  parent reply	other threads:[~2008-06-08 18:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-08  0:27 KVM: MMU: rmap_write_protect() hugepage iteration bug Marcelo Tosatti
2008-06-08  1:54 ` Andrea Arcangeli
2008-06-08  4:48   ` Marcelo Tosatti
2008-06-08  7:30     ` Avi Kivity
2008-06-08  8:03       ` Avi Kivity
2008-06-08  8:04         ` Avi Kivity
2008-06-08 18:31     ` Andrea Arcangeli [this message]
2008-06-08 19:52       ` Marcelo Tosatti
2008-06-08 20:30         ` Andrea Arcangeli
2008-06-09  0:20           ` Marcelo Tosatti
2008-06-09  0:55             ` Andrea Arcangeli

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=20080608183119.GA21835@duo.random \
    --to=andrea@qumranet.com \
    --cc=avi@qumranet.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    /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