Commit ccc7340a authored by Mathieu Desnoyers's avatar Mathieu Desnoyers Committed by Greg Kroah-Hartman

lttng: tracer control and core structures

Signed-off-by: default avatarMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 68577971
#ifndef _LTT_ENDIAN_H
#define _LTT_ENDIAN_H
/*
* ltt-endian.h
*
* Copyright 2010 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*
* Dual LGPL v2.1/GPL v2 license.
*/
#ifdef __KERNEL__
# include <asm/byteorder.h>
# ifdef __BIG_ENDIAN
# define __BYTE_ORDER __BIG_ENDIAN
# elif defined(__LITTLE_ENDIAN)
# define __BYTE_ORDER __LITTLE_ENDIAN
# else
# error "unknown endianness"
# endif
#ifndef __BIG_ENDIAN
# define __BIG_ENDIAN 4321
#endif
#ifndef __LITTLE_ENDIAN
# define __LITTLE_ENDIAN 1234
#endif
#else
# include <endian.h>
#endif
#endif /* _LTT_ENDIAN_H */
This diff is collapsed.
This diff is collapsed.
/*
* ltt-probes.c
*
* Copyright 2010 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*
* Holds LTTng probes registry.
*
* Dual LGPL v2.1/GPL v2 license.
*/
#include <linux/module.h>
#include <linux/list.h>
#include <linux/mutex.h>
#include <linux/seq_file.h>
#include "ltt-events.h"
static LIST_HEAD(probe_list);
static DEFINE_MUTEX(probe_mutex);
static
const struct lttng_event_desc *find_event(const char *name)
{
struct lttng_probe_desc *probe_desc;
int i;
list_for_each_entry(probe_desc, &probe_list, head) {
for (i = 0; i < probe_desc->nr_events; i++) {
if (!strcmp(probe_desc->event_desc[i]->name, name))
return probe_desc->event_desc[i];
}
}
return NULL;
}
int ltt_probe_register(struct lttng_probe_desc *desc)
{
int ret = 0;
int i;
mutex_lock(&probe_mutex);
/*
* TODO: This is O(N^2). Turn into a hash table when probe registration
* overhead becomes an issue.
*/
for (i = 0; i < desc->nr_events; i++) {
if (find_event(desc->event_desc[i]->name)) {
ret = -EEXIST;
goto end;
}
}
list_add(&desc->head, &probe_list);
end:
mutex_unlock(&probe_mutex);
return ret;
}
EXPORT_SYMBOL_GPL(ltt_probe_register);
void ltt_probe_unregister(struct lttng_probe_desc *desc)
{
mutex_lock(&probe_mutex);
list_del(&desc->head);
mutex_unlock(&probe_mutex);
}
EXPORT_SYMBOL_GPL(ltt_probe_unregister);
const struct lttng_event_desc *ltt_event_get(const char *name)
{
const struct lttng_event_desc *event;
int ret;
mutex_lock(&probe_mutex);
event = find_event(name);
mutex_unlock(&probe_mutex);
if (!event)
return NULL;
ret = try_module_get(event->owner);
WARN_ON_ONCE(!ret);
return event;
}
EXPORT_SYMBOL_GPL(ltt_event_get);
void ltt_event_put(const struct lttng_event_desc *event)
{
module_put(event->owner);
}
EXPORT_SYMBOL_GPL(ltt_event_put);
static
void *tp_list_start(struct seq_file *m, loff_t *pos)
{
struct lttng_probe_desc *probe_desc;
int iter = 0, i;
mutex_lock(&probe_mutex);
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];
}
}
/* End of list */
return NULL;
}
static
void *tp_list_next(struct seq_file *m, void *p, loff_t *ppos)
{
struct lttng_probe_desc *probe_desc;
int iter = 0, i;
(*ppos)++;
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];
}
}
/* End of list */
return NULL;
}
static
void tp_list_stop(struct seq_file *m, void *p)
{
mutex_unlock(&probe_mutex);
}
static
int tp_list_show(struct seq_file *m, void *p)
{
const struct lttng_event_desc *probe_desc = p;
/*
* Don't export lttng internal events (metadata).
*/
if (!strncmp(probe_desc->name, "lttng_", sizeof("lttng_") - 1))
return 0;
seq_printf(m, "event { name = %s; };\n",
probe_desc->name);
return 0;
}
static
const struct seq_operations lttng_tracepoint_list_seq_ops = {
.start = tp_list_start,
.next = tp_list_next,
.stop = tp_list_stop,
.show = tp_list_show,
};
static
int lttng_tracepoint_list_open(struct inode *inode, struct file *file)
{
return seq_open(file, &lttng_tracepoint_list_seq_ops);
}
const struct file_operations lttng_tracepoint_list_fops = {
.owner = THIS_MODULE,
.open = lttng_tracepoint_list_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};
#ifndef LTT_TRACER_CORE_H
#define LTT_TRACER_CORE_H
/*
* ltt-tracer-core.h
*
* Copyright (C) 2005-2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*
* This contains the core definitions for the Linux Trace Toolkit.
*
* Dual LGPL v2.1/GPL v2 license.
*/
#include <linux/list.h>
#include <linux/percpu.h>
#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
/* Align data on its natural alignment */
#define RING_BUFFER_ALIGN
#endif
#include "wrapper/ringbuffer/config.h"
struct ltt_session;
struct ltt_channel;
struct ltt_event;
#endif /* LTT_TRACER_CORE_H */
#ifndef _LTT_TRACER_H
#define _LTT_TRACER_H
/*
* ltt-tracer.h
*
* Copyright (C) 2005-2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*
* This contains the definitions for the Linux Trace Toolkit tracer.
*
* Dual LGPL v2.1/GPL v2 license.
*/
#include <stdarg.h>
#include <linux/types.h>
#include <linux/limits.h>
#include <linux/list.h>
#include <linux/cache.h>
#include <linux/timex.h>
#include <linux/wait.h>
#include <asm/atomic.h>
#include <asm/local.h>
#include "wrapper/trace-clock.h"
#include "ltt-tracer-core.h"
#include "ltt-events.h"
#define LTTNG_VERSION 0
#define LTTNG_PATCHLEVEL 9
#define LTTNG_SUBLEVEL 1
#ifndef CHAR_BIT
#define CHAR_BIT 8
#endif
/* Number of bytes to log with a read/write event */
#define LTT_LOG_RW_SIZE 32L
#define LTT_MAX_SMALL_SIZE 0xFFFFU
#ifdef RING_BUFFER_ALIGN
#define ltt_alignof(type) __alignof__(type)
#else
#define ltt_alignof(type) 1
#endif
/* Tracer properties */
#define CTF_MAGIC_NUMBER 0xC1FC1FC1
#define TSDL_MAGIC_NUMBER 0x75D11D57
/* CTF specification version followed */
#define CTF_SPEC_MAJOR 1
#define CTF_SPEC_MINOR 8
/* Tracer major/minor versions */
#define CTF_VERSION_MAJOR 0
#define CTF_VERSION_MINOR 1
/*
* Number of milliseconds to retry before failing metadata writes on buffer full
* condition. (10 seconds)
*/
#define LTTNG_METADATA_TIMEOUT_MSEC 10000
#define LTT_RFLAG_EXTENDED RING_BUFFER_RFLAG_END
#define LTT_RFLAG_END (LTT_RFLAG_EXTENDED << 1)
#endif /* _LTT_TRACER_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment