mmap Questions

2

Are mmap calls atomic in their effect? That is, does a mapping change made by mmap appear atomically to other threads accessing the affected region? As a litmus test, consider the case you do a mma...
Trout asked 21/1, 2020 at 17:1

1

I have a script that generally operates on entire block devices, and if every block that gets read is cached, it will evict data being used by other applications. To prevent this from happening, I ...
Titrate asked 31/7, 2021 at 21:24

4

Hypothetically, suppose I want to perform sequential writing to a potentially very large file. If I mmap() a gigantic region and madvise(MADV_SEQUENTIAL) on that entire region, then I can write to...
Karolinekaroly asked 19/2, 2013 at 21:59

4

Solved

I have a small example program which simply fopens a file and uses fgets to read it. Using strace, I notice that the first call to fgets runs a mmap system call, and then read system calls are used...
Charolettecharon asked 12/8, 2011 at 19:47

1

Solved

As I understand it, when you mmap a file you are basically mapping the pages from the page cache for that file directly into your process, and when you use O_DIRECT you are bypassing the page cache...
Westsouthwest asked 30/10, 2015 at 23:13

1

Linux mmap(2) says: MAP_PRIVATE Create a private copy-on-write mapping. Updates to the mapping are not visible to other processes mapping the same file, and are not carried through to the underlyi...
Cope asked 2/4, 2021 at 21:20

3

Solved

To be specific: why can I do this: FILE *fp = fopen("/proc/self/maps", "r"); char buf[513]; buf[512] = NULL; while(fgets(buf, 512, fp) > NULL) printf("%s", buf); b...
Skep asked 16/2, 2021 at 13:37

3

Solved

Overview I have a program bounded significantly by IO and am trying to speed it up. Using mmap seemed to be a good idea, but it actually degrades the performance relative to just using a series of...
Mentally asked 19/5, 2011 at 8:31

5

Typical implementations of malloc use brk/sbrk as the primary means of claiming memory from the OS. However, they also use mmap to get chunks for large allocations. Is there a real benefit to using...
Rundgren asked 19/4, 2019 at 22:35

1

Solved

I'm looking for, essentially, the ext4 equivalent of mremap(). I have a big mmap()'d file that I'm allocating arrays in, and the arrays need to grow. So I want to make the first array larger at its...
Onshore asked 8/12, 2020 at 19:41

2

Solved

In Linux, the mmap(2) man page explains that an anonymous mapping . . . is not backed by any file; its contents are initialized to zero. The FreeBSD mmap(2) man page does not make a similar gu...
Hay asked 9/7, 2013 at 3:42

1

Solved

I'm trying to share memory between a python process and a nodejs process started from the python process using an anonymous mmap. Essentially, the python process begins, initializes the mmap and st...
Leporid asked 20/10, 2020 at 20:38

2

I've been experimenting with MALLOC_MMAP_THRESHOLD_ and MALLOC_MMAP_MAX_ env variables to affect memory management in a long-running Python 2 process. See http://man7.org/linux/man-pages/man3/mall...
Chivalry asked 26/2, 2016 at 20:14

1

Solved

I've got an embedded ARM Linux box with a limited amount of RAM (512MB) and no swap space, on which I need to create and then manipulate a fairly large file (~200MB). Loading the entire file into R...
Durbin asked 5/2, 2020 at 15:43

3

Solved

I tried to create MAP_GROWSDOWN mapping with the expectation it would grow automatically. As specified in the manual page: MAP_GROWSDOWN This flag is used for stacks. It indicates to the kern...
Abstain asked 4/7, 2019 at 13:11

2

If I read and write a single file using normal IO APIs, writes are guaranteed to be atomic on a per-block basis. That is, if my write only modifies a single block, the operating system guarantees t...
Combination asked 21/9, 2010 at 10:17

6

Solved

What limits the size of a memory-mapped file? I know it can't be bigger than the largest continuous chunk of unallocated address space, and that there should be enough free disk space. But are ther...
Tartlet asked 7/4, 2009 at 16:1

1

Solved

I am implementing a JIT (for studies) and I would like to know if it is possible to run opcodes, without using mmap, since I am 'playing' on an operating system that MMAP does not have the MAP_ANON...
Brazil asked 7/4, 2020 at 21:17

3

Solved

How exactly is user memory and kernels memory differentiated inside the Linux kernel(in terms of giving security to kernel space)? What are the different ways I can write in kernel address space ...
Ferule asked 12/3, 2012 at 5:36

2

Solved

I'm trying to map device memory residing on 64-bit address into 32-bit process on 64-bit OS. I'm using the following lines baseaddr = addr & ~(sysconf(_SC_PAGE_SIZE) - 1); fd = open("/dev/mem"...
Lindalindahl asked 8/1, 2020 at 15:29

4

Solved

From the manual, I just know that mmap() maps a file to a virtual address space, so the file can be randomly accessed. But, it is unclear to me that whether the mapped file is loaded into memory im...
Gametocyte asked 29/10, 2013 at 8:55

2

Solved

I am banging my head into the wall with this. In my project, when I'm allocating memory with mmap the mapping (/proc/self/maps) shows that it is an readable and executable region despite I request...
Duplication asked 6/10, 2019 at 19:13

6

Solved

POSIX environments provide at least two ways of accessing files. There's the standard system calls open(), read(), write(), and friends, but there's also the option of using mmap() to map the file ...
Intinction asked 3/11, 2008 at 7:56

1

Given a process that creates a large linux kernel page cache via mmap'd files, running in a docker container (cgroup) with a memory limit causes kernel slab allocation errors: Jul 18 21:29:01 ip-1...
Crankpin asked 18/7, 2019 at 22:42

8

Solved

I have a long-living application with frequent memory allocation-deallocation. Will any malloc implementation return freed memory back to the system? What is, in this respect, the behavior of: ptm...
Incrassate asked 6/2, 2010 at 23:58

© 2022 - 2024 — McMap. All rights reserved.