Skip to contentSkip to conversation

function-graph: fix the output of set_graph_function

PATCH In review Li Zefan 2 participants 6 messages Jul 22, 2009 – Jul 24, 2009

Subsystems (2)
lore
Share & tools
lore

Li Zefan

author
#0 lore raw

PATCH 1/2 function-graph: fix the output of set_graph_function

It always shows "ftrace_graph_funcs":

 # echo 'sys_open' > set_graph_function
 # cat set_graph_function
 ftrace_graph_funcs
---
 kernel/trace/ftrace.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/trace/ftrace.c +1 -1
index 24e3ff5..c6c0c07 100644
@@ -2505,7 +2505,7 @@ static int g_show(struct seq_file *m, void *v)
 		return 0;
 	}
 
-	seq_printf(m, "%pf\n", v);
+	seq_printf(m, "%pf\n", (void *)*ptr);
 
 	return 0;
 }
Signature · 1 line
1.6.3
author
#1 lore raw

PATCH 2/2 function-graph: use ftrace_graph_funcs directly

No need to store ftrace_graph_funcs in file->private.

---
 kernel/trace/ftrace.c |   22 ++++------------------
 1 files changed, 4 insertions(+), 18 deletions(-)
kernel/trace/ftrace.c +4 -18
index c6c0c07..7179bff 100644
@@ -2463,11 +2463,9 @@ unsigned long ftrace_graph_funcs[FTRACE_GRAPH_MAX_FUNCS] __read_mostly;
 static void *
 __g_next(struct seq_file *m, loff_t *pos)
 {
-	unsigned long *array = m->private;
-
 	if (*pos >= ftrace_graph_count)
 		return NULL;
-	return &array[*pos];
+	return &ftrace_graph_funcs[*pos];
 }
 
 static void *
@@ -2531,16 +2529,10 @@ ftrace_graph_open(struct inode *inode, struct file *file)
 		ftrace_graph_count = 0;
 		memset(ftrace_graph_funcs, 0, sizeof(ftrace_graph_funcs));
 	}
+	mutex_unlock(&graph_lock);
 
-	if (file->f_mode & FMODE_READ) {
+	if (file->f_mode & FMODE_READ)
 		ret = seq_open(file, &ftrace_graph_seq_ops);
-		if (!ret) {
-			struct seq_file *m = file->private_data;
-			m->private = ftrace_graph_funcs;
-		}
-	} else
-		file->private_data = ftrace_graph_funcs;
-	mutex_unlock(&graph_lock);
 
 	return ret;
 }
@@ -2601,7 +2593,7 @@ ftrace_graph_write(struct file *file, const char __user *ubuf,
 		   size_t cnt, loff_t *ppos)
 {
 	unsigned char buffer[FTRACE_BUFF_MAX+1];
-	unsigned long *array;
+	unsigned long *array = ftrace_graph_funcs;
 	size_t read = 0;
 	ssize_t ret;
 	int index = 0;
@@ -2617,12 +2609,6 @@ ftrace_graph_write(struct file *file, const char __user *ubuf,
 		goto out;
 	}
 
-	if (file->f_mode & FMODE_READ) {
-		struct seq_file *m = file->private_data;
-		array = m->private;
-	} else
-		array = file->private_data;
-
 	ret = get_user(ch, ubuf++);
 	if (ret)
 		goto out;
Signature · 1 line
1.6.3
maintainer
#2 lore raw

Re: [PATCH -tip 2/2] function-graph: use ftrace_graph_funcs directly

Quoted 1 line · Li Zefan

No need to store ftrace_graph_funcs in file->private.

Thanks, I'll queue this up for 32.

-- Steve

maintainer
#3 lore raw
In reply to Li Zefan
Quoted 5 lines · Li Zefan

It always shows "ftrace_graph_funcs":

 # echo 'sys_open' > set_graph_function
 # cat set_graph_function
 ftrace_graph_funcs

Nice fix. Hmm, this probably should go into 31.

-- Steve

Quoted 23 lines
---
 kernel/trace/ftrace.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/trace/ftrace.c +1 -1
index 24e3ff5..c6c0c07 100644
@@ -2505,7 +2505,7 @@ static int g_show(struct seq_file *m, void *v)
 		return 0;
 	}
 
-	seq_printf(m, "%pf\n", v);
+	seq_printf(m, "%pf\n", (void *)*ptr);
 
 	return 0;
 }
Signature · 1 line
1.6.3
author
#4 lore raw
Quoted 10 lines · Steven Rostedt
Quoted 5 lines · Li Zefan

It always shows "ftrace_graph_funcs":

 # echo 'sys_open' > set_graph_function
 # cat set_graph_function
 ftrace_graph_funcs

Nice fix. Hmm, this probably should go into 31.

The bug is introduced by a patch in tracing/core,
so this fix is for -tip only. :)

maintainer
#5 lore raw
Quoted 9 lines · Li Zefan
Quoted 8 lines · Steven Rostedt
Quoted 5 lines · Li Zefan

It always shows "ftrace_graph_funcs":

 # echo 'sys_open' > set_graph_function
 # cat set_graph_function
 ftrace_graph_funcs
Quoted 5 lines
Quoted 2 lines

Nice fix. Hmm, this probably should go into 31.

The bug is introduced by a patch in tracing/core,
so this fix is for -tip only. :)

OK, thanks for telling me that. It makes it easier for the queue.

-- Steve