Skip to content

Commit

Permalink
sched/bmq: BMQ boost priority adjustment
Browse files Browse the repository at this point in the history
This is BMQ boost priority adjustment after the just fix commit for torvalds#89.
  • Loading branch information
cchalpha committed Sep 15, 2024
1 parent 7917ea3 commit af96aba
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 16 deletions.
3 changes: 0 additions & 3 deletions kernel/sched/alt_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -4875,9 +4875,6 @@ static void __sched notrace __schedule(unsigned int sched_mode)
#endif

if (likely(prev != next)) {
#ifdef CONFIG_SCHED_BMQ
rq->last_ts_switch = rq->clock;
#endif
next->last_ran = rq->clock_task;

/*printk(KERN_INFO "sched: %px -> %px\n", prev, next);*/
Expand Down
3 changes: 0 additions & 3 deletions kernel/sched/alt_sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,6 @@ struct rq {
/* Ensure that all clocks are in the same cache line */
u64 clock ____cacheline_aligned;
u64 clock_task;
#ifdef CONFIG_SCHED_BMQ
u64 last_ts_switch;
#endif

unsigned int nr_running;
unsigned long nr_uninterruptible;
Expand Down
17 changes: 7 additions & 10 deletions kernel/sched/bmq.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
/*
* BMQ only routines
*/
#define rq_switch_time(rq) ((rq)->clock - (rq)->last_ts_switch)
#define boost_threshold(p) (sysctl_sched_base_slice >> ((20 - (p)->boost_prio) / 2))

static inline void boost_task(struct task_struct *p)
static inline void boost_task(struct task_struct *p, int n)
{
int limit;

Expand All @@ -21,8 +18,7 @@ static inline void boost_task(struct task_struct *p)
return;
}

if (p->boost_prio > limit)
p->boost_prio--;
p->boost_prio = max(limit, p->boost_prio - n);
}

static inline void deboost_task(struct task_struct *p)
Expand Down Expand Up @@ -90,12 +86,13 @@ static inline void do_sched_yield_type_1(struct task_struct *p, struct rq *rq)

static inline void sched_task_ttwu(struct task_struct *p)
{
if(this_rq()->clock_task - p->last_ran > sysctl_sched_base_slice)
boost_task(p);
s64 delta = this_rq()->clock_task > p->last_ran;

if (likely(delta > 0))
boost_task(p, delta >> 22);
}

static inline void sched_task_deactivate(struct task_struct *p, struct rq *rq)
{
if (rq_switch_time(rq) < boost_threshold(p))
boost_task(p);
boost_task(p, 1);
}

0 comments on commit af96aba

Please sign in to comment.