Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1250116 > unrolled thread

[PATCH 0/3] Some tracing fixes.

Started byJiaxing Wang <hello.wjx@gmail.com>
First post2015-10-18 14:10 +0200
Last post2015-10-18 14:10 +0200
Articles 6 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/3] Some tracing fixes. Jiaxing Wang <hello.wjx@gmail.com> - 2015-10-18 14:10 +0200
    [PATCH 1/3] tracing: Update instance_rmdir() to use tracefs_remove_recursive. Jiaxing Wang <hello.wjx@gmail.com> - 2015-10-18 14:10 +0200
    [PATCH 2/3] tracing: Make tracing work when debugfs is not compiled or initialized. Jiaxing Wang <hello.wjx@gmail.com> - 2015-10-18 14:10 +0200
      Re: [PATCH 2/3] tracing: Make tracing work when debugfs is not  compiled or initialized. kbuild test robot <lkp@intel.com> - 2015-10-18 16:40 +0200
      Re: [PATCH 2/3] tracing: Make tracing work when debugfs is not  compiled or initialized. Jiaxing Wang <hello.wjx@gmail.com> - 2015-10-19 04:00 +0200
    [PATCH 3/3] tracing: Apply tracer specific options from kernel command line. Jiaxing Wang <hello.wjx@gmail.com> - 2015-10-18 14:10 +0200

#1250116 — [PATCH 0/3] Some tracing fixes.

FromJiaxing Wang <hello.wjx@gmail.com>
Date2015-10-18 14:10 +0200
Subject[PATCH 0/3] Some tracing fixes.
Message-ID<qkUWK-4JV-13@gated-at.bofh.it>
In short:
  The first patch update instance_rmdir() to use tracefs_remove_recursive.
  The second one make tracing work when debugfs is not initialized, currently
we get an empty directory after mounting tracefs manually.
  The third one makes it possible to specify tracer specific options from
kernel parameter, like the following:
  
  ftrace=function ftrace_filter=kfree trace_options=func_stack_trace

Jiaxing Wang (3):
  tracing: Update instance_rmdir() to use tracefs_remove_recursive.
  tracing: Make tracing work when debugfs is not compiled or
    initialized.
  tracing: Apply tracer specific options from kernel command line.

 kernel/trace/Kconfig |  1 -
 kernel/trace/trace.c | 72 +++++++++++++++++++++++++++++++++++++---------------
 2 files changed, 52 insertions(+), 21 deletions(-)

-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1250117 — [PATCH 1/3] tracing: Update instance_rmdir() to use tracefs_remove_recursive.

FromJiaxing Wang <hello.wjx@gmail.com>
Date2015-10-18 14:10 +0200
Subject[PATCH 1/3] tracing: Update instance_rmdir() to use tracefs_remove_recursive.
Message-ID<qkUWK-4JV-15@gated-at.bofh.it>
In reply to#1250116
Update instancd_rmdir to use tracefs_remove_recursive instead of
debugfs_remove_recursive.This was left in the transition from debugfs
to tracefs.

Signed-off-by: Jiaxing Wang <hello.wjx@gmail.com>
---
 kernel/trace/trace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 6e79408..69f9754 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -6602,7 +6602,7 @@ static int instance_rmdir(const char *name)
 	tracing_set_nop(tr);
 	event_trace_del_tracer(tr);
 	ftrace_destroy_function_files(tr);
-	debugfs_remove_recursive(tr->dir);
+	tracefs_remove_recursive(tr->dir);
 	free_trace_buffers(tr);
 
 	kfree(tr->name);
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1250118 — [PATCH 2/3] tracing: Make tracing work when debugfs is not compiled or initialized.

FromJiaxing Wang <hello.wjx@gmail.com>
Date2015-10-18 14:10 +0200
Subject[PATCH 2/3] tracing: Make tracing work when debugfs is not compiled or initialized.
Message-ID<qkUWK-4JV-17@gated-at.bofh.it>
In reply to#1250116
Currently tracing_init_dentry() returns -ENODEV when debugfs is not
initialized, which causes tracefs not populated with tracing files and
directories, so we will get an empty directory even after we manually
mount tracefs.

We can make tracing_init_dentry() return NULL as long as tracefs
is initialized and get a populated tracefs.

We also need to make global_trace.dir not NULL in order to pass the checks
in tracing_get_dentry() and add_tracer_options().

Signed-off-by: Jiaxing Wang <hello.wjx@gmail.com>
---
 kernel/trace/Kconfig |  1 -
 kernel/trace/trace.c | 29 +++++++++++++++++------------
 2 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
