Skip to content

Commit 60a6ca6

Browse files
committed
Merge branch 'locking-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull locking fixes from Ingo Molnar: "Two lockdep fixes for bugs introduced by the cross-release dependency tracking feature - plus a commit that disables it because performance regressed in an absymal fashion on some systems" * 'locking-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: locking/lockdep: Disable cross-release features for now locking/selftest: Avoid false BUG report locking/lockdep: Fix stacktrace mess
2 parents 2b34218 + b483cf3 commit 60a6ca6

File tree

3 files changed

+24
-30
lines changed

3 files changed

+24
-30
lines changed

kernel/locking/lockdep.c

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,10 +1873,10 @@ check_prev_add(struct task_struct *curr, struct held_lock *prev,
18731873
struct held_lock *next, int distance, struct stack_trace *trace,
18741874
int (*save)(struct stack_trace *trace))
18751875
{
1876+
struct lock_list *uninitialized_var(target_entry);
18761877
struct lock_list *entry;
1877-
int ret;
18781878
struct lock_list this;
1879-
struct lock_list *uninitialized_var(target_entry);
1879+
int ret;
18801880

18811881
/*
18821882
* Prove that the new <prev> -> <next> dependency would not
@@ -1890,8 +1890,17 @@ check_prev_add(struct task_struct *curr, struct held_lock *prev,
18901890
this.class = hlock_class(next);
18911891
this.parent = NULL;
18921892
ret = check_noncircular(&this, hlock_class(prev), &target_entry);
1893-
if (unlikely(!ret))
1893+
if (unlikely(!ret)) {
1894+
if (!trace->entries) {
1895+
/*
1896+
* If @save fails here, the printing might trigger
1897+
* a WARN but because of the !nr_entries it should
1898+
* not do bad things.
1899+
*/
1900+
save(trace);
1901+
}
18941902
return print_circular_bug(&this, target_entry, next, prev, trace);
1903+
}
18951904
else if (unlikely(ret < 0))
18961905
return print_bfs_bug(ret);
18971906

@@ -1938,7 +1947,7 @@ check_prev_add(struct task_struct *curr, struct held_lock *prev,
19381947
return print_bfs_bug(ret);
19391948

19401949

1941-
if (save && !save(trace))
1950+
if (!trace->entries && !save(trace))
19421951
return 0;
19431952

19441953
/*
@@ -1958,20 +1967,6 @@ check_prev_add(struct task_struct *curr, struct held_lock *prev,
19581967
if (!ret)
19591968
return 0;
19601969

1961-
/*
1962-
* Debugging printouts:
1963-
*/
1964-
if (verbose(hlock_class(prev)) || verbose(hlock_class(next))) {
1965-
graph_unlock();
1966-
printk("\n new dependency: ");
1967-
print_lock_name(hlock_class(prev));
1968-
printk(KERN_CONT " => ");
1969-
print_lock_name(hlock_class(next));
1970-
printk(KERN_CONT "\n");
1971-
dump_stack();
1972-
if (!graph_lock())
1973-
return 0;
1974-
}
19751970
return 2;
19761971
}
19771972

@@ -1986,8 +1981,12 @@ check_prevs_add(struct task_struct *curr, struct held_lock *next)
19861981
{
19871982
int depth = curr->lockdep_depth;
19881983
struct held_lock *hlock;
1989-
struct stack_trace trace;
1990-
int (*save)(struct stack_trace *trace) = save_trace;
1984+
struct stack_trace trace = {
1985+
.nr_entries = 0,
1986+
.max_entries = 0,
1987+
.entries = NULL,
1988+
.skip = 0,
1989+
};
19911990

19921991
/*
19931992
* Debugging checks.
@@ -2018,17 +2017,10 @@ check_prevs_add(struct task_struct *curr, struct held_lock *next)
20182017
*/
20192018
if (hlock->read != 2 && hlock->check) {
20202019
int ret = check_prev_add(curr, hlock, next,
2021-
distance, &trace, save);
2020+
distance, &trace, save_trace);
20222021
if (!ret)
20232022
return 0;
20242023

2025-
/*
2026-
* Stop saving stack_trace if save_trace() was
2027-
* called at least once:
2028-
*/
2029-
if (save && ret == 2)
2030-
save = NULL;
2031-
20322024
/*
20332025
* Stop after the first non-trylock entry,
20342026
* as non-trylock entries have added their

lib/Kconfig.debug

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,8 +1092,8 @@ config PROVE_LOCKING
10921092
select DEBUG_MUTEXES
10931093
select DEBUG_RT_MUTEXES if RT_MUTEXES
10941094
select DEBUG_LOCK_ALLOC
1095-
select LOCKDEP_CROSSRELEASE
1096-
select LOCKDEP_COMPLETIONS
1095+
select LOCKDEP_CROSSRELEASE if BROKEN
1096+
select LOCKDEP_COMPLETIONS if BROKEN
10971097
select TRACE_IRQFLAGS
10981098
default n
10991099
help

lib/locking-selftest.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2031,11 +2031,13 @@ void locking_selftest(void)
20312031
print_testname("mixed read-lock/lock-write ABBA");
20322032
pr_cont(" |");
20332033
dotest(rlock_ABBA1, FAILURE, LOCKTYPE_RWLOCK);
2034+
#ifdef CONFIG_PROVE_LOCKING
20342035
/*
20352036
* Lockdep does indeed fail here, but there's nothing we can do about
20362037
* that now. Don't kill lockdep for it.
20372038
*/
20382039
unexpected_testcase_failures--;
2040+
#endif
20392041

20402042
pr_cont(" |");
20412043
dotest(rwsem_ABBA1, FAILURE, LOCKTYPE_RWSEM);

0 commit comments

Comments
 (0)