[ltt-dev] [PATCH v3 3/4] Add get_ltt_root() to get dentry of ltt's root dir

Mathieu Desnoyers compudj at krystal.dyndns.org
Wed Nov 12 12:38:19 EST 2008


* Zhaolei (zhaolei at cn.fujitsu.com) wrote:
> get_ltt_root() is necessary for ltt-trace-control to create subdirs in ltt's
> debugfs dir.
> 
> Todo:
>   Make ltt-relay and ltt-relay-locked to create their dir in ltt's root dir as:
>   debugfs/ltt/relay and debugfs/ltt/relay-locked
> 

Maybe it's not that important to do the distinction between relay and
relay-locked using subdirectories. It will just confuse users.

The only thing I care about is that if a user creates a trace backed
with "relay" and then another trace with the same name, but backed with
"relay-locked", it does not crash the kernel and return the appropriate
error message. I think it will all work fine as-is now.

Maybe you could just remove the "todo" comments in this patch ?

Thanks,

Mathieu


> Signed-off-by: Zhao Lei <zhaolei at cn.fujitsu.com>
> ---
>  include/linux/ltt-core.h |    8 ++++++++
>  ltt/ltt-core.c           |   14 ++++++++++++++
>  ltt/ltt-relay-locked.c   |    6 +++++-
>  ltt/ltt-relay.c          |   13 ++++++-------
>  4 files changed, 33 insertions(+), 8 deletions(-)
> 
> diff --git a/include/linux/ltt-core.h b/include/linux/ltt-core.h
> index 7e5ee8b..076c3ed 100644
> --- a/include/linux/ltt-core.h
> +++ b/include/linux/ltt-core.h
> @@ -10,6 +10,9 @@
>  #include <linux/list.h>
>  #include <linux/percpu.h>
>  
> +/* ltt's root dir in debugfs */
> +#define LTT_ROOT        "ltt"
> +
>  /*
>   * All modifications of ltt_traces must be done by ltt-tracer.c, while holding
>   * the semaphore. Only reading of this information can be done elsewhere, with
> @@ -24,6 +27,11 @@ struct ltt_traces {
>  
>  extern struct ltt_traces ltt_traces;
>  
> +/*
> + * get dentry of ltt's root dir
> + */
> +struct dentry *get_ltt_root(void);
> +
>  /* Keep track of trap nesting inside LTT */
>  DECLARE_PER_CPU(unsigned int, ltt_nesting);
>  
> diff --git a/ltt/ltt-core.c b/ltt/ltt-core.c
> index aaad358..0ed1d06 100644
> --- a/ltt/ltt-core.c
> +++ b/ltt/ltt-core.c
> @@ -9,6 +9,7 @@
>  #include <linux/ltt-core.h>
>  #include <linux/percpu.h>
>  #include <linux/module.h>
> +#include <linux/debugfs.h>
>  
>  /* Traces structures */
>  struct ltt_traces ltt_traces = {
> @@ -20,6 +21,19 @@ EXPORT_SYMBOL(ltt_traces);
>  /* Traces list writer locking */
>  static DEFINE_MUTEX(ltt_traces_mutex);
>  
> +/* dentry of ltt's root dir */
> +static struct dentry *ltt_root_dentry;
> +struct dentry *get_ltt_root(void)
> +{
> +	if (!ltt_root_dentry) {
> +		ltt_root_dentry = debugfs_create_dir(LTT_ROOT, NULL);
> +		if (!ltt_root_dentry)
> +			printk(KERN_ERR "LTT : ctrate ltt root dir failed\n");
> +	}
> +	return ltt_root_dentry;
> +}
> +EXPORT_SYMBOL_GPL(get_ltt_root);
> +
>  void ltt_lock_traces(void)
>  {
>  	mutex_lock(&ltt_traces_mutex);
> diff --git a/ltt/ltt-relay-locked.c b/ltt/ltt-relay-locked.c
> index c40bdb2..3f01620 100644
> --- a/ltt/ltt-relay-locked.c
> +++ b/ltt/ltt-relay-locked.c
> @@ -122,7 +122,7 @@ static inline int last_tsc_overflow(struct ltt_channel_buf_struct *ltt_buf,
>  }
>  #endif
>  
> -static struct dentry *ltt_root_dentry;
> +static struct dentry *ltt_root_dentry
>  static struct file_operations ltt_file_operations;
>  
>  /*
> @@ -1594,6 +1594,10 @@ static int __init ltt_relay_init(void)
>  	ltt_root_dentry = debugfs_create_dir(LTT_RELAY_LOCKED_ROOT, NULL);
>  	if (ltt_root_dentry == NULL)
>  		return -EEXIST;
> +	/*
> +	 * Todo: create ltt-relay-locked's root dir in ltt's root dir as:
> +	 *   debugfs/ltt/relay-locked
> +	 */
>  
>  	ltt_file_operations = ltt_relay_file_operations;
>  	ltt_file_operations.owner = THIS_MODULE;
> diff --git a/ltt/ltt-relay.c b/ltt/ltt-relay.c
> index c6e1d52..9a727d8 100644
> --- a/ltt/ltt-relay.c
> +++ b/ltt/ltt-relay.c
> @@ -131,7 +131,6 @@ static inline int last_tsc_overflow(struct ltt_channel_buf_struct *ltt_buf,
>  }
>  #endif
>  
> -static struct dentry *ltt_root_dentry;
>  static struct file_operations ltt_file_operations;
>  
>  /*
> @@ -803,7 +802,7 @@ end:
>  static int ltt_relay_create_dirs(struct ltt_trace_struct *new_trace)
>  {
>  	new_trace->dentry.trace_root = debugfs_create_dir(new_trace->trace_name,
> -			ltt_root_dentry);
> +			get_ltt_root());
>  	if (new_trace->dentry.trace_root == NULL) {
>  		printk(KERN_ERR "LTT : Trace directory name %s already taken\n",
>  				new_trace->trace_name);
> @@ -1614,9 +1613,11 @@ static struct ltt_transport ltt_relay_transport = {
>  static int __init ltt_relay_init(void)
>  {
>  	printk(KERN_INFO "LTT : ltt-relay init\n");
> -	ltt_root_dentry = debugfs_create_dir(LTT_RELAY_ROOT, NULL);
> -	if (ltt_root_dentry == NULL)
> -		return -EEXIST;
> +
> +	/*
> +	 * Todo: create ltt-relay's root dir in ltt's root dir as:
> +	 *   debugfs/ltt/relay
> +	 */
>  
>  	ltt_file_operations = ltt_relay_file_operations;
>  	ltt_file_operations.owner = THIS_MODULE;
> @@ -1637,8 +1638,6 @@ static void __exit ltt_relay_exit(void)
>  	printk(KERN_INFO "LTT : ltt-relay exit\n");
>  
>  	ltt_transport_unregister(&ltt_relay_transport);
> -
> -	debugfs_remove(ltt_root_dentry);
>  }
>  
>  module_init(ltt_relay_init);
> -- 
> 1.5.5.3
> 
> 
> 
> 
> _______________________________________________
> 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