index 1153c43..59f6377f 100644
--- a/kernel/trace/Kconfig
+++ b/kernel/trace/Kconfig
@@ -95,7 +95,6 @@ config RING_BUFFER_ALLOW_SWAP
 
 config TRACING
 	bool
-	select DEBUG_FS
 	select RING_BUFFER
 	select STACKTRACE if STACKTRACE_SUPPORT
 	select TRACEPOINTS
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 69f9754..2d3042f 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -6706,6 +6706,8 @@ static struct vfsmount *trace_automount(void *ingore)
 	return mnt;
 }
 
+#define TRACE_TOP_DIR_ENTRY	((struct dentry *)1)
+
 /**
  * tracing_init_dentry - initialize top level trace array
  *
@@ -6716,27 +6718,30 @@ static struct vfsmount *trace_automount(void *ingore)
 struct dentry *tracing_init_dentry(void)
 {
 	struct trace_array *tr = &global_trace;
+	struct dentry *traced;
 
 	/* The top level trace array uses  NULL as parent */
 	if (tr->dir)
 		return NULL;
 
-	if (WARN_ON(!debugfs_initialized()))
+	if (WARN_ON(!tracefs_initialized()))
 		return ERR_PTR(-ENODEV);
 
-	/*
-	 * As there may still be users that expect the tracing
-	 * files to exist in debugfs/tracing, we must automount
-	 * the tracefs file system there, so older tools still
-	 * work with the newer kerenl.
-	 */
-	tr->dir = debugfs_create_automount("tracing", NULL,
-					   trace_automount, NULL);
-	if (!tr->dir) {
-		pr_warn_once("Could not create debugfs directory 'tracing'\n");
-		return ERR_PTR(-ENOMEM);
+	if (debugfs_initialized()) {
+		/*
+		 * As there may still be users that expect the tracing
+		 * files to exist in debugfs/tracing, we must automount
+		 * the tracefs file system there, so older tools still
+		 * work with the newer kerenl.
+		 */
+		traced = debugfs_create_automount("tracing", NULL,
+						   trace_automount, NULL);
+		if (!traced)
+			pr_warn_once("Could not create debugfs directory 'tracing'\n");
 	}
 
+	tr->dir = TRACE_TOP_DIR_ENTRY;
+
 	return NULL;
 }
 
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1250142 — Re: [PATCH 2/3] tracing: Make tracing work when debugfs is not compiled or initialized.

Fromkbuild test robot <lkp@intel.com>
Date2015-10-18 16:40 +0200
SubjectRe: [PATCH 2/3] tracing: Make tracing work when debugfs is not compiled or initialized.
Message-ID<qkXhT-809-7@gated-at.bofh.it>
In reply to#1250118

[Multipart message — attachments visible in raw view] — view raw

Hi Jiaxing,

