From patchwork Wed Jan 5 15:10:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Arcangeli X-Patchwork-Id: 77610 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 20BF0B70D4 for ; Thu, 6 Jan 2011 02:11:39 +1100 (EST) Received: from localhost ([127.0.0.1]:48857 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PaV1U-00014N-FV for incoming@patchwork.ozlabs.org; Wed, 05 Jan 2011 10:11:36 -0500 Received: from [140.186.70.92] (port=44566 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PaV0E-0000ew-HQ for qemu-devel@nongnu.org; Wed, 05 Jan 2011 10:10:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PaV0D-0008En-1V for qemu-devel@nongnu.org; Wed, 05 Jan 2011 10:10:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:62818) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PaV0C-0008EM-Pv for qemu-devel@nongnu.org; Wed, 05 Jan 2011 10:10:17 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p05FAE10029610 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 5 Jan 2011 10:10:14 -0500 Received: from random.random (ovpn-113-108.phx2.redhat.com [10.3.113.108]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p05FADcE019143; Wed, 5 Jan 2011 10:10:13 -0500 Date: Wed, 5 Jan 2011 16:10:12 +0100 From: Andrea Arcangeli To: Andreas =?iso-8859-1?Q?F=E4rber?= Subject: Re: [Qemu-devel] [PATCH] add MADV_DONTFORK to guest physical memory Message-ID: <20110105151012.GC15823@random.random> References: <20100915170824.GL5981@random.random> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Blue Swirl , Anthony Liguori , "qemu-devel@nongnu.org Developers" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The bug is still there so I rediffed the old patch against current code. On a related topic: could somebody give me advice on how to implement a command line (command line seems enough, the other option would be monitor command) to make the MADV_MERGEABLE conditional? I got KSM on THP working fine but KSM may decrease performance by increasing the number of copy on write and by splitting hugepages, so we'd like to be able to turn off KSM on a per-VM basis (not on the whole host, which of course we already can by setting /sys/kernel/mm/ksm/run to 0) so that high perf VMs will keep running at maximum speed with KSM off but others may still benefit from KSM. For that I need to make the below MADV_MERGEABLE madvise conditional to something and the code itself will be trivial, we've just to converge on a command line option (hopefully quickly ;). ====== Subject: avoid allocation failures during fork/exec for migrate/hotplug From: Andrea Arcangeli Mark all guest physical memory as MADV_DONTFORK to avoid false positive allocation failures during fork in migrate/netdev hotplug. Signed-off-by: Andrea Arcangeli --- diff --git a/exec.c b/exec.c index db9ff55..9e2aa12 100644 --- a/exec.c +++ b/exec.c @@ -2851,6 +2851,9 @@ ram_addr_t qemu_ram_alloc_from_ptr(DeviceState *dev, const char *name, new_block->host = qemu_vmalloc(size); #endif qemu_madvise(new_block->host, size, QEMU_MADV_MERGEABLE); + + /* no allocation failures during fork/exec for migrate/hotplug */ + qemu_madvise(new_block->host, size, QEMU_MADV_DONTFORK); } }