From 71b4de49654c8be906dce43f7bd837b68b46a6c2 Mon Sep 17 00:00:00 2001 From: Chen Xiaoguang Date: Tue, 22 Sep 2020 00:15:51 +0800 Subject: [PATCH] sched: get rq->lock before changing cpu limit of offline task Signed-off-by: Xiaoguang Chen Signed-off-by: He Chen --- kernel/sched/batch.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kernel/sched/batch.c b/kernel/sched/batch.c index 19e49e09b..74375f8f0 100644 --- a/kernel/sched/batch.c +++ b/kernel/sched/batch.c @@ -4939,6 +4939,8 @@ static ssize_t offline_proc_write(struct file *file, const char __user *ubuf, struct bt_rq *bt_rq; unsigned long tmp; int cpn; + struct rq *rq; + unsigned long flags; cpn = min((int)OFFLINE_NUMBUF, (int)cnt); if (copy_from_user(buffer, ubuf, cpn)) @@ -4949,11 +4951,14 @@ static ssize_t offline_proc_write(struct file *file, const char __user *ubuf, return -EINVAL; *to = tmp; - bt_rq = &cpu_rq(cpu)->bt; + rq = cpu_rq(cpu); + bt_rq = &rq->bt; + raw_spin_lock_irqsave(&rq->lock, flags); raw_spin_lock(&bt_rq->bt_runtime_lock); bt_rq->bt_runtime = (u64)sysctl_sched_bt_period * NSEC_PER_USEC * tmp / 100; raw_spin_unlock(&bt_rq->bt_runtime_lock); + raw_spin_unlock_irqrestore(&rq->lock, flags); return cnt; }