mmap

cuda - Zero-copy memory, memory-mapped file

六月ゝ 毕业季﹏ 提交于 2019-12-18 06:50:47
问题 I am trying to create a mapped memory file, containing uint32_t s, and then use that as zero-copy pinned memory as shown below for CUDA. I am getting the cudaErrorInvalidValue when getting the device pointer, having allocated space and mapped the memory from file. I know the error message (from the API) means : This indicates that one or more of the parameters passed to the API call is not within an acceptable range of values. But I'm struggling to figure out why I'm having this problem....

cuda - Zero-copy memory, memory-mapped file

笑着哭i 提交于 2019-12-18 06:50:35
问题 I am trying to create a mapped memory file, containing uint32_t s, and then use that as zero-copy pinned memory as shown below for CUDA. I am getting the cudaErrorInvalidValue when getting the device pointer, having allocated space and mapped the memory from file. I know the error message (from the API) means : This indicates that one or more of the parameters passed to the API call is not within an acceptable range of values. But I'm struggling to figure out why I'm having this problem....

munmap() failure with ENOMEM with private anonymous mapping

喜夏-厌秋 提交于 2019-12-18 03:51:13
问题 I have recently discovered that Linux does not guarantee that memory allocated with mmap can be freed with munmap if this leads to situation when number of VMA (Virtual Memory Area) structures exceed vm.max_map_count . Manpage states this (almost) clearly: ENOMEM The process's maximum number of mappings would have been exceeded. This error can also occur for munmap(), when unmapping a region in the middle of an existing mapping, since this results in two smaller mappings on either side of the

How to mmap the stack for the clone() system call on linux?

谁说胖子不能爱 提交于 2019-12-18 01:15:09
问题 The clone() system call on Linux takes a parameter pointing to the stack for the new created thread to use. The obvious way to do this is to simply malloc some space and pass that, but then you have to be sure you've malloc'd as much stack space as that thread will ever use (hard to predict). I remembered that when using pthreads I didn't have to do this, so I was curious what it did instead. I came across this site which explains, "The best solution, used by the Linux pthreads implementation

How to share APC cache between several PHP processes when running under FastCGI?

假装没事ソ 提交于 2019-12-17 21:52:44
问题 I'm currently running several copies of PHP/FastCGI, with APC enabled (under Apache+mod_fastcgi, if that matters). Can I share cache between the processes? How can I check if it's shared already? (I think the apc.mmap_file_mask ini setting might be involved, but I don't know how to use it.) (One of the reasons I think its not shared at the moment is that the apc.mmap_file_mask , as reported by the apc.php web interface flips between about 3 different values as I reload.) 回答1: APC does not

Why can't I mmap(MAP_FIXED) the highest virtual page in a 32-bit Linux process on a 64-bit kernel?

喜夏-厌秋 提交于 2019-12-17 20:00:33
问题 While attempting to test Is it allowed to access memory that spans the zero boundary in x86? in user-space on Linux, I wrote a 32-bit test program that tries to map the low and high pages of 32-bit virtual address space. After echo 0 | sudo tee /proc/sys/vm/mmap_min_addr , I can map the zero page, but I don't know why I can't map -4096 , i.e. (void*)0xfffff000 , the highest page. Why does mmap2((void*)-4096) return -ENOMEM ? strace ./a.out execve("./a.out", ["./a.out"], 0x7ffe08827c10 /* 65

Sharing memory between processes through the use of mmap()

不羁岁月 提交于 2019-12-17 18:27:09
问题 I'm in Linux 2.6. I have an environment where 2 processes simulate (using shared memory) the exchange of data through a simple implementation of the message passing mode. I have a client process (forked from the parent, which is the server) which writes a struct(message) to a memory mapped region created (after the fork) with: message *m = mmap(NULL, sizeof(message), PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0) This pointer is then written to a queue (in form of a linked list) into

Invalid argument for read-write mmap?

天涯浪子 提交于 2019-12-17 18:26:47
问题 I'm getting -EINVAL for some reason, and it's not clear to me why. Here's where I open and attempt to mmap the file: if ((fd = open(argv[1], O_RDWR)) < 0) { fprintf(stderr, "Failed to open %s: %s\n", argv[1], strerror(errno)); return 1; } struct stat statbuf; if (fstat(fd, &statbuf)) { fprintf(stderr, "stat filed: %s\n", strerror(errno)); return 1; } char* fbase = mmap(NULL, statbuf.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (fbase == MAP_FAILED) { fprintf(stderr, "mmap failed:

Does mmap with MAP_NORESERVE reserve physical memory?

两盒软妹~` 提交于 2019-12-17 12:31:11
问题 The mmap documentation says following about the flag MAP_NORESERVE. Do not reserve swap space for this mapping. When swap space is reserved, one has the guarantee that it is possible to modify the mapping. When swap space is not reserved one might get SIGSEGV upon a write if no physical memory is available. What I want actually is to only reserve virtual memory addresses and not have actual physical memory allocated. Can this be done with mmap with MAP_NORESERVE? If I want to use any physical

How to create and write to memory mapped files?

流过昼夜 提交于 2019-12-17 12:16:46
问题 Editor's note: This code example is from a version of Rust prior to 1.0 and the code it uses does not exist in Rust 1.0. Some answers have been updated to answer the core question for newer versions of Rust. I'm trying to create a memory mapped file using std::os::MemoryMap . The current approach looks as follows: use std::os; use std::ptr; use std::old_io as io; use std::os::unix::prelude::AsRawFd; use std::os::MapOption; let path = Path::new("test.mmap"); let f = match io::File::open_mode(