4 * Copyright 2010 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6 * Holds LTTng probes registry.
9 #include <linux/module.h>
10 #include <linux/list.h>
11 #include <linux/mutex.h>
13 #include "ltt-events.h"
15 static LIST_HEAD(probe_list
);
16 static DEFINE_MUTEX(probe_mutex
);
19 const struct lttng_event_desc
*find_event(const char *name
)
21 struct lttng_probe_desc
*probe_desc
;
24 list_for_each_entry(probe_desc
, &probe_list
, head
) {
25 for (i
= 0; i
< probe_desc
->nr_events
; i
++) {
26 if (!strcmp(probe_desc
->event_desc
[i
].name
, name
))
27 return &probe_desc
->event_desc
[i
];
34 * TODO: registration of probe descriptions in dynamically allocated memory (not
35 * directly in a module memory) will require some care for refcounting: it's
36 * currently done by just refcounting the module in event_get/put.
38 int ltt_probe_register(struct lttng_probe_desc
*desc
)
43 mutex_lock(&probe_mutex
);
45 * TODO: This is O(N^2). Turn into a hash table when probe registration
46 * overhead becomes an issue.
48 for (i
= 0; i
< desc
->nr_events
; i
++) {
49 if (find_event(desc
->event_desc
[i
].name
)) {
54 list_add(&desc
->head
, &probe_list
);
56 mutex_unlock(&probe_mutex
);
59 EXPORT_SYMBOL_GPL(ltt_probe_register
);
61 void ltt_probe_unregister(struct lttng_probe_desc
*desc
)
63 mutex_lock(&probe_mutex
);
64 list_del(&desc
->head
);
65 mutex_unlock(&probe_mutex
);
67 EXPORT_SYMBOL_GPL(ltt_probe_unregister
);
69 const struct lttng_event_desc
*ltt_event_get(const char *name
)
71 const struct lttng_event_desc
*event
;
74 mutex_lock(&probe_mutex
);
75 event
= find_event(name
);
78 ret
= try_module_get(__module_text_address((unsigned long) event
));
81 mutex_unlock(&probe_mutex
);
84 EXPORT_SYMBOL_GPL(ltt_event_get
);
86 void ltt_event_put(const struct lttng_event_desc
*event
)
88 module_put(__module_text_address((unsigned long) event
));
90 EXPORT_SYMBOL_GPL(ltt_event_put
);
This page took 0.079679 seconds and 4 git commands to generate.