]> granicus.if.org Git - zfs/commit
Add Thread Specific Data (TSD) Regression Test
authorBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 3 Dec 2010 23:49:57 +0000 (15:49 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 7 Dec 2010 18:02:44 +0000 (10:02 -0800)
commitb7dc3138375ed4c73f55183371b48db4e6e25d79
treeec8f09a95af44775ffbda577fbec087527db17c7
parent9fe45dc1ac5d0292a69cc91f951b984f21ae0aaa
Add Thread Specific Data (TSD) Regression Test

To validate the correct behavior of the TSD interfaces it's
important that we add a regression test.  This test is designed
to minimally exercise the fundamental TSD behavior, it does not
attempt to validate all potential corner cases.

The test will first create 32 keys via tsd_create() and register
a common destructor.  Next 16 wait threads will be created each
of which set/verify a random value for all 32 keys, then block
waiting to be released by the control thread.  Meanwhile the
control thread verifies that none of the destructors have been
run prematurely.

The next phase of the test is to create 16 exit threads which
set/verify a random value for all 32 keys.  They then immediately
exit.  This is is designed to verify tsd_exit() which will be
called via thread_exit().  This must result in all registered
destructors being run and the memory for the tsd being free'd.

After this tsd_destroy() is verified by destroying all 32 keys.
Once again we must see the expected number of destructors run
and the tsd memory free'd.  At this point the blocked threads
are released and they exit calling tsd_exit() which should do
very little since all the tsd has already been destroyed.

If this all goes off without a hitch the test passes.  To ensure
no memory has been leaked, I have manually verified that after
spl module unload no memory is reported leaked.
module/splat/splat-thread.c