Commit Graph

1313 Commits

Author SHA1 Message Date
Brian Behlendorf 529d515858 Merge branch 'fix-stack-dbuf_hold_impl' into refs/top-bases/fix-branch 2010-08-02 14:12:55 -07:00
Ned Bass 4d3fc57112 Reduce stack usage for recursive dbuf_hold_impl()
This commit preserves the recursive function dbuf_hold_impl() but moves
the local variables and function arguments to the heap to minimize
the stack frame size.  Enough space is initially allocated on the
stack for 20 levels of recursion.  This technique was based on commit
34229a2f2a which reduced stack usage of
traverse_visitbp().

dbuf_hold_impl() is mutually recursive with dbuf_findbp(),
but the latter function is also called from other functions.
Therefore dbuf_findbp() must contain logic to determine how to call
dbuf_hold_impl().  To this end, dbuf_hold_impl() now takes a
struct dbuf_hold_impl_data pointer as an argument.  If that argument
is NULL it calls dbuf_hold_impl() as before, otherwise it calls
__debuf_hold_impl() with a single dbuf_hold_impl_data pointer argument.
As the name implies, dbuf_hold_impl_data stores the arguments and local
variables for dbuf_hold_impl().

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2010-08-02 14:12:31 -07:00
Brian Behlendorf c7786edbf0 Initial commit for fix-stack-dbuf_hold_impl topic branch 2010-08-02 14:10:28 -07:00
Brian Behlendorf 2a9adcbffb Merge branch 'fix-stack-dsl_scan_visitbp' into refs/top-bases/fix-branch 2010-08-02 14:09:39 -07:00
Ned Bass 410d8c4e15 Reduce dsl_scan_visitbp stack usage by moving blkptr_t to heap
Github issue 22 reported a stack overrun when the zfs module was
loaded, possibly related to the presence of existing zpools created
under zfs-fuse.  The stack trace showed 9 levels of recursion between
dsl_scan_visitbp() and dsl_scan_recurse(). To reduce stack overhead in
that code path, this commit moves the 128 byte blkptr_t data strucutre
in dsl_scan_visitbp() to the heap.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2010-08-02 14:09:15 -07:00
Brian Behlendorf 911d2e0df4 Initial commit for fix-stack-dsl_scan_visitbp topic branch 2010-08-02 14:08:36 -07:00
Brian Behlendorf 425b8742a5 Merge branch 'fix-stack-zio_done' into refs/top-bases/fix-branch 2010-08-02 14:06:32 -07:00
Ned Bass d5658668e0 Reduce stack usage of zio_done
Eliminated local variables pointing to members of the zio struct.
Just refer to the struct members directly.  This saved about 32 bytes per
call, but this function can be called recurisvely up to 19 levels deep,
so we potentially save up to 608 bytes.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2010-08-02 14:05:49 -07:00
Brian Behlendorf df8e5bf1ca Initial commit for fix-stack-zio_done topic branch 2010-08-02 13:58:47 -07:00
Brian Behlendorf f3d8ee7357 Merge branch 'fix-stack-vdev_cache_read' into refs/top-bases/fix-branch 2010-08-02 13:57:39 -07:00
Brian Behlendorf 48669030fe Reduce stack in vdev_cache_read
Moving the vdev_cache_entry_t struct ve_search from the stack to
the heap saves ~100 bytes.
2010-08-02 13:57:15 -07:00
Brian Behlendorf 215b84f12f Merge branch 'fix-stack-inline' into refs/top-bases/fix-branch 2010-08-02 13:49:05 -07:00
Brian Behlendorf 8d443f35c4 Merge branch 'fix-stack-ztest' into refs/top-bases/fix-branch 2010-08-02 13:49:04 -07:00
Ned Bass 411dd65af1 Inline zio_execute() to reduce stack use
Deep recursive call chains are contributing to segfaults in ztest due to
heavy stack use.  Inlining zio_execute() helps reduce the stack depth of
the zio_notify_parent() -> zio_execute() -> zio_wait() recursive cycle.
I am no longer seeing ztest segfaults in this code path with this change.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2010-08-02 13:47:49 -07:00
Ned Bass 526d004cf5 Inline dbuf_findbp() to reduce stack use
Deep recursive call chains are contributing to segfaults in ztest due
to heavy stack use.  Inlining dbuf_findbp() helps reduce the stack depth
of the dbuf_findbp() -> dbuf_hold_impl() cycle.  However, segfaults are
still occurring in this code path, so further reductions are still needed.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2010-08-02 13:47:21 -07:00
Ned Bass dd72f3d647 Inline zio_notify_parent() to reduce stack use
Deep recursive call chains are contributing to segfaults in ztest due
to heavy stack use.  Inlining zio_notify_parent() helps reduce the
stack depth of the zio_notify_parent() -> zio_execute() -> zio_done()
recursive cycle.  I am no longer seeing ztest segfaults in this code
path with this change combined with the zio_done() stack reduction in
the previous commit.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2010-08-02 13:46:48 -07:00
Brian Behlendorf ca5262f030 Reduce stack by inlining spa_impl_load
The spa_load function may call itself recursively through
the spa_load_impl function.  This call path of spa_load->
spa_load_impl->spa_load->spa_load_impl takes 640 bytes of
stack.  By forcing spa_load_impl to be inlined as part of
spa_load the can be reduced to 448 bytes, for a savings of
192 bytes,
2010-08-02 13:45:28 -07:00
Brian Behlendorf a8a452d74b Initial commit for fix-stack-inline topic branch 2010-08-02 13:44:56 -07:00
Ned Bass bb20b03060 Move ztest_od_t structures to the heap
A number of ztest functions create one or more 312B ztest_od_t data
structures.  To conserve stack usage, this commit moves all of these data
structures to the heap.  However, I am still seeing ztest segfaults due
to heavy stack usage of the dbuf_findbp() -> dbuf_hold_impl() recursion.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2010-08-02 13:42:25 -07:00
Brian Behlendorf bb064e0220 Merge branch 'fix-taskq' into refs/top-bases/fix-branch 2010-08-02 13:21:51 -07:00
Ricardo M. Correia 4ca4dfe9bb Fix taskq_dispatch() call in zio_taskq_dispatch().
The feature branch 'fix-taskq' in Linux's ZFS tree changes the taskq_dispatch()
flag from TQ_SLEEP to TQ_NOSLEEP to avoid sleeping in some circumstances.

