#include "register.h"
#include "manage-apps.h"
#include "manage-kernel.h"
+#include "modprobe.h"
static const char *help_msg =
#ifdef LTTNG_EMBED_HELP
sessiond_cleanup();
/*
- * Wait for all pending call_rcu work to complete tearing shutting down
+ * Wait for all pending call_rcu work to complete before shutting down
* the notification thread. This call_rcu work includes shutting down
* UST apps and event notifier pipes.
*/
}
/*
- * Teardown of error accounting needs be done after the teardown of the
- * notification thread as all error buckets must have been released by
- * their users (conditions).
+ * Error accounting teardown has to be done after the teardown of all
+ * event notifier pipes to ensure that no tracer may try to use the
+ * error accounting facilities.
*/
event_notifier_error_accounting_fini();
+ /*
+ * Unloading the kernel modules needs to be done after all kernel
+ * ressources have been released. In our case, this includes the
+ * notification fd, the event notifier group fd, error accounting fd,
+ * all event and event notifier fds, etc.
+ *
+ * In short, at this point, we need to have called close() on all fds
+ * received from the kernel tracer.
+ */
+ if (is_root && !config.no_kernel) {
+ DBG("Unloading kernel modules");
+ modprobe_remove_lttng_all();
+ }
+
/*
* Ensure all prior call_rcu are done. call_rcu callbacks may push
* hash tables to the ht_cleanup thread. Therefore, we ensure that
modprobe[sizeof(modprobe) - 1] = '\0';
ret = system(modprobe);
if (ret == -1) {
- ERR("Unable to launch modprobe -r for module %s",
- modules[i].name);
- } else if (modules[i].load_policy == KERNEL_MODULE_PROPERTY_LOAD_POLICY_REQUIRED && WEXITSTATUS(ret) != 0) {
- ERR("Unable to remove module %s",
- modules[i].name);
+ if (modules[i].load_policy == KERNEL_MODULE_PROPERTY_LOAD_POLICY_REQUIRED) {
+ ERR("Unable to launch modprobe -r for required module %s",
+ modules[i].name);
+ } else {
+ DBG("Unable to launch modprobe -r for optional module %s",
+ modules[i].name);
+ }
+ } else if (WEXITSTATUS(ret) != 0) {
+ if (modules[i].load_policy == KERNEL_MODULE_PROPERTY_LOAD_POLICY_REQUIRED) {
+ ERR("Unable to remove required module %s",
+ modules[i].name);
+ } else {
+ DBG("Unable to remove optional module %s",
+ modules[i].name);
+ }
} else {
- DBG("Modprobe removal successful %s",
- modules[i].name);
+ DBG("Modprobe removal successful %s", modules[i].name);
}
}
}