diff --git a/sys/config/GENERIC b/sys/config/GENERIC index e9717f9..0ede60f 100644 --- a/sys/config/GENERIC +++ b/sys/config/GENERIC @@ -54,6 +54,8 @@ options AHD_REG_PRETTY_PRINT # Print register bitfields in debug # output. Adds ~215k to driver. options DSCHED_FQ # Fair-queuing disk scheduler +options KTR +options KTR_TOKENS # ALTQ options ALTQ #alternate queueing options ALTQ_CBQ #class based queueing diff --git a/sys/kern/lwkt_token.c b/sys/kern/lwkt_token.c index 37ae5b9..9ace0bc 100644 --- a/sys/kern/lwkt_token.c +++ b/sys/kern/lwkt_token.c @@ -86,6 +86,9 @@ static lwkt_token pool_tokens[LWKT_NUM_POOL_TOKENS]; #define TOKEN_STRING "REF=%p TOK=%p TD=%p" #define TOKEN_ARGS lwkt_tokref_t ref, lwkt_token_t tok, struct thread *td +#define TOKEN_STRING1 "TOK=%p %s:%d" +#define TOKEN_ARGS1 lwkt_token_t tok, char *func, int line + #define CONTENDED_STRING TOKEN_STRING " (contention started)" #define UNCONTENDED_STRING TOKEN_STRING " (contention stopped)" #if !defined(KTR_TOKENS) @@ -95,6 +98,8 @@ static lwkt_token pool_tokens[LWKT_NUM_POOL_TOKENS]; KTR_INFO_MASTER(tokens); KTR_INFO(KTR_TOKENS, tokens, fail, 0, TOKEN_STRING, TOKEN_ARGS); KTR_INFO(KTR_TOKENS, tokens, succ, 1, TOKEN_STRING, TOKEN_ARGS); +KTR_INFO(KTR_TOKENS, tokens, gettok, 2, TOKEN_STRING1, TOKEN_ARGS1); +KTR_INFO(KTR_TOKENS, tokens, reltok, 3, TOKEN_STRING1, TOKEN_ARGS1); #if 0 KTR_INFO(KTR_TOKENS, tokens, release, 2, TOKEN_STRING, TOKEN_ARGS); KTR_INFO(KTR_TOKENS, tokens, remote, 3, TOKEN_STRING, TOKEN_ARGS); @@ -108,6 +113,9 @@ KTR_INFO(KTR_TOKENS, tokens, contention_stop, 7, UNCONTENDED_STRING, TOKEN_ARGS) #define logtoken(name, ref) \ KTR_LOG(tokens_ ## name, ref, ref->tr_tok, curthread) +#define logtoken1(name, tok, f, l) \ + KTR_LOG(tokens_ ## name, tok, f, l) + /* * Global tokens. These replace the MP lock for major subsystem locking. * These tokens are initially used to lockup both global and individual @@ -598,11 +606,18 @@ _lwkt_getalltokens_sorted(thread_t td) return (TRUE); } +void +lwkt_gettoken_debug(lwkt_token_t tok, const char *func, int line) +{ + logtoken1(gettok, tok, __DECONST(char *, func), line); + lwkt_gettoken2(tok); +} + /* * Get a serializing token. This routine can block. */ void -lwkt_gettoken(lwkt_token_t tok) +lwkt_gettoken2(lwkt_token_t tok) { thread_t td = curthread; lwkt_tokref_t ref; @@ -756,6 +771,12 @@ lwkt_getpooltoken(void *ptr) return (tok); } +void +lwkt_reltoken_debug(lwkt_token_t tok, const char *func, int line) +{ + logtoken1(reltok, tok, __DECONST(char *, func), line); + lwkt_reltoken2(tok); +} /* * Release a serializing token. * @@ -763,7 +784,7 @@ lwkt_getpooltoken(void *ptr) * asserted. */ void -lwkt_reltoken(lwkt_token_t tok) +lwkt_reltoken2(lwkt_token_t tok) { thread_t td = curthread; lwkt_tokref_t ref; @@ -795,7 +816,7 @@ void lwkt_relpooltoken(void *ptr) { lwkt_token_t tok = _lwkt_token_pool_lookup(ptr); - lwkt_reltoken(tok); + lwkt_reltoken_debug(tok, __func__, __LINE__); } /* diff --git a/sys/sys/thread.h b/sys/sys/thread.h index 0d9c444..59fa040 100644 --- a/sys/sys/thread.h +++ b/sys/sys/thread.h @@ -81,6 +81,10 @@ typedef TAILQ_HEAD(lwkt_queue, thread) lwkt_queue; struct intrframe; #endif +#define lwkt_gettoken(tok) lwkt_gettoken_debug(tok, __func__, __LINE__) +//#define lwkt_gettoken_shared(tok) lwkt_gettoken_shared_debug(tok, __func__, __LINE__) +#define lwkt_reltoken(tok) lwkt_reltoken_debug(tok, __func__, __LINE__) + /* * Tokens are used to serialize access to information. They are 'soft' * serialization entities that only stay in effect while a thread is @@ -450,11 +454,13 @@ extern void lwkt_rele(thread_t); extern void lwkt_passive_release(thread_t); extern void lwkt_maybe_splz(thread_t); -extern void lwkt_gettoken(lwkt_token_t); +extern void lwkt_gettoken_debug(lwkt_token_t, const char *, int); +extern void lwkt_reltoken_debug(lwkt_token_t, const char *, int); +extern void lwkt_gettoken2(lwkt_token_t); +extern void lwkt_reltoken2(lwkt_token_t); extern void lwkt_gettoken_shared(lwkt_token_t); extern void lwkt_gettoken_hard(lwkt_token_t); extern int lwkt_trytoken(lwkt_token_t); -extern void lwkt_reltoken(lwkt_token_t); extern void lwkt_reltoken_hard(lwkt_token_t); extern int lwkt_cnttoken(lwkt_token_t, thread_t); extern int lwkt_getalltokens(thread_t, int);