diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2009-10-06 20:28:29 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-10-06 20:28:29 -0400 |
commit | bcdce7195e0eab55b37dbd53be53057f38006380 (patch) | |
tree | b4480a2e43561adf2060d1b8da818535cc91dc04 /include | |
parent | bd32cafc4707ccc1e66fafdb47fac42217569070 (diff) |
net: speedup sk_wake_async()
An incoming datagram must bring into cpu cache *lot* of cache lines,
in particular : (other parts omitted (hash chains, ip route cache...))
On 32bit arches :
offsetof(struct sock, sk_rcvbuf) =0x30 (read)
offsetof(struct sock, sk_lock) =0x34 (rw)
offsetof(struct sock, sk_sleep) =0x50 (read)
offsetof(struct sock, sk_rmem_alloc) =0x64 (rw)
offsetof(struct sock, sk_receive_queue)=0x74 (rw)
offsetof(struct sock, sk_forward_alloc)=0x98 (rw)
offsetof(struct sock, sk_callback_lock)=0xcc (rw)
offsetof(struct sock, sk_drops) =0xd8 (read if we add dropcount support, rw if frame dropped)
offsetof(struct sock, sk_filter) =0xf8 (read)
offsetof(struct sock, sk_socket) =0x138 (read)
offsetof(struct sock, sk_data_ready) =0x15c (read)
We can avoid sk->sk_socket and socket->fasync_list referencing on sockets
with no fasync() structures. (socket->fasync_list ptr is probably already in cache
because it shares a cache line with socket->wait, ie location pointed by sk->sk_sleep)
This avoids one cache line load per incoming packet for common cases (no fasync())
We can leave (or even move in a future patch) sk->sk_socket in a cold location
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/net/sock.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/include/net/sock.h b/include/net/sock.h index 1621935aad5b..98398bdec57d 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -504,6 +504,7 @@ enum sock_flags { | |||
504 | SOCK_TIMESTAMPING_SOFTWARE, /* %SOF_TIMESTAMPING_SOFTWARE */ | 504 | SOCK_TIMESTAMPING_SOFTWARE, /* %SOF_TIMESTAMPING_SOFTWARE */ |
505 | SOCK_TIMESTAMPING_RAW_HARDWARE, /* %SOF_TIMESTAMPING_RAW_HARDWARE */ | 505 | SOCK_TIMESTAMPING_RAW_HARDWARE, /* %SOF_TIMESTAMPING_RAW_HARDWARE */ |
506 | SOCK_TIMESTAMPING_SYS_HARDWARE, /* %SOF_TIMESTAMPING_SYS_HARDWARE */ | 506 | SOCK_TIMESTAMPING_SYS_HARDWARE, /* %SOF_TIMESTAMPING_SYS_HARDWARE */ |
507 | SOCK_FASYNC, /* fasync() active */ | ||
507 | }; | 508 | }; |
508 | 509 | ||
509 | static inline void sock_copy_flags(struct sock *nsk, struct sock *osk) | 510 | static inline void sock_copy_flags(struct sock *nsk, struct sock *osk) |
@@ -1396,7 +1397,7 @@ static inline unsigned long sock_wspace(struct sock *sk) | |||
1396 | 1397 | ||
1397 | static inline void sk_wake_async(struct sock *sk, int how, int band) | 1398 | static inline void sk_wake_async(struct sock *sk, int how, int band) |
1398 | { | 1399 | { |
1399 | if (sk->sk_socket && sk->sk_socket->fasync_list) | 1400 | if (sock_flag(sk, SOCK_FASYNC)) |
1400 | sock_wake_async(sk->sk_socket, how, band); | 1401 | sock_wake_async(sk->sk_socket, how, band); |
1401 | } | 1402 | } |
1402 | 1403 | ||