NHacker Next
  • new
  • past
  • show
  • ask
  • show
  • jobs
  • submit
The phaseout of the mmap() file operation in Linux (lwn.net)
Denvercoder9 5 days ago [-]
To be clear, this is about the internal implementation in the kernel, the mmap() system call is not going anywhere.
aa-jv 5 days ago [-]
I'm relieved, but also somewhat befuddled that someone would write such a shocking headline. It immediately had me reaching for the lkml archives to find out whats really going on.
denotational 1 days ago [-]
In its defence, the headline says "file operation" rather than "syscall", which makes it slightly less egregious: it's referring to `mmap` as a member of `struct file_operations`.
dooglius 1 days ago [-]
The mmap syscall operates on files so it's still very easily misinterpreted
commandersaki 1 days ago [-]
Which worked as intended; I first had a shock, did a double take, and realised there was nuance in file operation, read a little bit of the article and confirmed my suspicion it didn't have anything to do with the syscall.
1 days ago [-]
arp242 22 hours ago [-]
mmap is POSIX, so it's not going anywhere and you can rely on it until POSIX systems are phased out or the heat death of the universe, whichever comes sooner.
K0IN 5 days ago [-]
thank you that was the first thing I had to check.
ajross 1 days ago [-]
Indeed. But even so, it's mildly shocking, as struct file_operations has been one of the deepest (and most promiscuously) integrated and most conservative bits of the kernel API. This stuff dates back decades and almost never changes. And there are a lot of raw file drivers[1] still there from eras most people have forgotten about.

This is a big, big reorg even for Linux.

[1] To be fair, most of which probably don't support mapping.

kragen 1 days ago [-]
Yes, that's true. However, it's a kernel-internal API, and those have never been considered stable, unlike the system call ABIs, which are mostly sacrosanct. Except for, like, uselib(). This is because pretty much all the code that calls the kernel-internal APIs is in a monorepo, so you can fix it all when you make the change.

Also, it's not that the core kernel is ceasing to provide a facility that drivers depended on; rather, it's ceasing to depend on a facility that drivers provided. But doing so involves adding this new mmap_prepare() thing, which is making the kernel depend on a new facility that drivers now must provide, I guess?

porridgeraisin 5 days ago [-]
"We do NOT break userspace"
sethops1 1 days ago [-]
_shifty eyes over at cgroups_
o11c 1 days ago [-]
Or the numerous syscall breakages (2.4 to 2.6 was most notable, but there have been plenty before/since).

Or all sorts of things in /proc/ and /sys/.

And the sheer nastiness of PPID 0.

And ...

doubletwoyou 2 days ago [-]
That comment about how /dev/zero used to be used to allocate anonymous pages, anyone have more info? All I could find was a wikipedia article [0]

[0] https://en.m.wikipedia.org/wiki//dev/zero

jeffbee 1 days ago [-]
That's it, there isn't any more to know. When the ancient unixes first began to support anonymous maps, they were just hacked into existing code with "zero" as the file, because the only through-line in the unix family history is that the API must be as hideous as it needs to be to accommodate lazy system authors.
mort96 1 days ago [-]
Wait, by "allocating anonymous pages" we just mean memory allocation from the kernel that's used for implementing e.g malloc, right? Did memory mapped files come before memory allocation so that it "made sense" to implement memory allocation as "mapping in /dev/zero"?

Or was some amount heap memory always just mapped into the process in early UNIX so that the need to map more pages only appeared as programs started to demand more heap memory than whatever the standard amount was?

pdw 1 days ago [-]
In those days malloc would use sbrk to allocate memory. And yes, mmap was designed to memory map files. Using it to allocate anonymous pages came later.
mort96 1 days ago [-]
Oh, I had never even heard of those syscalls before! Thanks, that makes sense.
ars 1 days ago [-]
There is more to know, does the code special case this? Does it use the file name? Major minor number? Or does it actually read zero's from it and place them in memory?
convolvatron 1 days ago [-]
it wouldn't be too hard to look at the source for mmap and zero, but since the topic of this article is the removal of the mmap 'virtual function' in the file, that would have been a pretty good place to throw a zero-page allocation
DonHopkins 1 days ago [-]
I hope the new API is flexible enough to support my proposed /dev/seven, an infinite source of ^G.

https://news.ycombinator.com/item?id=17532285

>DonHopkins on July 14, 2018 | parent | context | favorite | on: The everything-is-a-file principle – Linus Torvald...

>I always wanted /dev/zero, which is used to mmap zeros into memory, to be more general and use the device minor number to define which byte gets mapped, so you could mknod /dev/seven with a minor number of 7, to provide an infinite source of beeps!

danudey 1 days ago [-]
Can we also have /dev/bseven, which is the same thing but as a block device? Convenient if you ever want to be able to acquire ^G at larger scale, or randomly seek through your infinite ^G.
mort96 1 days ago [-]
I want a /dev/yes. I'm tired of typing 'yes | apt install' etc. I want to type '</dev/yes apt install'. Just an infinite stream of "y\n".
matja 1 days ago [-]
drob518 1 days ago [-]
Yea, that’s a clickbait headline. A lot less concerning once you read the first paragraphs.
Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact
Rendered at 01:52:49 GMT+0000 (Coordinated Universal Time) with Vercel.