[tip:core/objtool] tools: Copy hashtable.h into tools directory

From: tip-bot for Josh Poimboeuf
Date: Wed Mar 09 2016 - 06:47:32 EST


Commit-ID: 1698872b5c772aebc5c43ca445cc0a79f12b9fcc
Gitweb: http://git.kernel.org/tip/1698872b5c772aebc5c43ca445cc0a79f12b9fcc
Author: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
AuthorDate: Wed, 9 Mar 2016 00:06:59 -0600
Committer: Ingo Molnar <mingo@xxxxxxxxxx>
CommitDate: Wed, 9 Mar 2016 10:48:09 +0100

tools: Copy hashtable.h into tools directory

Copy hashtable.h from include/linux/tools.h. It's needed by objtool in
the next patch in the series.

Add some includes that it needs, and remove references to
kernel-specific features like RCU and __read_mostly.

Also change some if its dependency headers' includes to use quotes
instead of brackets so gcc can find them.

Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: Andy Lutomirski <luto@xxxxxxxxxx>
Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxxxxx>
Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Cc: Bernd Petrovitsch <bernd@xxxxxxxxxxxxxxxxxxx>
Cc: Borislav Petkov <bp@xxxxxxxxx>
Cc: Chris J Arges <chris.j.arges@xxxxxxxxxxxxx>
Cc: Jiri Slaby <jslaby@xxxxxxx>
Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Cc: Michal Marek <mmarek@xxxxxxx>
Cc: Namhyung Kim <namhyung@xxxxxxxxx>
Cc: Pedro Alves <palves@xxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: live-patching@xxxxxxxxxxxxxxx
Link: http://lkml.kernel.org/r/be3bef72f6540d8a510515408119d968a0e18179.1457502970.git.jpoimboe@xxxxxxxxxx
Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
---
tools/include/asm-generic/bitops/__fls.h | 2 +-
tools/include/asm-generic/bitops/fls.h | 2 +-
tools/include/asm-generic/bitops/fls64.h | 2 +-
{include => tools/include}/linux/hashtable.h | 69 +++-------------------------
4 files changed, 9 insertions(+), 66 deletions(-)

diff --git a/tools/include/asm-generic/bitops/__fls.h b/tools/include/asm-generic/bitops/__fls.h
index 2218b9a..494c9c6 100644
--- a/tools/include/asm-generic/bitops/__fls.h
+++ b/tools/include/asm-generic/bitops/__fls.h
@@ -1 +1 @@
-#include <../../../../include/asm-generic/bitops/__fls.h>
+#include "../../../../include/asm-generic/bitops/__fls.h"
diff --git a/tools/include/asm-generic/bitops/fls.h b/tools/include/asm-generic/bitops/fls.h
index dbf711a..0e4995f 100644
--- a/tools/include/asm-generic/bitops/fls.h
+++ b/tools/include/asm-generic/bitops/fls.h
@@ -1 +1 @@
-#include <../../../../include/asm-generic/bitops/fls.h>
+#include "../../../../include/asm-generic/bitops/fls.h"
diff --git a/tools/include/asm-generic/bitops/fls64.h b/tools/include/asm-generic/bitops/fls64.h
index 980b1f6..35bee00 100644
--- a/tools/include/asm-generic/bitops/fls64.h
+++ b/tools/include/asm-generic/bitops/fls64.h
@@ -1 +1 @@
-#include <../../../../include/asm-generic/bitops/fls64.h>
+#include "../../../../include/asm-generic/bitops/fls64.h"
diff --git a/include/linux/hashtable.h b/tools/include/linux/hashtable.h
similarity index 65%
copy from include/linux/hashtable.h
copy to tools/include/linux/hashtable.h
index 661e5c2..c65cc0a 100644
--- a/include/linux/hashtable.h
+++ b/tools/include/linux/hashtable.h
@@ -9,17 +9,18 @@
#include <linux/list.h>
#include <linux/types.h>
#include <linux/kernel.h>
+#include <linux/bitops.h>
#include <linux/hash.h>
-#include <linux/rculist.h>
+#include <linux/log2.h>
+
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+#endif

