mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-24 18:03:25 +00:00
Enhance OSDK profile stability for SMP
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
5834f299bc
commit
d74d126e64
@ -49,6 +49,12 @@ fn do_parse_stack_traces(target_file: &PathBuf, args: &ProfileArgs) {
|
|||||||
profile.serialize_to(out_format, out_args.cpu_mask, out_file);
|
profile.serialize_to(out_format, out_args.cpu_mask, out_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
macro_rules! profile_round_delimiter {
|
||||||
|
() => {
|
||||||
|
"-<!OSDK_PROF_BT_ROUND!>-"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
fn do_collect_stack_traces(args: &ProfileArgs) {
|
fn do_collect_stack_traces(args: &ProfileArgs) {
|
||||||
let file_path = get_target_directory()
|
let file_path = get_target_directory()
|
||||||
.join("osdk")
|
.join("osdk")
|
||||||
@ -68,9 +74,9 @@ fn do_collect_stack_traces(args: &ProfileArgs) {
|
|||||||
let target_cmd = format!("target remote {}", remote);
|
let target_cmd = format!("target remote {}", remote);
|
||||||
let backtrace_cmd_seq = vec![
|
let backtrace_cmd_seq = vec![
|
||||||
"-ex",
|
"-ex",
|
||||||
"thread apply all bt -frame-arguments presence -frame-info short-location",
|
"t a a bt -frame-arguments presence -frame-info short-location",
|
||||||
"-ex",
|
"-ex",
|
||||||
"echo bt done\n",
|
concat!("echo ", profile_round_delimiter!(), "\n"),
|
||||||
"-ex",
|
"-ex",
|
||||||
"continue",
|
"continue",
|
||||||
];
|
];
|
||||||
@ -103,7 +109,7 @@ fn do_collect_stack_traces(args: &ProfileArgs) {
|
|||||||
loop {
|
loop {
|
||||||
let _ = gdb_stdout_reader.read_line(&mut gdb_stdout_buf);
|
let _ = gdb_stdout_reader.read_line(&mut gdb_stdout_buf);
|
||||||
gdb_output.push_str(&gdb_stdout_buf);
|
gdb_output.push_str(&gdb_stdout_buf);
|
||||||
if gdb_stdout_buf == "bt done\n" {
|
if gdb_stdout_buf.contains(profile_round_delimiter!()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
gdb_stdout_buf.clear();
|
gdb_stdout_buf.clear();
|
||||||
@ -121,7 +127,8 @@ fn do_collect_stack_traces(args: &ProfileArgs) {
|
|||||||
let out_args = &args.out_args;
|
let out_args = &args.out_args;
|
||||||
let out_path = out_args.output_path(None);
|
let out_path = out_args.output_path(None);
|
||||||
println!(
|
println!(
|
||||||
"Profile data collected. Writing the output to \"{}\".",
|
"{} profile samples collected. Writing the output to \"{}\".",
|
||||||
|
profile_buffer.cur_profile.nr_stack_traces(),
|
||||||
out_path.display()
|
out_path.display()
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -204,6 +211,10 @@ impl Profile {
|
|||||||
|
|
||||||
folded
|
folded
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn nr_stack_traces(&self) -> usize {
|
||||||
|
self.stack_traces.len()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -232,7 +243,7 @@ impl ProfileBuffer {
|
|||||||
// Otherwise it may initiate a new capture or a new CPU stack trace
|
// Otherwise it may initiate a new capture or a new CPU stack trace
|
||||||
|
|
||||||
// Check if this is a new CPU trace (starts with `Thread` and contains `CPU#N`)
|
// Check if this is a new CPU trace (starts with `Thread` and contains `CPU#N`)
|
||||||
if line.ends_with("[running])):") {
|
if line.ends_with("[running])):") || line.ends_with("[halted ])):") {
|
||||||
let cpu_id_idx = line.find("CPU#").unwrap();
|
let cpu_id_idx = line.find("CPU#").unwrap();
|
||||||
let cpu_id = line[cpu_id_idx + 4..]
|
let cpu_id = line[cpu_id_idx + 4..]
|
||||||
.split_whitespace()
|
.split_whitespace()
|
||||||
|
Reference in New Issue
Block a user