From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58431) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBNCM-0006I3-C9 for qemu-devel@nongnu.org; Mon, 28 Nov 2016 09:46:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cBNCL-0007Cc-7o for qemu-devel@nongnu.org; Mon, 28 Nov 2016 09:46:26 -0500 Date: Mon, 28 Nov 2016 15:46:14 +0100 From: Kevin Wolf Message-ID: <20161128144614.GA4754@noname.redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [PATCH for-2.8 0/4] Allow 'cache-clean-interval' in Linux only List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alberto Garcia Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Max Reitz Am 25.11.2016 um 12:27 hat Alberto Garcia geschrieben: > Hi all, > > The cache-clean-interval setting of qcow2 frees the memory of the L2 > cache tables that haven't been used after a certain interval of time. > > QEMU uses madvise() with MADV_DONTNEED for this. After that call, the > data in the specified cache tables is discarded by the kernel. The > problem with this behavior is that it is Linux-specific. madvise() > itself is not a standard system call and while other implementations > (e.g. FreeBSD) also have MADV_DONTNEED, they don't share the same > semantics. > > POSIX defines posix_madvise(), which has POSIX_MADV_DONTNEED, and > that's what QEMU uses in systems that don't implement madvise(). > However POSIX_MADV_DONTNEED also has different semantics and cannot be > used for our purposes. As a matter of fact, in glibc it is a no-op: > > https://github.molgen.mpg.de/git-mirror/glibc/blob/glibc-2.23/sysdeps/unix/sysv/linux/posix_madvise.c > > So while this all is mentioned in the QEMU documentation, there's > nothing preventing users of other systems from trying to use this > feature. In non-Linux systems it is worse than a no-op: it invalidates > perfectly valid cache tables for no reason without freeing their > memory. > > This series makes Linux a hard requirement for cache-clean-interval > and prints an error message in other systems. Thanks, applied to the block branch. Kevin