mirror of
https://github.com/raspberrypi/linux.git
synced 2026-01-04 18:27:36 +00:00
net: annotate data-races around sk->sk_forward_alloc
Every time sk->sk_forward_alloc is read locklessly,
add a READ_ONCE().
Add sk_forward_alloc_add() helper to centralize updates,
to reduce number of WRITE_ONCE().
Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
66d58f046c
commit
5e6300e7b3
@@ -1045,7 +1045,7 @@ static int sock_reserve_memory(struct sock *sk, int bytes)
|
||||
mem_cgroup_uncharge_skmem(sk->sk_memcg, pages);
|
||||
return -ENOMEM;
|
||||
}
|
||||
sk->sk_forward_alloc += pages << PAGE_SHIFT;
|
||||
sk_forward_alloc_add(sk, pages << PAGE_SHIFT);
|
||||
|
||||
WRITE_ONCE(sk->sk_reserved_mem,
|
||||
sk->sk_reserved_mem + (pages << PAGE_SHIFT));
|
||||
@@ -3139,10 +3139,10 @@ int __sk_mem_schedule(struct sock *sk, int size, int kind)
|
||||
{
|
||||
int ret, amt = sk_mem_pages(size);
|
||||
|
||||
sk->sk_forward_alloc += amt << PAGE_SHIFT;
|
||||
sk_forward_alloc_add(sk, amt << PAGE_SHIFT);
|
||||
ret = __sk_mem_raise_allocated(sk, size, amt, kind);
|
||||
if (!ret)
|
||||
sk->sk_forward_alloc -= amt << PAGE_SHIFT;
|
||||
sk_forward_alloc_add(sk, -(amt << PAGE_SHIFT));
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(__sk_mem_schedule);
|
||||
@@ -3174,7 +3174,7 @@ void __sk_mem_reduce_allocated(struct sock *sk, int amount)
|
||||
void __sk_mem_reclaim(struct sock *sk, int amount)
|
||||
{
|
||||
amount >>= PAGE_SHIFT;
|
||||
sk->sk_forward_alloc -= amount << PAGE_SHIFT;
|
||||
sk_forward_alloc_add(sk, -(amount << PAGE_SHIFT));
|
||||
__sk_mem_reduce_allocated(sk, amount);
|
||||
}
|
||||
EXPORT_SYMBOL(__sk_mem_reclaim);
|
||||
|
||||
Reference in New Issue
Block a user