Skip to content

Commit

Permalink
scx_rustland: handle graceful vs non-graceful exit
Browse files Browse the repository at this point in the history
Do not report an exit error message if it's not present. Moreover,
distinguish between a graceful exit vs a non-graceful exit.

NOTE: in the future the whole exit handling probably can be moved to a
more generic place (scx_utils) to prevent code duplication across
schedulers and also to prevent small inconsistencies like this one.

Signed-off-by: Andrea Righi <[email protected]>
  • Loading branch information
Andrea Righi committed Dec 22, 2023
1 parent c7b52d4 commit 6daab3d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions scheds/rust/scx_rustland/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,15 +275,19 @@ impl<'a> Scheduler<'a> {

// Called on exit to get exit code and exit message from the BPF part.
fn report_bpf_exit_kind(&mut self) -> Result<()> {
// Report msg if EXT_OPS_EXIT_ERROR.
match self.read_bpf_exit_kind() {
0 => Ok(()),
etype => {
etype if etype == 2 => {
let cstr = unsafe { CStr::from_ptr(self.skel.bss().exit_msg.as_ptr() as *const _) };
let msg = cstr
.to_str()
.context("Failed to convert exit msg to string")
.unwrap();
info!("BPF exit_kind={} msg={}", etype, msg);
bail!("BPF exit_kind={} msg={}", etype, msg);
}
etype => {
info!("BPF exit_kind={}", etype);
Ok(())
}
}
Expand Down

0 comments on commit 6daab3d

Please sign in to comment.