On 8/19/23 21:37, Warner Losh wrote:
+/* madvise(2) */
+static inline abi_long do_bsd_madvise(abi_long arg1, abi_long arg2,
+ abi_long arg3)
+{
+ /*
+ * A straight passthrough may not be safe because qemu sometimes
+ * turns private file-backed mapping into anonymous mappings. This
+ * will break MADV_DONTNEED. This is a hint, so ignoring and returing
+ * success is ok.
+ */
+ return get_errno(0);
This looks like it was copied from an early linux-user implementation, and
that seems to have been fixed to no longer cause problems. Can someone
that knows about the linux-user history here comment?
We now track pages that are "passthrough" and ok for DONTNEED etc.
case MADV_DONTNEED:
if (page_check_range(start, len, PAGE_PASSTHROUGH)) {
ret = get_errno(madvise(g2h_untagged(start), len, advice));
if ((advice == MADV_DONTNEED) && (ret == 0)) {
page_reset_target_data(start, start + len - 1);
}
}
It's still not ideal, but it's something.
r~