Thread (105 messages) 105 messages, 13 authors, 2008-11-24

Re: [PATCH 2/2] udp: RCU handling for Unicast packets.

From: Eric Dumazet <hidden>
Date: 2008-10-30 07:05:17

Eric Dumazet a écrit :
David Miller a écrit :
quoted
From: Eric Dumazet <redacted>
Date: Wed, 29 Oct 2008 23:08:30 +0100
quoted
@@ -1746,7 +1753,7 @@ void __init udp_table_init(struct udp_table 
*table)
     int i;
 
     for (i = 0; i < UDP_HTABLE_SIZE; i++) {
-        INIT_HLIST_HEAD(&table->hash[i].head);
+        table->hash[i].head.first = (struct hlist_node *)i;
Please hide this behind some list.h interface macro, even something
as simple as INIT_HLIST_HEAD_NULLS(X, index) would suffice.

And as Corey said, the code needs more comments for something as
clever as this! :-)
Yes I agree 100%, please give me one day to prepare a real patch,
or else akpm will kill us :)
If we design something that could be reused, say for TCP sockets, we need
to be able to handle very large number of 'NULL' pointers, say, up to 64*1024*1024

So lets use the low order bit, set to one for "NULL" pointers, and 0 for regular pointers.

This gives us 31 bits (or 63 bits) to store any valuable info :)

and all ...._nulls() macros would not need to know the max value (UDP_HTABLE_SIZE in UDP case),
since all they have to do is a test ((unsigned long)pos & 1)

At iterator exit, pos would contain the 'index' value, (pos >> 1), to hide this
implementation detail.

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help