projects
/
lttng-modules.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove dependency on kallsyms for irq_to_desc (kernel 3.4+)
[lttng-modules.git]
/
lttng-events.c
diff --git
a/lttng-events.c
b/lttng-events.c
index d00701466a5d47c532cf3d32c20368d19eda9527..3d0ef98464cfdfa0c2bec1040b8b52159fa0dcf6 100644
(file)
--- a/
lttng-events.c
+++ b/
lttng-events.c
@@
-46,14
+46,17
@@
#include <wrapper/random.h>
#include <wrapper/tracepoint.h>
#include <wrapper/list.h>
#include <wrapper/random.h>
#include <wrapper/tracepoint.h>
#include <wrapper/list.h>
+#include <wrapper/types.h>
#include <lttng-kernel-version.h>
#include <lttng-events.h>
#include <lttng-tracer.h>
#include <lttng-abi-old.h>
#include <lttng-endian.h>
#include <lttng-kernel-version.h>
#include <lttng-events.h>
#include <lttng-tracer.h>
#include <lttng-abi-old.h>
#include <lttng-endian.h>
+#include <lttng-string-utils.h>
#include <wrapper/vzalloc.h>
#include <wrapper/ringbuffer/backend.h>
#include <wrapper/ringbuffer/frontend.h>
#include <wrapper/vzalloc.h>
#include <wrapper/ringbuffer/backend.h>
#include <wrapper/ringbuffer/frontend.h>
+#include <wrapper/time.h>
#define METADATA_CACHE_DEFAULT_SIZE 4096
#define METADATA_CACHE_DEFAULT_SIZE 4096
@@
-87,7
+90,12
@@
int _lttng_field_statedump(struct lttng_session *session,
void synchronize_trace(void)
{
void synchronize_trace(void)
{
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,1,0))
+ synchronize_rcu();
+#else
synchronize_sched();
synchronize_sched();
+#endif
+
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
#ifdef CONFIG_PREEMPT_RT_FULL
synchronize_rcu();
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
#ifdef CONFIG_PREEMPT_RT_FULL
synchronize_rcu();
@@
-130,7
+138,7
@@
struct lttng_session *lttng_session_create(void)
int i;
mutex_lock(&sessions_mutex);
int i;
mutex_lock(&sessions_mutex);
- session =
k
zalloc(sizeof(struct lttng_session), GFP_KERNEL);
+ session =
lttng_kv
zalloc(sizeof(struct lttng_session), GFP_KERNEL);
if (!session)
goto err;
INIT_LIST_HEAD(&session->chan);
if (!session)
goto err;
INIT_LIST_HEAD(&session->chan);
@@
-161,7
+169,7
@@
struct lttng_session *lttng_session_create(void)
err_free_cache:
kfree(metadata_cache);
err_free_session:
err_free_cache:
kfree(metadata_cache);
err_free_session:
-
k
free(session);
+
lttng_kv
free(session);
err:
mutex_unlock(&sessions_mutex);
return NULL;
err:
mutex_unlock(&sessions_mutex);
return NULL;
@@
-184,7
+192,7
@@
void lttng_session_destroy(struct lttng_session *session)
int ret;
mutex_lock(&sessions_mutex);
int ret;
mutex_lock(&sessions_mutex);
-
ACCESS_ONCE(session->active) = 0
;
+
WRITE_ONCE(session->active, 0)
;
list_for_each_entry(chan, &session->chan, list) {
ret = lttng_syscalls_unregister(chan);
WARN_ON(ret);
list_for_each_entry(chan, &session->chan, list) {
ret = lttng_syscalls_unregister(chan);
WARN_ON(ret);
@@
-210,7
+218,7
@@
void lttng_session_destroy(struct lttng_session *session)
kref_put(&session->metadata_cache->refcount, metadata_cache_destroy);
list_del(&session->list);
mutex_unlock(&sessions_mutex);
kref_put(&session->metadata_cache->refcount, metadata_cache_destroy);
list_del(&session->list);
mutex_unlock(&sessions_mutex);
-
k
free(session);
+
lttng_kv
free(session);
}
int lttng_session_statedump(struct lttng_session *session)
}
int lttng_session_statedump(struct lttng_session *session)
@@
-259,16
+267,16
@@
int lttng_session_enable(struct lttng_session *session)
lib_ring_buffer_clear_quiescent_channel(chan->chan);
}
lib_ring_buffer_clear_quiescent_channel(chan->chan);
}
-
ACCESS_ONCE(session->active) = 1
;
-
ACCESS_ONCE(session->been_active) = 1
;
+
WRITE_ONCE(session->active, 1)
;
+
WRITE_ONCE(session->been_active, 1)
;
ret = _lttng_session_metadata_statedump(session);
if (ret) {
ret = _lttng_session_metadata_statedump(session);
if (ret) {
-
ACCESS_ONCE(session->active) = 0
;
+
WRITE_ONCE(session->active, 0)
;
goto end;
}
ret = lttng_statedump_start(session);
if (ret)
goto end;
}
ret = lttng_statedump_start(session);
if (ret)
-
ACCESS_ONCE(session->active) = 0
;
+
WRITE_ONCE(session->active, 0)
;
end:
mutex_unlock(&sessions_mutex);
return ret;
end:
mutex_unlock(&sessions_mutex);
return ret;
@@
-284,7
+292,7
@@
int lttng_session_disable(struct lttng_session *session)
ret = -EBUSY;
goto end;
}
ret = -EBUSY;
goto end;
}
-
ACCESS_ONCE(session->active) = 0
;
+
WRITE_ONCE(session->active, 0)
;
/* Set transient enabler state to "disabled" */
session->tstate = 0;
/* Set transient enabler state to "disabled" */
session->tstate = 0;
@@
-359,7
+367,7
@@
int lttng_channel_enable(struct lttng_channel *channel)
channel->tstate = 1;
lttng_session_sync_enablers(channel->session);
/* Set atomically the state to "enabled" */
channel->tstate = 1;
lttng_session_sync_enablers(channel->session);
/* Set atomically the state to "enabled" */
-
ACCESS_ONCE(channel->enabled) = 1
;
+
WRITE_ONCE(channel->enabled, 1)
;
end:
mutex_unlock(&sessions_mutex);
return ret;
end:
mutex_unlock(&sessions_mutex);
return ret;
@@
-379,7
+387,7
@@
int lttng_channel_disable(struct lttng_channel *channel)
goto end;
}
/* Set atomically the state to "disabled" */
goto end;
}
/* Set atomically the state to "disabled" */
-
ACCESS_ONCE(channel->enabled) = 0
;
+
WRITE_ONCE(channel->enabled, 0)
;
/* Set transient enabler state to "enabled" */
channel->tstate = 0;
lttng_session_sync_enablers(channel->session);
/* Set transient enabler state to "enabled" */
channel->tstate = 0;
lttng_session_sync_enablers(channel->session);
@@
-409,7
+417,7
@@
int lttng_event_enable(struct lttng_event *event)
case LTTNG_KERNEL_KPROBE:
case LTTNG_KERNEL_FUNCTION:
case LTTNG_KERNEL_NOOP:
case LTTNG_KERNEL_KPROBE:
case LTTNG_KERNEL_FUNCTION:
case LTTNG_KERNEL_NOOP:
-
ACCESS_ONCE(event->enabled) = 1
;
+
WRITE_ONCE(event->enabled, 1)
;
break;
case LTTNG_KERNEL_KRETPROBE:
ret = lttng_kretprobes_event_enable_state(event, 1);
break;
case LTTNG_KERNEL_KRETPROBE:
ret = lttng_kretprobes_event_enable_state(event, 1);
@@
-444,7
+452,7
@@
int lttng_event_disable(struct lttng_event *event)
case LTTNG_KERNEL_KPROBE:
case LTTNG_KERNEL_FUNCTION:
case LTTNG_KERNEL_NOOP:
case LTTNG_KERNEL_KPROBE:
case LTTNG_KERNEL_FUNCTION:
case LTTNG_KERNEL_NOOP:
-
ACCESS_ONCE(event->enabled) = 0
;
+
WRITE_ONCE(event->enabled, 0)
;
break;
case LTTNG_KERNEL_KRETPROBE:
ret = lttng_kretprobes_event_enable_state(event, 0);
break;
case LTTNG_KERNEL_KRETPROBE:
ret = lttng_kretprobes_event_enable_state(event, 0);
@@
-1115,8
+1123,8
@@
int lttng_session_list_tracker_pids(struct lttng_session *session)
ret = PTR_ERR(tracker_pids_list_file);
goto file_error;
}
ret = PTR_ERR(tracker_pids_list_file);
goto file_error;
}
- if (
atomic_long_add_unless(&session->file->f_count,
- 1, INT_MAX) == INT_MAX) {
+ if (
!atomic_long_add_unless(&session->file->f_count, 1, LONG_MAX)) {
+ ret = -EOVERFLOW;
goto refcount_error;
}
ret = lttng_tracker_pids_list_fops.open(NULL, tracker_pids_list_file);
goto refcount_error;
}
ret = lttng_tracker_pids_list_fops.open(NULL, tracker_pids_list_file);
@@
-1142,11
+1150,11
@@
fd_error:
* Enabler management.
*/
static
* Enabler management.
*/
static
-int lttng_match_enabler_
wildcard
(const char *desc_name,
- const char *
name
)
+int lttng_match_enabler_
star_glob
(const char *desc_name,
+ const char *
pattern
)
{
{
- /* Compare excluding final '*' */
-
if (strncmp(desc_name, name, strlen(name) - 1
))
+ if (!strutils_star_glob_match(pattern, LTTNG_SIZE_MAX,
+
desc_name, LTTNG_SIZE_MAX
))
return 0;
return 1;
}
return 0;
return 1;
}
@@
-1191,8
+1199,8
@@
int lttng_desc_match_enabler(const struct lttng_event_desc *desc,
return -EINVAL;
}
switch (enabler->type) {
return -EINVAL;
}
switch (enabler->type) {
- case LTTNG_ENABLER_
WILDCARD
:
- return lttng_match_enabler_
wildcard
(desc_name, enabler_name);
+ case LTTNG_ENABLER_
STAR_GLOB
:
+ return lttng_match_enabler_
star_glob
(desc_name, enabler_name);
case LTTNG_ENABLER_NAME:
return lttng_match_enabler_name(desc_name, enabler_name);
default:
case LTTNG_ENABLER_NAME:
return lttng_match_enabler_name(desc_name, enabler_name);
default:
@@
-1515,7
+1523,7
@@
void lttng_session_sync_enablers(struct lttng_session *session)
*/
enabled = enabled && session->tstate && event->chan->tstate;
*/
enabled = enabled && session->tstate && event->chan->tstate;
-
ACCESS_ONCE(event->enabled) = enabled
;
+
WRITE_ONCE(event->enabled, enabled)
;
/*
* Sync tracepoint registration with event enabled
* state.
/*
* Sync tracepoint registration with event enabled
* state.
@@
-1641,7
+1649,7
@@
int lttng_metadata_printf(struct lttng_session *session,
va_list ap;
struct lttng_metadata_stream *stream;
va_list ap;
struct lttng_metadata_stream *stream;
- WARN_ON_ONCE(!
ACCESS
_ONCE(session->active));
+ WARN_ON_ONCE(!
READ
_ONCE(session->active));
va_start(ap, fmt);
str = kvasprintf(GFP_KERNEL, fmt, ap);
va_start(ap, fmt);
str = kvasprintf(GFP_KERNEL, fmt, ap);
@@
-2228,7
+2236,7
@@
int _lttng_event_metadata_statedump(struct lttng_session *session,
{
int ret = 0;
{
int ret = 0;
- if (event->metadata_dumped || !
ACCESS
_ONCE(session->active))
+ if (event->metadata_dumped || !
READ
_ONCE(session->active))
return 0;
if (chan->channel_type == METADATA_CHANNEL)
return 0;
return 0;
if (chan->channel_type == METADATA_CHANNEL)
return 0;
@@
-2295,7
+2303,7
@@
int _lttng_channel_metadata_statedump(struct lttng_session *session,
{
int ret = 0;
{
int ret = 0;
- if (chan->metadata_dumped || !
ACCESS
_ONCE(session->active))
+ if (chan->metadata_dumped || !
READ
_ONCE(session->active))
return 0;
if (chan->channel_type == METADATA_CHANNEL)
return 0;
if (chan->channel_type == METADATA_CHANNEL)
@@
-2408,6
+2416,9
@@
int _lttng_event_header_declare(struct lttng_session *session)
* in future versions.
* This function may return a negative offset. It may happen if the
* system sets the REALTIME clock to 0 after boot.
* in future versions.
* This function may return a negative offset. It may happen if the
* system sets the REALTIME clock to 0 after boot.
+ *
+ * Use 64bit timespec on kernels that have it, this makes 32bit arch
+ * y2038 compliant.
*/
static
int64_t measure_clock_offset(void)
*/
static
int64_t measure_clock_offset(void)
@@
-2415,13
+2426,21
@@
int64_t measure_clock_offset(void)
uint64_t monotonic_avg, monotonic[2], realtime;
uint64_t tcf = trace_clock_freq();
int64_t offset;
uint64_t monotonic_avg, monotonic[2], realtime;
uint64_t tcf = trace_clock_freq();
int64_t offset;
- struct timespec rts = { 0, 0 };
unsigned long flags;
unsigned long flags;
+#ifdef LTTNG_KERNEL_HAS_TIMESPEC64
+ struct timespec64 rts = { 0, 0 };
+#else
+ struct timespec rts = { 0, 0 };
+#endif
/* Disable interrupts to increase correlation precision. */
local_irq_save(flags);
monotonic[0] = trace_clock_read64();
/* Disable interrupts to increase correlation precision. */
local_irq_save(flags);
monotonic[0] = trace_clock_read64();
+#ifdef LTTNG_KERNEL_HAS_TIMESPEC64
+ ktime_get_real_ts64(&rts);
+#else
getnstimeofday(&rts);
getnstimeofday(&rts);
+#endif
monotonic[1] = trace_clock_read64();
local_irq_restore(flags);
monotonic[1] = trace_clock_read64();
local_irq_restore(flags);
@@
-2452,7
+2471,7
@@
int _lttng_session_metadata_statedump(struct lttng_session *session)
struct lttng_event *event;
int ret = 0;
struct lttng_event *event;
int ret = 0;
- if (!
ACCESS
_ONCE(session->active))
+ if (!
READ
_ONCE(session->active))
return 0;
if (session->metadata_dumped)
goto skip_session;
return 0;
if (session->metadata_dumped)
goto skip_session;
@@
-2644,7
+2663,7
@@
void lttng_transport_unregister(struct lttng_transport *transport)
}
EXPORT_SYMBOL_GPL(lttng_transport_unregister);
}
EXPORT_SYMBOL_GPL(lttng_transport_unregister);
-#if (
defined(CONFIG_HOTPLUG_CPU) && (LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
))
+#if (
LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0
))
enum cpuhp_state lttng_hp_prepare;
enum cpuhp_state lttng_hp_online;
enum cpuhp_state lttng_hp_prepare;
enum cpuhp_state lttng_hp_online;
@@
-2760,7
+2779,7
@@
static void __exit lttng_exit_cpu_hotplug(void)
cpuhp_remove_multi_state(lttng_hp_prepare);
}
cpuhp_remove_multi_state(lttng_hp_prepare);
}
-#else /* #if (
CONFIG_HOTPLUG_CPU && (LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
)) */
+#else /* #if (
LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0
)) */
static int lttng_init_cpu_hotplug(void)
{
return 0;
static int lttng_init_cpu_hotplug(void)
{
return 0;
@@
-2768,7
+2787,7
@@
static int lttng_init_cpu_hotplug(void)
static void lttng_exit_cpu_hotplug(void)
{
}
static void lttng_exit_cpu_hotplug(void)
{
}
-#endif /* #else #if (
CONFIG_HOTPLUG_CPU && (LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
)) */
+#endif /* #else #if (
LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0
)) */
static int __init lttng_events_init(void)
static int __init lttng_events_init(void)
@@
-2807,12
+2826,22
@@
static int __init lttng_events_init(void)
ret = lttng_init_cpu_hotplug();
if (ret)
goto error_hotplug;
ret = lttng_init_cpu_hotplug();
if (ret)
goto error_hotplug;
- printk(KERN_NOTICE "LTTng: Loaded modules v%s.%s.%s%s (%s)\n",
+ printk(KERN_NOTICE "LTTng: Loaded modules v%s.%s.%s%s (%s)
%s%s
\n",
__stringify(LTTNG_MODULES_MAJOR_VERSION),
__stringify(LTTNG_MODULES_MINOR_VERSION),
__stringify(LTTNG_MODULES_PATCHLEVEL_VERSION),
LTTNG_MODULES_EXTRAVERSION,
__stringify(LTTNG_MODULES_MAJOR_VERSION),
__stringify(LTTNG_MODULES_MINOR_VERSION),
__stringify(LTTNG_MODULES_PATCHLEVEL_VERSION),
LTTNG_MODULES_EXTRAVERSION,
- LTTNG_VERSION_NAME);
+ LTTNG_VERSION_NAME,
+#ifdef LTTNG_EXTRA_VERSION_GIT
+ LTTNG_EXTRA_VERSION_GIT[0] == '\0' ? "" : " - " LTTNG_EXTRA_VERSION_GIT,
+#else
+ "",
+#endif
+#ifdef LTTNG_EXTRA_VERSION_NAME
+ LTTNG_EXTRA_VERSION_NAME[0] == '\0' ? "" : " - " LTTNG_EXTRA_VERSION_NAME);
+#else
+ "");
+#endif
return 0;
error_hotplug:
return 0;
error_hotplug:
@@
-2825,12
+2854,22
@@
error_kmem:
lttng_tracepoint_exit();
error_tp:
lttng_context_exit();
lttng_tracepoint_exit();
error_tp:
lttng_context_exit();
- printk(KERN_NOTICE "LTTng: Failed to load modules v%s.%s.%s%s (%s)\n",
+ printk(KERN_NOTICE "LTTng: Failed to load modules v%s.%s.%s%s (%s)
%s%s
\n",
__stringify(LTTNG_MODULES_MAJOR_VERSION),
__stringify(LTTNG_MODULES_MINOR_VERSION),
__stringify(LTTNG_MODULES_PATCHLEVEL_VERSION),
LTTNG_MODULES_EXTRAVERSION,
__stringify(LTTNG_MODULES_MAJOR_VERSION),
__stringify(LTTNG_MODULES_MINOR_VERSION),
__stringify(LTTNG_MODULES_PATCHLEVEL_VERSION),
LTTNG_MODULES_EXTRAVERSION,
- LTTNG_VERSION_NAME);
+ LTTNG_VERSION_NAME,
+#ifdef LTTNG_EXTRA_VERSION_GIT
+ LTTNG_EXTRA_VERSION_GIT[0] == '\0' ? "" : " - " LTTNG_EXTRA_VERSION_GIT,
+#else
+ "",
+#endif
+#ifdef LTTNG_EXTRA_VERSION_NAME
+ LTTNG_EXTRA_VERSION_NAME[0] == '\0' ? "" : " - " LTTNG_EXTRA_VERSION_NAME);
+#else
+ "");
+#endif
return ret;
}
return ret;
}
@@
-2848,16
+2887,33
@@
static void __exit lttng_events_exit(void)
kmem_cache_destroy(event_cache);
lttng_tracepoint_exit();
lttng_context_exit();
kmem_cache_destroy(event_cache);
lttng_tracepoint_exit();
lttng_context_exit();
- printk(KERN_NOTICE "LTTng: Unloaded modules v%s.%s.%s%s (%s)\n",
+ printk(KERN_NOTICE "LTTng: Unloaded modules v%s.%s.%s%s (%s)
%s%s
\n",
__stringify(LTTNG_MODULES_MAJOR_VERSION),
__stringify(LTTNG_MODULES_MINOR_VERSION),
__stringify(LTTNG_MODULES_PATCHLEVEL_VERSION),
LTTNG_MODULES_EXTRAVERSION,
__stringify(LTTNG_MODULES_MAJOR_VERSION),
__stringify(LTTNG_MODULES_MINOR_VERSION),
__stringify(LTTNG_MODULES_PATCHLEVEL_VERSION),
LTTNG_MODULES_EXTRAVERSION,
- LTTNG_VERSION_NAME);
+ LTTNG_VERSION_NAME,
+#ifdef LTTNG_EXTRA_VERSION_GIT
+ LTTNG_EXTRA_VERSION_GIT[0] == '\0' ? "" : " - " LTTNG_EXTRA_VERSION_GIT,
+#else
+ "",
+#endif
+#ifdef LTTNG_EXTRA_VERSION_NAME
+ LTTNG_EXTRA_VERSION_NAME[0] == '\0' ? "" : " - " LTTNG_EXTRA_VERSION_NAME);
+#else
+ "");
+#endif
}
module_exit(lttng_events_exit);
}
module_exit(lttng_events_exit);
+#include "extra_version/patches.i"
+#ifdef LTTNG_EXTRA_VERSION_GIT
+MODULE_INFO(extra_version_git, LTTNG_EXTRA_VERSION_GIT);
+#endif
+#ifdef LTTNG_EXTRA_VERSION_NAME
+MODULE_INFO(extra_version_name, LTTNG_EXTRA_VERSION_NAME);
+#endif
MODULE_LICENSE("GPL and additional rights");
MODULE_AUTHOR("Mathieu Desnoyers <mathieu.desnoyers@efficios.com>");
MODULE_DESCRIPTION("LTTng Events");
MODULE_LICENSE("GPL and additional rights");
MODULE_AUTHOR("Mathieu Desnoyers <mathieu.desnoyers@efficios.com>");
MODULE_DESCRIPTION("LTTng Events");
This page took
0.028501 seconds
and
4
git commands to generate.