diff options
author | Eric Dumazet <edumazet@google.com> | 2013-10-09 17:14:52 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-10-10 00:08:07 -0400 |
commit | ba537427d77cf274592f31ce94f4b4cadfad88b4 (patch) | |
tree | cf6398384e262e3460109a173daea105f88413ad /net | |
parent | 634fb979e8f3a70f04c1f2f519d0cd1142eb5c1a (diff) | |
download | blackbird-op-linux-ba537427d77cf274592f31ce94f4b4cadfad88b4.tar.gz blackbird-op-linux-ba537427d77cf274592f31ce94f4b4cadfad88b4.zip |
tcp: use ACCESS_ONCE() in tcp_update_pacing_rate()
sk_pacing_rate is read by sch_fq packet scheduler at any time,
with no synchronization, so make sure we update it in a
sensible way. ACCESS_ONCE() is how we instruct compiler
to not do stupid things, like using the memory location
as a temporary variable.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/tcp_input.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 47b8ab7dce9c..eb651a069a6c 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -755,7 +755,12 @@ static void tcp_update_pacing_rate(struct sock *sk) if (tp->srtt > 8 + 2) do_div(rate, tp->srtt); - sk->sk_pacing_rate = min_t(u64, rate, sk->sk_max_pacing_rate); + /* ACCESS_ONCE() is needed because sch_fq fetches sk_pacing_rate + * without any lock. We want to make sure compiler wont store + * intermediate values in this location. + */ + ACCESS_ONCE(sk->sk_pacing_rate) = min_t(u64, rate, + sk->sk_max_pacing_rate); } /* Calculate rto without backoff. This is the second half of Van Jacobson's |