summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/sock.h4
-rw-r--r--net/core/sock.c4
-rw-r--r--net/ipv4/inet_hashtables.c2
-rw-r--r--net/ipv4/udp.c2
-rw-r--r--net/ipv6/inet6_hashtables.c2
-rw-r--r--net/ipv6/udp.c2
6 files changed, 8 insertions, 8 deletions
diff --git a/include/net/sock.h b/include/net/sock.h
index c31a9ed86d5a..8f9adcfac41b 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -954,8 +954,8 @@ static inline void sk_incoming_cpu_update(struct sock *sk)
954{ 954{
955 int cpu = raw_smp_processor_id(); 955 int cpu = raw_smp_processor_id();
956 956
957 if (unlikely(sk->sk_incoming_cpu != cpu)) 957 if (unlikely(READ_ONCE(sk->sk_incoming_cpu) != cpu))
958 sk->sk_incoming_cpu = cpu; 958 WRITE_ONCE(sk->sk_incoming_cpu, cpu);
959} 959}
960 960
961static inline void sock_rps_record_flow_hash(__u32 hash) 961static inline void sock_rps_record_flow_hash(__u32 hash)
diff --git a/net/core/sock.c b/net/core/sock.c
index b8e758bcb6ad..ac78a570e43a 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1127,7 +1127,7 @@ set_rcvbuf:
1127 break; 1127 break;
1128 } 1128 }
1129 case SO_INCOMING_CPU: 1129 case SO_INCOMING_CPU:
1130 sk->sk_incoming_cpu = val; 1130 WRITE_ONCE(sk->sk_incoming_cpu, val);
1131 break; 1131 break;
1132 1132
1133 case SO_CNX_ADVICE: 1133 case SO_CNX_ADVICE:
@@ -1476,7 +1476,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
1476 break; 1476 break;
1477 1477
1478 case SO_INCOMING_CPU: 1478 case SO_INCOMING_CPU:
1479 v.val = sk->sk_incoming_cpu; 1479 v.val = READ_ONCE(sk->sk_incoming_cpu);
1480 break; 1480 break;
1481 1481
1482 case SO_MEMINFO: 1482 case SO_MEMINFO:
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index 97824864e40d..83fb00153018 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -240,7 +240,7 @@ static inline int compute_score(struct sock *sk, struct net *net,
240 return -1; 240 return -1;
241 241
242 score = sk->sk_family == PF_INET ? 2 : 1; 242 score = sk->sk_family == PF_INET ? 2 : 1;
243 if (sk->sk_incoming_cpu == raw_smp_processor_id()) 243 if (READ_ONCE(sk->sk_incoming_cpu) == raw_smp_processor_id())
244 score++; 244 score++;
245 } 245 }
246 return score; 246 return score;
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index d1ed160af202..1d58ce829dca 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -388,7 +388,7 @@ static int compute_score(struct sock *sk, struct net *net,
388 return -1; 388 return -1;
389 score += 4; 389 score += 4;
390 390
391 if (sk->sk_incoming_cpu == raw_smp_processor_id()) 391 if (READ_ONCE(sk->sk_incoming_cpu) == raw_smp_processor_id())
392 score++; 392 score++;
393 return score; 393 return score;
394} 394}
diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c
index cf60fae9533b..fbe9d4295eac 100644
--- a/net/ipv6/inet6_hashtables.c
+++ b/net/ipv6/inet6_hashtables.c
@@ -105,7 +105,7 @@ static inline int compute_score(struct sock *sk, struct net *net,
105 return -1; 105 return -1;
106 106
107 score = 1; 107 score = 1;
108 if (sk->sk_incoming_cpu == raw_smp_processor_id()) 108 if (READ_ONCE(sk->sk_incoming_cpu) == raw_smp_processor_id())
109 score++; 109 score++;
110 } 110 }
111 return score; 111 return score;
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 6324d3a8cb53..9fec580c968e 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -135,7 +135,7 @@ static int compute_score(struct sock *sk, struct net *net,
135 return -1; 135 return -1;
136 score++; 136 score++;
137 137
138 if (sk->sk_incoming_cpu == raw_smp_processor_id()) 138 if (READ_ONCE(sk->sk_incoming_cpu) == raw_smp_processor_id())
139 score++; 139 score++;
140 140
141 return score; 141 return score;