From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55477) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WIgcc-0004IZ-ED for qemu-devel@nongnu.org; Wed, 26 Feb 2014 10:42:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WIgcT-0005NL-Ix for qemu-devel@nongnu.org; Wed, 26 Feb 2014 10:42:10 -0500 Received: from mail-wg0-x22d.google.com ([2a00:1450:400c:c00::22d]:54139) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WIgcT-0005N5-BG for qemu-devel@nongnu.org; Wed, 26 Feb 2014 10:42:01 -0500 Received: by mail-wg0-f45.google.com with SMTP id y10so1784944wgg.28 for ; Wed, 26 Feb 2014 07:42:00 -0800 (PST) Date: Wed, 26 Feb 2014 16:41:54 +0100 From: Stefan Hajnoczi Message-ID: <20140226154154.GB20820@stefanha-thinkpad.muc.redhat.com> References: <530DBE6C.5030502@kamp.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <530DBE6C.5030502@kamp.de> Subject: Re: [Qemu-devel] qemu-img convert cache mode for source List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Lieven Cc: Kevin Wolf , Paolo Bonzini , "qemu-devel@nongnu.org" , Stefan Hajnoczi On Wed, Feb 26, 2014 at 11:14:04AM +0100, Peter Lieven wrote: > I was wondering if it would be a good idea to set the O_DIRECT mode for the source > files of a qemu-img convert process if the source is a host_device? > > Currently the backup of a host device is polluting the page cache. Points to consider: 1. O_DIRECT does not work on Linux tmpfs, you get EINVAL when opening the file. A fallback is necessary. 2. O_DIRECT has no readahead so performance could actually decrease. The question is, how important is reahead versus polluting page cache? 3. For raw files it would make sense to tell the kernel that access is sequential and data will be used only once. Then we can get the best of both worlds (avoid polluting page cache but still get readahead). This is done using posix_fadvise(2). The problem is what to do for image formats. An image file can be very fragmented so the readahead might not be a win. Does this mean that for image formats we should tell the kernel access will be random? Furthermore, maybe it's best to do readahead inside QEMU so that even network protocols (nbd, iscsi, etc) can get good performance. They act like O_DIRECT is always on. It seems reasonable to investigate this stuff more. Please run benchmarks so we have justification to merge patches. Stefan