lol

nixos/vm-tests: Remove msize mount option

This seems to be the root cause of the random page allocation failures
and @wizeman did a very good job on not only finding the root problem
but also giving a detailed explanation of it in #10828.

Here is an excerpt:

The problem here is that the kernel is trying to allocate a contiguous
section of 2^7=128 pages, which is 512 KB. This is way too much:
kernel pages tend to get fragmented over time and kernel developers
often go to great lengths to try allocating at most only 1 contiguous
page at a time whenever they can.

From the error message, it looks like the culprit is unionfs, but this
is misleading: unionfs is the name of the userspace process that was
running when the system ran out of memory, but it wasn't unionfs who
was allocating the memory: it was the kernel; specifically it was the
v9fs_dir_readdir_dotl() function, which is the code for handling the
readdir() function in the 9p filesystem (the filesystem that is used
to share a directory structure between a qemu host and its VM).

If you look at the code, here's what it's doing at the moment it tries
to allocate memory:

buflen = fid->clnt->msize - P9_IOHDRSZ;

rdir = v9fs_alloc_rdir_buf(file, buflen);

If you look into v9fs_alloc_rdir_buf(), you will see that it will try
to allocate a contiguous buffer of memory (using kzalloc(), which is a
wrapper around kmalloc()) of size buflen + 8 bytes or so.

So in reality, this code actually allocates a buffer of size
proportional to fid->clnt->msize. What is this msize? If you follow
the definition of the structures, you will see that it's the
negotiated buffer transfer size between 9p client and 9p server. On
the client side, it can be controlled with the msize mount option.

What this all means is that, the reason for running out of memory is
that the code (which we can't easily change) tries to allocate a
contiguous buffer of size more or less equal to "negotiated 9p
protocol buffer size", which seems to be way too big (in our NixOS
tests, at least).

After that initial finding, @lethalman tested the gnome3 gdm test
without setting the msize parameter at all and it seems to have resolved
the problem.

The reason why I'm committing this without testing against all of the
NixOS VM test is basically that I think we can only go better but not
worse than the current state.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>

aszlig a5bc11f9 9688c397

+7 -7
+3 -3
nixos/modules/virtualisation/qemu-vm.nix
··· 426 426 ${if cfg.writableStore then "/nix/.ro-store" else "/nix/store"} = 427 427 { device = "store"; 428 428 fsType = "9p"; 429 - options = "trans=virtio,version=9p2000.L,msize=1048576,cache=loose"; 429 + options = "trans=virtio,version=9p2000.L,cache=loose"; 430 430 neededForBoot = true; 431 431 }; 432 432 "/tmp/xchg" = 433 433 { device = "xchg"; 434 434 fsType = "9p"; 435 - options = "trans=virtio,version=9p2000.L,msize=1048576,cache=loose"; 435 + options = "trans=virtio,version=9p2000.L,cache=loose"; 436 436 neededForBoot = true; 437 437 }; 438 438 "/tmp/shared" = 439 439 { device = "shared"; 440 440 fsType = "9p"; 441 - options = "trans=virtio,version=9p2000.L,msize=1048576"; 441 + options = "trans=virtio,version=9p2000.L"; 442 442 neededForBoot = true; 443 443 }; 444 444 } // optionalAttrs cfg.writableStore
+2 -2
pkgs/build-support/vm/default.nix
··· 118 118 119 119 echo "mounting Nix store..." 120 120 mkdir -p /fs/nix/store 121 - mount -t 9p store /fs/nix/store -o trans=virtio,version=9p2000.L,msize=262144,cache=loose 121 + mount -t 9p store /fs/nix/store -o trans=virtio,version=9p2000.L,cache=loose 122 122 123 123 mkdir -p /fs/tmp /fs/run /fs/var 124 124 mount -t tmpfs -o "mode=1777" none /fs/tmp ··· 127 127 128 128 echo "mounting host's temporary directory..." 129 129 mkdir -p /fs/tmp/xchg 130 - mount -t 9p xchg /fs/tmp/xchg -o trans=virtio,version=9p2000.L,msize=262144,cache=loose 130 + mount -t 9p xchg /fs/tmp/xchg -o trans=virtio,version=9p2000.L,cache=loose 131 131 132 132 mkdir -p /fs/proc 133 133 mount -t proc none /fs/proc
+2 -2
pkgs/build-support/vm/windows/controller/default.nix
··· 48 48 mount -t proc none /fs/proc 49 49 50 50 mount -t 9p \ 51 - -o trans=virtio,version=9p2000.L,msize=262144,cache=loose \ 51 + -o trans=virtio,version=9p2000.L,cache=loose \ 52 52 store /fs/nix/store 53 53 54 54 mount -t 9p \ 55 - -o trans=virtio,version=9p2000.L,msize=262144,cache=loose \ 55 + -o trans=virtio,version=9p2000.L,cache=loose \ 56 56 xchg /fs/xchg 57 57 58 58 echo root:x:0:0::/root:/bin/false > /fs/etc/passwd