maybe someone here can help me figure out how to map a big (really big) work area and lock it in memory.
I wrote a little test program to try this out, and it fails. As a regular user, perror() tells me some "resource is temporarily unavailable". As root, it says it "cannot allocate memory". I'm only asking for 1 byte. What's the problem? BTW it also fails if it asks for a mibibyte (1<<20)./**
* @file
* <pre>"Find out the limits on locked memory"
* Last Modified: Mon Aug 18 07:31:01 PDT 2014</pre>
* @author Kevin O'Gorman
*/
#define _GNU_SOURCE /* enable some of the mmap flags */
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/mman.h>
int
main(int argc, char *argv[])
{
void *where;
size_t length = 1;
where = mmap(NULL, length, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB | MAP_LOCKED | MAP_POPULATE, -1, 0);
if (where != MAP_FAILED) {
printf("Mapped at %p\n", where);
} else {
perror("Mapping failed");
}
return EXIT_SUCCESS;
}
--
Kevin O'Gorman
programmer, n. an organism that transmutes caffeine into software.
programmer, n. an organism that transmutes caffeine into software.
Please consider the environment before printing this email. |
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies