[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190403084650.4414-3-juri.lelli@redhat.com>
Date: Wed, 3 Apr 2019 10:46:45 +0200
From: Juri Lelli <juri.lelli@...hat.com>
To: peterz@...radead.org, mingo@...hat.com, rostedt@...dmis.org,
tj@...nel.org
Cc: linux-kernel@...r.kernel.org, luca.abeni@...tannapisa.it,
claudio@...dence.eu.com, tommaso.cucinotta@...tannapisa.it,
bristot@...hat.com, mathieu.poirier@...aro.org, lizefan@...wei.com,
cgroups@...r.kernel.org
Subject: [PATCH v7 2/7] sched/core: Streamlining calls to task_rq_unlock()
From: Mathieu Poirier <mathieu.poirier@...aro.org>
Calls to task_rq_unlock() are done several times in function
__sched_setscheduler(). This is fine when only the rq lock needs to be
handled but not so much when other locks come into play.
This patch streamlines the release of the rq lock so that only one
location need to be modified when dealing with more than one lock.
No change of functionality is introduced by this patch.
Signed-off-by: Mathieu Poirier <mathieu.poirier@...aro.org>
Reviewed-by: Steven Rostedt (VMware) <rostedt@...dmis.org>
Acked-by: Tejun Heo <tj@...nel.org>
---
kernel/sched/core.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index ead464a0f2e5..98e835de1e7b 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4274,8 +4274,8 @@ static int __sched_setscheduler(struct task_struct *p,
* Changing the policy of the stop threads its a very bad idea:
*/
if (p == rq->stop) {
- task_rq_unlock(rq, p, &rf);
- return -EINVAL;
+ retval = -EINVAL;
+ goto unlock;
}
/*
@@ -4291,8 +4291,8 @@ static int __sched_setscheduler(struct task_struct *p,
goto change;
p->sched_reset_on_fork = reset_on_fork;
- task_rq_unlock(rq, p, &rf);
- return 0;
+ retval = 0;
+ goto unlock;
}
change:
@@ -4305,8 +4305,8 @@ static int __sched_setscheduler(struct task_struct *p,
if (rt_bandwidth_enabled() && rt_policy(policy) &&
task_group(p)->rt_bandwidth.rt_runtime == 0 &&
!task_group_is_autogroup(task_group(p))) {
- task_rq_unlock(rq, p, &rf);
- return -EPERM;
+ retval = -EPERM;
+ goto unlock;
}
#endif
#ifdef CONFIG_SMP
@@ -4321,8 +4321,8 @@ static int __sched_setscheduler(struct task_struct *p,
*/
if (!cpumask_subset(span, &p->cpus_allowed) ||
rq->rd->dl_bw.bw == 0) {
- task_rq_unlock(rq, p, &rf);
- return -EPERM;
+ retval = -EPERM;
+ goto unlock;
}
}
#endif
@@ -4341,8 +4341,8 @@ static int __sched_setscheduler(struct task_struct *p,
* is available.
*/
if ((dl_policy(policy) || dl_task(p)) && sched_dl_overflow(p, policy, attr)) {
- task_rq_unlock(rq, p, &rf);
- return -EBUSY;
+ retval = -EBUSY;
+ goto unlock;
}
p->sched_reset_on_fork = reset_on_fork;
@@ -4398,6 +4398,10 @@ static int __sched_setscheduler(struct task_struct *p,
preempt_enable();
return 0;
+
+unlock:
+ task_rq_unlock(rq, p, &rf);
+ return retval;
}
static int _sched_setscheduler(struct task_struct *p, int policy,
--
2.17.2
Powered by blists - more mailing lists