diff options
author | Etienne Dechamps <[email protected]> | 2012-09-27 13:31:46 +0200 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2012-10-03 13:32:48 -0700 |
commit | 0aebd4f9e3223e8f1e09de7b29bba4f375db840c (patch) | |
tree | 87de1c6b6e8ba60d124a5bafe8880aa69cbff254 /include | |
parent | 6d1d976b2c2c6b80de75a480c998466068066846 (diff) |
Create threads in detached state in userspace.
Currently, thread_create(), when called in userspace, creates a
joinable (i.e. not detached thread). This is the pthread default.
Unfortunately, this does not reproduce kthreads behavior (kthreads
are always detached). In addition, this contradicts the original
Solaris code which creates userspace threads in detached mode.
These joinable threads are never joined, which leads to a leakage of
pthread thread objects ("zombie threads"). This in turn results in
excessive ressource consumption, and possible ressource exhaustion in
extreme cases (e.g. long ztest runs).
This patch fixes the issue by creating userspace threads in detached
mode. The only exception is ztest worker threads which are meant to be
joinable.
Signed-off-by: Brian Behlendorf <[email protected]>
Issue #989
Diffstat (limited to 'include')
-rw-r--r-- | include/sys/zfs_context.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/include/sys/zfs_context.h b/include/sys/zfs_context.h index de8b943be..d8347a335 100644 --- a/include/sys/zfs_context.h +++ b/include/sys/zfs_context.h @@ -220,7 +220,7 @@ typedef struct kthread { #define thread_exit zk_thread_exit #define thread_create(stk, stksize, func, arg, len, pp, state, pri) \ zk_thread_create(stk, stksize, (thread_func_t)func, arg, \ - len, NULL, state, pri) + len, NULL, state, pri, PTHREAD_CREATE_DETACHED) #define thread_join(t) zk_thread_join(t) #define newproc(f,a,cid,pri,ctp,pid) (ENOSYS) @@ -228,7 +228,7 @@ extern kthread_t *zk_thread_current(void); extern void zk_thread_exit(void); extern kthread_t *zk_thread_create(caddr_t stk, size_t stksize, thread_func_t func, void *arg, size_t len, - proc_t *pp, int state, pri_t pri); + proc_t *pp, int state, pri_t pri, int detachstate); extern void zk_thread_join(kt_did_t tid); #define kpreempt_disable() ((void)0) |