Hi,
> Thanks for the detailed results and the test program. This reproduces the 
> failure independently
>  of rumpnet, and the 6 GiB guest satisfies every request below 2 GiB.
>
> Could you try a single 8 KiB allocation as the first request after boot in 
> the 2 GiB guest? That
> would tell us whether the two-page request also fails without the preceding 4 
> KiB allocation.
> Could you also share the GNU Mach build or package version used for these 
> runs so we can
> trace the allocation path in the matching source?
Thanks for the suggestion, it turned out to be the key.

A correction to my previous message first: in the 2 GiB run, the test
program was not the first request after boot. I had started rumpnet
before it (its 64 KiB allocation failed), and that is what matters.

All runs below are on the same Guix System x86_64 image in QEMU, each
in a fresh boot. In the first three, the test program is the first
command.

Single 8 KiB allocation, 2 GiB guest:

  size=  8192 pmin=0 pmax=0x100000000 align=0x1000 -> kr=0 pa=0x64140000

4 KiB followed by 8 KiB, 2 GiB guest:

  size=  4096 pmin=0 pmax=0x100000000 align=0x1000 -> kr=0 pa=0x6434e000
  size=  8192 pmin=0 pmax=0x100000000 align=0x1000 -> kr=0 pa=0x63d0e000

Full sequence from 4 KiB to 64 KiB, 2 GiB guest:

  size=  4096 pmin=0 pmax=0x100000000 align=0x1000 -> kr=0 pa=0x64824000
  size=  8192 pmin=0 pmax=0x100000000 align=0x1000 -> kr=0 pa=0x64900000
  size= 16384 pmin=0 pmax=0x100000000 align=0x1000 -> kr=0 pa=0x642fc000
  size= 32768 pmin=0 pmax=0x100000000 align=0x1000 -> kr=0 pa=0x64960000
  size= 65536 pmin=0 pmax=0x100000000 align=0x1000 -> kr=0 pa=0x64250000

So contiguous allocations work right after boot. The failure only
happens while rumpnet is running. In a single fresh boot (2 GiB):

  free -m:       used 444 MB, free 1539 MB
  contig 65536:  kr=0 pa=0x64370000

  settrans -cfga /dev/rumpnet /hurd/rumpnet
    (wm0: unable to allocate TX control data, error = 1)
  free -m:       used 674 MB, free 1308 MB
  contig 65536:  kr=6 pa=0

  settrans -fga /dev/rumpnet
  free -m:       used 447 MB, free 1535 MB
  contig 65536:  kr=0 pa=0x69200000

So while rumpnet holds about 230 MB, a 64 KiB contiguous allocation
fails from another process too, even with over 1.3 GB free, and it
works again once rumpnet is stopped. rumpnet's own 64 KiB DMA
allocation for wm(4) happens after it has taken that memory, so it
fails as well.

Versions:

  GNU Mach: 1.8+git20260224 (git tag v1.8+git20260224) as packaged in
  Guix, with Guix's gnumach-version.patch.
  uname: GNU-Mach 1.8/Hurd-0.9 x86_64
  rumpkernel: as packaged in Guix (0-20250111-1.0_20250), built from
  the hurd-team Debian repository at tag debian/0_20250111-6, with the
  patches listed in its debian/patches/series, plus local debug changes
  (logging of vm_allocate_contiguous() results, and using the PCI
  interrupt line instead of the ACPI GSI).

QEMU command line:

  qemu-system-x86_64 -m 2048 -M q35 -enable-kvm \
      -device e1000,netdev=net0 -netdev user,id=net0 \
      -snapshot -serial stdio -hda disk-image

The test program now takes sizes as arguments (with no arguments it
runs the 4 KiB to 64 KiB sequence):

#include <stdio.h>
#include <stdlib.h>
#include <hurd.h>
#include <mach.h>
#include <mach/gnumach.h>

static void
try (mach_port_t host, vm_size_t size)
{
  vm_address_t va = 0;
  rpc_phys_addr_t pa = 0;
  kern_return_t kr = vm_allocate_contiguous (host, mach_task_self (),
                                             &va, &pa, size,
                                             0, 0x100000000ULL, 0x1000);
  printf ("size=%6lu pmin=0 pmax=0x100000000 align=0x1000 -> kr=%d pa=%#llx\n",
          (unsigned long) size, kr, (unsigned long long) pa);
}

int
main (int argc, char **argv)
{
  mach_port_t host;

  if (get_privileged_ports (&host, NULL))
    {
      perror ("get_privileged_ports");
      return 1;
    }

  if (argc > 1)
    for (int i = 1; i < argc; i++)
      try (host, strtoul (argv[i], NULL, 0));
  else
    for (vm_size_t size = 4096; size <= 65536; size *= 2)
      try (host, size);

  return 0;
}


Thanks,
Tristan

Reply via email to