#define DEFINE_HASHTABLE(name, bits) \
struct hlist_head name[1 << (bits)] = \
{ [0 ... ((1 << (bits)) - 1)] = HLIST_HEAD_INIT }

-#define DEFINE_READ_MOSTLY_HASHTABLE(name, bits) \
- struct hlist_head name[1 << (bits)] __read_mostly = \
- { [0 ... ((1 << (bits)) - 1)] = HLIST_HEAD_INIT }
-
#define DECLARE_HASHTABLE(name, bits) \
struct hlist_head name[1 << (bits)]

@@ -60,15 +61,6 @@ static inline void __hash_init(struct hlist_head *ht, unsigned int sz)
hlist_add_head(node, &hashtable[hash_min(key, HASH_BITS(hashtable))])

/**
- * hash_add_rcu - add an object to a rcu enabled hashtable
- * @hashtable: hashtable to add to
- * @node: the &struct hlist_node of the object to be added
- * @key: the key of the object to be added
- */
-#define hash_add_rcu(hashtable, node, key) \
- hlist_add_head_rcu(node, &hashtable[hash_min(key, HASH_BITS(hashtable))])
-
-/**
* hash_hashed - check whether an object is in any hashtable
* @node: the &struct hlist_node of the object to be checked
*/
@@ -107,15 +99,6 @@ static inline void hash_del(struct hlist_node *node)
}

/**
- * hash_del_rcu - remove an object from a rcu enabled hashtable
- * @node: &struct hlist_node of the object to remove
- */
-static inline void hash_del_rcu(struct hlist_node *node)
-{
- hlist_del_init_rcu(node);
-}
-
-/**
* hash_for_each - iterate over a hashtable
* @name: hashtable to iterate
* @bkt: integer to use as bucket loop cursor
@@ -128,18 +111,6 @@ static inline void hash_del_rcu(struct hlist_node *node)
hlist_for_each_entry(obj, &name[bkt], member)

/**
- * hash_for_each_rcu - iterate over a rcu enabled hashtable
- * @name: hashtable to iterate
- * @bkt: integer to use as bucket loop cursor
- * @obj: the type * to use as a loop cursor for each entry
- * @member: the name of the hlist_node within the struct
- */
-#define hash_for_each_rcu(name, bkt, obj, member) \
- for ((bkt) = 0, obj = NULL; obj == NULL && (bkt) < HASH_SIZE(name);\
- (bkt)++)\
- hlist_for_each_entry_rcu(obj, &name[bkt], member)
-
-/**
* hash_for_each_safe - iterate over a hashtable safe against removal of
* hash entry
* @name: hashtable to iterate
@@ -165,34 +136,6 @@ static inline void hash_del_rcu(struct hlist_node *node)
hlist_for_each_entry(obj, &name[hash_min(key, HASH_BITS(name))], member)

/**
- * hash_for_each_possible_rcu - iterate over all possible objects hashing to the
- * same bucket in an rcu enabled hashtable
- * in a rcu enabled hashtable
- * @name: hashtable to iterate
- * @obj: the type * to use as a loop cursor for each entry
- * @member: the name of the hlist_node within the struct
- * @key: the key of the objects to iterate over
- */
-#define hash_for_each_possible_rcu(name, obj, member, key) \
- hlist_for_each_entry_rcu(obj, &name[hash_min(key, HASH_BITS(name))],\
- member)
-
-/**
- * hash_for_each_possible_rcu_notrace - iterate over all possible objects hashing
- * to the same bucket in an rcu enabled hashtable in a rcu enabled hashtable
- * @name: hashtable to iterate
- * @obj: the type * to use as a loop cursor for each entry
- * @member: the name of the hlist_node within the struct
- * @key: the key of the objects to iterate over
- *
- * This is the same as hash_for_each_possible_rcu() except that it does
- * not do any RCU debugging or tracing.
- */
-#define hash_for_each_possible_rcu_notrace(name, obj, member, key) \
- hlist_for_each_entry_rcu_notrace(obj, \
- &name[hash_min(key, HASH_BITS(name))], member)
-
-/**
* hash_for_each_possible_safe - iterate over all possible objects hashing to the
* same bucket safe against removals
* @name: hashtable to iterate