From: Juri Lelli <juri.lelli@redhat.com>
To: peterz@infradead.org, mingo@redhat.com, rostedt@goodmis.org,
tj@kernel.org
Cc: linux-kernel@vger.kernel.org, luca.abeni@santannapisa.it,
claudio@evidence.eu.com, tommaso.cucinotta@santannapisa.it,
bristot@redhat.com, mathieu.poirier@linaro.org,
lizefan@huawei.com, cgroups@vger.kernel.org
Subject: [PATCH v7 2/7] sched/core: Streamlining calls to task_rq_unlock()
Date: Wed, 3 Apr 2019 10:46:45 +0200 [thread overview]
Message-ID: <20190403084650.4414-3-juri.lelli@redhat.com> (raw)
In-Reply-To: <20190403084650.4414-1-juri.lelli@redhat.com>
From: Mathieu Poirier <mathieu.poirier@linaro.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@linaro.org>
Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Acked-by: Tejun Heo <tj@kernel.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
next prev parent reply other threads:[~2019-04-03 8:46 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-03 8:46 [PATCH v7 0/7] sched/deadline: fix cpusets bandwidth accounting Juri Lelli
2019-04-03 8:46 ` [PATCH v7 1/7] sched/topology: Adding function partition_sched_domains_locked() Juri Lelli
2019-04-05 12:04 ` Peter Zijlstra
2019-04-05 12:52 ` Juri Lelli
2019-04-03 8:46 ` Juri Lelli [this message]
2019-04-03 8:46 ` [PATCH v7 3/7] cgroup/cpuset: make callback_lock raw Juri Lelli
2019-04-03 8:46 ` [PATCH v7 4/7] sched/core: Prevent race condition between cpuset and __sched_setscheduler() Juri Lelli
2019-04-05 12:36 ` Peter Zijlstra
2019-04-05 12:53 ` Juri Lelli
2019-04-03 8:46 ` [PATCH v7 5/7] cpuset: Rebuild root domain deadline accounting information Juri Lelli
2019-04-03 8:46 ` [PATCH v7 6/7] cgroup/cpuset: Use cpuset_mutex to protect seq_show operations Juri Lelli
2019-04-03 8:46 ` [PATCH v7 7/7] sched/deadline: Fix bandwidth accounting at all levels after offline migration Juri Lelli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190403084650.4414-3-juri.lelli@redhat.com \
--to=juri.lelli@redhat.com \
--cc=bristot@redhat.com \
--cc=cgroups@vger.kernel.org \
--cc=claudio@evidence.eu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan@huawei.com \
--cc=luca.abeni@santannapisa.it \
--cc=mathieu.poirier@linaro.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tj@kernel.org \
--cc=tommaso.cucinotta@santannapisa.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).