Skip to content

Commit

Permalink
sched/alt: Fix BMQ bugs
Browse files Browse the repository at this point in the history
Two bugs cause torvalds#89 issue,
* Unable to deboost task when time slice expired.
* New forked task is running at MAX_PRIORITY_ADJ.
  • Loading branch information
cchalpha committed Nov 18, 2024
1 parent 1fae03c commit 1b2ce3f
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions kernel/sched/bmq.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,16 @@ inline int task_running_nice(struct task_struct *p)
}

static inline void sched_update_rq_clock(struct rq *rq) {}
static inline void sched_task_renew(struct task_struct *p, const struct rq *rq) {}
static inline void sched_task_sanity_check(struct task_struct *p, struct rq *rq) {}

static void sched_task_fork(struct task_struct *p, struct rq *rq)
static inline void sched_task_renew(struct task_struct *p, const struct rq *rq)
{
p->boost_prio = MAX_PRIORITY_ADJ;
if (rq_switch_time(rq) > sysctl_sched_base_slice)
deboost_task(p);
}

static inline void sched_task_sanity_check(struct task_struct *p, struct rq *rq) {}
static void sched_task_fork(struct task_struct *p, struct rq *rq) {}

static inline void do_sched_yield_type_1(struct task_struct *p, struct rq *rq)
{
p->boost_prio = MAX_PRIORITY_ADJ;
Expand All @@ -92,10 +94,6 @@ static inline void sched_task_ttwu(struct task_struct *p)

static inline void sched_task_deactivate(struct task_struct *p, struct rq *rq)
{
u64 switch_ns = rq_switch_time(rq);

if (switch_ns < boost_threshold(p))
if (rq_switch_time(rq) < boost_threshold(p))
boost_task(p);
else if (switch_ns > sysctl_sched_base_slice)
deboost_task(p);
}

0 comments on commit 1b2ce3f

Please sign in to comment.