Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F171535808
D21048.id60114.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D21048.id60114.diff
View Options
Index: head/sys/kern/subr_epoch.c
===================================================================
--- head/sys/kern/subr_epoch.c
+++ head/sys/kern/subr_epoch.c
@@ -438,26 +438,20 @@
*/
critical_enter();
thread_unlock(td);
- owner = turnstile_lock(ts, &lock);
- /*
- * The owner pointer indicates that the lock succeeded.
- * Only in case we hold the lock and the turnstile we
- * locked is still the one that curwaittd is blocked on
- * can we continue. Otherwise the turnstile pointer has
- * been changed out from underneath us, as in the case
- * where the lock holder has signalled curwaittd,
- * and we need to continue.
- */
- if (owner != NULL && ts == curwaittd->td_blocked) {
- MPASS(TD_IS_INHIBITED(curwaittd) &&
- TD_ON_LOCK(curwaittd));
- critical_exit();
- turnstile_wait(ts, owner, curwaittd->td_tsqueue);
- counter_u64_add(turnstile_count, 1);
- thread_lock(td);
- return;
- } else if (owner != NULL)
+
+ if (turnstile_lock(ts, &lock, &owner)) {
+ if (ts == curwaittd->td_blocked) {
+ MPASS(TD_IS_INHIBITED(curwaittd) &&
+ TD_ON_LOCK(curwaittd));
+ critical_exit();
+ turnstile_wait(ts, owner,
+ curwaittd->td_tsqueue);
+ counter_u64_add(turnstile_count, 1);
+ thread_lock(td);
+ return;
+ }
turnstile_unlock(ts, lock);
+ }
thread_lock(td);
critical_exit();
KASSERT(td->td_locks == locksheld,
Index: head/sys/kern/subr_turnstile.c
===================================================================
--- head/sys/kern/subr_turnstile.c
+++ head/sys/kern/subr_turnstile.c
@@ -566,24 +566,26 @@
return (ts);
}
-struct thread *
-turnstile_lock(struct turnstile *ts, struct lock_object **lockp)
+bool
+turnstile_lock(struct turnstile *ts, struct lock_object **lockp,
+ struct thread **tdp)
{
struct turnstile_chain *tc;
struct lock_object *lock;
if ((lock = ts->ts_lockobj) == NULL)
- return (NULL);
+ return (false);
tc = TC_LOOKUP(lock);
mtx_lock_spin(&tc->tc_lock);
mtx_lock_spin(&ts->ts_lock);
if (__predict_false(lock != ts->ts_lockobj)) {
mtx_unlock_spin(&tc->tc_lock);
mtx_unlock_spin(&ts->ts_lock);
- return (NULL);
+ return (false);
}
*lockp = lock;
- return (ts->ts_owner);
+ *tdp = ts->ts_owner;
+ return (true);
}
void
Index: head/sys/sys/turnstile.h
===================================================================
--- head/sys/sys/turnstile.h
+++ head/sys/sys/turnstile.h
@@ -99,7 +99,8 @@
struct turnstile *turnstile_trywait(struct lock_object *);
void turnstile_unpend(struct turnstile *);
void turnstile_wait(struct turnstile *, struct thread *, int);
-struct thread *turnstile_lock(struct turnstile *, struct lock_object **);
+bool turnstile_lock(struct turnstile *, struct lock_object **,
+ struct thread **);
void turnstile_unlock(struct turnstile *, struct lock_object *);
void turnstile_assert(struct turnstile *);
#endif /* _KERNEL */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Sep 12, 3:36 PM (5 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38800627
Default Alt Text
D21048.id60114.diff (2 KB)
Attached To
Mode
D21048: Fix epoch's use of turnstile_lock().
Attached
Detach File
Event Timeline
Log In to Comment