3 ms·
On Linux, one used to be able to execute mmap() on /proc/self/mem. I used this to implement bank switching for an emulator. Despite Torvalds' recent rant about
by mcculley 9y ago
On Linux, one used to be able to execute mmap() on /proc/self/mem. I used this to implement bank switching for an emulator. Despite Torvalds' recent rant about preserving backward compatibility for userspace, this feature was removed at some point.
- cat199 9y agowhy is that necessary in this case vs some other use of mmap?
- mcculley 9y agoIt allowed one to map the zero page to a region and then quickly swap it for another region. This benefited code that emulated 16-bit address spaces.
- cat199 9y agoso, it made the equivalent portable code easier to write, am I correct?
- mcculley 9y agoNo, if I remember correctly, there was no other way to do what I was doing without using some file on the filesystem as the chunk of memory to be swapped. Calling mmap() on /proc/self/mem allowed one to make a block of memory show up at the zero page and swap it with another with a single system call, instead of copying the block back and forth. It has been at least a decade since I touched that code, so I may be misremembering.
- koverstreet 9y agoDid you ever complain on the list, or look into why it was removed? I'd be really curious why it was removed myself.
- mcculley 9y agoI didn't complain. At some point I upgraded my kernel and the code stopped working. This was over 10 years ago. I seem to remember going to the list and seeing that it had been removed due to a security problem. I also seem to remember a Torvalds line about only crazy people wanting to use such a feature. I had lost interest in maintaining the code, so I didn't pursue it.