[auto build test ERROR on tip/perf/core -- if it's inappropriate base, please suggest rules for selecting the more suitable base]

url:    https://github.com/0day-ci/linux/commits/Jiaxing-Wang/Some-tracing-fixes/20151018-200252
config: arm-omap2plus_defconfig (attached as .config)
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=arm 

All error/warnings (new ones prefixed by >>):

   kernel/trace/trace.c: In function 'tracing_init_dentry':
>> kernel/trace/trace.c:6737:3: error: implicit declaration of function 'debugfs_create_automount' [-Werror=implicit-function-declaration]
      traced = debugfs_create_automount("tracing", NULL,
      ^
>> kernel/trace/trace.c:6737:10: warning: assignment makes pointer from integer without a cast
      traced = debugfs_create_automount("tracing", NULL,
             ^
   cc1: some warnings being treated as errors

vim +/debugfs_create_automount +6737 kernel/trace/trace.c

  6731			/*
  6732			 * As there may still be users that expect the tracing
  6733			 * files to exist in debugfs/tracing, we must automount
  6734			 * the tracefs file system there, so older tools still
  6735			 * work with the newer kerenl.
  6736			 */
> 6737			traced = debugfs_create_automount("tracing", NULL,
  6738							   trace_automount, NULL);
  6739			if (!traced)
  6740				pr_warn_once("Could not create debugfs directory 'tracing'\n");

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[toc] | [prev] | [next] | [standalone]


#1250280 — Re: [PATCH 2/3] tracing: Make tracing work when debugfs is not compiled or initialized.

FromJiaxing Wang <hello.wjx@gmail.com>
Date2015-10-19 04:00 +0200
SubjectRe: [PATCH 2/3] tracing: Make tracing work when debugfs is not compiled or initialized.
Message-ID<ql7TY-6Dn-9@gated-at.bofh.it>
In reply to#1250118
Sorry for the last patch, please use this to add stub for
debugfs_create_automount().

From b3b877d8d9fd9795ea1055042039a272e47f4dc5 Mon Sep 17 00:00:00 2001
From: Jiaxing Wang <hello.wjx@gmail.com>
Date: Mon, 19 Oct 2015 09:46:12 +0800
Subject: [PATCH] debugfs: Add stub function for debugfs_create_automount().

Add stub for debugfs_create_automount() for when debugfs is not configured
in.

Signed-off-by: Jiaxing Wang <hello.wjx@gmail.com>
---
 include/linux/debugfs.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h
index 9beb636..b42ef88 100644
--- a/include/linux/debugfs.h
+++ b/include/linux/debugfs.h
@@ -160,6 +160,14 @@ static inline struct dentry *debugfs_create_symlink(const char *name,
 	return ERR_PTR(-ENODEV);
 }
 
+static inline struct dentry *debugfs_create_automount(const char *name,
+					struct dentry *parent,
+					struct vfsmount *(*f)(void *),
+					void *data)
+{
+	return ERR_PTR(-ENODEV);
+}
+
 static inline void debugfs_remove(struct dentry *dentry)
 { }
 
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1250119 — [PATCH 3/3] tracing: Apply tracer specific options from kernel command line.

FromJiaxing Wang <hello.wjx@gmail.com>
Date2015-10-18 14:10 +0200
Subject[PATCH 3/3] tracing: Apply tracer specific options from kernel command line.
Message-ID<qkUWL-4JV-27@gated-at.bofh.it>
In reply to#1250116
Currently, the trace_options parameter is only applied in
tracer_alloc_buffers() when global_trace.current_trace is nop_trace,
so a tracer specific option will not be applied even when the specific
tracer is also enabled from kernel command line. For example, the
'func_stack_trace' option can't be enabled with the following kernel
parameter:

  ftrace=function ftrace_filter=kfree trace_options=func_stack_trace

We can enable tracer specific options by simply apply the options again
if the specific tracer is also supplied from command line and started
in register_tracer().

To keep trace_boot_options_buf from overwritten by strsep() and strstrip()
and can be parsed again, a copy is made for them to work on.

Also make register_tracer() be __init to access the __init data, and
in fact register_tracer is only called from __init code.

Signed-off-by: Jiaxing Wang <hello.wjx@gmail.com>
---
 kernel/trace/trace.c | 41 ++++++++++++++++++++++++++++++++++-------
 1 file changed, 34 insertions(+), 7 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 2d3042f..d42af59 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1204,13 +1204,15 @@ static inline int run_tracer_selftest(struct tracer *type)
 }
 #endif /* CONFIG_FTRACE_STARTUP_TEST */
 
+static int __init apply_trace_boot_options(void);
+
 /**
  * register_tracer - register a tracer with the ftrace system.
  * @type - the plugin for the tracer
  *
  * Register a new plugin tracer.
  */
-int register_tracer(struct tracer *type)
+int __init register_tracer(struct tracer *type)
 {
 	struct tracer *t;
 	int ret = 0;
@@ -1268,6 +1270,9 @@ int register_tracer(struct tracer *type)
 	/* Do we want this tracer to start on bootup? */
 	tracing_set_tracer(&global_trace, type->name);
 	default_bootup_tracer = NULL;
+
+	apply_trace_boot_options();
+
 	/* disable other selftests, since this will break it. */
 	tracing_selftest_disabled = true;
 #ifdef CONFIG_FTRACE_STARTUP_TEST
@@ -3603,6 +3608,33 @@ static int trace_set_options(struct trace_array *tr, char *option)
 	return ret;
 }
 
+static int __init apply_trace_boot_options(void)
+{
+	char *option;
+	char *buf;
+	char *str;
+	size_t len;
+
+	if (trace_boot_options) {
+		len = strlen(trace_boot_options);
+
+		buf = str = kmalloc(len + 1, GFP_KERNEL);
+		if (!buf)
+			return -ENOMEM;
+
+		memcpy(buf, trace_boot_options, len + 1);
+
+		while (str) {
+			option = strsep(&str, ",");
+			trace_set_options(&global_trace, option);
+		}
+
+		kfree(buf);
+	}
+
+	return 0;
+}
+
 static ssize_t
 tracing_trace_options_write(struct file *filp, const char __user *ubuf,
 			size_t cnt, loff_t *ppos)
@@ -7153,12 +7185,7 @@ __init static int tracer_alloc_buffers(void)
 	INIT_LIST_HEAD(&global_trace.events);
 	list_add(&global_trace.list, &ftrace_trace_arrays);
 
-	while (trace_boot_options) {
-		char *option;
-
-		option = strsep(&trace_boot_options, ",");
-		trace_set_options(&global_trace, option);
-	}
+	apply_trace_boot_options();
 
 	register_snapshot_cmd();
 
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web