diff options
author | Eric Dumazet <dada1@cosmosbay.com> | 2008-10-08 17:18:04 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-10-08 17:18:04 -0400 |
commit | 3c689b7320ae6f20dba6a8b71806a6c6fd604ee8 (patch) | |
tree | f9417dbd9f4aca952a1aba3e9a0f2a5a6e088dcd /net/ipv4/inet_connection_sock.c | |
parent | 9088c5609584684149f3fb5b065aa7f18dcb03ff (diff) |
inet: cleanup of local_port_range
I noticed sysctl_local_port_range[] and its associated seqlock
sysctl_local_port_range_lock were on separate cache lines.
Moreover, sysctl_local_port_range[] was close to unrelated
variables, highly modified, leading to cache misses.
Moving these two variables in a structure can help data
locality and moving this structure to read_mostly section
helps sharing of this data among cpus.
Cleanup of extern declarations (moved in include file where
they belong), and use of inet_get_local_port_range()
accessor instead of direct access to ports values.
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/inet_connection_sock.c')
-rw-r--r-- | net/ipv4/inet_connection_sock.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index 21fcc5a9045f..bd1278a2d828 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c | |||
@@ -30,20 +30,22 @@ EXPORT_SYMBOL(inet_csk_timer_bug_msg); | |||
30 | #endif | 30 | #endif |
31 | 31 | ||
32 | /* | 32 | /* |
33 | * This array holds the first and last local port number. | 33 | * This struct holds the first and last local port number. |
34 | */ | 34 | */ |
35 | int sysctl_local_port_range[2] = { 32768, 61000 }; | 35 | struct local_ports sysctl_local_ports __read_mostly = { |
36 | DEFINE_SEQLOCK(sysctl_port_range_lock); | 36 | .lock = SEQLOCK_UNLOCKED, |
37 | .range = { 32768, 61000 }, | ||
38 | }; | ||
37 | 39 | ||
38 | void inet_get_local_port_range(int *low, int *high) | 40 | void inet_get_local_port_range(int *low, int *high) |
39 | { | 41 | { |
40 | unsigned seq; | 42 | unsigned seq; |
41 | do { | 43 | do { |
42 | seq = read_seqbegin(&sysctl_port_range_lock); | 44 | seq = read_seqbegin(&sysctl_local_ports.lock); |
43 | 45 | ||
44 | *low = sysctl_local_port_range[0]; | 46 | *low = sysctl_local_ports.range[0]; |
45 | *high = sysctl_local_port_range[1]; | 47 | *high = sysctl_local_ports.range[1]; |
46 | } while (read_seqretry(&sysctl_port_range_lock, seq)); | 48 | } while (read_seqretry(&sysctl_local_ports.lock, seq)); |
47 | } | 49 | } |
48 | EXPORT_SYMBOL(inet_get_local_port_range); | 50 | EXPORT_SYMBOL(inet_get_local_port_range); |
49 | 51 | ||