[ltt-dev] [PATCH v5 2/5] Add support for set each channel's overwrite mode

Zhaolei zhaolei at cn.fujitsu.com
Thu Nov 13 21:24:02 EST 2008


Now we can set one "overwrite" per channel.
It is a superset of "mode" concept, so concept of "mode" is removed.

Signed-off-by: Zhao Lei <zhaolei at cn.fujitsu.com>
---
 include/linux/ltt-tracer.h |    5 +-
 ltt/ltt-tracer.c           |  100 ++++++++++++++++++++++++++++++++------------
 2 files changed, 76 insertions(+), 29 deletions(-)

diff --git a/include/linux/ltt-tracer.h b/include/linux/ltt-tracer.h
index c4ac07c..9ae8a35 100644
--- 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;
@@ -251,7 +252,6 @@ struct ltt_trace_struct {
 		struct dentry			*control_root;
 	} dentry;
 	struct rchan_callbacks callbacks;
-	enum trace_mode mode;
 	struct kref kref; /* Each channel has a kref of the trace struct */
 	struct ltt_transport *transport;
 	struct kref ltt_transport_kref;
@@ -698,11 +698,12 @@ union ltt_control_args {
 
 int ltt_trace_setup(const char *trace_name);
 int ltt_trace_set_type(const char *trace_name, const char *trace_type);
-int ltt_trace_set_mode(const char *trace_name, enum trace_mode mode);
 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
index b419329..6990c9b 100644
--- a/ltt/ltt-tracer.c
+++ b/ltt/ltt-tracer.c
@@ -411,28 +411,6 @@ traces_error:
 }
 EXPORT_SYMBOL_GPL(ltt_trace_set_type);
 
-int ltt_trace_set_mode(const char *trace_name, enum trace_mode mode)
-{
-	int err = 0;
-	struct ltt_trace_struct *trace;
-
-	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;
-	}
-
-	trace->mode = mode;
-
-traces_error:
-	ltt_unlock_traces();
-	return err;
-}
-EXPORT_SYMBOL_GPL(ltt_trace_set_mode);
-
 /*
  * Todo:
  * Make similar function in channel.c,
@@ -560,6 +538,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;
+
+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 +649,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);
@@ -692,10 +707,6 @@ static int ltt_trace_create(const char *trace_name, const char *trace_type,
 	if (IS_ERR_VALUE(err))
 		return err;
 
-	err = ltt_trace_set_mode(trace_name, mode);
-	if (IS_ERR_VALUE(err))
-		return err;
-
 	err = ltt_trace_set_channel_subbufsize(trace_name,
 		LTT_METADATA_CHANNEL, subbuf_size_low);
 	if (IS_ERR_VALUE(err))
@@ -706,6 +717,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 +733,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 +749,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 +765,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 +781,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 +797,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