public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tracing: dont reset set_ftrace_filter/notrace when opened with r/w perm
@ 2009-07-16 16:51 Jiri Olsa
  2009-07-17  9:37 ` Li Zefan
  2009-07-21  1:11 ` Steven Rostedt
  0 siblings, 2 replies; 9+ messages in thread
From: Jiri Olsa @ 2009-07-16 16:51 UTC (permalink / raw)
  To: Ingo Molnar, Steven Rostedt; +Cc: lkml

If user setup set_ftrace_filter/set_ftrace_notrace files and then opens them
with read&write permissions, the previous setup will be removed.

Tested with following program:

[snip]
#include <stdio.h>
#include <string.h>

int main(int argc, char **argv)
{
	FILE *f;
	char *mode = "w+";
	char *file = argv[1];

	if (argc == 3)
		mode = argv[2];

	if (NULL == (f = fopen(file, mode))) {
		perror("fopen failed");
		return -1;
	}

	while(!feof(f)) {
#define BUFLEN 100
		char buf[BUFLEN];
		memset(buf, 0, BUFLEN);
		fgets(buf, BUFLEN, f);
		printf(buf);
	}

	fclose(f);
	return 0;
}
[snip]

wbr,
jirka


Signed-off-by: Jiri Olsa <jolsa@redhat.com>

---
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 4521c77..11394bc 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1661,10 +1661,6 @@ ftrace_regex_open(struct inode *inode, struct file *file, int enable)
 		return -ENOMEM;
 
 	mutex_lock(&ftrace_regex_lock);
-	if ((file->f_mode & FMODE_WRITE) &&
-	    !(file->f_flags & O_APPEND))
-		ftrace_filter_reset(enable);
-
 	if (file->f_mode & FMODE_READ) {
 		iter->pg = ftrace_pages_start;
 		iter->flags = enable ? FTRACE_ITER_FILTER :
@@ -2260,6 +2256,9 @@ ftrace_regex_write(struct file *file, const char __user *ubuf,
 		return 0;
 
 	mutex_lock(&ftrace_regex_lock);
+	if ((file->f_mode & FMODE_WRITE) &&
+	    !(file->f_flags & O_APPEND))
+		ftrace_filter_reset(enable);
 
 	if (file->f_mode & FMODE_READ) {
 		struct seq_file *m = file->private_data;

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-07-22 15:19 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-16 16:51 [PATCH] tracing: dont reset set_ftrace_filter/notrace when opened with r/w perm Jiri Olsa
2009-07-17  9:37 ` Li Zefan
2009-07-17 11:10   ` Jiri Olsa
2009-07-20  0:55     ` Li Zefan
2009-07-20  1:32       ` Frederic Weisbecker
2009-07-22 12:19         ` Jiri Olsa
2009-07-21  1:11 ` Steven Rostedt
2009-07-22  7:42   ` Jiri Olsa
2009-07-22 15:19     ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox