Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
forked fromtorvalds/linux

Commit6c7c98b

Browse files
Paolo Abenidavem330
Paolo Abeni
authored andcommitted
sock: avoid dirtying sk_stamp, if possible
sock_recv_ts_and_drops() unconditionally set sk->sk_stamp forevery packet, even if the SOCK_TIMESTAMP flag is not set in therelated socket.If selinux is enabled, this cause a cache miss for every packetsince sk->sk_stamp and sk->sk_security share the same cacheline.With this change sk_stamp is set only if the SOCK_TIMESTAMPflag is set, and is cleared for the first packet, so that the userperceived behavior is unchanged.This gives up to 5% speed-up under udp-flood with small packets.Signed-off-by: Paolo Abeni <pabeni@redhat.com>Acked-by: Eric Dumazet <edumazet@google.com>Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent7801a32 commit6c7c98b

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

‎include/net/sock.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2239,6 +2239,7 @@ sock_recv_timestamp(struct msghdr *msg, struct sock *sk, struct sk_buff *skb)
22392239
void__sock_recv_ts_and_drops(structmsghdr*msg,structsock*sk,
22402240
structsk_buff*skb);
22412241

2242+
#defineSK_DEFAULT_STAMP (-1L * NSEC_PER_SEC)
22422243
staticinlinevoidsock_recv_ts_and_drops(structmsghdr*msg,structsock*sk,
22432244
structsk_buff*skb)
22442245
{
@@ -2249,8 +2250,10 @@ static inline void sock_recv_ts_and_drops(struct msghdr *msg, struct sock *sk,
22492250

22502251
if (sk->sk_flags&FLAGS_TS_OR_DROPS||sk->sk_tsflags&TSFLAGS_ANY)
22512252
__sock_recv_ts_and_drops(msg,sk,skb);
2252-
else
2253+
elseif (unlikely(sk->sk_flags&SOCK_TIMESTAMP))
22532254
sk->sk_stamp=skb->tstamp;
2255+
elseif (unlikely(sk->sk_stamp==SK_DEFAULT_STAMP))
2256+
sk->sk_stamp=0;
22542257
}
22552258

22562259
void__sock_tx_timestamp(__u16tsflags,__u8*tx_flags);

‎net/core/sock.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2613,7 +2613,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
26132613
sk->sk_rcvtimeo=MAX_SCHEDULE_TIMEOUT;
26142614
sk->sk_sndtimeo=MAX_SCHEDULE_TIMEOUT;
26152615

2616-
sk->sk_stamp=ktime_set(-1L,0);
2616+
sk->sk_stamp=SK_DEFAULT_STAMP;
26172617

26182618
#ifdefCONFIG_NET_RX_BUSY_POLL
26192619
sk->sk_napi_id=0;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp