scx_lavd: remove the time restriction in preemption

Previously, the preemption is allowed only when a task is at the
early in its time slice by using LAVD_PREEMPT_KICK_MARGIN and
LAVD_PREEMPT_TICK_MARGIN. This is not necessary any more because
the lock holder preemption can avoid harmful preemptions. So we
remove LAVD_PREEMPT_KICK_MARGIN and LAVD_PREEMPT_TICK_MARGIN and
unleash the preemption.

Signed-off-by: Changwoo Min <changwoo@igalia.com>
This commit is contained in:
Changwoo Min 2024-10-22 01:30:26 +09:00
parent 07ed821511
commit 6fb57643fb
2 changed files with 3 additions and 9 deletions

View File

@ -41,9 +41,6 @@ enum consts_internal {
LAVD_CPU_ID_HERE = ((u32)-2),
LAVD_CPU_ID_NONE = ((u32)-1),
LAVD_PREEMPT_KICK_MARGIN = (1ULL * NSEC_PER_MSEC),
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 */

View File

@ -79,8 +79,7 @@ static bool is_worth_kick_other_task(struct task_ctx *taskc)
static bool can_cpu_be_kicked(u64 now, struct cpu_ctx *cpuc)
{
return cpuc->is_online &&
(now - cpuc->last_kick_clk) >= LAVD_PREEMPT_KICK_MARGIN;
return cpuc->is_online && (now >= cpuc->last_kick_clk);
}
static struct cpu_ctx *find_victim_cpu(const struct cpumask *cpumask,
@ -106,8 +105,7 @@ static struct cpu_ctx *find_victim_cpu(const struct cpumask *cpumask,
/*
* Get task's preemption information for comparison.
*/
prm_task.stopping_tm_est_ns = get_est_stopping_time(taskc) +
LAVD_PREEMPT_KICK_MARGIN;
prm_task.stopping_tm_est_ns = get_est_stopping_time(taskc);
prm_task.lat_cri = taskc->lat_cri;
prm_task.cpuc = cpuc = get_cpu_ctx();
if (!cpuc) {
@ -296,8 +294,7 @@ static bool try_yield_current_cpu(struct task_struct *p_run,
* zero.
*/
prm_run.stopping_tm_est_ns = taskc_run->last_running_clk +
taskc_run->run_time_ns -
LAVD_PREEMPT_TICK_MARGIN;
taskc_run->run_time_ns;
prm_run.lat_cri = taskc_run->lat_cri;
bpf_rcu_read_lock();