Re: hugetlb: reservation race leading to under provisioning

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

 



I have only now realized I haven't attached the promissed program to
replicate the issue.

$ cat badmmap.c
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <hugetlbfs.h>
#include <sys/mman.h>
int main(int argc, const char **argv) {
  const size_t len = 224 * 1024 * 1024;
  int count = (argc > 1) ? atoi(argv[1]) : 1000;
  int i;
  for (i = 0; i < count; ++i) {
    int fd = hugetlbfs_unlinked_fd();
    void *ptr = mmap(0, len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
    if (ptr == MAP_FAILED) {
      fprintf(stderr, "mmap() failed on iteration %d (%s)\n", i, strerror(errno));
      return 1;
    }
    close(fd);
    if (munmap(ptr, len) < 0) {
      fprintf(stderr, "munmap() failed on iteration %d (%s)\n", i, strerror(errno));
      return 1;
    }
  }
  printf("PASSED %d iters\n", count);
  return 0;
}

$ cc -o badmmap badmmap.c -lhugetlbfs

Run 8 or so instances in parallel to reproduce.
-- 
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]