mmap

GDB can't access mmap()'d kernel allocated memory?

和自甴很熟 提交于 2019-12-01 18:51:00
I'm running into an issue with GDB and some buffers allocated in kernel space. The buffers are allocated by a kernel module that is supposed to allocate contiguous blocks of memory, and then memory mapped into userspace via a mmap() call. GDB, however, can't seem to access these blocks at any time. For example, after hitting a breakpoint in GDB: (gdb) x /10xb 0x4567e000 0x4567e000: Cannot access memory at address 0x4567e000 However, looking at the application's currently mapped memory regions in /proc//smaps shows: 4567e000-456d3000 rwxs 8913f000 00:0d 883 /dev/cmem Size: 340 kB Rss: 340 kB

system call to map memory to a file descriptor (inverse mmap)?

眉间皱痕 提交于 2019-12-01 17:00:20
I want to be able to map memory to a file descriptor so I can use some existing functions that need a file descriptor. Here's essentially what I'm looking for: void do_operation1(int fd); char data[DATA_MAX] = { /* embedded binary data */ }; int fd = addr_to_fd(data, DATA_MAX); do_operation1(fd); /* ... operate on fd ... */ What system call, or calls, can I use to accomplish this? Enquimot You should Check out shm_open() . Some implementations have fmemopen() . (Then of course you have to call fileno() ). If yours doesn't, you can build it yourself with fork() and pipe() . Sure, just open(argv

system call to map memory to a file descriptor (inverse mmap)?

五迷三道 提交于 2019-12-01 16:19:33
问题 I want to be able to map memory to a file descriptor so I can use some existing functions that need a file descriptor. Here's essentially what I'm looking for: void do_operation1(int fd); char data[DATA_MAX] = { /* embedded binary data */ }; int fd = addr_to_fd(data, DATA_MAX); do_operation1(fd); /* ... operate on fd ... */ What system call, or calls, can I use to accomplish this? 回答1: You should Check out shm_open() . 回答2: Some implementations have fmemopen() . (Then of course you have to

How can I reserve virtual memory in Linux?

寵の児 提交于 2019-12-01 09:50:17
I have an application that reserves a contiguous memory block using VirtualAllocEx on Windows with the MEM_RESERVE flag. This reserves a virtual memory block, but does not back it with a physical page or page file chunk. Hence, accessing the allocated memory will result in a segmentation fault -- but other allocations will not intersect with this virtual memory block. How can I do the same for Linux with mmap? I did notice the answer in this question , but does that really guarantee that say, 1 GB of physical memory won't be allocated to my process if I don't touch the allocated pages? I don't

Why in mmap PROT_READ equals PROT_EXEC

萝らか妹 提交于 2019-12-01 06:57:27
问题 I tried to allocate some memory pages with read only access using mmap function. I printed /proc/self/maps to check if the memory protection was working. It showed like this even though the protection argument of mmap was PROT_READ 7fec0c585000-7fec0c785000 r-xp 00000000 00:00 0 This means that when I ask the kernel to allocate some read only memory pages it mark them as executable too. I did some other test and I realized that when I ask for a write only pages, PROT_WRITE without PROT_READ ,

How can I reserve virtual memory in Linux?

ε祈祈猫儿з 提交于 2019-12-01 05:43:43
问题 I have an application that reserves a contiguous memory block using VirtualAllocEx on Windows with the MEM_RESERVE flag. This reserves a virtual memory block, but does not back it with a physical page or page file chunk. Hence, accessing the allocated memory will result in a segmentation fault -- but other allocations will not intersect with this virtual memory block. How can I do the same for Linux with mmap? I did notice the answer in this question, but does that really guarantee that say,

Substitute for NSData deprecated dataWithContentsOfMappedFile

只谈情不闲聊 提交于 2019-12-01 05:31:40
So +(id)dataWithContentsOfMappedFile:(NSString *)path is apparently deprecated since iOS 5.0. It sounds to me like I should avoid using it, but then what should I use instead? I was using mmap to create memory mapped files and it worked with iOS5, but in iOS6, something is wrong because I get an error as soon as I try to update or read the buffer. int fd = open(path, O_RDWR); off_t offset = 0; snapshotData = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, offset); close(fd); Use +dataWithContentsOfFile:options:error: . Pass NSDataReadingMappedIfSafe as the option. You can also use

Explanation/information sought: Windows write I/O performance with “fsync” (FlushFileBuffers)

拟墨画扇 提交于 2019-12-01 04:52:43
This question is in follow up of an earlier question I posted: Windows fsync (FlushFileBuffers) performance with large files . Where I found a possible solution but also new questions. While benchmarking different scenarios for fsynced writes, I found a number of surprising results. I am hoping someone can help explain or point me in the direction of information that explains these results. What this benchmark does is writing random blocks (pages 4096 bytes large) to a file sequentially in batches of 8 pages (32 K) and then flushing the writes. It writes a total of 200000 pages, amounting to a

Codeforces Round #556 Div. 2

隐身守侯 提交于 2019-12-01 03:46:36
Codeforces Round #556 Div. 2 [A. Stock Arbitraging](https://codeforces.com/contest/1150/problem/A) [B. Tiling Challenge](https://codeforces.com/contest/1150/problem/B) [C. Prefix Sum Primes](https://codeforces.com/contest/1150/problem/C) 手速场,输了手速,在线掉分。 A. Stock Arbitraging Welcome to Codeforces Stock Exchange! We’re pretty limited now as we currently allow trading on one stock, Codeforces Ltd. We hope you’ll still be able to make profit from the market! In the morning, there are n opportunities to buy shares. The i-th of them allows to buy as many shares as you want, each at the price of si

How to get writes via an mmap mapped memory pointer to flush immediately?

风流意气都作罢 提交于 2019-11-30 21:36:13
I'm having what appears to be a caching problem when using /dev/mem with mmap on a dual ARM processor system (Xilinx Zynq, to be exact). My configuration is asymmettric, with one processor running Linux and the other processor running a bare metal application. They communicate through a block of RAM that isn't in the Linux virtual memory space (it was excluded by the devicetree file). When my userspace Linux application writes to memory using the pointer returned from mmap(), it can take anywhere from 100 ms to well over a second for the second processor to detect the changed memory content.