Changeset View
Standalone View
sys/kern/kern_umtx.c
Show First 20 Lines • Show All 765 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
static void | static void | ||||
abs_timeout_init(struct abs_timeout *timo, int clockid, int absolute, | abs_timeout_init(struct abs_timeout *timo, int clockid, int absolute, | ||||
const struct timespec *timeout) | const struct timespec *timeout) | ||||
{ | { | ||||
timo->clockid = clockid; | timo->clockid = clockid; | ||||
if (!absolute) { | if (!absolute) { | ||||
kib: () are not needed. | |||||
Done Inline ActionsTrue, but I like them. However, style(9) discourages them, so I'll remove them. vangyzen: True, but I like them. However, style(9) discourages them, so I'll remove them. | |||||
kern_clock_gettime(curthread, clockid, &timo->end); | kern_clock_gettime(curthread, clockid, &timo->end); | ||||
timo->cur = timo->end; | timo->cur = timo->end; | ||||
timespecadd(&timo->end, timeout); | timespecadd(&timo->end, timeout); | ||||
} else { | } else { | ||||
timo->end = *timeout; | timo->end = *timeout; | ||||
kern_clock_gettime(curthread, clockid, &timo->cur); | kern_clock_gettime(curthread, clockid, &timo->cur); | ||||
} | } | ||||
} | } | ||||
Show All 33 Lines | if (rb) | ||||
return (UMUTEX_RB_OWNERDEAD); | return (UMUTEX_RB_OWNERDEAD); | ||||
else if ((flags & UMUTEX_NONCONSISTENT) != 0) | else if ((flags & UMUTEX_NONCONSISTENT) != 0) | ||||
return (UMUTEX_RB_NOTRECOV); | return (UMUTEX_RB_NOTRECOV); | ||||
else | else | ||||
return (UMUTEX_UNOWNED); | return (UMUTEX_UNOWNED); | ||||
} | } | ||||
/* | /* | ||||
Done Inline ActionsThis will be removed before commit. vangyzen: This will be removed before commit. | |||||
* Put thread into sleep state, before sleeping, check if | * Put thread into sleep state, before sleeping, check if | ||||
* thread was removed from umtx queue. | * thread was removed from umtx queue. | ||||
*/ | */ | ||||
static inline int | static inline int | ||||
umtxq_sleep(struct umtx_q *uq, const char *wmesg, struct abs_timeout *abstime) | umtxq_sleep(struct umtx_q *uq, const char *wmesg, struct abs_timeout *abstime) | ||||
{ | { | ||||
struct umtxq_chain *uc; | struct umtxq_chain *uc; | ||||
int error, timo; | int error, timo, priority; | ||||
priority = PCATCH | PDROP; | |||||
if (abstime != NULL) { | |||||
switch (abstime->clockid) { | |||||
case CLOCK_REALTIME: | |||||
case CLOCK_REALTIME_PRECISE: | |||||
case CLOCK_REALTIME_FAST: | |||||
priority |= PRTCLK; | |||||
break; | |||||
} | |||||
} | |||||
uc = umtxq_getchain(&uq->uq_key); | uc = umtxq_getchain(&uq->uq_key); | ||||
UMTXQ_LOCKED_ASSERT(uc); | UMTXQ_LOCKED_ASSERT(uc); | ||||
Done Inline ActionsI understand why this reading of rtc_generation needs acquire semantic: we ensure that if we see updated rtc_generation, then we also see the updated timehands. But I do not quite see why other rtc_generation reads, in particular, in sleeping_on_old_rtc() and in sleepq_switch(), need the acquire. sleeping_on_old_rtc() happens in the same thread that incremented the variable. sleepq_switch() only needs the value of the variable, it does not order its read with other happenings in tc_windup() which did release write. Could you, please, explain your use of _acq there ? kib: I understand why this reading of rtc_generation needs acquire semantic: we ensure that if we… | |||||
Done Inline ActionsThere is no good reason. I'm embarrassed to say, it was absent-minded. Of course, you're right that only this function needs the acquire semantic. vangyzen: There is no good reason. I'm embarrassed to say, it was absent-minded. Of course, you're… | |||||
for (;;) { | for (;;) { | ||||
if (!(uq->uq_flags & UQF_UMTXQ)) | if (!(uq->uq_flags & UQF_UMTXQ)) | ||||
return (0); | return (0); | ||||
if (abstime != NULL) { | if (abstime != NULL) { | ||||
timo = abs_timeout_gethz(abstime); | timo = abs_timeout_gethz(abstime); | ||||
if (timo < 0) | if (timo < 0) | ||||
return (ETIMEDOUT); | return (ETIMEDOUT); | ||||
} else | } else | ||||
timo = 0; | timo = 0; | ||||
error = msleep(uq, &uc->uc_lock, PCATCH | PDROP, wmesg, timo); | error = msleep(uq, &uc->uc_lock, priority, wmesg, timo); | ||||
if (error != EWOULDBLOCK) { | if (error != EWOULDBLOCK && error != ERELOOKUP) { | ||||
umtxq_lock(&uq->uq_key); | umtxq_lock(&uq->uq_key); | ||||
break; | break; | ||||
} | } | ||||
if (abstime != NULL) | if (abstime != NULL) | ||||
abs_timeout_update(abstime); | abs_timeout_update(abstime); | ||||
umtxq_lock(&uq->uq_key); | umtxq_lock(&uq->uq_key); | ||||
} | } | ||||
return (error); | return (error); | ||||
} | } | ||||
Done Inline ActionsToo many blank lines. kib: Too many blank lines. | |||||
/* | /* | ||||
* Convert userspace address into unique logical address. | * Convert userspace address into unique logical address. | ||||
*/ | */ | ||||
int | int | ||||
umtx_key_get(const void *addr, int type, int share, struct umtx_key *key) | umtx_key_get(const void *addr, int type, int share, struct umtx_key *key) | ||||
{ | { | ||||
struct thread *td = curthread; | struct thread *td = curthread; | ||||
vm_map_t map; | vm_map_t map; | ||||
▲ Show 20 Lines • Show All 3,681 Lines • Show Last 20 Lines |
() are not needed.