Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761243AbbKTU7M (ORCPT ); Fri, 20 Nov 2015 15:59:12 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:57498 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761109AbbKTU5x (ORCPT ); Fri, 20 Nov 2015 15:57:53 -0500 From: Josef Bacik To: , , Subject: [PATCH 07/11] trace-cmd: add trace-hash to libtracecmd Date: Fri, 20 Nov 2015 15:57:29 -0500 Message-ID: <1448053053-24188-8-git-send-email-jbacik@fb.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1448053053-24188-1-git-send-email-jbacik@fb.com> References: <1448053053-24188-1-git-send-email-jbacik@fb.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [192.168.52.123] X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2015-11-20_12:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5835 Lines: 198 trace-hash is a pretty useful tool, expose it through libtracecmd and install trace-hash.h with install_libs. Thanks, Signed-off-by: Josef Bacik --- Makefile | 5 +++-- trace-hash-local.h | 60 ------------------------------------------------------ trace-hash.h | 40 +++++++++++++++++++++++++++++++++--- trace-mem.c | 2 +- trace-profile.c | 1 + 5 files changed, 42 insertions(+), 66 deletions(-) delete mode 100644 trace-hash-local.h diff --git a/Makefile b/Makefile index 7877b50..d812f77 100644 --- a/Makefile +++ b/Makefile @@ -324,7 +324,7 @@ TRACE_GUI_OBJS = trace-filter.o trace-compat.o trace-filter-hash.o trace-dialog. trace-xml.o TRACE_CMD_OBJS = trace-cmd.o trace-record.o trace-read.o trace-split.o trace-listen.o \ trace-stack.o trace-hist.o trace-mem.o trace-snapshot.o trace-stat.o \ - trace-hash.o trace-profile.o + trace-profile.o TRACE_VIEW_OBJS = trace-view.o trace-view-store.o TRACE_GRAPH_OBJS = trace-graph.o trace-plot.o trace-plot-cpu.o trace-plot-task.o TRACE_VIEW_MAIN_OBJS = trace-view-main.o $(TRACE_VIEW_OBJS) $(TRACE_GUI_OBJS) @@ -337,7 +337,7 @@ TCMD_LIB_OBJS = $(PEVENT_LIB_OBJS) trace-util.o trace-input.o trace-ftrace.o \ trace-output.o trace-record.o trace-recorder.o \ trace-restore.o trace-usage.o trace-blk-hack.o \ kbuffer-parse.o event-plugin.o trace-hooks.o \ - trace-stream.o + trace-stream.o trace-hash.o PLUGIN_OBJS = PLUGIN_OBJS += plugin_jbd2.o @@ -585,6 +585,7 @@ install_libs: libs $(Q)$(call do_install,libparsevent.so,$(libdir_SQ)) $(Q)$(call do_install,event-parse.h,$(includedir_SQ)) $(Q)$(call do_install,trace-cmd.h,$(includedir_SQ)) + $(Q)$(call do_install,trace-hash.h,$(includedir_SQ)) doc: $(MAKE) -C $(src)/Documentation all diff --git a/trace-hash-local.h b/trace-hash-local.h deleted file mode 100644 index b2a1002..0000000 --- a/trace-hash-local.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2009, Steven Rostedt - * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License (not later!) - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see - * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - */ -#ifndef _TRACE_HASH_LOCAL_H -#define _TRACE_HASH_LOCAL_H - -static inline unsigned int trace_hash(int val) -{ - int hash, tmp; - - hash = 12546869; /* random prime */ - - /* - * The following hash is based off of Paul Hsieh's super fast hash: - * http://www.azillionmonkeys.com/qed/hash.html - * Note, he released this code unde the GPL 2.0 license, which - * is the same as the license for the programs that use it here. - */ - - hash += (val & 0xffff); - tmp = (val >> 16) ^ hash; - hash = (hash << 16) ^ tmp; - hash += hash >> 11; - - hash ^= hash << 3; - hash += hash >> 5; - hash ^= hash << 4; - hash += hash >> 17; - hash ^= hash << 25; - hash += hash >> 6; - - return hash; -} - -static inline unsigned int trace_hash_str(char *str) -{ - int val = 0; - int i; - - for (i = 0; str[i]; i++) - val += ((int)str[i]) << (i & 0xf); - return trace_hash(val); -} -#endif /* _TRACE_HASH_LOCAL_H */ diff --git a/trace-hash.h b/trace-hash.h index 2529f4d..e96fd91 100644 --- a/trace-hash.h +++ b/trace-hash.h @@ -20,9 +20,6 @@ #ifndef _TRACE_HASH_H #define _TRACE_HASH_H -#include "trace-hash-local.h" -#include "list.h" - struct trace_hash_item { struct trace_hash_item *next; struct trace_hash_item *prev; @@ -69,4 +66,41 @@ struct trace_hash_item * trace_hash_find(struct trace_hash *hash, unsigned long long key, trace_hash_func match, void *data); +static inline unsigned int trace_hash(int val) +{ + int hash, tmp; + + hash = 12546869; /* random prime */ + + /* + * The following hash is based off of Paul Hsieh's super fast hash: + * http://www.azillionmonkeys.com/qed/hash.html + * Note, he released this code unde the GPL 2.0 license, which + * is the same as the license for the programs that use it here. + */ + + hash += (val & 0xffff); + tmp = (val >> 16) ^ hash; + hash = (hash << 16) ^ tmp; + hash += hash >> 11; + + hash ^= hash << 3; + hash += hash >> 5; + hash ^= hash << 4; + hash += hash >> 17; + hash ^= hash << 25; + hash += hash >> 6; + + return hash; +} + +static inline unsigned int trace_hash_str(char *str) +{ + int val = 0; + int i; + + for (i = 0; str[i]; i++) + val += ((int)str[i]) << (i & 0xf); + return trace_hash(val); +} #endif /* _TRACE_HASH_H */ diff --git a/trace-mem.c b/trace-mem.c index a949b15..aa2ccd8 100644 --- a/trace-mem.c +++ b/trace-mem.c @@ -34,7 +34,7 @@ #include #include "trace-local.h" -#include "trace-hash-local.h" +#include "trace-hash.h" #include "list.h" static int kmalloc_type; diff --git a/trace-profile.c b/trace-profile.c index 7e41025..1eac0b4 100644 --- a/trace-profile.c +++ b/trace-profile.c @@ -28,6 +28,7 @@ #endif #include "trace-local.h" #include "trace-hash.h" +#include "list.h" #ifdef WARN_NO_AUDIT # warning "lib audit not found, using raw syscalls " \ -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/