Skip to content

Commit 61a943e

Browse files
committed
synch: print read/write indication for held rwlocks
Signed-off-by: Josef 'Jeff' Sipek <[email protected]>
1 parent 72f1764 commit 61a943e

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

synch.c

+24-1
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,27 @@ static inline char *get_synch_chars(struct lock_info *info, char buf[2])
137137
return buf;
138138
}
139139

140+
static inline char *get_held_chars(struct held_lock *held, char buf[2])
141+
{
142+
char *ptr = buf;
143+
144+
switch (held->info->type) {
145+
case SYNCH_TYPE_MUTEX:
146+
break;
147+
case SYNCH_TYPE_RW:
148+
*ptr = held->rwlock_wr ? 'w' : 'r';
149+
ptr++;
150+
break;
151+
case SYNCH_TYPE_COND:
152+
break;
153+
}
154+
155+
/* null terminate for good measure */
156+
*ptr = '\0';
157+
158+
return buf;
159+
}
160+
140161
static void print_invalid_call(const char *fxn, const struct lock_context *where)
141162
{
142163
panic("lockdep: invalid call to %s at %s:%d", fxn, where->file,
@@ -193,12 +214,14 @@ static void print_held_locks(struct held_lock *highlight)
193214
struct lock_info *info = cur->info;
194215
struct lock *lock = container_of(info, struct lock, info);
195216
char synch_chars[2];
217+
char held_chars[2];
196218

197-
cmn_err(CE_CRIT, "lockdep: %s #%zd: %s (%p) %s <%s> acquired at %s:%d",
219+
cmn_err(CE_CRIT, "lockdep: %s #%zd: %s (%p) %s <%s%s> acquired at %s:%d",
198220
(cur == highlight) ? "->" : " ",
199221
i, info->name, lock,
200222
synch_type_str(info->type),
201223
get_synch_chars(info, synch_chars),
224+
get_held_chars(cur, held_chars),
202225
cur->where.file, cur->where.line);
203226
}
204227
}

0 commit comments

Comments
 (0)