Re: F39 proposal: Increase vm.max_map_count value (System-Wide Change proposal)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* Ben Cotton:

> Concerns over possible downsides were raised. I am not aware of any,
> but more input here is desired.

You can play with the following program to overload the kernel with many
mappings:

#include <err.h>
#include <sys/mman.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

int
main (int argc, char **argv)
{
  int count;
  if (argc != 2 || (count = atoi (argv[1])) < 1) {
    fprintf (stderr, "usage: %s PAGE-COUNT\n", argv[0]);
    return 1;
  }
  long page_size = sysconf (_SC_PAGE_SIZE);
  size_t total_size;
  if (__builtin_mul_overflow (page_size, count, &total_size))
    errx (1, "page count too large: %d", count);
  void *p = mmap (NULL, total_size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS,
                  -1, 0);
  if (p == MAP_FAILED)
    err (1, "mmap (%zu bytes)", total_size);
  char *p0 = p;
  for (unsigned i = 0; i < (unsigned) count; i += 2) {
    if (mprotect (p0, page_size, PROT_READ | PROT_WRITE) != 0)
      err (1, "mprotect (after %u mappings)", i);
    p0 += 2 * page_size;
  }
}

In my experiments, the kernel OOM handler does not terminate this
mapping-creating process, but random desktop services first.  If the
stress tester runs directly under GNOME Terminal, it may get terminated
early enough for the desktop to recover (with some services missing,
like calendar and tracker).  But if it runs under tmux in the background
(still as non-root), it either crashes or freezes the desktop.

This was with kernel 6.2.9-200.fc37.x86_64.

So I would like to echo the suggestion that this should go upstream
first, along with some OOM handler improvements.

Thanks,
Florian
_______________________________________________
devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Users]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]

  Powered by Linux