[ltt-dev] [PATCH take2 10/13] implement text output framework

Mathieu Desnoyers compudj at krystal.dyndns.org
Mon Feb 23 14:22:04 EST 2009


* Lai Jiangshan (laijs at cn.fujitsu.com) wrote:
> introduce simple framework for text output for lttng.
> 
> Signed-off-by: Lai Jiangshan <laijs at cn.fujitsu.com>
> ---
> diff --git a/include/linux/ltt-channels.h b/include/linux/ltt-channels.h
> index 4a3924b..db513cb 100644
> --- a/include/linux/ltt-channels.h
> +++ b/include/linux/ltt-channels.h
> @@ -10,6 +10,7 @@
>  #include <linux/limits.h>
>  #include <linux/kref.h>
>  #include <linux/list.h>
> +#include <linux/fs.h>
>  
>  #define EVENTS_PER_CHANNEL	65536
>  
> @@ -21,6 +22,7 @@ struct ltt_channel_struct {
>  	struct ltt_trace_struct	*trace;
>  	void *buf;
>  	void *trans_channel_data;
> +	atomic_t channel_disabled;

Hrm, let's go back on this one, I'm definitely not convinced it's
required nor good to have. If you want to do it properly, you should
wait until someone has issued a trace stop (putting the channed in
active = 0 state) if you ever need to ensure nobody is writing to it
while you read.

But... why do you need this at all anyway ? The correct way to do it is
to support reading from buffers _even_ when they are written to. This is
done by ltt-relay ltt_open/ltt_close/ltt_poll/ltt_ioctl. Please abstract
these so the get/put and other operations can be done through an
internal kernel API used both by the bin-to-text converter and the
modified open/close/ioctl/poll functions.

Mathieu

>  	int overwrite:1;
>  	int active:1;
>  	unsigned int n_subbufs_order;
> @@ -45,6 +48,7 @@ struct ltt_channel_struct {
>  	void (*buffer_end) (struct rchan_buf *buf,
>  			u64 tsc, unsigned int offset, unsigned int subbuf_idx);
>  	struct kref kref;	/* Channel transport reference count */
> +	struct dentry *txt_entry;
>  	struct ltt_channel_buf_access_ops *buf_access_ops;
>  	unsigned int subbuf_size;
>  	unsigned int subbuf_cnt;
> diff --git a/include/linux/ltt-tracer.h b/include/linux/ltt-tracer.h
> index ece6819..b49cac2 100644
> --- a/include/linux/ltt-tracer.h
> +++ b/include/linux/ltt-tracer.h
> @@ -20,6 +20,7 @@
>  #include <linux/ltt-core.h>
>  #include <linux/marker.h>
>  #include <linux/trace-clock.h>
> +#include <linux/debugfs.h>
>  #include <asm/atomic.h>
>  #include <asm/local.h>
>  
> @@ -212,6 +216,7 @@ struct ltt_trace_struct {
>  	struct ltt_channel_setting *settings;
>  	struct {
>  		struct dentry			*trace_root;
> +		struct dentry			*txt_root;
>  	} dentry;
>  	struct rchan_callbacks callbacks;
>  	struct kref kref; /* Each channel has a kref of the trace struct */
> @@ -712,6 +786,49 @@ void ltt_unlock_traces(void);
>  
>  extern void ltt_dump_softirq_vec(void *call_data);
>  
> +#ifdef CONFIG_LTT_TEXT_OUTPUT
> +struct dentry *ltt_txt_create(struct ltt_trace_struct *trace,
> +		struct ltt_channel_struct *ltt_channel);
> +void ltt_txt_remove(struct ltt_channel_struct *ltt_channel, struct dentry *txt);
> +extern struct dentry *ltt_txt_dir_dentry;
> +
> +static inline int ltt_txt_create_dir(struct ltt_trace_struct *new_trace)
> +{
> +	new_trace->dentry.txt_root = debugfs_create_dir(new_trace->trace_name,
> +			ltt_txt_dir_dentry);
> +	if (!new_trace->dentry.txt_root)
> +		return -EEXIST;
> +	return 0;
> +}
> +
> +static inline void ltt_txt_remove_dir(struct ltt_trace_struct *trace)
> +{
> +	debugfs_remove(trace->dentry.txt_root);
> +}
> +
> +#else
> +static inline struct dentry *ltt_txt_create(struct ltt_trace_struct *trace,
> +		struct ltt_channel_struct *ltt_channel)
> +{
> +	return (struct dentry *)1;
> +}
> +
> +static inline
> +void ltt_txt_remove(struct ltt_channel_struct *ltt_channel, struct dentry *txt)
> +{
> +}
> +
> +static inline int ltt_txt_create_dir(struct ltt_trace_struct *trace)
> +{
> +	return 0;
> +}
> +
> +static inline void ltt_txt_remove_dir(struct ltt_trace_struct *trace)
> +{
> +}
> +
> +#endif
> +
>  #ifdef CONFIG_HAVE_LTT_DUMP_TABLES
>  extern void ltt_dump_sys_call_table(void *call_data);
>  extern void ltt_dump_idt_table(void *call_data);
> diff --git a/ltt/Kconfig b/ltt/Kconfig
> index 36548b5..91f2f05 100644
> --- a/ltt/Kconfig
> +++ b/ltt/Kconfig
> @@ -65,6 +65,9 @@ config LTT_RELAY_LOCKED
>  	  Support using the slow spinlock and interrupt disable algorithm to log
>  	  the data obtained through LTT.
>  
> +config LTT_TEXT_OUTPUT
> +	def_bool n
> +
>  config LTT_RELAY_CHECK_RANDOM_ACCESS
>  	bool "Debug check for random access in ltt relay buffers"
>  	depends on LTT_RELAY
> 
> 
> 
> _______________________________________________
> ltt-dev mailing list
> ltt-dev at lists.casi.polymtl.ca
> http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
> 

-- 
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68




More information about the lttng-dev mailing list