All of lore.kernel.org
 help / color / mirror / Atom feed
* [for-next][PATCH 0/7] tracing: Various cleanups and small fixes
@ 2013-04-19 14:04 Steven Rostedt
  2013-04-19 14:04 ` [for-next][PATCH 1/7] kernel: tracing: Use strlcpy instead of strncpy Steven Rostedt
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Steven Rostedt @ 2013-04-19 14:04 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker

[-- Attachment #1: Type: text/plain, Size: 866 bytes --]

This will be added to the queue for 3.10 and uploaded to my for-next
branch in my git repo.

Chen Gang (1):
      kernel: tracing: Use strlcpy instead of strncpy

Namhyung Kim (5):
      tracing: Fix off-by-one on allocating stat->pages
      tracing: Reset ftrace_graph_filter_enabled if count is zero
      tracing: Get rid of unneeded key calculation in ftrace_hash_move()
      tracing: Check return value of tracing_init_dentry()
      ftrace: Get rid of ftrace_profile_bits

zhangwei(Jovi) (1):
      tracing: Remove obsolete macro guard _TRACE_PROFILE_INIT

----
 include/trace/ftrace.h     |    2 --
 kernel/trace/ftrace.c      |   29 +++++++++--------------------
 kernel/trace/trace.c       |    6 ++++--
 kernel/trace/trace_stack.c |    2 ++
 kernel/trace/trace_stat.c  |    2 ++
 5 files changed, 17 insertions(+), 24 deletions(-)

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

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

* [for-next][PATCH 1/7] kernel: tracing: Use strlcpy instead of strncpy
  2013-04-19 14:04 [for-next][PATCH 0/7] tracing: Various cleanups and small fixes Steven Rostedt
@ 2013-04-19 14:04 ` Steven Rostedt
  2013-04-19 14:04 ` [for-next][PATCH 2/7] tracing: Fix off-by-one on allocating stat->pages Steven Rostedt
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Steven Rostedt @ 2013-04-19 14:04 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker, Chen Gang

[-- Attachment #1: Type: text/plain, Size: 2005 bytes --]

From: Chen Gang <gang.chen@asianux.com>

Use strlcpy() instead of strncpy() as it will always add a '\0'
to the end of the string even if the buffer is smaller than what
is being copied.

Link: http://lkml.kernel.org/r/51624254.30301@asianux.com

Signed-off-by: Chen Gang <gang.chen@asianux.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/ftrace.c |    4 ++--
 kernel/trace/trace.c  |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 2577082..548a1f7 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -3496,14 +3496,14 @@ static char ftrace_filter_buf[FTRACE_FILTER_SIZE] __initdata;
 
 static int __init set_ftrace_notrace(char *str)
 {
-	strncpy(ftrace_notrace_buf, str, FTRACE_FILTER_SIZE);
+	strlcpy(ftrace_notrace_buf, str, FTRACE_FILTER_SIZE);
 	return 1;
 }
 __setup("ftrace_notrace=", set_ftrace_notrace);
 
 static int __init set_ftrace_filter(char *str)
 {
-	strncpy(ftrace_filter_buf, str, FTRACE_FILTER_SIZE);
+	strlcpy(ftrace_filter_buf, str, FTRACE_FILTER_SIZE);
 	return 1;
 }
 __setup("ftrace_filter=", set_ftrace_filter);
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 829b2be..07860b9 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -125,7 +125,7 @@ static bool allocate_snapshot;
 
 static int __init set_cmdline_ftrace(char *str)
 {
-	strncpy(bootup_tracer_buf, str, MAX_TRACER_SIZE);
+	strlcpy(bootup_tracer_buf, str, MAX_TRACER_SIZE);
 	default_bootup_tracer = bootup_tracer_buf;
 	/* We are using ftrace early, expand it */
 	ring_buffer_expanded = true;
@@ -164,7 +164,7 @@ static char *trace_boot_options __initdata;
 
 static int __init set_trace_boot_options(char *str)
 {
-	strncpy(trace_boot_options_buf, str, MAX_TRACER_SIZE);
+	strlcpy(trace_boot_options_buf, str, MAX_TRACER_SIZE);
 	trace_boot_options = trace_boot_options_buf;
 	return 0;
 }
-- 
1.7.10.4



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

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

* [for-next][PATCH 2/7] tracing: Fix off-by-one on allocating stat->pages
  2013-04-19 14:04 [for-next][PATCH 0/7] tracing: Various cleanups and small fixes Steven Rostedt
  2013-04-19 14:04 ` [for-next][PATCH 1/7] kernel: tracing: Use strlcpy instead of strncpy Steven Rostedt
