facebookexperimental / hermit

Hermit launches linux x86_64 programs in a special, hermetically isolated sandbox to control their execution. Hermit translates normal, nondeterministic behavior, into deterministic, repeatable behavior. This can be used for various applications, including replay-debugging, reproducible artifacts, chaos mode concurrency testing and bug analysis.
Other
1.17k stars 31 forks source link

Question: Is scheduler preemptive? #23

Closed MBkkt closed 1 year ago

MBkkt commented 1 year ago

If yes how it works? Maybe you can share some open design docs/notes/comments?

If no, have you plan to change it?

rrnewton commented 1 year ago

Thanks for your question. FYI, we're in the process of porting information from our internal wikis to an externalizable set of design docs.

Yes, it's definitely preemptive. We use the retired-branch-conditional perf counter (RCBs) in order to preempt syscall-free regions of the guest execution. This facility is built in at the Reverie layer as the set_timer_precise function, which arranges for a callback to trigger exactly N RCB events after that call. There's a whole bunch of logic for setting what these time slices should be: either a large slice of time only as a backstop for breaking busy-waits, or a smaller random slice of time under --chaos, in order to explore thread interleavings.

Of course, syscalls, cpuid, rdtsc, and signals are all intercepted events that switch control to the scheduler as well.

MBkkt commented 1 year ago

Understood, thanks!

But in that case, can I specify some calls to not included to this?

Try to explain why do I want it:

What if I run something in CI, it failed, I have seed, but if I run it with log debug, or something like this. it will be other path in "execution graph".

Is it possible to disable perf counter and some syscalls from going to scheduler?