X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/blobdiff_plain/0658a929038b8748f5ef610ee5364a8995d60f66..c6fbe95aea00066c24a4d2c2f84bb848374c08c7:/sys/sys/thread.h diff --git a/sys/sys/thread.h b/sys/sys/thread.h index 5c26a1c7fd..18baa5733a 100644 --- a/sys/sys/thread.h +++ b/sys/sys/thread.h @@ -98,57 +98,26 @@ struct intrframe; * Tokens are managed through a helper reference structure, lwkt_tokref, * which is typically declared on the caller's stack. Multiple tokref's * may reference the same token. - * - * It is possible to detect that your token was temporarily lost via - * lwkt_token_is_stale(), which uses the t_lastowner field. This field - * does NOT necessarily represent the current owner and can become stale - * (not point to a valid structure). It is used solely to detect - * whether the token was temporarily lost to another thread. The lost - * state is cleared by the function. */ typedef struct lwkt_token { -#ifdef SMP - struct spinlock t_spinlock; /* Controls access */ -#else - struct spinlock t_unused01; -#endif - struct thread *t_owner; /* The current owner of the token */ - int t_count; /* Per-thread count */ - struct thread *t_lastowner; /* Last owner that acquired token */ + struct lwkt_tokref *t_ref; /* Owning ref or NULL */ } lwkt_token; -#ifdef SMP -#define LWKT_TOKEN_INITIALIZER(head) \ -{ \ - .t_spinlock = SPINLOCK_INITIALIZER(head.t_spinlock), \ - .t_owner = NULL, \ - .t_lastowner = NULL, \ - .t_count = 0 \ +#define LWKT_TOKEN_INITIALIZER(head) \ +{ \ + .t_ref = NULL \ } -#else -#define LWKT_TOKEN_INITIALIZER(head) \ -{ \ - .t_owner = NULL, \ - .t_lastowner = NULL, \ - .t_count = 0 \ -} -#endif -#define ASSERT_LWKT_TOKEN_HELD(token) \ - KKASSERT((token)->t_owner == curthread) +#define ASSERT_LWKT_TOKEN_HELD(tok) \ + KKASSERT((tok)->t_ref->tr_owner == curthread) typedef struct lwkt_tokref { lwkt_token_t tr_tok; /* token in question */ + struct thread *tr_owner; /* me */ lwkt_tokref_t tr_next; /* linked list */ - int tr_state; /* 0 = don't have, 1 = have */ } lwkt_tokref; -#define LWKT_TOKREF_INIT(tok) \ - { tok, NULL, 0 } -#define LWKT_TOKREF_DECLARE(name, tok) \ - lwkt_tokref name = LWKT_TOKREF_INIT(tok) - #define MAXCPUFIFO 16 /* power of 2 */ #define MAXCPUFIFO_MASK (MAXCPUFIFO - 1) #define LWKT_MAXTOKENS 16 /* max tokens beneficially held by thread */ @@ -211,6 +180,11 @@ typedef struct lwkt_cpu_msg { * * NOTE: td_pri is bumped by TDPRI_CRIT when entering a critical section, * but this does not effect how the thread is scheduled by LWKT. + * + * NOTE: td_ucred is synchronized from the p_ucred on user->kernel syscall, + * trap, and AST/signal transitions to provide a stable ucred for + * (primarily) system calls. This field will be NULL for pure kernel + * threads. */ struct md_intr_info; struct caps_kinfo; @@ -253,6 +227,7 @@ struct thread { struct timeval td_start; /* start time for a thread/process */ char td_comm[MAXCOMLEN+1]; /* typ 16+1 bytes */ struct thread *td_preempted; /* we preempted this thread */ + struct ucred *td_ucred; /* synchronized from p_ucred */ struct caps_kinfo *td_caps; /* list of client and server registrations */ lwkt_tokref_t td_toks; /* tokens beneficially held */ #ifdef DEBUG_CRIT_SECTIONS @@ -379,10 +354,10 @@ extern void lwkt_relalltokens(thread_t); extern void lwkt_drain_token_requests(void); extern void lwkt_token_init(lwkt_token_t); extern void lwkt_token_uninit(lwkt_token_t); -extern int lwkt_token_is_stale(lwkt_tokref_t); extern void lwkt_token_pool_init(void); -extern lwkt_token_t lwkt_token_pool_get(void *); +extern lwkt_token_t lwkt_token_pool_lookup(void *); +extern void lwkt_getpooltoken(lwkt_tokref_t, void *); extern void lwkt_setpri(thread_t, int); extern void lwkt_setpri_initial(thread_t, int); @@ -426,8 +401,6 @@ extern int lwkt_create (void (*func)(void *), void *, struct thread **, struct thread *, int, int, const char *, ...); extern void lwkt_exit (void) __dead2; extern void lwkt_remove_tdallq (struct thread *); -extern void lwkt_mp_lock_contested(void); -extern void lwkt_mp_lock_uncontested(void); #endif