diff mbox

netfilter: don't need to initialize instance_table

Message ID 1291889421-10794-1-git-send-email-xiaosuo@gmail.com
State Rejected, archived
Delegated to: David Miller
Headers show

Commit Message

Changli Gao Dec. 9, 2010, 10:10 a.m. UTC
Since instance_table is a static array, and has been zeroed already, we
don't need to take CPU cycles to initialize it.

Signed-off-by: Changli Gao <xiaosuo@gmail.com>
---
 net/netfilter/nfnetlink_queue.c |    3 ---
 1 file changed, 3 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Jan Engelhardt Dec. 9, 2010, 2:03 p.m. UTC | #1
On Thursday 2010-12-09 11:10, Changli Gao wrote:

>Since instance_table is a static array, and has been zeroed already, we
>don't need to take CPU cycles to initialize it.
>
>Signed-off-by: Changli Gao <xiaosuo@gmail.com>
>---
> net/netfilter/nfnetlink_queue.c |    3 ---
> 1 file changed, 3 deletions(-)
>diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
>index 68e67d1..9c80d6f 100644
>--- a/net/netfilter/nfnetlink_queue.c
>+++ b/net/netfilter/nfnetlink_queue.c
>@@ -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.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Changli Gao Dec. 9, 2010, 2:27 p.m. UTC | #2
On Thu, Dec 9, 2010 at 10:03 PM, Jan Engelhardt <jengelh@medozas.de> wrote:
>
> 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.
David Miller Dec. 9, 2010, 7:56 p.m. UTC | #3
From: Changli Gao <xiaosuo@gmail.com>
Date: Thu,  9 Dec 2010 18:10:21 +0800

> Since instance_table is a static array, and has been zeroed already, we
> don't need to take CPU cycles to initialize it.
> 
> Signed-off-by: Changli Gao <xiaosuo@gmail.com>

Adding a dependency on the implementation of HLISTs is not a good
idea, I would not apply this patch.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller Dec. 9, 2010, 8:05 p.m. UTC | #4
From: Changli Gao <xiaosuo@gmail.com>
Date: Thu, 9 Dec 2010 22:27:24 +0800

> On Thu, Dec 9, 2010 at 10:03 PM, Jan Engelhardt <jengelh@medozas.de> wrote:
>>
>> 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.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
index 68e67d1..9c80d6f 100644
--- a/net/netfilter/nfnetlink_queue.c
+++ b/net/netfilter/nfnetlink_queue.c
@@ -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) {