Skip to content

Allow 'cache-clean-interval' in Linux only

Alberto Garcia qemu-devel 1 version Applied

Status from this message: Thanks, applied to the block branch.

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 1 replyApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/4qcow2: Make qcow2_cache_table_release() work only in Linuxblock/qcow2-cache.c+3 -20 replies
2/4qcow2: Allow 'cache-clean-interval' in Linux onlyblock/qcow2.c+8 -00 replies
3/4qcow2: Remove stale commentblock/qcow2-cache.c+0 -10 replies
4/4docs: Specify that cache-clean-interval is only supported in Linuxdocs/qcow2-cache.txt+3 -20 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [Qemu-devel] [PATCH for-2.8 0/4] Allow 'cache-clean-interval' in Linux only

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.

Regards,

Berto

Alberto Garcia (4):
qcow2: Make qcow2_cache_table_release() work only in Linux
qcow2: Allow 'cache-clean-interval' in Linux only
qcow2: Remove stale comment
docs: Specify that cache-clean-interval is only supported in Linux

 block/qcow2-cache.c  | 6 +++---
 block/qcow2.c        | 8 ++++++++
 docs/qcow2-cache.txt | 5 +++--
 3 files changed, 14 insertions(+), 5 deletions(-)
Signature · 1 line
2.10.2