mirror of
https://github.com/JakeHillion/scx.git
synced 2024-11-26 11:30:22 +00:00
scx_lavd: print the overall status of a scheduled task
L or R: Latency-critical, Regular H or I: performance-Hungry, performance-Insensitive B or T: Big, liTtle E or G: Eligible, Greedy P or N: Preemption, Not Signed-off-by: Changwoo Min <changwoo@igalia.com>
This commit is contained in:
parent
22d4b13e8e
commit
fc0ffeb45b
@ -91,6 +91,12 @@ enum consts {
|
||||
LAVD_LATENCY_CRITICAL_DSQ = 0, /* a global DSQ for latency-criticcal tasks */
|
||||
LAVD_REGULAR_DSQ = 1, /* a global DSQ for non-latency-criticcal tasks */
|
||||
LAVD_DSQ_STARVE_TIMEOUT = (5ULL * NSEC_PER_USEC),
|
||||
|
||||
LAVD_STATUS_STR_LEN = 5, /* {LR: Latency-critical, Regular}
|
||||
{HI: performance-Hungry, performance-Insensitive}
|
||||
{BT: Big, liTtle}
|
||||
{EG: Eligible, Greedy}
|
||||
{PN: Preemption, Not} */
|
||||
};
|
||||
|
||||
/*
|
||||
@ -218,6 +224,7 @@ struct task_ctx {
|
||||
struct task_ctx_x {
|
||||
pid_t pid;
|
||||
char comm[TASK_COMM_LEN + 1];
|
||||
char stat[LAVD_STATUS_STR_LEN + 1];
|
||||
u16 static_prio; /* nice priority */
|
||||
u32 cpu_id; /* where a task ran */
|
||||
u64 cpu_util; /* cpu utilization in [0..100] */
|
||||
@ -235,7 +242,6 @@ enum {
|
||||
LAVD_CMD_NOP = 0x0,
|
||||
LAVD_CMD_SCHED_N = 0x1,
|
||||
LAVD_CMD_PID = 0x2,
|
||||
LAVD_CMD_DUMP = 0x3,
|
||||
};
|
||||
|
||||
enum {
|
||||
|
@ -439,6 +439,15 @@ int submit_task_ctx(struct task_struct *p, struct task_ctx *taskc, u32 cpu_id)
|
||||
m->taskc_x.nr_active = stat_cur->nr_active;
|
||||
m->taskc_x.cpuperf_cur = cpuc->cpuperf_cur;
|
||||
|
||||
m->taskc_x.stat[0] = taskc->lat_cri > stat_cur->avg_lat_cri ?
|
||||
'L' : 'R';
|
||||
m->taskc_x.stat[1] = taskc->perf_cri > stat_cur->avg_perf_cri ?
|
||||
'H' : 'I';
|
||||
m->taskc_x.stat[2] = cpuc->big_core ? 'B' : 'T';
|
||||
m->taskc_x.stat[3] = taskc->greedy_ratio <= 1000 ? 'E' : 'G';
|
||||
m->taskc_x.stat[4] = taskc->victim_cpu >= 0 ? 'P' : 'N';
|
||||
m->taskc_x.stat[5] = '\0';
|
||||
|
||||
memcpy(&m->taskc, taskc, sizeof(m->taskc));
|
||||
|
||||
bpf_ringbuf_submit(m, 0);
|
||||
@ -491,25 +500,6 @@ static bool have_scheduled(struct task_ctx *taskc)
|
||||
return taskc->slice_ns != 0;
|
||||
}
|
||||
|
||||
static void proc_dump_all_tasks(struct task_struct *p)
|
||||
{
|
||||
struct task_struct *pos;
|
||||
struct task_ctx *taskc;
|
||||
|
||||
bpf_rcu_read_lock();
|
||||
|
||||
bpf_for_each(task, pos, NULL, BPF_TASK_ITER_ALL_THREADS) {
|
||||
/*
|
||||
* Print information about ever-scheduled tasks.
|
||||
*/
|
||||
taskc = get_task_ctx(pos);
|
||||
if (taskc && have_scheduled(taskc))
|
||||
submit_task_ctx(pos, taskc, LAVD_CPU_ID_NONE);
|
||||
}
|
||||
|
||||
bpf_rcu_read_unlock();
|
||||
}
|
||||
|
||||
static void try_proc_introspec_cmd(struct task_struct *p,
|
||||
struct task_ctx *taskc, u32 cpu_id)
|
||||
{
|
||||
@ -525,16 +515,6 @@ static void try_proc_introspec_cmd(struct task_struct *p,
|
||||
case LAVD_CMD_PID:
|
||||
proc_introspec_pid(p, taskc, cpu_id);
|
||||
break;
|
||||
case LAVD_CMD_DUMP:
|
||||
/*
|
||||
* When multiple tasks can compete to dump all, only the winner
|
||||
* task actually does the job.
|
||||
*/
|
||||
ret = __sync_bool_compare_and_swap(&intrspc.cmd,
|
||||
LAVD_CMD_DUMP, LAVD_CMD_NOP);
|
||||
if (ret)
|
||||
proc_dump_all_tasks(p);
|
||||
break;
|
||||
case LAVD_CMD_NOP:
|
||||
/* do nothing */
|
||||
break;
|
||||
|
@ -325,7 +325,7 @@ impl<'a> Scheduler<'a> {
|
||||
|
||||
if mseq % 32 == 1 {
|
||||
info!(
|
||||
"| {:6} | {:7} | {:17} \
|
||||
"| {:6} | {:7} | {:17} | {:5} \
|
||||
| {:4} | {:4} | {:12} \
|
||||
| {:14} | {:8} | {:7} \
|
||||
| {:8} | {:7} | {:8} \
|
||||
@ -336,6 +336,7 @@ impl<'a> Scheduler<'a> {
|
||||
"mseq",
|
||||
"pid",
|
||||
"comm",
|
||||
"stat",
|
||||
"cpu",
|
||||
"vtmc",
|
||||
"vddln_ns",
|
||||
@ -362,8 +363,12 @@ impl<'a> Scheduler<'a> {
|
||||
let c_tx_cm_str: &CStr = unsafe { CStr::from_ptr(c_tx_cm) };
|
||||
let tx_comm: &str = c_tx_cm_str.to_str().unwrap();
|
||||
|
||||
let c_tx_st: *const c_char = (&tx.stat as *const [c_char; 6]) as *const c_char;
|
||||
let c_tx_st_str: &CStr = unsafe { CStr::from_ptr(c_tx_st) };
|
||||
let tx_stat: &str = c_tx_st_str.to_str().unwrap();
|
||||
|
||||
info!(
|
||||
"| {:6} | {:7} | {:17} \
|
||||
"| {:6} | {:7} | {:17} | {:5} \
|
||||
| {:4} | {:4} | {:12} \
|
||||
| {:14} | {:8} | {:7} \
|
||||
| {:8} | {:7} | {:8} \
|
||||
@ -374,6 +379,7 @@ impl<'a> Scheduler<'a> {
|
||||
mseq,
|
||||
tx.pid,
|
||||
tx_comm,
|
||||
tx_stat,
|
||||
tx.cpu_id,
|
||||
tc.victim_cpu,
|
||||
tc.vdeadline_delta_ns,
|
||||
@ -420,11 +426,6 @@ impl<'a> Scheduler<'a> {
|
||||
if self.intrspc.requested == false as u8 {
|
||||
return;
|
||||
}
|
||||
|
||||
// Once dumped, it is done.
|
||||
if self.intrspc.cmd == LAVD_CMD_DUMP {
|
||||
self.intrspc.cmd = LAVD_CMD_NOP;
|
||||
}
|
||||
}
|
||||
|
||||
fn running(&mut self) -> bool {
|
||||
@ -505,7 +506,8 @@ fn main() -> Result<()> {
|
||||
" Note that scx_lavd currently is not optimized for multi-CCX/NUMA architectures."
|
||||
);
|
||||
info!(" Stay tuned for future improvements!");
|
||||
|
||||
info!(
|
||||
" stat: ('L'atency-critical, 'R'egular) (performance-'H'ungry, performance-'I'nsensitive) ('B'ig, li'T'tle) ('E'ligigle, 'G'reedy) ('P'reempting, 'N'ot)");
|
||||
info!("scx_lavd scheduler starts running.");
|
||||
if !sched.run()?.should_restart() {
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user