[ltt-dev] [PATCH v3 2/4] Add ltt_trace_set_channel_overwrite to support set each channel's overwrite mode
Zhaolei
zhaolei at cn.fujitsu.com
Tue Nov 11 03:59:18 EST 2008
Now we can set each channel's overwrite mode.
Signed-off-by: Zhao Lei <zhaolei at cn.fujitsu.com>
---
include/linux/ltt-tracer.h | 3 ++
ltt/ltt-tracer.c | 74 +++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 76 insertions(+), 1 deletions(-)
mode change 100644 => 100755 include/linux/ltt-tracer.h
mode change 100644 => 100755 ltt/ltt-tracer.c
diff --git a/include/linux/ltt-tracer.h b/include/linux/ltt-tracer.h
old mode 100644
new mode 100755
index c4ac07c..937371b
--- a/include/linux/ltt-tracer.h
+++ b/include/linux/ltt-tracer.h
@@ -239,6 +239,7 @@ struct ltt_trace_struct {
struct {
unsigned subbuf_size;
unsigned subbuf_cnt;
+ unsigned overwrite;
} channels[NR_LTT_CHANNELS];
} setting;
u32 freq_scale;
@@ -703,6 +704,8 @@ int ltt_trace_set_channel_subbufsize(const char *trace_name,
const char *channel_name, unsigned size);
int ltt_trace_set_channel_subbufcount(const char *trace_name,
const char *channel_name, unsigned cnt);
+int ltt_trace_set_channel_overwrite(const char *trace_name,
+ const char *channel_name, unsigned overwrite);
int ltt_trace_alloc(const char *trace_name);
int ltt_trace_destroy(const char *trace_name);
int ltt_trace_start(const char *trace_name);
diff --git a/ltt/ltt-tracer.c b/ltt/ltt-tracer.c
old mode 100644
new mode 100755
index b419329..f1b3e44
--- a/ltt/ltt-tracer.c
+++ b/ltt/ltt-tracer.c
@@ -560,6 +560,43 @@ traces_error:
}
EXPORT_SYMBOL_GPL(ltt_trace_set_channel_subbufcount);
+int ltt_trace_set_channel_overwrite(const char *trace_name,
+ const char *channel_name, unsigned overwrite)
+{
+ int err = 0;
+ struct ltt_trace_struct *trace;
+ enum ltt_channels channel;
+
+ ltt_lock_traces();
+
+ trace = _ltt_trace_find_setup(trace_name);
+ if (!trace) {
+ printk(KERN_ERR "LTT : Trace not found %s\n", trace_name);
+ err = -ENOENT;
+ goto traces_error;
+ }
+
+ channel = get_channel_type_from_name(channel_name);
+ if (channel == NR_LTT_CHANNELS) {
+ printk(KERN_ERR "LTT : Channel %s is not present.\n",
+ channel_name);
+ err = -EINVAL;
+ goto traces_error;
+ }
+
+ if (overwrite && channel == LTT_CHANNEL_METADATA) {
+ err = -EINVAL;
+ goto traces_error;
+ }
+
+ trace->setting.channels[channel].overwrite = overwrite ? 1 : 0;
+
+traces_error:
+ ltt_unlock_traces();
+ return err;
+}
+EXPORT_SYMBOL_GPL(ltt_trace_set_channel_overwrite);
+
int ltt_trace_alloc(const char *trace_name)
{
int err = 0;
@@ -634,7 +671,7 @@ int ltt_trace_alloc(const char *trace_name)
+ chan_infos[chan].channel_index),
subbuf_size,
subbuf_cnt,
- is_channel_overwrite(chan, trace->mode));
+ trace->setting.channels[chan].overwrite);
if (err != 0) {
printk(KERN_ERR "LTT : Can't create channel %s.\n",
chan_infos[chan].name);
@@ -706,6 +743,12 @@ static int ltt_trace_create(const char *trace_name, const char *trace_type,
if (IS_ERR_VALUE(err))
return err;
+ err = ltt_trace_set_channel_overwrite(trace_name,
+ LTT_METADATA_CHANNEL,
+ is_channel_overwrite(LTT_CHANNEL_METADATA, mode));
+ if (IS_ERR_VALUE(err))
+ return err;
+
err = ltt_trace_set_channel_subbufsize(trace_name,
LTT_INTERRUPTS_CHANNEL, subbuf_size_low);
if (IS_ERR_VALUE(err))
@@ -716,6 +759,12 @@ static int ltt_trace_create(const char *trace_name, const char *trace_type,
if (IS_ERR_VALUE(err))
return err;
+ err = ltt_trace_set_channel_overwrite(trace_name,
+ LTT_INTERRUPTS_CHANNEL,
+ is_channel_overwrite(LTT_CHANNEL_INTERRUPTS, mode));
+ if (IS_ERR_VALUE(err))
+ return err;
+
err = ltt_trace_set_channel_subbufsize(trace_name,
LTT_PROCESSES_CHANNEL, subbuf_size_med);
if (IS_ERR_VALUE(err))
@@ -726,6 +775,12 @@ static int ltt_trace_create(const char *trace_name, const char *trace_type,
if (IS_ERR_VALUE(err))
return err;
+ err = ltt_trace_set_channel_overwrite(trace_name,
+ LTT_PROCESSES_CHANNEL,
+ is_channel_overwrite(LTT_CHANNEL_PROCESSES, mode));
+ if (IS_ERR_VALUE(err))
+ return err;
+
err = ltt_trace_set_channel_subbufsize(trace_name, LTT_MODULES_CHANNEL,
subbuf_size_low);
if (IS_ERR_VALUE(err))
@@ -736,6 +791,12 @@ static int ltt_trace_create(const char *trace_name, const char *trace_type,
if (IS_ERR_VALUE(err))
return err;
+ err = ltt_trace_set_channel_overwrite(trace_name,
+ LTT_MODULES_CHANNEL,
+ is_channel_overwrite(LTT_CHANNEL_MODULES, mode));
+ if (IS_ERR_VALUE(err))
+ return err;
+
err = ltt_trace_set_channel_subbufsize(trace_name, LTT_NETWORK_CHANNEL,
subbuf_size_low);
if (IS_ERR_VALUE(err))
@@ -746,6 +807,12 @@ static int ltt_trace_create(const char *trace_name, const char *trace_type,
if (IS_ERR_VALUE(err))
return err;
+ err = ltt_trace_set_channel_overwrite(trace_name,
+ LTT_NETWORK_CHANNEL,
+ is_channel_overwrite(LTT_CHANNEL_NETWORK, mode));
+ if (IS_ERR_VALUE(err))
+ return err;
+
err = ltt_trace_set_channel_subbufsize(trace_name, LTT_CPU_CHANNEL,
subbuf_size_high);
if (IS_ERR_VALUE(err))
@@ -756,6 +823,11 @@ static int ltt_trace_create(const char *trace_name, const char *trace_type,
if (IS_ERR_VALUE(err))
return err;
+ err = ltt_trace_set_channel_overwrite(trace_name,
+ LTT_CPU_CHANNEL, is_channel_overwrite(LTT_CHANNEL_CPU, mode));
+ if (IS_ERR_VALUE(err))
+ return err;
+
err = ltt_trace_alloc(trace_name);
if (IS_ERR_VALUE(err))
return err;
--
1.5.5.3
More information about the lttng-dev
mailing list