aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYing Xue <ying.xue@windriver.com>2014-12-02 02:00:23 -0500
committerDavid S. Miller <davem@davemloft.net>2014-12-08 20:39:55 -0500
commit1b61e70ad13e1c907f143c3b0a1694df640639c0 (patch)
treef36b4e8e5a25e8c02fea68cfe5bf54d097cc788d
parent60c04aecd8a72a84869308bdf2289a7aabb9a88c (diff)
tipc: remove size variable from publ_list struct
The size variable is introduced in publ_list struct to help us exactly calculate SKB buffer sizes needed by publications when all publications in name table are delivered in bulk in named_distribute(). But if publication SKB buffer size is assumed to MTU, the size variable in publ_list struct can be completely eliminated at the cost of wasting a bit memory space for last SKB. Signed-off-by: Ying Xue <ying.xue@windriver.com> Signed-off-by: Tero Aho <tero.aho@coriant.com> Reviewed-by: Erik Hugne <erik.hugne@ericsson.com> Reviewed-by: Jon Maloy <jon.maloy@ericsson.com> Tested-by: Erik Hugne <erik.hugne@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/tipc/name_distr.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c
index 56248db75274..628cd85b647e 100644
--- a/net/tipc/name_distr.c
+++ b/net/tipc/name_distr.c
@@ -41,26 +41,21 @@
41/** 41/**
42 * struct publ_list - list of publications made by this node 42 * struct publ_list - list of publications made by this node
43 * @list: circular list of publications 43 * @list: circular list of publications
44 * @list_size: number of entries in list
45 */ 44 */
46struct publ_list { 45struct publ_list {
47 struct list_head list; 46 struct list_head list;
48 u32 size;
49}; 47};
50 48
51static struct publ_list publ_zone = { 49static struct publ_list publ_zone = {
52 .list = LIST_HEAD_INIT(publ_zone.list), 50 .list = LIST_HEAD_INIT(publ_zone.list),
53 .size = 0,
54}; 51};
55 52
56static struct publ_list publ_cluster = { 53static struct publ_list publ_cluster = {
57 .list = LIST_HEAD_INIT(publ_cluster.list), 54 .list = LIST_HEAD_INIT(publ_cluster.list),
58 .size = 0,
59}; 55};
60 56
61static struct publ_list publ_node = { 57static struct publ_list publ_node = {
62 .list = LIST_HEAD_INIT(publ_node.list), 58 .list = LIST_HEAD_INIT(publ_node.list),
63 .size = 0,
64}; 59};
65 60
66static struct publ_list *publ_lists[] = { 61static struct publ_list *publ_lists[] = {
@@ -147,7 +142,6 @@ struct sk_buff *tipc_named_publish(struct publication *publ)
147 struct distr_item *item; 142 struct distr_item *item;
148 143
149 list_add_tail(&publ->local_list, &publ_lists[publ->scope]->list); 144 list_add_tail(&publ->local_list, &publ_lists[publ->scope]->list);
150 publ_lists[publ->scope]->size++;
151 145
152 if (publ->scope == TIPC_NODE_SCOPE) 146 if (publ->scope == TIPC_NODE_SCOPE)
153 return NULL; 147 return NULL;
@@ -172,7 +166,6 @@ struct sk_buff *tipc_named_withdraw(struct publication *publ)
172 struct distr_item *item; 166 struct distr_item *item;
173 167
174 list_del(&publ->local_list); 168 list_del(&publ->local_list);
175 publ_lists[publ->scope]->size--;
176 169
177 if (publ->scope == TIPC_NODE_SCOPE) 170 if (publ->scope == TIPC_NODE_SCOPE)
178 return NULL; 171 return NULL;
@@ -200,16 +193,12 @@ static void named_distribute(struct sk_buff_head *list, u32 dnode,
200 struct publication *publ; 193 struct publication *publ;
201 struct sk_buff *skb = NULL; 194 struct sk_buff *skb = NULL;
202 struct distr_item *item = NULL; 195 struct distr_item *item = NULL;
203 uint dsz = pls->size * ITEM_SIZE;
204 uint msg_dsz = (tipc_node_get_mtu(dnode, 0) / ITEM_SIZE) * ITEM_SIZE; 196 uint msg_dsz = (tipc_node_get_mtu(dnode, 0) / ITEM_SIZE) * ITEM_SIZE;
205 uint rem = dsz; 197 uint msg_rem = msg_dsz;
206 uint msg_rem = 0;
207 198
208 list_for_each_entry(publ, &pls->list, local_list) { 199 list_for_each_entry(publ, &pls->list, local_list) {
209 /* Prepare next buffer: */ 200 /* Prepare next buffer: */
210 if (!skb) { 201 if (!skb) {
211 msg_rem = min_t(uint, rem, msg_dsz);
212 rem -= msg_rem;
213 skb = named_prepare_buf(PUBLICATION, msg_rem, dnode); 202 skb = named_prepare_buf(PUBLICATION, msg_rem, dnode);
214 if (!skb) { 203 if (!skb) {
215 pr_warn("Bulk publication failure\n"); 204 pr_warn("Bulk publication failure\n");
@@ -227,8 +216,14 @@ static void named_distribute(struct sk_buff_head *list, u32 dnode,
227 if (!msg_rem) { 216 if (!msg_rem) {
228 __skb_queue_tail(list, skb); 217 __skb_queue_tail(list, skb);
229 skb = NULL; 218 skb = NULL;
219 msg_rem = msg_dsz;
230 } 220 }
231 } 221 }
222 if (skb) {
223 msg_set_size(buf_msg(skb), INT_H_SIZE + (msg_dsz - msg_rem));
224 skb_trim(skb, INT_H_SIZE + (msg_dsz - msg_rem));
225 __skb_queue_tail(list, skb);
226 }
232} 227}
233 228
234/** 229/**