However, this has the side effect that taskq_dispatch() now may fail, and since
the return code was not even being checked, it could lead to zio's not being
scheduled to execute.

I'm fixing this in a simplistic but not very elegant way, by just looping until
taskq_dispatch() succeeds.

Signed-off-by: Ricardo M. Correia <ricardo.correia@oracle.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2010-08-02 13:12:54 -07:00
Brian Behlendorf 4471454be8 Merge branch 'fix-stack-ztest' into refs/top-bases/fix-branch 2010-07-23 11:42:21 -07:00
Brian Behlendorf 085c18fa55 Merge commit 'refs/top-bases/fix-stack-ztest' into fix-stack-ztest 2010-07-23 11:42:20 -07:00
Ned Bass be92edb218 Add extra guard space if needed
Some buggy NPTL threading implementations include the guard area within
the stack size allocations.  In this case we need to allocate an extra
page to account for the guard area since we only have two pages of usable
stack on Linux.  Added an autoconf test that detects such implementations
by running a test program designed to segfault if the bug is present.
Set a flag NPTL_GUARD_WITHIN_STACK that is tested to decide if extra
stack space must be allocated for the guard area.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2010-07-23 11:38:00 -07:00
Brian Behlendorf a2cf158872 Merge branch 'fix-stack-ztest' into refs/top-bases/fix-branch 2010-07-21 10:08:22 -07:00
Brian Behlendorf 8d6a2d0626 Merge commit 'refs/top-bases/fix-stack-ztest' into fix-stack-ztest 2010-07-21 10:08:22 -07:00
Ned Bass 75d868af70 Fixed typo that set thread STACK_SIZE to 24k instead of 8k
__linux__ was mispelled as _linux_ so #ifdef was always
selecting the Solaris STACK_SIZE value.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2010-07-21 10:04:21 -07:00
Brian Behlendorf 015677660a Merge branch 'fix-stack-traverse_visitbp' into refs/top-bases/fix-branch 2010-06-29 16:57:39 -07:00
Brian Behlendorf f20301b41b Minor fix to ensure tv_depth is there when debugging is disabled. 2010-06-29 16:52:42 -07:00
Brian Behlendorf b8bafc851f Merge branch 'fix-stack-ztest' into refs/top-bases/fix-branch 2010-06-29 14:41:35 -07:00
Brian Behlendorf d0ddee3859 Merge commit 'refs/top-bases/fix-stack-ztest' into fix-stack-ztest 2010-06-29 14:41:34 -07:00
Brian Behlendorf 213d6423b5 Merge commit 'refs/top-bases/fix-pthreads' into fix-pthreads 2010-06-29 14:41:34 -07:00
Brian Behlendorf c366e466e3 Merge commit 'refs/top-bases/fix-stack-traverse_visitbp' into fix-stack-traverse_visitbp 2010-06-29 14:41:32 -07:00
Brian Behlendorf f47cc9aac2 Merge branch 'fix-stack-traverse_visitbp' into refs/top-bases/fix-branch 2010-06-29 14:41:32 -07:00
Brian Behlendorf 4b23500c4a Merge branch 'fix-stack-traverse_impl' into refs/top-bases/fix-branch 2010-06-29 14:41:31 -07:00
Brian Behlendorf 490eb4db5c Merge commit 'refs/top-bases/fix-stack-traverse_impl' into fix-stack-traverse_impl 2010-06-29 14:41:30 -07:00
Brian Behlendorf daef43003b Merge branch 'fix-stack-vn_open' into refs/top-bases/fix-branch 2010-06-29 14:41:29 -07:00
Brian Behlendorf 861af03304 Merge commit 'refs/top-bases/fix-stack-vn_open' into fix-stack-vn_open 2010-06-29 14:41:28 -07:00
Brian Behlendorf 33b9043394 Merge branch 'fix-stack-dsl_dataset_destroy' into refs/top-bases/fix-branch 2010-06-29 14:41:27 -07:00
Brian Behlendorf 5721f147c5 Merge commit 'refs/top-bases/fix-stack-dsl_dataset_destroy' into fix-stack-dsl_dataset_destroy 2010-06-29 14:41:27 -07:00
Brian Behlendorf 46acb1b8d2 Merge branch 'fix-stack-dmu_objset_snapshot' into refs/top-bases/fix-branch 2010-06-29 14:41:25 -07:00
Brian Behlendorf 50c15019cb Merge commit 'refs/top-bases/fix-stack-dmu_objset_snapshot' into fix-stack-dmu_objset_snapshot 2010-06-29 14:41:25 -07:00
Brian Behlendorf b8b1c5abb9 Merge branch 'fix-stack-noinline' into refs/top-bases/fix-branch 2010-06-29 14:41:24 -07:00
Brian Behlendorf 002a52896d Merge commit 'refs/top-bases/fix-stack-noinline' into fix-stack-noinline 2010-06-29 14:41:23 -07:00
Brian Behlendorf f568df2d32 Merge branch 'fix-stack-dsl_deleg_get' into refs/top-bases/fix-branch 2010-06-29 14:41:22 -07:00
Brian Behlendorf 89cd45bf85 Merge commit 'refs/top-bases/fix-stack-dsl_deleg_get' into fix-stack-dsl_deleg_get 2010-06-29 14:41:22 -07:00
Brian Behlendorf 4e8810b3ff Merge branch 'fix-stack-dsl_dir_open_spa' into refs/top-bases/fix-branch 2010-06-29 14:41:20 -07:00
Brian Behlendorf fd66f491b4 Merge commit 'refs/top-bases/fix-stack-dsl_dir_open_spa' into fix-stack-dsl_dir_open_spa 2010-06-29 14:41:20 -07:00
Brian Behlendorf eed68d5e3f Merge branch 'fix-stack-lzjb' into refs/top-bases/fix-branch 2010-06-29 14:41:19 -07:00
Brian Behlendorf 1badbf8463 Merge commit 'refs/top-bases/fix-stack-lzjb' into fix-stack-lzjb 2010-06-29 14:41:18 -07:00