Questions tagged [mmap]

mmap is a POSIX-compliant Unix system call that maps files or devices into memory.

mmap() creates a new mapping in the virtual address space of the calling process.

https://en.wikipedia.org/wiki/Mmap

1936 questions
0
votes
1 answer

why multi-thread cant improve a mmap task?

I have a big task, which need to read 500 files (50G in total). for every file, i should read it out, and do some calculation according to data from file. just calculate, nothing else. and i can ensure tasks are independent, just share some…
nick
  • 832
  • 3
  • 12
0
votes
1 answer

Reading tpacket3_hdr from Packet MMAP and getting payload body

I have a tpacket3_hdr *ppd pointer object. I know how to extract iphdr and tcphdr but what if I need the body part of a packet. I am trying like this struct iphdr *ip = (struct iphdr *) ((uint8_t *) eth + ETH_HLEN); struct tcphdr *tcp=(struct…
user786
  • 3,902
  • 4
  • 40
  • 72
0
votes
1 answer

Can I enforce sbrk return address to be within a certain specific range?

I want to make sure the return address of sbrk is within a certain specific range. I read somewhere that sbrk allocates from an area allocated at program initialization. So I'm wondering if there's anyway I can enforce the program initialization to…
AetX
  • 193
  • 6
0
votes
0 answers

Is there any way I can enforce a process's base address?

When create a process, how does the system designate its base address? Is there anyway I can enforce it? For example, I have an address 0x55d1008fc000, and I'd like the process to always start from this address.
AetX
  • 193
  • 6
0
votes
1 answer

How to return physical pages while keeping virtual addresses mapped?

I'd like to reserve a large contiguous region (4GiB) of virtual address space. I can do this with mmap. Then, as I write to the memory, the kernel will gradually cause it to become physically backed. At some stage I'd like to return physical pages…
rp123
  • 3,623
  • 1
  • 18
  • 20
0
votes
0 answers

How to assign/declear a structure to a particular address pointed by a pointer?

I'm trying to assign a structure to a particular memory type(write-back) location. My ultimate goal is to read from that memory location into L1D cache. To achieve this, I did the following, Using the sample code from MTRR (Memory Type Range…
user45698746
  • 305
  • 2
  • 13
0
votes
1 answer

Most portable way to use mprotect() on allocated memory

I was wondering if there is a portable way to dynamically allocate memory and then restrict read/write access to a portion of this memory, e. g. using the POSIX function mprotect(). I can think of the following approaches: Allocate memory using…
Socob
  • 1,189
  • 1
  • 12
  • 26
0
votes
1 answer

mmap PCIe BAR and print content of addr is ffffffff

I tried to use mmap() in the linux user mode to map the resource2 file in sysfs to obtain the BAR of the pcie device. The code is shown below. char *devname = "/sys/bus/pci/devices/0000:04:00.2/resource2"; res_fd = open(devname, O_RDWR); if (res_fd…
xisme
  • 19
  • 4
0
votes
0 answers

mmap(MAP_SHARED) call not working in GPFS

I am having problems with files that were modified with mmap(MAP_SHARED) in GPFS file system. Here is what I am doing: #define SZ 10 int fd = open("out", O_RDWR | O_CREAT | O_TRUNC, 0660); ftruncate(fd, SZ); void *buf = mmap(0, SZ, PROT_READ |…
max bushlya
  • 63
  • 1
  • 6
0
votes
3 answers

using pointer aritmetic in void*

My machine is ubuntu 20.04 I have a assignment that say "Using the system calls (mmap and munmap) implement your own functions for dynamic memory allocation: mymalloc and myfree, which have the same functionality as malloc and free from the standard…
Muzaffer
  • 5
  • 4
0
votes
0 answers

need to debug MMAP so where is the object file for MMAP or module containing MMAP() -- how to find in linux?

I am trying to debug MMAP with kprobe but I dont know how to set break points inside MMAP. In my lib/modules there I searched but could not find that resembles mmap containing module. how can I debug mmap with kprobe so I need object file of the…
user786
  • 3,902
  • 4
  • 40
  • 72
0
votes
0 answers

What is an effective POSIX define check for mmap support?

I'm coming from a windows background so I'm a bit new here, but I'm trying to conditionally use mmap() but only if the platform supports it. I know now it's a POSIX standard, and I'd like to check for it in my code. However, I'm confused as to the…
0
votes
1 answer

Difference results with mmap (c), fopen(c) and ifstream(c++)

I have 3 different programs (mmap,fopen,ifstream) to count the occurance of a character in a file. I do this to test the performance of different techniques of file reading from the memory. But even though i get the same count for ifstream and…
0
votes
0 answers

Can setrlimit be used to force mmap to return VA within 64GB range?

I am working on a ARM64 server and trying to make an old program work. I don't have to source code, just a binary. The binary uses a LuaJit which does not support 48bit Virtual Address(VA). However, my kernel uses 48bit VA. LuaJit uses mmap to…
DeanSinaean
  • 2,297
  • 4
  • 16
  • 19
0
votes
0 answers

Creating a file in program, mapping the file, and using memcpy... all permissions open, but error code is 'permission denied'?

UPDATE: okay, the mapping did not succeed, and the errno I am getting says 'permission denied.' Given that the target file has all permissions 'on,' I am running out of ideas for what is causing the failure. I'm trying to copy a 1GB file to a file…
Nick B.
  • 63
  • 1
  • 8