Page MenuHomeFreeBSD

D31249.id92558.diff
No OneTemporary

D31249.id92558.diff

Index: sys/kern/kern_umtx.c
===================================================================
--- sys/kern/kern_umtx.c
+++ sys/kern/kern_umtx.c
@@ -213,13 +213,6 @@
#define BUSY_SPINS 200
-struct abs_timeout {
- int clockid;
- bool is_abs_real; /* TIMER_ABSTIME && CLOCK_REALTIME* */
- struct timespec cur;
- struct timespec end;
-};
-
struct umtx_copyops {
int (*copyin_timeout)(const void *uaddr, struct timespec *tsp);
int (*copyin_umtx_time)(const void *uaddr, size_t size,
@@ -267,7 +260,10 @@
"umtx chain stats");
#endif
-static void abs_timeout_update(struct abs_timeout *timo);
+static inline void umtx_abs_timeout_init2(struct umtx_abs_timeout *timo,
+ const struct _umtx_time *umtxtime);
+static int umtx_abs_timeout_gethz(struct umtx_abs_timeout *timo);
+static inline void umtx_abs_timeout_update(struct umtx_abs_timeout *timo);
static void umtx_shm_init(void);
static void umtxq_sysinit(void *);
@@ -278,7 +274,8 @@
static void umtxq_unbusy(struct umtx_key *key);
static void umtxq_insert_queue(struct umtx_q *uq, int q);
static void umtxq_remove_queue(struct umtx_q *uq, int q);
-static int umtxq_sleep(struct umtx_q *uq, const char *wmesg, struct abs_timeout *);
+static int umtxq_sleep(struct umtx_q *uq, const char *wmesg,
+ struct umtx_abs_timeout *);
static int umtxq_count(struct umtx_key *key);
static struct umtx_pi *umtx_pi_alloc(int);
static void umtx_pi_free(struct umtx_pi *pi);
@@ -741,15 +738,15 @@
return tvtohz(&tv);
}
-static void
-abs_timeout_init(struct abs_timeout *timo, int clockid, int absolute,
- const struct timespec *timeout)
+void
+umtx_abs_timeout_init(struct umtx_abs_timeout *timo, int clockid,
+ int absolute, const struct timespec *timeout)
{
timo->clockid = clockid;
if (!absolute) {
timo->is_abs_real = false;
- abs_timeout_update(timo);
+ umtx_abs_timeout_update(timo);
timespecadd(&timo->cur, timeout, &timo->end);
} else {
timo->end = *timeout;
@@ -761,28 +758,29 @@
* after setting td_rtcgen; otherwise, read it here.
*/
if (!timo->is_abs_real) {
- abs_timeout_update(timo);
+ umtx_abs_timeout_update(timo);
}
}
}
static void
-abs_timeout_init2(struct abs_timeout *timo, const struct _umtx_time *umtxtime)
+umtx_abs_timeout_init2(struct umtx_abs_timeout *timo,
+ const struct _umtx_time *umtxtime)
{
- abs_timeout_init(timo, umtxtime->_clockid,
+ umtx_abs_timeout_init(timo, umtxtime->_clockid,
(umtxtime->_flags & UMTX_ABSTIME) != 0, &umtxtime->_timeout);
}
-static inline void
-abs_timeout_update(struct abs_timeout *timo)
+static void
+umtx_abs_timeout_update(struct umtx_abs_timeout *timo)
{
kern_clock_gettime(curthread, timo->clockid, &timo->cur);
}
static int
-abs_timeout_gethz(struct abs_timeout *timo)
+umtx_abs_timeout_gethz(struct umtx_abs_timeout *timo)
{
struct timespec tts;
@@ -810,14 +808,15 @@
* thread was removed from umtx queue.
*/
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 umtx_abs_timeout *abstime)
{
struct umtxq_chain *uc;
int error, timo;
if (abstime != NULL && abstime->is_abs_real) {
curthread->td_rtcgen = atomic_load_acq_int(&rtc_generation);
- abs_timeout_update(abstime);
+ umtx_abs_timeout_update(abstime);
}
uc = umtxq_getchain(&uq->uq_key);
@@ -828,7 +827,7 @@
break;
}
if (abstime != NULL) {
- timo = abs_timeout_gethz(abstime);
+ timo = umtx_abs_timeout_gethz(abstime);
if (timo < 0) {
error = ETIMEDOUT;
break;
@@ -844,7 +843,7 @@
if (abstime->is_abs_real)
curthread->td_rtcgen =
atomic_load_acq_int(&rtc_generation);
- abs_timeout_update(abstime);
+ umtx_abs_timeout_update(abstime);
}
umtxq_lock(&uq->uq_key);
}
@@ -916,7 +915,7 @@
do_wait(struct thread *td, void *addr, u_long id,
struct _umtx_time *timeout, int compat32, int is_private)
{
- struct abs_timeout timo;
+ struct umtx_abs_timeout timo;
struct umtx_q *uq;
u_long tmp;
uint32_t tmp32;
@@ -928,7 +927,7 @@
return (error);
if (timeout != NULL)
- abs_timeout_init2(&timo, timeout);
+ umtx_abs_timeout_init2(&timo, timeout);
umtxq_lock(&uq->uq_key);
umtxq_insert(uq);
@@ -989,7 +988,7 @@
do_lock_normal(struct thread *td, struct umutex *m, uint32_t flags,
struct _umtx_time *timeout, int mode)
{
- struct abs_timeout timo;
+ struct umtx_abs_timeout timo;
struct umtx_q *uq;
uint32_t owner, old, id;
int error, rv;
@@ -998,7 +997,7 @@
uq = td->td_umtxq;
error = 0;
if (timeout != NULL)
- abs_timeout_init2(&timo, timeout);
+ umtx_abs_timeout_init2(&timo, timeout);
/*
* Care must be exercised when dealing with umtx structure. It
@@ -1657,7 +1656,7 @@
*/
static int
umtxq_sleep_pi(struct umtx_q *uq, struct umtx_pi *pi, uint32_t owner,
- const char *wmesg, struct abs_timeout *timo, bool shared)
+ const char *wmesg, struct umtx_abs_timeout *timo, bool shared)
{
struct thread *td, *td1;
struct umtx_q *uq1;
@@ -1795,7 +1794,7 @@
do_lock_pi(struct thread *td, struct umutex *m, uint32_t flags,
struct _umtx_time *timeout, int try)
{
- struct abs_timeout timo;
+ struct umtx_abs_timeout timo;
struct umtx_q *uq;
struct umtx_pi *pi, *new_pi;
uint32_t id, old_owner, owner, old;
@@ -1810,7 +1809,7 @@
return (error);
if (timeout != NULL)
- abs_timeout_init2(&timo, timeout);
+ umtx_abs_timeout_init2(&timo, timeout);
umtxq_lock(&uq->uq_key);
pi = umtx_pi_lookup(&uq->uq_key);
@@ -2131,7 +2130,7 @@
do_lock_pp(struct thread *td, struct umutex *m, uint32_t flags,
struct _umtx_time *timeout, int try)
{
- struct abs_timeout timo;
+ struct umtx_abs_timeout timo;
struct umtx_q *uq, *uq2;
struct umtx_pi *pi;
uint32_t ceiling;
@@ -2146,7 +2145,7 @@
return (error);
if (timeout != NULL)
- abs_timeout_init2(&timo, timeout);
+ umtx_abs_timeout_init2(&timo, timeout);
su = (priv_check(td, PRIV_SCHED_RTPRIO) == 0);
for (;;) {
@@ -2536,7 +2535,7 @@
do_cv_wait(struct thread *td, struct ucond *cv, struct umutex *m,
struct timespec *timeout, u_long wflags)
{
- struct abs_timeout timo;
+ struct umtx_abs_timeout timo;
struct umtx_q *uq;
uint32_t flags, clockid, hasw;
int error;
@@ -2583,8 +2582,8 @@
error = do_unlock_umutex(td, m, false);
if (timeout != NULL)
- abs_timeout_init(&timo, clockid, (wflags & CVWAIT_ABSTIME) != 0,
- timeout);
+ umtx_abs_timeout_init(&timo, clockid,
+ (wflags & CVWAIT_ABSTIME) != 0, timeout);
umtxq_lock(&uq->uq_key);
if (error == 0) {
@@ -2684,7 +2683,7 @@
do_rw_rdlock(struct thread *td, struct urwlock *rwlock, long fflag,
struct _umtx_time *timeout)
{
- struct abs_timeout timo;
+ struct umtx_abs_timeout timo;
struct umtx_q *uq;
uint32_t flags, wrflags;
int32_t state, oldstate;
@@ -2700,7 +2699,7 @@
return (error);
if (timeout != NULL)
- abs_timeout_init2(&timo, timeout);
+ umtx_abs_timeout_init2(&timo, timeout);
wrflags = URWLOCK_WRITE_OWNER;
if (!(fflag & URWLOCK_PREFER_READER) && !(flags & URWLOCK_PREFER_READER))
@@ -2869,7 +2868,7 @@
static int
do_rw_wrlock(struct thread *td, struct urwlock *rwlock, struct _umtx_time *timeout)
{
- struct abs_timeout timo;
+ struct umtx_abs_timeout timo;
struct umtx_q *uq;
uint32_t flags;
int32_t state, oldstate;
@@ -2886,7 +2885,7 @@
return (error);
if (timeout != NULL)
- abs_timeout_init2(&timo, timeout);
+ umtx_abs_timeout_init2(&timo, timeout);
blocked_readers = 0;
for (;;) {
@@ -3164,7 +3163,7 @@
static int
do_sem_wait(struct thread *td, struct _usem *sem, struct _umtx_time *timeout)
{
- struct abs_timeout timo;
+ struct umtx_abs_timeout timo;
struct umtx_q *uq;
uint32_t flags, count, count1;
int error, rv, rv1;
@@ -3178,7 +3177,7 @@
return (error);
if (timeout != NULL)
- abs_timeout_init2(&timo, timeout);
+ umtx_abs_timeout_init2(&timo, timeout);
again:
umtxq_lock(&uq->uq_key);
@@ -3269,7 +3268,7 @@
static int
do_sem2_wait(struct thread *td, struct _usem2 *sem, struct _umtx_time *timeout)
{
- struct abs_timeout timo;
+ struct umtx_abs_timeout timo;
struct umtx_q *uq;
uint32_t count, flags;
int error, rv;
@@ -3277,7 +3276,7 @@
uq = td->td_umtxq;
flags = fuword32(&sem->_flags);
if (timeout != NULL)
- abs_timeout_init2(&timo, timeout);
+ umtx_abs_timeout_init2(&timo, timeout);
again:
error = umtx_key_get(sem, TYPE_SEM, GET_SHARE(flags), &uq->uq_key);
@@ -3336,7 +3335,7 @@
if (error == ERESTART)
error = EINTR;
if (error == EINTR) {
- abs_timeout_update(&timo);
+ umtx_abs_timeout_update(&timo);
timespecsub(&timo.end, &timo.cur,
&timeout->_timeout);
}
Index: sys/sys/umtxvar.h
===================================================================
--- sys/sys/umtxvar.h
+++ sys/sys/umtxvar.h
@@ -78,6 +78,13 @@
#define PROCESS_SHARE 1
#define AUTO_SHARE 2
+struct umtx_abs_timeout {
+ int clockid;
+ bool is_abs_real; /* TIMER_ABSTIME && CLOCK_REALTIME* */
+ struct timespec cur;
+ struct timespec end;
+};
+
struct thread;
static inline int
@@ -89,6 +96,8 @@
k1->info.both.b == k2->info.both.b);
}
+void umtx_abs_timeout_init(struct umtx_abs_timeout *, int, int,
+ const struct timespec *);
int umtx_copyin_timeout(const void *, struct timespec *);
void umtx_exec(struct proc *p);
int umtx_key_get(const void *, int, int, struct umtx_key *);

File Metadata

Mime Type
text/plain
Expires
Mon, Aug 31, 3:04 PM (12 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37695970
Default Alt Text
D31249.id92558.diff (9 KB)

Event Timeline