aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/sched.c')
-rw-r--r--kernel/sched.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index 61245b8d0f16..7d97ff7c4478 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -6939,20 +6939,26 @@ static void free_rootdomain(struct root_domain *rd)
6939 6939
6940static void rq_attach_root(struct rq *rq, struct root_domain *rd) 6940static void rq_attach_root(struct rq *rq, struct root_domain *rd)
6941{ 6941{
6942 struct root_domain *old_rd = NULL;
6942 unsigned long flags; 6943 unsigned long flags;
6943 6944
6944 spin_lock_irqsave(&rq->lock, flags); 6945 spin_lock_irqsave(&rq->lock, flags);
6945 6946
6946 if (rq->rd) { 6947 if (rq->rd) {
6947 struct root_domain *old_rd = rq->rd; 6948 old_rd = rq->rd;
6948 6949
6949 if (cpumask_test_cpu(rq->cpu, old_rd->online)) 6950 if (cpumask_test_cpu(rq->cpu, old_rd->online))
6950 set_rq_offline(rq); 6951 set_rq_offline(rq);
6951 6952
6952 cpumask_clear_cpu(rq->cpu, old_rd->span); 6953 cpumask_clear_cpu(rq->cpu, old_rd->span);
6953 6954
6954 if (atomic_dec_and_test(&old_rd->refcount)) 6955 /*
6955 free_rootdomain(old_rd); 6956 * If we dont want to free the old_rt yet then
6957 * set old_rd to NULL to skip the freeing later
6958 * in this function:
6959 */
6960 if (!atomic_dec_and_test(&old_rd->refcount))
6961 old_rd = NULL;
6956 } 6962 }
6957 6963
6958 atomic_inc(&rd->refcount); 6964 atomic_inc(&rd->refcount);
@@ -6963,6 +6969,9 @@ static void rq_attach_root(struct rq *rq, struct root_domain *rd)
6963 set_rq_online(rq); 6969 set_rq_online(rq);
6964 6970
6965 spin_unlock_irqrestore(&rq->lock, flags); 6971 spin_unlock_irqrestore(&rq->lock, flags);
6972
6973 if (old_rd)
6974 free_rootdomain(old_rd);
6966} 6975}
6967 6976
6968static int __init_refok init_rootdomain(struct root_domain *rd, bool bootmem) 6977static int __init_refok init_rootdomain(struct root_domain *rd, bool bootmem)