Skip to content

Commit ca42c84

Browse files
committed
example(uffd): dont panic if read(2) from uffd returns -EAGAIN
Started seeing the below failure in test_population_latency: thread 'main' panicked at .../uffd/fault_all_handler.rs:41:18: uffd_msg not ready note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace I am not entierly sure how this can happen, because the read from the uffd is supposed to be blocking, but maybe it's a weird interaction with the fault-all behavior (e.g. there was a uffd event queues, but because we faulted everything it got cancelled again?), so let's just try going back to read(2) if we dont read anything. Signed-off-by: Patrick Roy <[email protected]>
1 parent e3a06b4 commit ca42c84

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/firecracker/examples/uffd/fault_all_handler.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ fn main() {
3737
runtime.run(
3838
|uffd_handler: &mut UffdHandler| {
3939
// Read an event from the userfaultfd.
40-
let event = uffd_handler
41-
.read_event()
42-
.expect("Failed to read uffd_msg")
43-
.expect("uffd_msg not ready");
40+
let Some(event) = uffd_handler.read_event().expect("Failed to read uffd_msg") else {
41+
return;
42+
};
4443

4544
if let userfaultfd::Event::Pagefault { addr, .. } = event {
4645
let bit =

0 commit comments

Comments
 (0)