Skip to content

Commit

Permalink
Merge pull request #612 from multics69/lavd-monitor
Browse files Browse the repository at this point in the history
scx_lavd: add --monitor flag and two micro-optimizations
  • Loading branch information
multics69 authored Sep 6, 2024
2 parents 0fa369b + d9274bd commit e3243c5
Show file tree
Hide file tree
Showing 6 changed files with 523 additions and 68 deletions.
10 changes: 10 additions & 0 deletions scheds/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions scheds/rust/scx_lavd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ simplelog = "0.12"
static_assertions = "1.1.0"
rlimit = "0.10.1"
plain = "0.2.3"
gpoint = "0.2"

[build-dependencies]
scx_utils = { path = "../../../rust/scx_utils", version = "1.0.3" }
Expand Down
30 changes: 28 additions & 2 deletions scheds/rust/scx_lavd/src/bpf/intf.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,12 @@ enum consts {
LAVD_PREEMPT_TICK_MARGIN = (100ULL * NSEC_PER_USEC),

LAVD_SYS_STAT_INTERVAL_NS = (50ULL * NSEC_PER_MSEC),
LAVD_SYS_STAT_DECAY_TIMES = (2ULL * LAVD_TIME_ONE_SEC) / LAVD_SYS_STAT_INTERVAL_NS,
LAVD_CC_PER_CORE_MAX_CTUIL = 500, /* maximum per-core CPU utilization */
LAVD_CC_PER_TURBO_CORE_MAX_CTUIL = 750, /* maximum per-core CPU utilization for a turbo core */
LAVD_CC_NR_ACTIVE_MIN = 1, /* num of mininum active cores */
LAVD_CC_NR_OVRFLW = 1, /* num of overflow cores */
LAVD_CC_CPU_PIN_INTERVAL = (2ULL * LAVD_TIME_ONE_SEC),
LAVD_CC_CPU_PIN_INTERVAL = (1ULL * LAVD_TIME_ONE_SEC),
LAVD_CC_CPU_PIN_INTERVAL_DIV = (LAVD_CC_CPU_PIN_INTERVAL /
LAVD_SYS_STAT_INTERVAL_NS),

Expand Down Expand Up @@ -122,6 +123,16 @@ struct sys_stat {

volatile u32 nr_violation; /* number of utilization violation */
volatile u32 nr_active; /* number of active cores */

volatile u64 nr_sched; /* total scheduling so far */
volatile u64 nr_migration; /* number of task migration */
volatile u64 nr_preemption; /* number of preemption */
volatile u64 nr_greedy; /* number of greedy tasks scheduled */
volatile u64 nr_perf_cri; /* number of performance-critical tasks scheduled */
volatile u64 nr_lat_cri; /* number of latency-critical tasks scheduled */
volatile u64 nr_big; /* scheduled on big core */
volatile u64 nr_pc_on_big; /* performance-critical tasks scheduled on big core */
volatile u64 nr_lc_on_big; /* latency-critical tasks scheduled on big core */
};

/*
Expand Down Expand Up @@ -169,7 +180,7 @@ struct cpu_ctx {
*/
volatile u32 max_lat_cri; /* maximum latency criticality */
volatile u32 sum_lat_cri; /* sum of latency criticality */
volatile u32 sched_nr; /* number of schedules */
volatile u32 nr_sched; /* number of schedules */

/*
* Information used to keep track of performance criticality
Expand Down Expand Up @@ -205,6 +216,15 @@ struct cpu_ctx {
struct bpf_cpumask __kptr *tmp_o_mask; /* temporary cpu mask */
struct bpf_cpumask __kptr *tmp_t_mask; /* temporary cpu mask */
struct bpf_cpumask __kptr *tmp_t2_mask; /* temporary cpu mask */

/*
* Information for statistics.
*/
volatile u32 nr_migration; /* number of migrations */
volatile u32 nr_preemption; /* number of migrations */
volatile u32 nr_greedy; /* number of greedy tasks scheduled */
volatile u32 nr_perf_cri;
volatile u32 nr_lat_cri;
} __attribute__((aligned(CACHELINE_SIZE)));

/*
Expand Down Expand Up @@ -242,12 +262,18 @@ struct task_ctx {
volatile s32 victim_cpu;
u16 slice_boost_prio; /* how many times a task fully consumed the slice */
u8 wakeup_ft; /* regular wakeup = 1, sync wakeup = 2 */

/*
* Task's performance criticality
*/
u8 on_big; /* executable on a big core */
u8 on_little; /* executable on a little core */
u32 perf_cri; /* performance criticality of a task */

/*
* Information for statistics collection
*/
u32 cpu_id; /* CPU ID scheduled on */
};

/*
Expand Down
Loading

0 comments on commit e3243c5

Please sign in to comment.