From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1545CC4360F for ; Wed, 6 Mar 2019 18:30:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D8A7B21734 for ; Wed, 6 Mar 2019 18:30:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727744AbfCFSap (ORCPT ); Wed, 6 Mar 2019 13:30:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60908 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727261AbfCFSa0 (ORCPT ); Wed, 6 Mar 2019 13:30:26 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3B3F666997; Wed, 6 Mar 2019 18:30:25 +0000 (UTC) Received: from [10.18.17.32] (dhcp-17-32.bos.redhat.com [10.18.17.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9B75318E3F; Wed, 6 Mar 2019 18:30:15 +0000 (UTC) From: Nitesh Narayan Lal To: "Michael S. Tsirkin" Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, pbonzini@redhat.com, lcapitulino@redhat.com, pagupta@redhat.com, wei.w.wang@intel.com, yang.zhang.wz@gmail.com, riel@surriel.com, david@redhat.com, dodgen@google.com, konrad.wilk@oracle.com, dhildenb@redhat.com, aarcange@redhat.com, alexander.duyck@gmail.com Subject: Re: [RFC][Patch v9 0/6] KVM: Guest Free Page Hinting References: <20190306155048.12868-1-nitesh@redhat.com> <20190306110501-mutt-send-email-mst@kernel.org> <20190306130955-mutt-send-email-mst@kernel.org> Organization: Red Hat Inc, Message-ID: Date: Wed, 6 Mar 2019 13:30:14 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190306130955-mutt-send-email-mst@kernel.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="xHjQbFXLnS08psK94Kg6ph6iXR74gEdrn" X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 06 Mar 2019 18:30:25 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --xHjQbFXLnS08psK94Kg6ph6iXR74gEdrn Content-Type: multipart/mixed; boundary="Gh4ItdDszVTLb9zJu98nTqlKBPzKrYx6H"; protected-headers="v1" From: Nitesh Narayan Lal To: "Michael S. Tsirkin" Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, pbonzini@redhat.com, lcapitulino@redhat.com, pagupta@redhat.com, wei.w.wang@intel.com, yang.zhang.wz@gmail.com, riel@surriel.com, david@redhat.com, dodgen@google.com, konrad.wilk@oracle.com, dhildenb@redhat.com, aarcange@redhat.com, alexander.duyck@gmail.com Message-ID: Subject: Re: [RFC][Patch v9 0/6] KVM: Guest Free Page Hinting --Gh4ItdDszVTLb9zJu98nTqlKBPzKrYx6H Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 3/6/19 1:12 PM, Michael S. Tsirkin wrote: > On Wed, Mar 06, 2019 at 01:07:50PM -0500, Nitesh Narayan Lal wrote: >> On 3/6/19 11:09 AM, Michael S. Tsirkin wrote: >>> On Wed, Mar 06, 2019 at 10:50:42AM -0500, Nitesh Narayan Lal wrote: >>>> The following patch-set proposes an efficient mechanism for handing = freed memory between the guest and the host. It enables the guests with n= o page cache to rapidly free and reclaims memory to and from the host res= pectively. >>>> >>>> Benefit: >>>> With this patch-series, in our test-case, executed on a single syste= m and single NUMA node with 15GB memory, we were able to successfully lau= nch 5 guests(each with 5 GB memory) when page hinting was enabled and 3 w= ithout it. (Detailed explanation of the test procedure is provided at the= bottom under Test - 1). >>>> >>>> Changelog in v9: >>>> * Guest free page hinting hook is now invoked after a page has been= merged in the buddy. >>>> * Free pages only with order FREE_PAGE_HINTING_MIN_ORDER(cur= rently defined as MAX_ORDER - 1) are captured. >>>> * Removed kthread which was earlier used to perform the scanning, i= solation & reporting of free pages. >>>> * Pages, captured in the per cpu array are sorted based on the zone= numbers. This is to avoid redundancy of acquiring zone locks. >>>> * Dynamically allocated space is used to hold the isolated g= uest free pages. >>>> * All the pages are reported asynchronously to the host via = virtio driver. >>>> * Pages are returned back to the guest buddy free list only = when the host response is received. >>>> >>>> Pending items: >>>> * Make sure that the guest free page hinting's current imple= mentation doesn't break hugepages or device assigned guests. >>>> * Follow up on VIRTIO_BALLOON_F_PAGE_POISON's device side support. = (It is currently missing) >>>> * Compare reporting free pages via vring with vhost. >>>> * Decide between MADV_DONTNEED and MADV_FREE. >>>> * Analyze overall performance impact due to guest free page hinting= =2E >>>> * Come up with proper/traceable error-message/logs. >>>> >>>> Tests: >>>> 1. Use-case - Number of guests we can launch >>>> >>>> NUMA Nodes =3D 1 with 15 GB memory >>>> Guest Memory =3D 5 GB >>>> Number of cores in guest =3D 1 >>>> Workload =3D test allocation program allocates 4GB memory, touches = it via memset and exits. >>>> Procedure =3D >>>> The first guest is launched and once its console is up, the test al= location program is executed with 4 GB memory request (Due to this the gu= est occupies almost 4-5 GB of memory in the host in a system without page= hinting). Once this program exits at that time another guest is launched= in the host and the same process is followed. We continue launching the = guests until a guest gets killed due to low memory condition in the host.= >>>> >>>> Results: >>>> Without hinting =3D 3 >>>> With hinting =3D 5 >>>> >>>> 2. Hackbench >>>> Guest Memory =3D 5 GB=20 >>>> Number of cores =3D 4 >>>> Number of tasks Time with Hinting Time without Hinting >>>> 4000 19.540 17.818 >>>> >>> How about memhog btw? >>> Alex reported: >>> >>> My testing up till now has consisted of setting up 4 8GB VMs on a sy= stem >>> with 32GB of memory and 4GB of swap. To stress the memory on the sys= tem I >>> would run "memhog 8G" sequentially on each of the guests and observe= how >>> long it took to complete the run. The observed behavior is that on t= he >>> systems with these patches applied in both the guest and on the host= I was >>> able to complete the test with a time of 5 to 7 seconds per guest. O= n a >>> system without these patches the time ranged from 7 to 49 seconds pe= r >>> guest. I am assuming the variability is due to time being spent writ= ing >>> pages out to disk in order to free up space for the guest. >>> >> Here are the results: >> >> Procedure: 3 Guests of size 5GB is launched on a single NUMA node with= >> total memory of 15GB and no swap. In each of the guest, memhog is run >> with 5GB. Post-execution of memhog, Host memory usage is monitored by >> using Free command. >> >> Without Hinting: >> =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2= =A0=C2=A0 Time of execution=C2=A0=C2=A0=C2=A0 Host used memory >> Guest 1:=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 45 seconds=C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 5.4 GB >> Guest 2:=C2=A0=C2=A0 =C2=A0=C2=A0 =C2=A0 45 seconds=C2=A0=C2=A0=C2=A0 = =C2=A0=C2=A0 =C2=A0=C2=A0 =C2=A0 10 GB >> Guest 3:=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 1=C2=A0 minute=C2=A0=C2=A0= =C2=A0 =C2=A0=C2=A0 =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 15 GB >> >> With Hinting: >> =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 =C2=A0= Time of execution =C2=A0=C2=A0=C2=A0 Host used memory >> Guest 1:=C2=A0=C2=A0 =C2=A0=C2=A0 =C2=A0 49 seconds=C2=A0=C2=A0=C2=A0 = =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 2.4 GB >> Guest 2:=C2=A0=C2=A0 =C2=A0=C2=A0 =C2=A0 40 seconds=C2=A0=C2=A0=C2=A0 = =C2=A0=C2=A0 =C2=A0=C2=A0 =C2=A0 4.3 GB >> Guest 3:=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 50 seconds=C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 6.3 GB > OK so no improvement. If we are looking in terms of memory we are getting back from the guest, then there is an improvement. However, if we are looking at the improvement in terms of time of execution of memhog then yes there is non= e. > OTOH Alex's patches cut time down to 5-7 seconds > which seems better.=20 I haven't investigated memhog as such so cannot comment on what exactly it does and why there was a time difference. I can take a look at it. > Want to try testing Alex's patches for comparison? Somehow I am not in a favor of doing a hypercall on every page (with huge TLB order/MAX_ORDER -1) as I think it will be costly. I can try using Alex's host side logic instead of virtio. Let me know what you think? > --=20 Regards Nitesh --Gh4ItdDszVTLb9zJu98nTqlKBPzKrYx6H-- --xHjQbFXLnS08psK94Kg6ph6iXR74gEdrn Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEkXcoRVGaqvbHPuAGo4ZA3AYyozkFAlyAEbYACgkQo4ZA3AYy ozmsKQ//VF+74g1jkdSVQK75bfLGAqPYy9geeG07EhZ6PmPy8QXvPLLswl5R4hKz 9Y4Uxf/53xyYxiwGRfccHTd2pA6c8rhF+yZvqRyQobFRmGCVwoL8YuusD1dBf3Gn eCEhoP+mDScQ/fmhmbvsWd49RtMVBayqkK6slghn29nsla6dEVqpEWPeBX3g+pFe 7s4tc6WY/mX1KTwMrIhkyEqQCATPlmFOAxLLzTk4WvlgxxBBRyxvThwovhE2xrLw I2iRjw6KtNVfacnNk9sFVHJhyhmOUKIZQwIqCl4e6JFtuV29odl5n/9RGjsWh6Ur mOG5UJKTA6QhChtWn/8IfmGQUOnEkiRH+svH4q4mh9+g8DlnLdoWrKvn9iUnlb0J tpbYnhnFMGg/90tjJHvHcEoFgaqCjs8HKGg5D6NavKVniK07RCYjFoa3hWJZH+S2 i+9W0oB4OhWXh4JIWNBfq8bA5anS8YkewNMI/oHeioCZa3Gb+++FMvCVoOZ1r8bg EbBKcEy61FmP/F7wWsSP9TrjqHMbOqTX9obvyjnN84ZKKcmKywo5E0R2EzuEWduO xo+9yOkTUQg4GVcTnAqZxyqCu2ovEGhfmZrPFerRyAtkRTYxYcj+kJRHdEgmea/A 1GIiUOg7DFu/OlgOvtbbbZl1HqsDXODU6emmYXxUeXvprfmW+YA= =8G1M -----END PGP SIGNATURE----- --xHjQbFXLnS08psK94Kg6ph6iXR74gEdrn--