#ifndef _LTT_SESSIOND_H
#define _LTT_SESSIOND_H
-#define DEFAULT_HOME_DIR "/tmp"
+#define DEFAULT_HOME_DIR "/tmp"
#define DEFAULT_UST_SOCK_DIR DEFAULT_HOME_DIR "/ust-app-socks"
#define DEFAULT_GLOBAL_APPS_PIPE DEFAULT_UST_SOCK_DIR "/global"
-#define DEFAULT_TRACE_OUTPUT DEFAULT_HOME_DIR "/lttng"
+#define DEFAULT_TRACE_OUTPUT DEFAULT_HOME_DIR "/lttng"
+
+struct module_param {
+ const char *name;
+ int required;
+};
/* LTTng kernel tracer modules list */
-const char *kernel_modules_list[] = {
- "lib-ring-buffer",
- "ltt-relay",
- "ltt-ring-buffer-client-discard",
- "ltt-ring-buffer-client-overwrite",
- "ltt-ring-buffer-metadata-client",
- "ltt-ring-buffer-client-mmap-discard",
- "ltt-ring-buffer-client-mmap-overwrite",
- "ltt-ring-buffer-metadata-mmap-client",
- "lttng-ftrace",
- "lttng-kprobes",
- "lttng-kretprobes",
- "lttng-probe-block",
- "lttng-probe-irq",
- "lttng-probe-kvm",
- "lttng-probe-lttng",
- "lttng-probe-sched",
- "lttng-probe-syscalls",
- "lttng-types",
- NULL,
+const struct module_param kernel_modules_list[] = {
+ /* used by ltt-relay, unload last */
+ { "lttng-ftrace", 0 },
+ { "lttng-kprobes", 0 },
+ { "lttng-kretprobes", 0 },
+
+ { "lib-ring-buffer", 1 },
+ { "ltt-relay", 1 },
+ { "ltt-ring-buffer-client-discard", 1 },
+ { "ltt-ring-buffer-client-overwrite", 1 },
+ { "ltt-ring-buffer-metadata-client", 1 },
+ { "ltt-ring-buffer-client-mmap-discard", 1 },
+ { "ltt-ring-buffer-client-mmap-overwrite", 1 },
+ { "ltt-ring-buffer-metadata-mmap-client", 1 },
+ { "lttng-probe-lttng", 1 },
+ { "lttng-types", 0 },
+ { "lttng-probe-block", 0 },
+ { "lttng-probe-irq", 0 },
+ { "lttng-probe-kvm", 0 },
+ { "lttng-probe-sched", 0 },
+ { "lttng-probe-syscalls", 0 },
};
extern const char default_home_dir[],
static pthread_mutex_t kconsumerd_pid_mutex; /* Mutex to control kconsumerd pid assignation */
+static int modprobe_remove_kernel_modules(void);
+
/*
* Pointer initialized before thread creation.
*
DBG("Closing kernel fd");
close(kernel_tracer_fd);
+
+ DBG("Unloading kernel modules");
+ modprobe_remove_kernel_modules();
}
/*
*/
static int modprobe_kernel_modules(void)
{
- int ret = 0, i = 0;
+ int ret = 0, i;
char modprobe[256];
- while (kernel_modules_list[i] != NULL) {
- ret = snprintf(modprobe, sizeof(modprobe), "/sbin/modprobe %s",
- kernel_modules_list[i]);
+ for (i = 0; i < ARRAY_SIZE(kernel_modules_list); i++) {
+ ret = snprintf(modprobe, sizeof(modprobe),
+ "/sbin/modprobe %s%s",
+ kernel_modules_list[i].required ? "" : "--quiet ",
+ kernel_modules_list[i].name);
if (ret < 0) {
perror("snprintf modprobe");
goto error;
}
+ modprobe[sizeof(modprobe) - 1] = '\0';
ret = system(modprobe);
+ if (ret == -1) {
+ ERR("Unable to launch modprobe for module %s",
+ kernel_modules_list[i].name);
+ } else if (kernel_modules_list[i].required
+ && WEXITSTATUS(ret) != 0) {
+ ERR("Unable to load module %s",
+ kernel_modules_list[i].name);
+ } else {
+ DBG("Modprobe successfully %s",
+ kernel_modules_list[i].name);
+ }
+ }
+
+error:
+ return ret;
+}
+
+/*
+ * modprobe_remove_kernel_modules
+ * Remove modules in reverse load order.
+ */
+static int modprobe_remove_kernel_modules(void)
+{
+ int ret = 0, i;
+ char modprobe[256];
+
+ for (i = ARRAY_SIZE(kernel_modules_list) - 1; i >= 0; i--) {
+ ret = snprintf(modprobe, sizeof(modprobe),
+ "/sbin/modprobe --remove --quiet %s",
+ kernel_modules_list[i].name);
if (ret < 0) {
- ERR("Unable to load module %s", kernel_modules_list[i]);
+ perror("snprintf modprobe --remove");
+ goto error;
+ }
+ modprobe[sizeof(modprobe) - 1] = '\0';
+ ret = system(modprobe);
+ if (ret == -1) {
+ ERR("Unable to launch modprobe --remove for module %s",
+ kernel_modules_list[i].name);
+ } else if (kernel_modules_list[i].required
+ && WEXITSTATUS(ret) != 0) {
+ ERR("Unable to remove module %s",
+ kernel_modules_list[i].name);
+ } else {
+ DBG("Modprobe removal successful %s",
+ kernel_modules_list[i].name);
}
- DBG("Modprobe successfully %s", kernel_modules_list[i]);
- i++;
}
error: