lkml.org 
[lkml]   [2015]   [Nov]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 07/11] trace-cmd: add trace-hash to libtracecmd
Date
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 <jbacik@fb.com>
---
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 <srostedt@redhat.com>
- *
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- *
- * 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 <http://www.gnu.org/licenses>
- *
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- */
-#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 <signal.h>

#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


\
 
 \ /
  Last update: 2015-11-20 22:21    [W:0.091 / U:0.228 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site