@ 2013-04-19 14:04 ` Steven Rostedt
  2013-04-19 14:04 ` [for-next][PATCH 3/7] tracing: Reset ftrace_graph_filter_enabled if count is zero Steven Rostedt
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Steven Rostedt @ 2013-04-19 14:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker, Namhyung Kim,
	stable, Namhyung Kim

[-- Attachment #1: Type: text/plain, Size: 984 bytes --]

From: Namhyung Kim <namhyung.kim@lge.com>

The first page was allocated separately, so no need to start from 0.

Link: http://lkml.kernel.org/r/1364820385-32027-2-git-send-email-namhyung@kernel.org

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: stable@vger.kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/ftrace.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 548a1f7..c9f3149 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -676,7 +676,7 @@ int ftrace_profile_pages_init(struct ftrace_profile_stat *stat)
 
 	pages = DIV_ROUND_UP(functions, PROFILES_PER_PAGE);
 
-	for (i = 0; i < pages; i++) {
+	for (i = 1; i < pages; i++) {
 		pg->next = (void *)get_zeroed_page(GFP_KERNEL);
 		if (!pg->next)
 			goto out_free;
-- 
1.7.10.4



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

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

* [for-next][PATCH 3/7] tracing: Reset ftrace_graph_filter_enabled if count is zero
  2013-04-19 14:04 [for-next][PATCH 0/7] tracing: Various cleanups and small fixes Steven Rostedt
  2013-04-19 14:04 ` [for-next][PATCH 1/7] kernel: tracing: Use strlcpy instead of strncpy Steven Rostedt
  2013-04-19 14:04 ` [for-next][PATCH 2/7] tracing: Fix off-by-one on allocating stat->pages Steven Rostedt
@ 2013-04-19 14:04 ` Steven Rostedt
  2013-04-19 14:04 ` [for-next][PATCH 4/7] tracing: Get rid of unneeded key calculation in ftrace_hash_move() Steven Rostedt
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Steven Rostedt @ 2013-04-19 14:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker, Namhyung Kim,
	stable, Namhyung Kim

[-- Attachment #1: Type: text/plain, Size: 924 bytes --]

From: Namhyung Kim <namhyung.kim@lge.com>

The ftrace_graph_count can be decreased with a "!" pattern, so that
the enabled flag should be updated too.

Link: http://lkml.kernel.org/r/1365663698-2413-1-git-send-email-namhyung@kernel.org

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: stable@vger.kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/ftrace.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index c9f3149..9e31987 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -3792,7 +3792,8 @@ out:
 	if (fail)
 		return -EINVAL;
 
-	ftrace_graph_filter_enabled = 1;
+	ftrace_graph_filter_enabled = !!(*idx);
+
 	return 0;
 }
 
-- 
1.7.10.4



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

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

* [for-next][PATCH 4/7] tracing: Get rid of unneeded key calculation in ftrace_hash_move()
  2013-04-19 14:04 [for-next][PATCH 0/7] tracing: Various cleanups and small fixes Steven Rostedt
                   ` (2 preceding siblings ...)
  2013-04-19 14:04 ` [for-next][PATCH 3/7] tracing: Reset ftrace_graph_filter_enabled if count is zero Steven Rostedt
@ 2013-04-19 14:04 ` Steven Rostedt
  2013-04-19 14:04 ` [for-next][PATCH 5/7] tracing: Check return value of tracing_init_dentry() Steven Rostedt
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Steven Rostedt @ 2013-04-19 14:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker, Namhyung Kim

[-- Attachment #1: Type: text/plain, Size: 1133 bytes --]

From: Namhyung Kim <namhyung.kim@lge.com>

It's not used anywhere in the function.

Link: http://lkml.kernel.org/r/1365553093-10180-1-git-send-email-namhyung@kernel.org

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/ftrace.c |    5 -----
 1 file changed, 5 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 9e31987..3b84fc1 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1320,7 +1320,6 @@ ftrace_hash_move(struct ftrace_ops *ops, int enable,
 	struct hlist_head *hhd;
 	struct ftrace_hash *old_hash;
 	struct ftrace_hash *new_hash;
-	unsigned long key;
 	int size = src->count;
 	int bits = 0;
 	int ret;
@@ -1363,10 +1362,6 @@ ftrace_hash_move(struct ftrace_ops *ops, int enable,
 	for (i = 0; i < size; i++) {
 		hhd = &src->buckets[i];
 		hlist_for_each_entry_safe(entry, tp, tn, hhd, hlist) {
-			if (bits > 0)
-				key = hash_long(entry->ip, bits);
-			else
-				key = 0;
 			remove_hash_entry(src, entry);
 			__add_hash_entry(new_hash, entry);
 		}
-- 
1.7.10.4



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

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

* [for-next][PATCH 5/7] tracing: Check return value of tracing_init_dentry()
  2013-04-19 14:04 [for-next][PATCH 0/7] tracing: Various cleanups and small fixes Steven Rostedt
                   ` (3 preceding siblings ...)
  2013-04-19 14:04 ` [for-next][PATCH 4/7] tracing: Get rid of unneeded key calculation in ftrace_hash_move() Steven Rostedt
@ 2013-04-19 14:04 ` Steven Rostedt
  2013-04-19 14:04 ` [for-next][PATCH 6/7] ftrace: Get rid of ftrace_profile_bits Steven Rostedt
  2013-04-19 14:04 ` [for-next][PATCH 7/7] tracing: Remove obsolete macro guard _TRACE_PROFILE_INIT Steven Rostedt
  6 siblings, 0 replies; 8+ messages in thread
From: Steven Rostedt @ 2013-04-19 14:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker, Namhyung Kim,
	stable, Namhyung Kim

[-- Attachment #1: Type: text/plain, Size: 1785 bytes --]

From: Namhyung Kim <namhyung.kim@lge.com>

Check return value and bail out if it's NULL.

Link: http://lkml.kernel.org/r/1365553093-10180-2-git-send-email-namhyung@kernel.org

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: stable@vger.kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace.c       |    2 ++
 kernel/trace/trace_stack.c |    2 ++
 kernel/trace/trace_stat.c  |    2 ++
 3 files changed, 6 insertions(+)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 07860b9..7297079 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -5953,6 +5953,8 @@ static __init int tracer_init_debugfs(void)
 	trace_access_lock_init();
 
 	d_tracer = tracing_init_dentry();
+	if (!d_tracer)
+		return 0;
 
 	init_tracer_debugfs(&global_trace, d_tracer);
 
diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
index aab277b..8c3f37e 100644
--- a/kernel/trace/trace_stack.c
+++ b/kernel/trace/trace_stack.c
@@ -431,6 +431,8 @@ static __init int stack_trace_init(void)
 	struct dentry *d_tracer;
 
 	d_tracer = tracing_init_dentry();
+	if (!d_tracer)
+		return 0;
 
 	trace_create_file("stack_max_size", 0644, d_tracer,
 			&max_stack_size, &stack_max_size_fops);
diff --git a/kernel/trace/trace_stat.c b/kernel/trace/trace_stat.c
index 96cffb2..847f88a 100644
--- a/kernel/trace/trace_stat.c
+++ b/kernel/trace/trace_stat.c
@@ -307,6 +307,8 @@ static int tracing_stat_init(void)
 	struct dentry *d_tracing;
 
 	d_tracing = tracing_init_dentry();
+	if (!d_tracing)
+		return 0;
 
 	stat_dir = debugfs_create_dir("trace_stat", d_tracing);
 	if (!stat_dir)
-- 
1.7.10.4



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

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

* [for-next][PATCH 6/7] ftrace: Get rid of ftrace_profile_bits
  2013-04-19 14:04 [for-next][PATCH 0/7] tracing: Various cleanups and small fixes Steven Rostedt
                   ` (4 preceding siblings ...)
  2013-04-19 14:04 ` [for-next][PATCH 5/7] tracing: Check return value of tracing_init_dentry() Steven Rostedt
@ 2013-04-19 14:04 ` Steven Rostedt
  2013-04-19 14:04 ` [for-next][PATCH 7/7] tracing: Remove obsolete macro guard _TRACE_PROFILE_INIT Steven Rostedt
  6 siblings, 0 replies; 8+ messages in thread
From: Steven Rostedt @ 2013-04-19 14:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker, Namhyung Kim

[-- Attachment #1: Type: text/plain, Size: 2267 bytes --]

From: Namhyung Kim <namhyung.kim@lge.com>

It seems that function profiler's hash size is fixed at 1024.  Add and
use FTRACE_PROFILE_HASH_BITS instead and update hash size macro.

Link: http://lkml.kernel.org/r/1365551750-4504-1-git-send-email-namhyung@kernel.org

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/ftrace.c |   15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 3b84fc1..9b44abb 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -486,7 +486,6 @@ struct ftrace_profile_stat {
 #define PROFILES_PER_PAGE					\
 	(PROFILE_RECORDS_SIZE / sizeof(struct ftrace_profile))
 
-static int ftrace_profile_bits __read_mostly;
 static int ftrace_profile_enabled __read_mostly;
 
 /* ftrace_profile_lock - synchronize the enable and disable of the profiler */
@@ -494,7 +493,8 @@ static DEFINE_MUTEX(ftrace_profile_lock);
 
 static DEFINE_PER_CPU(struct ftrace_profile_stat, ftrace_profile_stats);
 
-#define FTRACE_PROFILE_HASH_SIZE 1024 /* must be power of 2 */
+#define FTRACE_PROFILE_HASH_BITS 10
+#define FTRACE_PROFILE_HASH_SIZE (1 << FTRACE_PROFILE_HASH_BITS)
 
 static void *
 function_stat_next(void *v, int idx)
@@ -725,13 +725,6 @@ static int ftrace_profile_init_cpu(int cpu)
 	if (!stat->hash)
 		return -ENOMEM;
 
-	if (!ftrace_profile_bits) {
-		size--;
-
-		for (; size; size >>= 1)
-			ftrace_profile_bits++;
-	}
-
 	/* Preallocate the function profiling pages */
 	if (ftrace_profile_pages_init(stat) < 0) {
 		kfree(stat->hash);
@@ -765,7 +758,7 @@ ftrace_find_profiled_func(struct ftrace_profile_stat *stat, unsigned long ip)
 	struct hlist_node *n;
 	unsigned long key;
 
-	key = hash_long(ip, ftrace_profile_bits);
+	key = hash_long(ip, FTRACE_PROFILE_HASH_BITS);
 	hhd = &stat->hash[key];
 
 	if (hlist_empty(hhd))
@@ -784,7 +777,7 @@ static void ftrace_add_profile(struct ftrace_profile_stat *stat,
 {
 	unsigned long key;
 
-	key = hash_long(rec->ip, ftrace_profile_bits);
+	key = hash_long(rec->ip, FTRACE_PROFILE_HASH_BITS);
 	hlist_add_head_rcu(&rec->node, &stat->hash[key]);
 }
 
-- 
1.7.10.4



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

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

* [for-next][PATCH 7/7] tracing: Remove obsolete macro guard _TRACE_PROFILE_INIT
  2013-04-19 14:04 [for-next][PATCH 0/7] tracing: Various cleanups and small fixes Steven Rostedt
                   ` (5 preceding siblings ...)
  2013-04-19 14:04 ` [for-next][PATCH 6/7] ftrace: Get rid of ftrace_profile_bits Steven Rostedt
@ 2013-04-19 14:04 ` Steven Rostedt
  6 siblings, 0 replies; 8+ messages in thread
From: Steven Rostedt @ 2013-04-19 14:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker, zhangwei(Jovi)

[-- Attachment #1: Type: text/plain, Size: 774 bytes --]

From: "zhangwei(Jovi)" <jovi.zhangwei@huawei.com>

The macro _TRACE_PROFILE_INIT was removed a long time ago,
but an "#undef" guard was left behind. Remove it.

Link: http://lkml.kernel.org/r/514684EE.6000805@huawei.com

Signed-off-by: zhangwei(Jovi) <jovi.zhangwei@huawei.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 include/trace/ftrace.h |    2 --
 1 file changed, 2 deletions(-)

diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
index 4bda044..19edd7f 100644
--- a/include/trace/ftrace.h
+++ b/include/trace/ftrace.h
@@ -704,5 +704,3 @@ static inline void perf_test_probe_##call(void)				\
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
 #endif /* CONFIG_PERF_EVENTS */
 
-#undef _TRACE_PROFILE_INIT
-
-- 
1.7.10.4



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

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

end of thread, other threads:[~2013-04-19 14:08 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-19 14:04 [for-next][PATCH 0/7] tracing: Various cleanups and small fixes Steven Rostedt
2013-04-19 14:04 ` [for-next][PATCH 1/7] kernel: tracing: Use strlcpy instead of strncpy Steven Rostedt
2013-04-19 14:04 ` [for-next][PATCH 2/7] tracing: Fix off-by-one on allocating stat->pages Steven Rostedt
2013-04-19 14:04 ` [for-next][PATCH 3/7] tracing: Reset ftrace_graph_filter_enabled if count is zero Steven Rostedt
2013-04-19 14:04 ` [for-next][PATCH 4/7] tracing: Get rid of unneeded key calculation in ftrace_hash_move() Steven Rostedt
2013-04-19 14:04 ` [for-next][PATCH 5/7] tracing: Check return value of tracing_init_dentry() Steven Rostedt
2013-04-19 14:04 ` [for-next][PATCH 6/7] ftrace: Get rid of ftrace_profile_bits Steven Rostedt
2013-04-19 14:04 ` [for-next][PATCH 7/7] tracing: Remove obsolete macro guard _TRACE_PROFILE_INIT Steven Rostedt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.