History

sched/numa: Fix task_numa_free() lockdep splat

Sasha reported that lockdep claims that the following commit: made numa_group.lock interrupt unsafe: 156654f491dd ("sched/numa: Move task_numa_free() to __put_task_struct()") While I don't see how that could be, given the commit in question moved task_numa_free() from one irq enabled region to another, the below does make both gripes and lockups upon gripe with numa=fake=4 go away.

Mike Galbraith committed 12 years ago

Commit 60e69ee1 parent 467cbd22 files · +16 −6Browse files

Unified · Split

2 files
  1. kernel/sched/fair.c +7 −6
  2. kernel/sched/sched.h +9 −0
kernel/sched/fair.c+7−6
@@ -1497,7 +1497,7 @@ static void task_numa_placement(struct task_struct *p) · 1496 unmodified lines
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) · 68 unmodified lines
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, · 98 unmodified lines
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, · 7 unmodified lines
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) · 12 unmodified lines
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 }
kernel/sched/sched.h+9−0
@@ -1385,6 +1385,15 @@ static inline void double_lock(spinlock_t *l1, spinlock_t *l2) · 1384 unmodified lines
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)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t