From: Chegu Vinod Subject: Re: How to determine the backing host physical memory for a given guest ? Date: Fri, 11 May 2012 01:22:26 +0000 (UTC) Message-ID: References: <4FAA752D.9020905@redhat.com> <4FABE004.9010808@linux.vnet.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE To: kvm@vger.kernel.org Return-path: Received: from plane.gmane.org ([80.91.229.3]:50685 "EHLO plane.gmane.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754159Ab2EKBWj (ORCPT ); Thu, 10 May 2012 21:22:39 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1SSeZ1-0000Bs-OE for kvm@vger.kernel.org; Fri, 11 May 2012 03:22:36 +0200 Received: from zcce02cs1742-db20.houston.hp.com ([15.203.233.76]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 11 May 2012 03:22:35 +0200 Received: from chegu_vinod by zcce02cs1742-db20.houston.hp.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 11 May 2012 03:22:35 +0200 Sender: kvm-owner@vger.kernel.org List-ID: Andrew Theurer linux.vnet.ibm.com> writes: >=20 > On 05/09/2012 08:46 AM, Avi Kivity wrote: > > On 05/09/2012 04:05 PM, Chegu Vinod wrote: > >> Hello, > >> > >> On an 8 socket Westmere host I am attempting to run a single guest= and > >> characterize the virtualization overhead for a system intensive > >> workload (AIM7-high_systime) as the size of the guest scales (10wa= y/64G, > >> 20way/128G, ... 80way/512G). > >> > >> To do some comparisons between the native vs. guest runs. I have > >> been using "numactl" to control the cpu node& memory node binding= s for > >> the qemu instance. For larger guest sizes I end up binding across= multiple > >> localities. for e.g. a 40 way guest : > >> > >> numactl --cpunodebind=3D0,1,2,3 --membind=3D0,1,2,3 \ > >> qemu-system-x86_64 -smp 40 -m 262144 \ > >> <....> > >> > >> I understand that actual mappings from a guest virtual address to = host=20 physical > >> address could change. > >> > >> Is there a way to determine [at a given instant] which host's NUMA= node is > >> providing the backing physical memory for the active guest's kerne= l and > >> also for the the apps actively running in the guest ? > >> > >> Guessing that there is a better way (some tool available?) than ju= st > >> diff'ng the per node memory usage...from the before and after outp= ut of > >> "numactl --hardware" on the host. > >> > > > > Not sure if that's what you want, but there's Documentation/vm/page= map.txt. > > >=20 > You can look at /proc/=E2=89=A4pid>/numa_maps and see all the mapping= s for the=20 > qemu process. There should be one really large mapping for the guest= =20 > memory, and in that line a number of dirty pages list potentially for= =20 > each NUMA node. This will tell you how much from each node, but not=20 > specifically "which page is mapped where". Thanks . I will look at this in more detail. >=20 > Keep in mind with the current numactl you are using, you will likely = not=20 > get the benefits of NUMA enhancements found in the linux kernel from=20 > your guest (or host). There are a couple reasons: (1) your guest doe= s=20 > not have a NUMA topology defined (based on what I see from the qemu=20 > command above), so it will not do anything special based on the host=20 > topology. Also, things that are broken down per-NUMA-node like some=20 > spin-locks and sched-domains are now system-wide/flat. This is a big= =20 > deal for scheduler and other things like kmem allocation. With a sin= gle=20 > 80way VM with no NUMA, you will likely have massive spin-lock content= ion=20 > on some workloads.=20 We had seen evidence of increased lock contentions (via lockstat etc.)a= s the=20 guest size increased.=20 [On a related note : Given the nature of the system intensive workload.= =2E. the=20 combination of the ticket based locks in the guest OS + PLE handling co= de in=20 the host kernel was not helping. So temporarily worked around this. Hop= e to try=20 out the PV locks changes soon....]. Regarding the -numa option : I had earlier (about a ~month ago) tried the -numa option. The layout I= =20 specified didn't match the layout the guest saw. Haven't yet looked int= o the=20 exact reason...but came to know that there was already an open issue:=20 https://bugzilla.redhat.com/show_bug.cgi?id=3D816804=20 Also remember noticing a warning message when the -numa option was used= for a=20 guest with more than 64VCPUs. (in my case with 80 VCPUs). Will be look= ing at=20 the code soon to see if there is any limitation... I have been using [more or less the upstream version of] qemu directly = to start=20 the guest. For guest sizes : 10way, 20way, 40way 60way I had been usin= g numactl=20 just to control the numa nodes where the guest ends up running. After t= he guest=20 booted up I used to set the affinity of the the VCPUs (to the specific = cores on=20 the host) by via "taskset" (this was a touch painful... when compared t= o virsh=20 vcpupin). For 80way guest (on an 80way host) I don't use numactl. =20 Noticed that doing a "taskset" to pin the VCPUs didn't always give a be= tter=20 performance...perhaps this is due to the absence of a NUMA layout in th= e guest. (2) Once the VM does have NUMA toplogy (via qemu=20 > -numa), one still cannot manually set mempolicy for a portion of the = VM=20 > memory that represents each NUMA node in the VM (or have this done=20 > automatically with something like autoNUMA). Therefore, it's difficu= lt=20 > to forcefully map each of the VM's node's memory to the corresponding= =20 > host node. >=20 > There are a some things you can do to mitigate some of this. Definit= ely=20 > define the VM to match the NUMA topology found on the host. =20 The native/host platform has multiple levels of NUMA... node distances: node 0 1 2 3 4 5 6 7=20 0: 10 14 23 23 27 27 27 27=20 1: 14 10 23 23 27 27 27 27=20 2: 23 23 10 14 27 27 27 27=20 3: 23 23 14 10 27 27 27 27=20 4: 27 27 27 27 10 14 23 23=20 5: 27 27 27 27 14 10 23 23=20 6: 27 27 27 27 23 23 10 14=20 7: 27 27 27 27 23 23 14 10=20 The qemu's -numa option seems to only allow for one level (i.e.=20 specify multiple sockets etc). Am I missing something ? > at least allow good scaling wrt locks and scheduler in the guest. As= =20 > for getting memory placement close (a page in VM node x actually resi= des=20 > in host node x), you have to rely on vcpu pinning + guest NUMA topolo= gy,=20 > combined with default mempolicy in the guest and host. =20 I did recompile both the kernels with the SLUB allocator enabled... > As pages are=20 > faulted in the guest, the hope is that the vcpu which did the faultin= g=20 > is running in the right node (guest and host), its guest OS mempolicy= =20 > ensures this page is to be allocated in the guest local node, and tha= t=20 > allocation cause a fault in qemu, which is -also- running on the -hos= t-=20 > node X. The vcpu pinning is critical to get qemu to fault that memor= y=20 > to the correct node. =20 In the absence of a NUMA layout in the guest it doesn't look like pinni= ng=20 helped... but I think I understand what you are saying. Thanks! > Make sure you do not use numactl for any of this.=20 > I would suggest using libvirt and define the vcpu-pinning and the n= uma=20 > topology in the XML. I will try this in the coming days (waiting to get back on the system := )).=20 Thanks for the detailed response !=20 Vinod >=20 > -Andrew Theurer >=20 > -- > 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 >=20 >=20