mirror of
https://github.com/JakeHillion/scx.git
synced 2024-11-25 19:10:23 +00:00
scx_lavd: boost the latency critility of kernel threads
Many kernel threads performs latency critical tasks (e.g., net, gpu). In particular, AMD GPU driver runs the most part in the kernel space using kworker. Hence, treat kernel threads as if a woken up task. Signed-off-by: Changwoo Min <changwoo@igalia.com>
This commit is contained in:
parent
10f0378e9d
commit
95e2f4dabe
@ -65,6 +65,7 @@ enum consts {
|
||||
LAVD_LC_RUNTIME_MAX = LAVD_TARGETED_LATENCY_NS,
|
||||
LAVD_LC_RUNTIME_SHIFT = 15,
|
||||
LAVD_LC_WAKEUP_FT = 30,
|
||||
LAVD_LC_KTHREAD_FT = 30,
|
||||
|
||||
LAVD_SLICE_BOOST_MAX_FT = 3, /* maximum additional 3x of slice */
|
||||
LAVD_SLICE_BOOST_MAX_STEP = 6, /* 6 slice exhausitions in a row */
|
||||
|
@ -1188,6 +1188,11 @@ static s64 calc_static_prio_factor(struct task_struct *p)
|
||||
return (20 - get_nice_prio(p)) >> 1;
|
||||
}
|
||||
|
||||
static bool is_kernel_task(struct task_struct *p)
|
||||
{
|
||||
return !!(p->flags & PF_KTHREAD);
|
||||
}
|
||||
|
||||
static u64 calc_lat_cri(struct task_struct *p, struct task_ctx *taskc,
|
||||
u64 enq_flags)
|
||||
{
|
||||
@ -1231,6 +1236,13 @@ static u64 calc_lat_cri(struct task_struct *p, struct task_ctx *taskc,
|
||||
taskc->wakeup_ft += !!(enq_flags & SCX_ENQ_WAKEUP);
|
||||
lat_cri += taskc->wakeup_ft * LAVD_LC_WAKEUP_FT;
|
||||
|
||||
/*
|
||||
* Prioritize a kernel task since many kernel tasks serve
|
||||
* latency-critical jobs.
|
||||
*/
|
||||
if (is_kernel_task(p))
|
||||
lat_cri += LAVD_LC_KTHREAD_FT;
|
||||
|
||||
/*
|
||||
* Make sure the lat_cri is non-zero.
|
||||
*/
|
||||
@ -2196,11 +2208,6 @@ void BPF_STRUCT_OPS(lavd_enqueue, struct task_struct *p, u64 enq_flags)
|
||||
taskc->vdeadline_log_clk, enq_flags);
|
||||
}
|
||||
|
||||
static bool is_kernel_task(struct task_struct *p)
|
||||
{
|
||||
return !!(p->flags & PF_KTHREAD);
|
||||
}
|
||||
|
||||
static bool use_full_cpus(void)
|
||||
{
|
||||
struct sys_stat *stat_cur = get_sys_stat_cur();
|
||||
|
Loading…
Reference in New Issue
Block a user