aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/net.c
diff options
context:
space:
mode:
authorAllan Stephens <allan.stephens@windriver.com>2011-02-25 18:42:52 -0500
committerPaul Gortmaker <paul.gortmaker@windriver.com>2011-03-13 16:35:17 -0400
commit672d99e19a12b703c9e2d71ead8fb8b8a85a3886 (patch)
treecca078684f8adee7450cadcb565176f0a8b111ff /net/tipc/net.c
parentf831c963b5c20bec230edce89e25f369996be5db (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.c15
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 @@
39#include "name_distr.h" 39#include "name_distr.h"
40#include "subscr.h" 40#include "subscr.h"
41#include "port.h" 41#include "port.h"
42#include "node.h"
42#include "config.h" 43#include "config.h"
43 44
44/* 45/*
@@ -108,27 +109,21 @@
108*/ 109*/
109 110
110DEFINE_RWLOCK(tipc_net_lock); 111DEFINE_RWLOCK(tipc_net_lock);
111struct tipc_node **tipc_nodes;
112u32 tipc_highest_node;
113atomic_t tipc_num_links; 112atomic_t tipc_num_links;
114 113
115static int net_start(void) 114static int net_start(void)
116{ 115{
117 tipc_nodes = kcalloc(4096, sizeof(*tipc_nodes), GFP_ATOMIC);
118 tipc_highest_node = 0;
119 atomic_set(&tipc_num_links, 0); 116 atomic_set(&tipc_num_links, 0);
120 117
121 return tipc_nodes ? 0 : -ENOMEM; 118 return 0;
122} 119}
123 120
124static void net_stop(void) 121static void net_stop(void)
125{ 122{
126 u32 n_num; 123 struct tipc_node *node, *t_node;
127 124
128 for (n_num = 1; n_num <= tipc_highest_node; n_num++) 125 list_for_each_entry_safe(node, t_node, &tipc_node_list, list)
129 tipc_node_delete(tipc_nodes[n_num]); 126 tipc_node_delete(node);
130 kfree(tipc_nodes);
131 tipc_nodes = NULL;
132} 127}
133 128
134static void net_route_named_msg(struct sk_buff *buf) 129static void net_route_named_msg(struct sk_buff *buf)