Skip to content

Commit 1b61e70

Browse files
ying-xuedavem330
authored andcommitted
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>
1 parent 60c04ae commit 1b61e70

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

net/tipc/name_distr.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,21 @@
4141
/**
4242
* struct publ_list - list of publications made by this node
4343
* @list: circular list of publications
44-
* @list_size: number of entries in list
4544
*/
4645
struct publ_list {
4746
struct list_head list;
48-
u32 size;
4947
};
5048

5149
static struct publ_list publ_zone = {
5250
.list = LIST_HEAD_INIT(publ_zone.list),
53-
.size = 0,
5451
};
5552

5653
static struct publ_list publ_cluster = {
5754
.list = LIST_HEAD_INIT(publ_cluster.list),
58-
.size = 0,
5955
};
6056

6157
static struct publ_list publ_node = {
6258
.list = LIST_HEAD_INIT(publ_node.list),
63-
.size = 0,
6459
};
6560

6661
static struct publ_list *publ_lists[] = {
@@ -147,7 +142,6 @@ struct sk_buff *tipc_named_publish(struct publication *publ)
147142
struct distr_item *item;
148143

149144
list_add_tail(&publ->local_list, &publ_lists[publ->scope]->list);
150-
publ_lists[publ->scope]->size++;
151145

152146
if (publ->scope == TIPC_NODE_SCOPE)
153147
return NULL;
@@ -172,7 +166,6 @@ struct sk_buff *tipc_named_withdraw(struct publication *publ)
172166
struct distr_item *item;
173167

174168
list_del(&publ->local_list);
175-
publ_lists[publ->scope]->size--;
176169

177170
if (publ->scope == TIPC_NODE_SCOPE)
178171
return NULL;
@@ -200,16 +193,12 @@ static void named_distribute(struct sk_buff_head *list, u32 dnode,
200193
struct publication *publ;
201194
struct sk_buff *skb = NULL;
202195
struct distr_item *item = NULL;
203-
uint dsz = pls->size * ITEM_SIZE;
204196
uint msg_dsz = (tipc_node_get_mtu(dnode, 0) / ITEM_SIZE) * ITEM_SIZE;
205-
uint rem = dsz;
206-
uint msg_rem = 0;
197+
uint msg_rem = msg_dsz;
207198

208199
list_for_each_entry(publ, &pls->list, local_list) {
209200
/* Prepare next buffer: */
210201
if (!skb) {
211-
msg_rem = min_t(uint, rem, msg_dsz);
212-
rem -= msg_rem;
213202
skb = named_prepare_buf(PUBLICATION, msg_rem, dnode);
214203
if (!skb) {
215204
pr_warn("Bulk publication failure\n");
@@ -227,8 +216,14 @@ static void named_distribute(struct sk_buff_head *list, u32 dnode,
227216
if (!msg_rem) {
228217
__skb_queue_tail(list, skb);
229218
skb = NULL;
219+
msg_rem = msg_dsz;
230220
}
231221
}
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+
}
232227
}
233228

234229
/**

0 commit comments

Comments
 (0)