"User-space data may not be resident in RAM"
"User-space data may not be resident in RAM"
Posted Jul 9, 2020 6:28 UTC (Thu) by epa (subscriber, #39769)In reply to: "User-space data may not be resident in RAM" by Fowl
Parent article: Sleepable BPF programs
As for ordinary fork() where you won't immediately exec() afterwards, that might not spoil things, as it's only *writing* to user-space memory that can cause a copy-on-write fault, not reading it. And a system call to read bytes from a file into some memory may as well reserve the physical space in advance, rather than allocating it only once data comes back from the disk.
Posted Jul 9, 2020 6:35 UTC (Thu)
by Cyberax (✭ supporter ✭, #52523)
[Link] (3 responses)
Posted Jul 9, 2020 8:55 UTC (Thu)
by epa (subscriber, #39769)
[Link] (2 responses)
Posted Jul 9, 2020 13:28 UTC (Thu)
by Fowl (subscriber, #65667)
[Link]
So you'd have to not write in *both* the parent and the child until the child execs.
Posted Jul 9, 2020 17:54 UTC (Thu)
by Cyberax (✭ supporter ✭, #52523)
[Link]
Posted Jul 9, 2020 13:13 UTC (Thu)
by Fowl (subscriber, #65667)
[Link] (2 responses)
Hey, Oh and how does thread-local storage work? Can you move it between threads? Is it even common? Does it depends on the thread ID? Is it possible to fake the TID? I don't know
Hmm and how do you know when you can free the stack you've just allocated for this new out-of-process-but-same-address-space thread you've just started? And I bet python and other runtime-y things are not going to be happy with two threads that think they're the same. Maybe block the parent until the child Anyway, I had fun spending 15 minutes thinking about it.
Posted Jul 9, 2020 13:20 UTC (Thu)
by Fowl (subscriber, #65667)
[Link] (1 responses)
Still, fun.
Posted Jul 9, 2020 17:06 UTC (Thu)
by JGR (subscriber, #93631)
[Link]
Posted Jul 9, 2020 21:39 UTC (Thu)
by ibukanov (subscriber, #3942)
[Link]
"User-space data may not be resident in RAM"
Unless you're writing from other threads...
"User-space data may not be resident in RAM"
"User-space data may not be resident in RAM"
"User-space data may not be resident in RAM"
Ha, that's an interesting idea - "User-space data may not be resident in RAM"
fork_nocow()
. Exist in the parent's address space until exec()
.
clone(2)
already exists! A trampoline to spill all your registers to memory and you're done. Except for having to be careful not to leak any memory, as the memory would leak in the parent too, it's probably a friendlier environment than using regular fork - all your threads are still there. Oh and locks, who knows what's going on with that.
exec
s? I'm going to wave my magic wand and proclaim that if you did this you could then share the same stack on both sides of this new fork_nocow
.
Oh I'm an idiot. "User-space data may not be resident in RAM"
fork
has to return - of course you can't share a stack. Copying/COWing just the stack would mess up all those RAII and scope based resource cleanup things. More likely to work with a callback, but then you've thrown away the almost-compatibility with existing code that was the whole point.
"User-space data may not be resident in RAM"
"User-space data may not be resident in RAM"