sched: get rq->lock before changing cpu limit of offline task

Signed-off-by: Xiaoguang Chen <xiaoggchen@tencent.com>
Signed-off-by: He Chen <xiaoggchen@tencent.com>
This commit is contained in:
Chen Xiaoguang 2020-09-22 00:15:51 +08:00 committed by He Chen
parent 7b0b2d84b9
commit 71b4de4965
1 changed files with 6 additions and 1 deletions

View File

@ -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;
}