lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1260850127-9766-14-git-send-email-zamsden@redhat.com>
Date:	Mon, 14 Dec 2009 18:08:40 -1000
From:	Zachary Amsden <zamsden@...hat.com>
To:	kvm@...r.kernel.org
Cc:	Zachary Amsden <zamsden@...hat.com>, Avi Kivity <avi@...hat.com>,
	Marcelo Tosatti <mtosatti@...hat.com>,
	Joerg Roedel <joerg.roedel@....com>,
	linux-kernel@...r.kernel.org, Dor Laor <dlaor@...hat.com>
Subject: [PATCH RFC: kvm tsc virtualization 13/20] Combine observed TSC deviation into moving average

Signed-off-by: Zachary Amsden <zamsden@...hat.com>
---
 arch/x86/kvm/x86.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index c66dede..8bd362b 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -914,6 +914,7 @@ static void sync_tsc_helper(int measure_cpu, s64 *delta, atomic_t *ready)
 /*
  * Average and trim the samples of any outliers; we use > 2 x sigma
  */
+static u64 tsc_deviation;
 static s64 average_samples(s64 *samples, unsigned num_samples)
 {
 	unsigned i, j;
@@ -936,6 +937,11 @@ static s64 average_samples(s64 *samples, unsigned num_samples)
 	stddev = stddev / (num_samples - 1);
 	stddev = int_sqrt(stddev);
 
+	/* Accumulate deviation measurement into a moving average */
+	tsc_deviation = tsc_deviation ?
+		((tsc_deviation << 4) - tsc_deviation + stddev) >> 4 :
+		stddev;
+
 	/* Throw out anything outside 2x stddev */
 	stddev <<= 1;
 	average = 0, j = 0;
@@ -950,10 +956,12 @@ static s64 average_samples(s64 *samples, unsigned num_samples)
 	}
 	if (j > 0)
 		average = average / j;
-	else
+	else {
 		printk(KERN_ERR "kvm: TSC samples failed to converge!\n");
-	pr_debug("%s: mean = %lld, stddev = %llu, average = %lld\n",
-		 __func__, mean, stddev, average);
+		average = mean;
+	}
+	pr_debug("%s: mean=%lld, stddev=%llu, average=%lld hdev=%llu\n",
+		 __func__, mean, stddev, average, tsc_deviation);
 
 	return average;
 }
-- 
1.6.5.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