From owner-freebsd-virtualization@FreeBSD.ORG Mon Apr 21 17:39:16 2014 Return-Path: Delivered-To: freebsd-virtualization@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 781ABBCD; Mon, 21 Apr 2014 17:39:16 +0000 (UTC) Received: from alto.onthenet.com.au (alto.OntheNet.com.au [203.13.68.12]) by mx1.freebsd.org (Postfix) with ESMTP id 3A97C1155; Mon, 21 Apr 2014 17:39:15 +0000 (UTC) Received: from dommail.onthenet.com.au (dommail.OntheNet.com.au [203.13.70.57]) by alto.onthenet.com.au (Postfix) with ESMTPS id D109312451; Tue, 22 Apr 2014 03:39:13 +1000 (EST) Received: from Peter-Grehans-MacBook-Pro-2.local (c-174-51-225-141.hsd1.co.comcast.net [174.51.225.141]) by dommail.onthenet.com.au (MOS 4.2.4-GA) with ESMTP id BTN62243 (AUTH peterg@ptree32.com.au); Tue, 22 Apr 2014 03:39:11 +1000 Message-ID: <535557BC.8030300@freebsd.org> Date: Mon, 21 Apr 2014 11:39:08 -0600 From: Peter Grehan User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: Roman Bogorodskiy Subject: Re: Understanding CPU and memory usage in Bhyve References: <20140421102138.GA6157@kloomba> In-Reply-To: <20140421102138.GA6157@kloomba> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-virtualization@FreeBSD.org X-BeenThere: freebsd-virtualization@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "Discussion of various virtualization techniques FreeBSD supports." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Apr 2014 17:39:16 -0000 Hi Roman, > For the CPU, there's some info provided by bhyvectl, e.g.: > > /usr/sbin/bhyvectl --vm=bhyve --get-stats --cpu=1 > > in the field 'vcpu total runtime', for example: > > vcpu total runtime 8178870653 > > Two question about that: > > 1. What are the units used here? Looks like it's ticks, so if I want to > convert this number, to, say, nanoseconds, would it be right to do > something like: > > X * 1000**3 / kern.clockrate.stathz > > (X beeing the value returned by bhyvectl and kern.clockrate is a > sysctl name)? It's in TSC units so you can convert to nsecs using the machdep.tsc_freq sysctl node. > 2. This value shows only vcpu time, without hypervisor time? That's correct. To get the hypervisor and vCPU time together, you can use existing CPU usage reporting (e.g. that used by top et al). > For the memory stats, it's less obvious. Does guest always use an amount > of memory specified at startup with '-m' (i.e. bhyve -m 1G) or it could > use less? That's the maximum it can use. We currently don't expose the incore amount from the vmspace representing the guest's physical - that should be added to bhyvectl soon. > What is the format of bhyvectl --get-{low,high}mem output? The number reported there isn't to do with guest usage, but how the memory is divided between < 4G and above 4G. For example, the default for bhyve is to use up to 3G below 4G, provide 1GB for PCI MMIO decode, and then put the remainder of guest memory above 4G. Here's an example for an 8G VM, with 3G of guest mem below 4G (starting address 0), and 5G above 4G (starting address 4G): lowmem 0x0000000000000000/3221225472 highmem 0x0000000100000000/5368709120 > PS I found it a little confusing that bhyvectl displays vcpu0 stats by > default if --cpu is not provided, expected it provide info of all vcpus > in the guest by default. Yes, that's a relic of the days when there was only a single vCPU supported :( > Also, didn't find a way to get a number of vcpus in a running guest. Until the vCPU state is exposed by bhyvectl, or we provide a sysctl, you can use heuristics: the number of vCPU threads for the bhyve process, or scan all vCPUs and only count those that have a non-zero RIP. later, Peter.