Moritz Tanner has uploaded this change for review.
log: Start crash handler monitor after daemonizing
With USE_UNWIND_ENRICHED_BT, init_logging() starts the crash handler
monitor fridge thread. main() calls init_logging() through
nfs_prereq_init() before it calls daemon(). The new thread first calls
rcu_register_thread(), which takes rcu_registry_lock in liburcu-bp.
If daemon() forks while the monitor thread holds rcu_registry_lock, the
child inherits the lock in the locked state. The owning thread does not
exist in the child, and no other thread releases the lock. The next RCU
registration in the child hangs. For main() this is init_op_context()
in ReadExports(), after the last startup log message
"nfs_try_lift_grace ... check grace". Every fridge thread the child
starts later waits on the same lock. The daemon never binds its port.
The hang occurs at random. On a 112 CPU host, most starts of a forking
ganesha.nfsd hung. Running ganesha.nfsd with -F prevents the hang.
fork() copies only the calling thread. The daemonized child therefore
runs without a crash handler monitor.
Start the monitor thread from main() after daemonizing. nfs_libmain()
does not fork, so it starts the monitor thread right after
nfs_prereq_init().
Change-Id: If9065456a248a6dd54d13d9b2b3ec616111be305
Signed-off-by: Moritz Tanner <moritz.tanner@linbit.com>
---
M src/MainNFSD/libganesha_nfsd.ver
M src/MainNFSD/nfs_lib.c
M src/MainNFSD/nfs_main.c
M src/include/log.h
M src/log/log_functions.c
5 files changed, 20 insertions(+), 9 deletions(-)
git pull ssh://review.gerrithub.io:29418/ffilz/nfs-ganesha refs/changes/57/1256857/1
To view, visit change 1256857. To unsubscribe, or for help writing mail filters, visit settings.