Skip to content

Commit 8f98f6f

Browse files
committed
Merge branch 'sched-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull scheduler fixes from Ingo Molnar: "Two fixes: - a SCHED_DEADLINE task selection fix - a sched/numa related lockdep splat fix" * 'sched-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: sched: Check for stop task appearance when balancing happens sched/numa: Fix task_numa_free() lockdep splat
2 parents 8de3f7a + a1d9a32 commit 8f98f6f

File tree

4 files changed

+32
-11
lines changed

4 files changed

+32
-11
lines changed

kernel/sched/deadline.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,8 +1021,17 @@ struct task_struct *pick_next_task_dl(struct rq *rq, struct task_struct *prev)
10211021

10221022
dl_rq = &rq->dl;
10231023

1024-
if (need_pull_dl_task(rq, prev))
1024+
if (need_pull_dl_task(rq, prev)) {
10251025
pull_dl_task(rq);
1026+
/*
1027+
* pull_rt_task() can drop (and re-acquire) rq->lock; this
1028+
* means a stop task can slip in, in which case we need to
1029+
* re-start task selection.
1030+
*/
1031+
if (rq->stop && rq->stop->on_rq)
1032+
return RETRY_TASK;
1033+
}
1034+
10261035
/*
10271036
* When prev is DL, we may throttle it in put_prev_task().
10281037
* So, we update time before we check for dl_nr_running.

kernel/sched/fair.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,7 +1497,7 @@ static void task_numa_placement(struct task_struct *p)
14971497
/* If the task is part of a group prevent parallel updates to group stats */
14981498
if (p->numa_group) {
14991499
group_lock = &p->numa_group->lock;
1500-
spin_lock(group_lock);
1500+
spin_lock_irq(group_lock);
15011501
}
15021502

15031503
/* Find the node with the highest number of faults */
@@ -1572,7 +1572,7 @@ static void task_numa_placement(struct task_struct *p)
15721572
}
15731573
}
15741574

1575-
spin_unlock(group_lock);
1575+
spin_unlock_irq(group_lock);
15761576
}
15771577

15781578
/* Preferred node as the node with the most faults */
@@ -1677,7 +1677,8 @@ static void task_numa_group(struct task_struct *p, int cpupid, int flags,
16771677
if (!join)
16781678
return;
16791679

1680-
double_lock(&my_grp->lock, &grp->lock);
1680+
BUG_ON(irqs_disabled());
1681+
double_lock_irq(&my_grp->lock, &grp->lock);
16811682

16821683
for (i = 0; i < NR_NUMA_HINT_FAULT_STATS * nr_node_ids; i++) {
16831684
my_grp->faults[i] -= p->numa_faults_memory[i];
@@ -1691,7 +1692,7 @@ static void task_numa_group(struct task_struct *p, int cpupid, int flags,
16911692
grp->nr_tasks++;
16921693

16931694
spin_unlock(&my_grp->lock);
1694-
spin_unlock(&grp->lock);
1695+
spin_unlock_irq(&grp->lock);
16951696

16961697
rcu_assign_pointer(p->numa_group, grp);
16971698

@@ -1710,14 +1711,14 @@ void task_numa_free(struct task_struct *p)
17101711
void *numa_faults = p->numa_faults_memory;
17111712

17121713
if (grp) {
1713-
spin_lock(&grp->lock);
1714+
spin_lock_irq(&grp->lock);
17141715
for (i = 0; i < NR_NUMA_HINT_FAULT_STATS * nr_node_ids; i++)
17151716
grp->faults[i] -= p->numa_faults_memory[i];
17161717
grp->total_faults -= p->total_numa_faults;
17171718

17181719
list_del(&p->numa_entry);
17191720
grp->nr_tasks--;
1720-
spin_unlock(&grp->lock);
1721+
spin_unlock_irq(&grp->lock);
17211722
rcu_assign_pointer(p->numa_group, NULL);
17221723
put_numa_group(grp);
17231724
}
@@ -6727,7 +6728,8 @@ static int idle_balance(struct rq *this_rq)
67276728
out:
67286729
/* Is there a task of a high priority class? */
67296730
if (this_rq->nr_running != this_rq->cfs.h_nr_running &&
6730-
(this_rq->dl.dl_nr_running ||
6731+
((this_rq->stop && this_rq->stop->on_rq) ||
6732+
this_rq->dl.dl_nr_running ||
67316733
(this_rq->rt.rt_nr_running && !rt_rq_throttled(&this_rq->rt))))
67326734
pulled_task = -1;
67336735

kernel/sched/rt.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,10 +1362,11 @@ pick_next_task_rt(struct rq *rq, struct task_struct *prev)
13621362
pull_rt_task(rq);
13631363
/*
13641364
* pull_rt_task() can drop (and re-acquire) rq->lock; this
1365-
* means a dl task can slip in, in which case we need to
1366-
* re-start task selection.
1365+
* means a dl or stop task can slip in, in which case we need
1366+
* to re-start task selection.
13671367
*/
1368-
if (unlikely(rq->dl.dl_nr_running))
1368+
if (unlikely((rq->stop && rq->stop->on_rq) ||
1369+
rq->dl.dl_nr_running))
13691370
return RETRY_TASK;
13701371
}
13711372

kernel/sched/sched.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,6 +1385,15 @@ static inline void double_lock(spinlock_t *l1, spinlock_t *l2)
13851385
spin_lock_nested(l2, SINGLE_DEPTH_NESTING);
13861386
}
13871387

1388+
static inline void double_lock_irq(spinlock_t *l1, spinlock_t *l2)
1389+
{
1390+
if (l1 > l2)
1391+
swap(l1, l2);
1392+
1393+
spin_lock_irq(l1);
1394+
spin_lock_nested(l2, SINGLE_DEPTH_NESTING);
1395+
}
1396+
13881397
static inline void double_raw_lock(raw_spinlock_t *l1, raw_spinlock_t *l2)
13891398
{
13901399
if (l1 > l2)

0 commit comments

Comments
 (0)