diff options
author | Allan Stephens <allan.stephens@windriver.com> | 2011-02-25 18:42:52 -0500 |
---|---|---|
committer | Paul Gortmaker <paul.gortmaker@windriver.com> | 2011-03-13 16:35:17 -0400 |
commit | 672d99e19a12b703c9e2d71ead8fb8b8a85a3886 (patch) | |
tree | cca078684f8adee7450cadcb565176f0a8b111ff /net/tipc/net.c | |
parent | f831c963b5c20bec230edce89e25f369996be5db (diff) |
tipc: Convert node object array to a hash table
Replaces the dynamically allocated array of pointers to the cluster's
node objects with a static hash table. Hash collisions are resolved
using chaining, with a typical hash chain having only a single node,
to avoid degrading performance during processing of incoming packets.
The conversion to a hash table reduces the memory requirements for
TIPC's node table to approximately the same size it had prior to
the previous commit.
In addition to the hash table itself, TIPC now also maintains a
linked list for the node objects, sorted by ascending network address.
This list allows TIPC to continue sending responses to user space
applications that request node and link information in sorted order.
The list also improves performance when name table update messages are
sent by making it easier to identify the nodes that must be notified.
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Diffstat (limited to 'net/tipc/net.c')
-rw-r--r-- | net/tipc/net.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/net/tipc/net.c b/net/tipc/net.c index b5b337f5516d..cce8d086f173 100644 --- a/net/tipc/net.c +++ b/net/tipc/net.c @@ -39,6 +39,7 @@ #include "name_distr.h" #include "subscr.h" #include "port.h" +#include "node.h" #include "config.h" /* @@ -108,27 +109,21 @@ */ DEFINE_RWLOCK(tipc_net_lock); -struct tipc_node **tipc_nodes; -u32 tipc_highest_node; atomic_t tipc_num_links; static int net_start(void) { - tipc_nodes = kcalloc(4096, sizeof(*tipc_nodes), GFP_ATOMIC); - tipc_highest_node = 0; atomic_set(&tipc_num_links, 0); - return tipc_nodes ? 0 : -ENOMEM; + return 0; } static void net_stop(void) { - u32 n_num; + struct tipc_node *node, *t_node; - for (n_num = 1; n_num <= tipc_highest_node; n_num++) - tipc_node_delete(tipc_nodes[n_num]); - kfree(tipc_nodes); - tipc_nodes = NULL; + list_for_each_entry_safe(node, t_node, &tipc_node_list, list) + tipc_node_delete(node); } static void net_route_named_msg(struct sk_buff *buf) |