From patchwork Tue Aug 14 16:24:50 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 1321791 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id C946640210 for ; Tue, 14 Aug 2012 16:27:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756834Ab2HNQ0m (ORCPT ); Tue, 14 Aug 2012 12:26:42 -0400 Received: from mail-bk0-f46.google.com ([209.85.214.46]:39086 "EHLO mail-bk0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752652Ab2HNQ0k (ORCPT ); Tue, 14 Aug 2012 12:26:40 -0400 Received: by mail-bk0-f46.google.com with SMTP id j10so208146bkw.19 for ; Tue, 14 Aug 2012 09:26:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=ChduV/To6S5bRuwjDo4dS9VfjOStMXL7uD/y+VOgeQM=; b=deQqgAtpkJ+3zshfIUQ1xTYRD4I8w65ojYZM0FOfWM2USqHf8moo4Jw8iysUwX3Osg yE0a4BiQftGdkwS4W+0Jw96V0lIVuieVF+W6kp5QXRy+4a5lHi5h5+Qfuu+9jt2gOBeF QDfHAIxODU/+/HDAZvx2hBX+FBbZslCvLo7KIKV8lul9OAXmowvPswWU2J7Qqo85lfWI gzFCBL06hK5/teP7/gsh9F0tjbMBTDVTGZi3nYb2m5SPtE3fFPjd0QPyvRyvXEhWGI42 lrNYx4d33WJmcwLcaCrYZEgnZJVLuXQM/PSzQ15HrnK+c0WotcRhnVKpEoOXXxVueUUC cCjg== Received: by 10.204.152.75 with SMTP id f11mr6713063bkw.83.1344961599378; Tue, 14 Aug 2012 09:26:39 -0700 (PDT) Received: from localhost.localdomain (95-89-78-76-dynip.superkabel.de. [95.89.78.76]) by mx.google.com with ESMTPS id t23sm1470660bks.4.2012.08.14.09.26.33 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 14 Aug 2012 09:26:35 -0700 (PDT) From: Sasha Levin To: torvalds@linux-foundation.org Cc: tj@kernel.org, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, paul.gortmaker@windriver.com, davem@davemloft.net, rostedt@goodmis.org, mingo@elte.hu, ebiederm@xmission.com, aarcange@redhat.com, ericvh@gmail.com, netdev@vger.kernel.org, josh@joshtriplett.org, eric.dumazet@gmail.com, mathieu.desnoyers@efficios.com, axboe@kernel.dk, agk@redhat.com, dm-devel@redhat.com, neilb@suse.de, ccaulfie@redhat.com, teigland@redhat.com, Trond.Myklebust@netapp.com, bfields@fieldses.org, fweisbec@gmail.com, jesse@nicira.com, venkat.x.venkatsubra@oracle.com, ejt@redhat.com, snitzer@redhat.com, edumazet@google.com, linux-nfs@vger.kernel.org, dev@openvswitch.org, rds-devel@oss.oracle.com, lw@cn.fujitsu.com, Sasha Levin Subject: [PATCH 16/16] tracing output: use new hashtable implementation Date: Tue, 14 Aug 2012 18:24:50 +0200 Message-Id: <1344961490-4068-17-git-send-email-levinsasha928@gmail.com> X-Mailer: git-send-email 1.7.8.6 In-Reply-To: <1344961490-4068-1-git-send-email-levinsasha928@gmail.com> References: <1344961490-4068-1-git-send-email-levinsasha928@gmail.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 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 --- 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 #include #include +#include #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);