SoW-2019-0002: Dynamic Snapshot
[deliverable/lttng-modules.git] / lttng-probes.c
index ee75e33d7881f9528043dd492a63351ef73714de..24f76f355560bb926438c0fe63908b2750704945 100644 (file)
@@ -1,23 +1,10 @@
-/*
+/* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1)
+ *
  * lttng-probes.c
  *
  * Holds LTTng probes registry.
  *
  * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; only
- * version 2.1 of the License.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <linux/module.h>
@@ -25,7 +12,7 @@
 #include <linux/mutex.h>
 #include <linux/seq_file.h>
 
-#include "lttng-events.h"
+#include <lttng-events.h>
 
 /*
  * probe list is protected by sessions lock.
@@ -44,6 +31,10 @@ static LIST_HEAD(lazy_probe_init);
  */
 static int lazy_nesting;
 
+DEFINE_PER_CPU(struct lttng_dynamic_len_stack, lttng_dynamic_len_stack);
+
+EXPORT_PER_CPU_SYMBOL_GPL(lttng_dynamic_len_stack);
+
 /*
  * Called under sessions lock.
  */
@@ -133,6 +124,8 @@ void fixup_lazy_probes(void)
        }
        ret = lttng_fix_pending_events();
        WARN_ON_ONCE(ret);
+       ret = lttng_fix_pending_triggers();
+       WARN_ON_ONCE(ret);
        lazy_nesting--;
 }
 
@@ -182,7 +175,7 @@ int lttng_probe_register(struct lttng_probe_desc *desc)
         * the probe immediately, since we cannot delay event
         * registration because they are needed ASAP.
         */
-       if (lttng_session_active())
+       if (lttng_session_active() || lttng_trigger_active())
                fixup_lazy_probes();
 end:
        lttng_unlock_sessions();
@@ -207,7 +200,7 @@ EXPORT_SYMBOL_GPL(lttng_probe_unregister);
  * Called with sessions lock held.
  */
 static
-const struct lttng_event_desc *find_event(const char *name)
+const struct lttng_event_desc *find_event_desc(const char *name)
 {
        struct lttng_probe_desc *probe_desc;
        int i;
@@ -224,37 +217,39 @@ const struct lttng_event_desc *find_event(const char *name)
 /*
  * Called with sessions lock held.
  */
-const struct lttng_event_desc *lttng_event_get(const char *name)
+const struct lttng_event_desc *lttng_event_desc_get(const char *name)
 {
-       const struct lttng_event_desc *event;
+       const struct lttng_event_desc *event_desc;
        int ret;
 
-       event = find_event(name);
-       if (!event)
+       event_desc = find_event_desc(name);
+       if (!event_desc)
                return NULL;
-       ret = try_module_get(event->owner);
+       ret = try_module_get(event_desc->owner);
        WARN_ON_ONCE(!ret);
-       return event;
+       return event_desc;
 }
-EXPORT_SYMBOL_GPL(lttng_event_get);
+EXPORT_SYMBOL_GPL(lttng_event_desc_get);
 
 /*
  * Called with sessions lock held.
  */
-void lttng_event_put(const struct lttng_event_desc *event)
+void lttng_event_desc_put(const struct lttng_event_desc *event_desc)
 {
-       module_put(event->owner);
+       module_put(event_desc->owner);
 }
-EXPORT_SYMBOL_GPL(lttng_event_put);
+EXPORT_SYMBOL_GPL(lttng_event_desc_put);
 
 static
 void *tp_list_start(struct seq_file *m, loff_t *pos)
 {
        struct lttng_probe_desc *probe_desc;
+       struct list_head *probe_list;
        int iter = 0, i;
 
        lttng_lock_sessions();
-       list_for_each_entry(probe_desc, &_probe_list, head) {
+       probe_list = lttng_get_probe_list_head();
+       list_for_each_entry(probe_desc, probe_list, head) {
                for (i = 0; i < probe_desc->nr_events; i++) {
                        if (iter++ >= *pos)
                                return (void *) probe_desc->event_desc[i];
@@ -268,10 +263,12 @@ static
 void *tp_list_next(struct seq_file *m, void *p, loff_t *ppos)
 {
        struct lttng_probe_desc *probe_desc;
+       struct list_head *probe_list;
        int iter = 0, i;
 
        (*ppos)++;
-       list_for_each_entry(probe_desc, &_probe_list, head) {
+       probe_list = lttng_get_probe_list_head();
+       list_for_each_entry(probe_desc, probe_list, head) {
                for (i = 0; i < probe_desc->nr_events; i++) {
                        if (iter++ >= *ppos)
                                return (void *) probe_desc->event_desc[i];
@@ -318,3 +315,12 @@ const struct file_operations lttng_tracepoint_list_fops = {
        .llseek = seq_lseek,
        .release = seq_release,
 };
+
+int lttng_probes_init(void)
+{
+       int cpu;
+
+       for_each_possible_cpu(cpu)
+               per_cpu_ptr(&lttng_dynamic_len_stack, cpu)->offset = 0;
+       return 0;
+}
This page took 0.02693 seconds and 5 git commands to generate.