Skip to content

Commit 72f1764

Browse files
committed
synch: keep track of whether rwlock is held as reader or writer
Signed-off-by: Josef 'Jeff' Sipek <[email protected]>
1 parent c3ae41d commit 72f1764

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

synch.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ struct held_lock {
7575
struct lock_info *info;
7676
struct lock_context where;
7777
enum synch_type type;
78+
bool rwlock_wr:1;
7879
};
7980

8081
static __thread struct held_lock held_stack[JEFFPC_LOCK_STACK_DEPTH];
@@ -469,7 +470,8 @@ static void check_magic(struct lock_info *info, const char *op,
469470
}
470471

471472
static void check_unheld_for_lock(struct lock_info *info,
472-
const struct lock_context *where)
473+
const struct lock_context *where,
474+
bool rwlock_wr)
473475
{
474476
#ifdef JEFFPC_LOCK_TRACKING
475477
struct held_lock *held;
@@ -500,6 +502,7 @@ static void check_unheld_for_lock(struct lock_info *info,
500502
held->info = info;
501503
held->where = *where;
502504
held->type = info->type;
505+
held->rwlock_wr = rwlock_wr;
503506
#endif
504507
}
505508

@@ -576,7 +579,7 @@ static void verify_lock_lock(const struct lock_context *where, struct lock *l)
576579
print_invalid_call("MXLOCK", where);
577580

578581
check_magic(&l->info, "acquire", where, SYNCH_TYPE_MUTEX);
579-
check_unheld_for_lock(&l->info, where);
582+
check_unheld_for_lock(&l->info, where, false);
580583
}
581584

582585
static void verify_lock_unlock(const struct lock_context *where, struct lock *l)
@@ -622,7 +625,7 @@ static void verify_rw_lock(const struct lock_context *where, struct rwlock *l,
622625
print_invalid_call("RWLOCK", where);
623626

624627
check_magic(&l->info, "acquire", where, SYNCH_TYPE_RW);
625-
check_unheld_for_lock(&l->info, where);
628+
check_unheld_for_lock(&l->info, where, wr);
626629
}
627630

628631
static void verify_rw_unlock(const struct lock_context *where, struct rwlock *l)

0 commit comments

Comments
 (0)