- To: torvalds@xxxxxxxxxxxxxxxxxxxx
- Subject: [PATCH 16/16] tracing output: use new hashtable implementation
- From: Sasha Levin <levinsasha928@xxxxxxxxx>
- Date: Tue, 14 Aug 2012 18:24:50 +0200
- Cc: tj@xxxxxxxxxx, akpm@xxxxxxxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, linux-mm@xxxxxxxxx, paul.gortmaker@xxxxxxxxxxxxx, davem@xxxxxxxxxxxxx, rostedt@xxxxxxxxxxx, mingo@xxxxxxx, ebiederm@xxxxxxxxxxxx, aarcange@xxxxxxxxxx, ericvh@xxxxxxxxx, netdev@xxxxxxxxxxxxxxx, josh@xxxxxxxxxxxxxxxx, eric.dumazet@xxxxxxxxx, mathieu.desnoyers@xxxxxxxxxxxx, axboe@xxxxxxxxx, agk@xxxxxxxxxx, dm-devel@xxxxxxxxxx, neilb@xxxxxxx, ccaulfie@xxxxxxxxxx, teigland@xxxxxxxxxx, Trond.Myklebust@xxxxxxxxxx, bfields@xxxxxxxxxxxx, fweisbec@xxxxxxxxx, jesse@xxxxxxxxxx, venkat.x.venkatsubra@xxxxxxxxxx, ejt@xxxxxxxxxx, snitzer@xxxxxxxxxx, edumazet@xxxxxxxxxx, linux-nfs@xxxxxxxxxxxxxxx, dev@xxxxxxxxxxxxxxx, rds-devel@xxxxxxxxxxxxxx, lw@xxxxxxxxxxxxxx, Sasha Levin <levinsasha928@xxxxxxxxx>
- Delivered-to: linux-mm-outgoing@xxxxxxxxx
- Delivered-to: int-list-linux-mm@xxxxxxxxx
- Delivered-to: linux-mm@xxxxxxxxx
- In-reply-to: <1344961490-4068-1-git-send-email-levinsasha928@gmail.com>
Switch tracing to use the new hashtable implementation. This reduces the amount of
generic unrelated code in the tracing module.
Signed-off-by: Sasha Levin <levinsasha928@xxxxxxxxx>
---
kernel/trace/trace_output.c | 20 ++++++++------------
1 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
index 123b189..1324c1a 100644
--- a/kernel/trace/trace_output.c
+++ b/kernel/trace/trace_output.c
@@ -8,15 +8,15 @@
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/ftrace.h>
+#include <linux/hashtable.h>
#include "trace_output.h"
-/* must be a power of 2 */
-#define EVENT_HASHSIZE 128
+#define EVENT_HASH_BITS 7
DECLARE_RWSEM(trace_event_mutex);
-static struct hlist_head event_hash[EVENT_HASHSIZE] __read_mostly;
+static DEFINE_HASHTABLE(event_hash, EVENT_HASH_BITS);
static int next_event_type = __TRACE_LAST_TYPE + 1;
@@ -712,11 +712,8 @@ struct trace_event *ftrace_find_event(int type)
{
struct trace_event *event;
struct hlist_node *n;
- unsigned key;
- key = type & (EVENT_HASHSIZE - 1);
-
- hlist_for_each_entry(event, n, &event_hash[key], node) {
+ hash_for_each_possible(event_hash, event, n, node, type) {
if (event->type == type)
return event;
}
@@ -781,7 +778,6 @@ void trace_event_read_unlock(void)
*/
int register_ftrace_event(struct trace_event *event)
{
- unsigned key;
int ret = 0;
down_write(&trace_event_mutex);
@@ -833,9 +829,7 @@ int register_ftrace_event(struct trace_event *event)
if (event->funcs->binary == NULL)
event->funcs->binary = trace_nop_print;
- key = event->type & (EVENT_HASHSIZE - 1);
-
- hlist_add_head(&event->node, &event_hash[key]);
+ hash_add(event_hash, &event->node, event->type);
ret = event->type;
out:
@@ -850,7 +844,7 @@ EXPORT_SYMBOL_GPL(register_ftrace_event);
*/
int __unregister_ftrace_event(struct trace_event *event)
{
- hlist_del(&event->node);
+ hash_del(&event->node);
list_del(&event->list);
return 0;
}
@@ -1323,6 +1317,8 @@ __init static int init_events(void)
}
}
+ hash_init(event_hash);
+
return 0;
}
early_initcall(init_events);
--
1.7.8.6
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>
[Site Home]
[Linux ARM Kernel]
[Linux ARM]
[Linux Omap]
[Fedora ARM]
[IETF Annouce]
[Security]
[Bugtraq]
[Linux]
[Linux OMAP]
[Linux MIPS]
[ECOS]
[Tools]
[DDR & Rambus]
[Asterisk Internet PBX]
[Linux API]
[Monitors]