From owner-freebsd-current@FreeBSD.ORG Tue Aug 16 05:30:28 2011 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C0BA1106564A for ; Tue, 16 Aug 2011 05:30:28 +0000 (UTC) (envelope-from silby@silby.com) Received: from relay01.pair.com (relay01.pair.com [209.68.5.15]) by mx1.freebsd.org (Postfix) with SMTP id 684718FC12 for ; Tue, 16 Aug 2011 05:30:28 +0000 (UTC) Received: (qmail 31785 invoked by uid 0); 16 Aug 2011 05:03:45 -0000 Received: from 66.41.4.180 (HELO ?192.168.1.195?) (66.41.4.180) by relay01.pair.com with SMTP; 16 Aug 2011 05:03:45 -0000 X-pair-Authenticated: 66.41.4.180 Date: Tue, 16 Aug 2011 00:03:44 -0500 (CDT) From: Mike Silbersack X-X-Sender: silby@telemachus.local To: freebsd-current@freebsd.org Message-ID: User-Agent: Alpine 2.00 (OSX 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII Cc: jkim@freebsd.org Subject: [patch] Disable TSC on SMP VMs X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Aug 2011 05:30:28 -0000 Hi all, Thanks to a lightning strike, I recently upgraded my ESXi 4.1 system from an old Athlon X2 to a shiny new Core i5-2500K. I order to see how fast it was, I decided to run some buildworlds. I tried my FreeBSD 9 based VM first, and was unhappy with what I saw - many mpt timeouts were reported, and the filesystem ended up requiring a lot of fscking. My FreeBSD 8 based VM, on the other hand, was quite happy. After some trial and error, I determined that using the TSC as a timecounter with the VM in SMP mode was the root cause. If I switch the VM to one vCPU and run with the TSC, the buildworld runs fine. If I leave it with two vCPUs and change the timecounter to ACPI, then it runs fine too. Based on these results, I created the attached patch; it turns the priority of the TSC down to -100 if it determines that it is running inside a virtualized SMP environment. (I did not do testing on KVM or qemu, but I am assuming that they probably do not have TSC emulation perfect either.) I'd like to get this into 9.0 so that it works reliably for people who run it in a virtual environment on modern hardware. If someone could code review the patch, I would greatly appreciate it. Thanks, Mike "Silby" Silbersack