aboutsummaryrefslogtreecommitdiff
path: root/include/lock.h
diff options
context:
space:
mode:
authorAndrew Donnellan <andrew.donnellan@au1.ibm.com>2019-04-18 15:21:06 +1000
committerStewart Smith <stewart@linux.ibm.com>2019-05-20 14:20:29 +1000
commit1706e0311c47b2bfda3db1ef6168628072e7878b (patch)
treef881fdad88e9cd50ef00ceaaa62609448a9b8f46 /include/lock.h
parent1a548857ce1f02f43585b326a891eed18a7b43b3 (diff)
downloadskiboot-1706e0311c47b2bfda3db1ef6168628072e7878b.zip
skiboot-1706e0311c47b2bfda3db1ef6168628072e7878b.tar.gz
skiboot-1706e0311c47b2bfda3db1ef6168628072e7878b.tar.bz2
core/lock: Add debug options to store backtrace of where lock was taken
Contrary to popular belief, skiboot developers are imperfect and occasionally write locking bugs. When we exit skiboot, we check if we're still holding any locks, and if so, we print an error with a list of the locks currently held and the locations where they were taken. However, this only tells us the location where lock() was called, which may not be enough to work out what's going on. To give us more to go on with, we can store backtrace data in the lock and print that out when we unexpectedly still hold locks. Because the backtrace data is rather big, we only enable this if DEBUG_LOCKS_BACKTRACE is defined, which in turn is switched on when DEBUG=1. (We disable DEBUG_LOCKS_BACKTRACE in some of the memory allocation tests because the locks used by the memory allocator take up too much room in the fake skiboot heap.) Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
Diffstat (limited to 'include/lock.h')
-rw-r--r--include/lock.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/lock.h b/include/lock.h
index b187573..e08ec08 100644
--- a/include/lock.h
+++ b/include/lock.h
@@ -23,6 +23,12 @@
#include <ccan/list/list.h>
#include <ccan/str/str.h>
+#ifdef DEBUG_LOCKS_BACKTRACE
+#include <stack.h>
+
+#define LOCKS_BACKTRACE_MAX_ENTS 60
+#endif
+
struct lock {
/* Lock value has bit 63 as lock bit and the PIR of the owner
* in the top 32-bit
@@ -38,6 +44,11 @@ struct lock {
/* file/line of lock owner */
const char *owner;
+#ifdef DEBUG_LOCKS_BACKTRACE
+ struct bt_entry bt_buf[LOCKS_BACKTRACE_MAX_ENTS];
+ struct bt_metadata bt_metadata;
+#endif
+
/* linkage in per-cpu list of owned locks */
struct list_node list;
};