All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nikola Ciprich <extmaillist@linuxbox.cz>
To: Zachary Amsden <zamsden@redhat.com>
Cc: Avi Kivity <avi@redhat.com>,
	Nikola Ciprich <nikola.ciprich@linuxbox.cz>,
	KVM list <kvm@vger.kernel.org>,
	Linux kernel list <linux-kernel@vger.kernel.org>
Subject: Re: regression - 2.6.36 -> 2.6.37 - kvm - 32bit SMP guests don't boot
Date: Sun, 27 Feb 2011 18:20:52 +0100	[thread overview]
Message-ID: <20110227172052.GB2474@nik-comp.lan> (raw)
In-Reply-To: <4D67C077.6060108@redhat.com>

> I was not aware of the thread.  Please cc me directly, or add a keyword  
> I track - timekeeping, TSC..
Hello Zachary, thanks for Your time looking at this!
> That change alone may not bisect well; without further fixes on top of  
> it, you may end up with a hang or stall, which is likely to manifest in  
> a vendor-specific way.
I'm not sure I really understand You here, but this change is exactly to
what I got while bisecting. With later revisions, including this one,
32bit SMP guests don't boot, before it, they do..
>
> Basically there were a few differences in the platform code about how  
> TSC was dealt with on systems which did not have stable clocks, this  
> brought the logic into one location, but there was a slight change to  
> the logic here.
>
> Note very carefully, the logic on SVM is gated by a condition before  
> this change:
>
>         if (unlikely(cpu != vcpu->cpu)) {
> -               u64 delta;
> -
> -               if (check_tsc_unstable()) {
> -                       /*
> -                        * Make sure that the guest sees a monotonically
> -                        * increasing TSC.
> -                        */
> -                       delta = vcpu->arch.host_tsc - native_read_tsc();
> -                       svm->vmcb->control.tsc_offset += delta;
> -                       if (is_nested(svm))
> -                               svm->nested.hsave->control.tsc_offset +=  
> delta;
> -               }
> -               vcpu->cpu = cpu;
> -               kvm_migrate_timers(vcpu);
>
>
> So this only happens with a system which reports TSC as unstable.  After  
> the change, KVM itself may report the TSC as unstable:
>
> +       if (unlikely(vcpu->cpu != cpu)) {
> +               /* Make sure TSC doesn't go backwards */
> +               s64 tsc_delta = !vcpu->arch.last_host_tsc ? 0 :
> +                               native_read_tsc() -  
> vcpu->arch.last_host_tsc;
> +               if (tsc_delta < 0)
> +                       mark_tsc_unstable("KVM discovered backwards TSC");
> +               if (check_tsc_unstable())
> +                       kvm_x86_ops->adjust_tsc_offset(vcpu, -tsc_delta);
> +               kvm_migrate_timers(vcpu);
> +               vcpu->cpu = cpu;
> +       }
>
> If the platform has very small TSC deltas across CPUs, but indicates the  
> TSC is stable, this could result in KVM marking the TSC unstable.  If  
> that is the case, this compensation logic will kick in to avoid  
> backwards TSCs.
>
> Note however, that the logic is not perfect; time which passes while not  
> running on any CPU will be erased, as the delta compensation removes not  
> just backwards, but any elapsed time from the TSC.  In extreme cases,  
> this could result in time appearing to stand still.... with guests  
> failing to boot.
>
> This was addressed with a later change, which catches up the missing time:
>
> commit c285545f813d7b0ce989fd34e42ad1fe785dc65d
yes, but this change is already included in 2.6.37, so maybe some other fix is needed?
if You have some idea what could be changed, I'll gladly test whatever You recommend,
but I'm afraid that's all I can do, since this is a bit of a rocket science for me, sorry :(
nik




> Author: Zachary Amsden <zamsden@redhat.com>
> Date:   Sat Sep 18 14:38:15 2010 -1000
>
>     KVM: x86: TSC catchup mode
>
>     Negate the effects of AN TYM spell while kvm thread is preempted by  
> tracking
>     conversion factor to the highest TSC rate and catching the TSC up  
> when it has
>     fallen behind the kernel view of time.  Note that once triggered, we 
> don't
>     turn off catchup mode.
>
>     A slightly more clever version of this is possible, which only does  
> catchup
>     when TSC rate drops, and which specifically targets only CPUs with  
> broken
>     TSC, but since these all are considered unstable_tsc(), this patch  
> covers
>     all necessary cases.
>
>     Signed-off-by: Zachary Amsden <zamsden@redhat.com>
>     Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

-- 
-------------------------------------
Ing. Nikola CIPRICH
LinuxBox.cz, s.r.o.
28. rijna 168, 709 01 Ostrava

tel.:   +420 596 603 142
fax:    +420 596 621 273
mobil:  +420 777 093 799

www.linuxbox.cz

mobil servis: +420 737 238 656
email servis: servis@linuxbox.cz
-------------------------------------

  reply	other threads:[~2011-02-27 17:21 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-23 23:42 regression - 2.6.36 -> 2.6.37 - kvm - 32bit SMP guests don't boot Nikola Ciprich
2011-02-24 10:17 ` Avi Kivity
2011-02-24 10:48   ` Nikola Ciprich
2011-02-24 10:52     ` Avi Kivity
2011-02-24 11:27       ` Nikola Ciprich
2011-02-24 12:26         ` Avi Kivity
2011-02-24 12:41           ` Nikola Ciprich
2011-02-24 12:51             ` Avi Kivity
2011-02-24 12:57               ` Nikola Ciprich
2011-02-25 10:48                 ` Nikola Ciprich
2011-02-25 14:45                   ` Zachary Amsden
2011-02-27 17:20                     ` Nikola Ciprich [this message]
2011-02-28 13:51                       ` Zachary Amsden
2011-02-28 14:32                         ` Nikola Ciprich
2011-02-28 15:17                           ` Zachary Amsden
2011-02-28 15:28                             ` Nikola Ciprich
2011-02-28 15:56                               ` Zachary Amsden
2011-02-28 17:13                                 ` Nikola Ciprich
2011-02-28 17:15                                 ` Nikola Ciprich
2011-03-03  1:56                                   ` Zachary Amsden
2011-03-03  7:06                                     ` Nikola Ciprich
2011-03-03 20:47                                       ` Zachary Amsden
2011-03-03 21:06                                         ` Nikola Ciprich
2011-03-03 21:58                                           ` Zachary Amsden
2011-03-03 22:01                                             ` Nikola Ciprich
2011-03-04 15:13                                               ` Zachary Amsden
2011-03-04 18:27                                                 ` Nikola Ciprich
2011-03-04 19:09                                                   ` Glauber Costa
2011-03-04 20:55                                                     ` Nikola Ciprich
2011-03-04 21:41                                                       ` Glauber Costa
2011-03-04 22:36                                                         ` Nikola Ciprich
2011-03-04 22:59                                                           ` Zachary Amsden
2011-03-05  1:17                                                           ` Zachary Amsden
2011-03-05  7:21                                                             ` Nikola Ciprich
2011-03-06 14:53                                                               ` Zachary Amsden
2011-03-06 16:03                                                                 ` Nikola Ciprich
2011-03-04 22:57                                                     ` Zachary Amsden

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=20110227172052.GB2474@nik-comp.lan \
    --to=extmaillist@linuxbox.cz \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nikola.ciprich@linuxbox.cz \
    --cc=zamsden@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.