From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58777) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WIgqM-0003Pu-PX for qemu-devel@nongnu.org; Wed, 26 Feb 2014 10:56:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WIgqH-0002Jg-Kw for qemu-devel@nongnu.org; Wed, 26 Feb 2014 10:56:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:14637) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WIgqH-0002JU-CF for qemu-devel@nongnu.org; Wed, 26 Feb 2014 10:56:17 -0500 Message-ID: <530E0E40.3070907@redhat.com> Date: Wed, 26 Feb 2014 08:54:40 -0700 From: Eric Blake MIME-Version: 1.0 References: <530DBE6C.5030502@kamp.de> <20140226154154.GB20820@stefanha-thinkpad.muc.redhat.com> In-Reply-To: <20140226154154.GB20820@stefanha-thinkpad.muc.redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="VrxDTmDUUMp05HR6w2DBDLSe4A5cfMVwQ" Subject: Re: [Qemu-devel] qemu-img convert cache mode for source List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi , Peter Lieven Cc: Kevin Wolf , Paolo Bonzini , "qemu-devel@nongnu.org" , Stefan Hajnoczi This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --VrxDTmDUUMp05HR6w2DBDLSe4A5cfMVwQ Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 02/26/2014 08:41 AM, Stefan Hajnoczi wrote: > 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 fo= r 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. >=20 > Points to consider: >=20 > 1. O_DIRECT does not work on Linux tmpfs, you get EINVAL when opening > the file. A fallback is necessary. >=20 > 2. O_DIRECT has no readahead so performance could actually decrease. > The question is, how important is reahead versus polluting page > cache? >=20 > 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 bes= t > of both worlds (avoid polluting page cache but still get readahead).= > This is done using posix_fadvise(2). Except that posix_fadvise is advisory only (the kernel is free to ignore it), and currently not stateful enough inside the kernel to be useful when handing fds between processes. For several years now, I've asked if the kernel could provide better guarantees about what posix_fadvise can actually do, and expose user-space introspection of those guarantees through procfs and/or fpathconf. See https://bugzilla.redhat.com/show_bug.cgi?id=3D634653 for some backstory on libvirt's dealings with O_DIRECT. I'd really like to ditch libvirt's use of O_DIRECT in favor of posix_fadvise for avoiding page cache pollution, but the kernel isn't at a point yet that lets libvirt do that. I suppose that if the kernel ever does improve posix_fadvise, then both libvirt and qemu would benefit from it. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --VrxDTmDUUMp05HR6w2DBDLSe4A5cfMVwQ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJTDg5AAAoJEKeha0olJ0NqumcIAJsJpRC/DKH08a+gm8sT2j5F KXENZTl2wKIg7xREra/Uqrhge0G/9PoFK4t8eBTW7viCZ6IRkx9IlVysNIchQ79X mbW5LSvpTCiaiN9Nx0REH5Oc3Jx6tWfCEGkr5+DY5TBhESh6Qc6i65VlOJMvmrH2 +JKj4n202EsV6/bnCxTUoMRwBnASPyg+9gwN2Mg+gtxEieyDGdgs2nIeSqTkmvZZ wMthPbWGr3eMDSNVGA8tbsbAaZo6cv/xxttwXSzzMcHWFEJHVE6/g4n6uBLyEbaT cucJJGirsr+2z7RSl657g3mUWVuuizVoVo53RqqkmEMGbGFhnr548BCepDEtlKE= =PpsC -----END PGP SIGNATURE----- --VrxDTmDUUMp05HR6w2DBDLSe4A5cfMVwQ--