Skip to contentSkip to conversation

netfilter: don't need to initialize instance_table

PATCH In review Changli Gao 3 participants 5 messages Dec 9, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netfilter: don't need to initialize instance_table

Since instance_table is a static array, and has been zeroed already, we don't need to take CPU cycles to initialize it.

---
 net/netfilter/nfnetlink_queue.c |    3 ---
 1 file changed, 3 deletions(-)
net/netfilter/nfnetlink_queue.c +0 -3
index 68e67d1..9c80d6f 100644
@@ -893,9 +893,6 @@ static int __init nfnetlink_queue_init(void)
 {
 	int i, status = -ENOMEM;
 
-	for (i = 0; i < INSTANCE_BUCKETS; i++)
-		INIT_HLIST_HEAD(&instance_table[i]);
-
 	netlink_register_notifier(&nfqnl_rtnl_notifier);
 	status = nfnetlink_subsys_register(&nfqnl_subsys);
 	if (status < 0) {
#1 lore raw
Quoted 12 lines · Changli Gao

Since instance_table is a static array, and has been zeroed already, we don't need to take CPU cycles to initialize it.

---
net/netfilter/nfnetlink_queue.c | 3 ---

1 file changed, 3 deletions(-)
net/netfilter/nfnetlink_queue.c +0 -0
index 68e67d1..9c80d6f 100644

net/netfilter/nfnetlink_queue.c static int __init nfnetlink_queue_init(void) · line 898

Quoted 9 lines
net/netfilter/nfnetlink_queue.c +0 -3
@@ -893,9 +893,6 @@ static int __init nfnetlink_queue_init(void)
 {
 	int i, status = -ENOMEM;
 
-	for (i = 0; i < INSTANCE_BUCKETS; i++)
-		INIT_HLIST_HEAD(&instance_table[i]);
-
 	netlink_register_notifier(&nfqnl_rtnl_notifier);
 	status = nfnetlink_subsys_register(&nfqnl_subsys);
 	if (status < 0) {

This is here for correctness and documentation. If the hlist implementation changed, one would have a hard time figuring out the callsites which then need to add the initialization back.

#2 lore raw
Quoted 5 lines · Jan Engelhardt

This is here for correctness and documentation. If the hlist implementation changed, one would have a hard time figuring out the callsites which then need to add the initialization back.

I am quite sure there are other users rely on this assumption. So who wants to change the macro INIT_HLIST_HEAD() has to review all the code. It is a huge task, but can't be avoided.

For now, calling INIT_HLIST_HEAD() has no benefit, but wastes CPU cycles and increases the image size.

Thanks.

Signature · 2 lines
Regards,
Changli Gao([email protected])
maintainer
#3 lore raw

From: Changli Gao <[email protected]>
Date: Thu, 9 Dec 2010 22:27:24 +0800

Quoted 10 lines · Jan Engelhardt
Quoted 5 lines

This is here for correctness and documentation. If the hlist implementation changed, one would have a hard time figuring out the callsites which then need to add the initialization back.

I am quite sure there are other users rely on this assumption. So who wants to change the macro INIT_HLIST_HEAD() has to review all the code. It is a huge task, but can't be avoided.

Wrong. Adding debugging facilities to the hlist head would just require changing this macro.

That is, unless we apply patches like your's, which we won't.