Page MenuHomeFreeBSD

D59222.diff
No OneTemporary

D59222.diff

diff --git a/sys/kern/kern_rangelock.c b/sys/kern/kern_rangelock.c
--- a/sys/kern/kern_rangelock.c
+++ b/sys/kern/kern_rangelock.c
@@ -813,6 +813,58 @@
void
_rangelock_cookie_assert(void *cookie, int what, const char *file, int line)
{
+ struct rl_q_entry *entry;
+ struct thread *td;
+ uintptr_t c;
+
+ c = (uintptr_t)cookie;
+ switch (what) {
+ case RCA_LOCKED:
+ if (c == RL_RET_CHEAT_RLOCKED || c == RL_RET_CHEAT_WLOCKED)
+ break;
+ entry = cookie;
+ if ((entry->rl_q_flags & RL_LOCK_TYPE_MASK) == 0)
+ panic("rangelock not held (%#x) @ %s:%d\n",
+ entry->rl_q_flags, file, line);
+ td = entry->rl_q_owner;
+ if (td != curthread)
+ panic("rangelock held by thread %d @ %s:%d\n",
+ td != NULL ? td->td_tid : -1, file, line);
+ break;
+ case RCA_RLOCKED:
+ if (c == RL_RET_CHEAT_RLOCKED)
+ break;
+ if (c == RL_RET_CHEAT_WLOCKED)
+ panic("rangelock not rlocked (%#lx) @ %s:%d\n",
+ c, file, line);
+ entry = cookie;
+ if ((entry->rl_q_flags & RL_LOCK_TYPE_MASK) != RL_LOCK_READ)
+ panic("rangelock not rlocked (%#x) @ %s:%d\n",
+ entry->rl_q_flags, file, line);
+ td = entry->rl_q_owner;
+ if (td != curthread)
+ panic("rangelock held by thread %d @ %s:%d\n",
+ td != NULL ? td->td_tid : -1, file, line);
+ break;
+ case RCA_WLOCKED:
+ if (c == RL_RET_CHEAT_WLOCKED)
+ break;
+ if (c == RL_RET_CHEAT_RLOCKED)
+ panic("rangelock not wlocked (%#lx) @ %s:%d\n",
+ c, file, line);
+ entry = cookie;
+ if ((entry->rl_q_flags & RL_LOCK_TYPE_MASK) != RL_LOCK_WRITE)
+ panic("rangelock not wlocked (%#x) @ %s:%d\n",
+ entry->rl_q_flags, file, line);
+ td = entry->rl_q_owner;
+ if (td != curthread)
+ panic("rangelock held by thread %d @ %s:%d\n",
+ td != NULL ? td->td_tid : -1, file, line);
+ break;
+ default:
+ panic("rangelock cookie assert type %d @ %s:%d\n",
+ what, file, line);
+ }
}
#endif /* INVARIANT_SUPPORT */
diff --git a/sys/kern/uipc_shm.c b/sys/kern/uipc_shm.c
--- a/sys/kern/uipc_shm.c
+++ b/sys/kern/uipc_shm.c
@@ -742,7 +742,7 @@
KASSERT(length >= 0, ("shm_dotruncate: length < 0"));
object = shmfd->shm_object;
VM_OBJECT_ASSERT_WLOCKED(object);
- rangelock_cookie_assert(rl_cookie, RA_WLOCKED);
+ rangelock_cookie_assert(rl_cookie, RCA_WLOCKED);
if (length == shmfd->shm_size)
return (0);
nobjsize = OFF_TO_IDX(length + PAGE_MASK);
@@ -807,7 +807,7 @@
KASSERT(length >= 0, ("shm_dotruncate_largepage: length < 0"));
object = shmfd->shm_object;
VM_OBJECT_ASSERT_WLOCKED(object);
- rangelock_cookie_assert(rl_cookie, RA_WLOCKED);
+ rangelock_cookie_assert(rl_cookie, RCA_WLOCKED);
oldobjsz = object->size;
newobjsz = OFF_TO_IDX(length);
@@ -1584,7 +1584,7 @@
int docow, error, rv, try;
bool curmap;
- rangelock_cookie_assert(rl_cookie, RA_LOCKED);
+ rangelock_cookie_assert(rl_cookie, RCA_LOCKED);
if (shmfd->shm_lp_psind == 0)
return (EINVAL);

File Metadata

Mime Type
text/plain
Expires
Fri, Sep 4, 6:42 AM (6 h, 4 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37943783
Default Alt Text
D59222.diff (2 KB)

Event Timeline