Create threads in detached state in userspace.
authorEtienne Dechamps <etienne.dechamps@ovh.net>
Thu, 27 Sep 2012 11:31:46 +0000 (13:31 +0200)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 3 Oct 2012 20:32:48 +0000 (13:32 -0700)
commit0aebd4f9e3223e8f1e09de7b29bba4f375db840c
tree87de1c6b6e8ba60d124a5bafe8880aa69cbff254
parent6d1d976b2c2c6b80de75a480c998466068066846
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 <behlendorf1@llnl.gov>
Issue #989
cmd/ztest/ztest.c
include/sys/zfs_context.h
lib/libzpool/kernel.c