Skip to content

Commit

Permalink
sched/alt: Fix for v5.14-prjc-r0 fails on x86 UP build
Browse files Browse the repository at this point in the history
Mainline add some sched-core related api which cause below fails on x86
UP build, torvalds#30.
  • Loading branch information
cchalpha committed Nov 18, 2024
1 parent d115527 commit ccb13fe
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
24 changes: 24 additions & 0 deletions kernel/sched/alt_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,30 @@ rq_unlock_irqrestore(struct rq *rq, struct rq_flags *rf)
raw_spin_unlock_irqrestore(&rq->lock, rf->flags);
}

void raw_spin_rq_lock_nested(struct rq *rq, int subclass)
{
raw_spinlock_t *lock;

/* Matches synchronize_rcu() in __sched_core_enable() */
preempt_disable();

for (;;) {
lock = __rq_lockp(rq);
raw_spin_lock_nested(lock, subclass);
if (likely(lock == __rq_lockp(rq))) {
/* preempt_count *MUST* be > 1 */
preempt_enable_no_resched();
return;
}
raw_spin_unlock(lock);
}
}

void raw_spin_rq_unlock(struct rq *rq)
{
raw_spin_unlock(rq_lockp(rq));
}

/*
* RQ-clock updating methods:
*/
Expand Down
30 changes: 30 additions & 0 deletions kernel/sched/alt_sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,36 @@ this_rq_lock_irq(struct rq_flags *rf)
return rq;
}

extern void raw_spin_rq_lock_nested(struct rq *rq, int subclass);
extern void raw_spin_rq_unlock(struct rq *rq);

static inline raw_spinlock_t *__rq_lockp(struct rq *rq)
{
return &rq->lock;
}

static inline raw_spinlock_t *rq_lockp(struct rq *rq)
{
return __rq_lockp(rq);
}

static inline void raw_spin_rq_lock(struct rq *rq)
{
raw_spin_rq_lock_nested(rq, 0);
}

static inline void raw_spin_rq_lock_irq(struct rq *rq)
{
local_irq_disable();
raw_spin_rq_lock(rq);
}

static inline void raw_spin_rq_unlock_irq(struct rq *rq)
{
raw_spin_rq_unlock(rq);
local_irq_enable();
}

static inline int task_current(struct rq *rq, struct task_struct *p)
{
return rq->curr == p;
Expand Down

0 comments on commit ccb13fe

Please sign in to comment.