Skip to content

Commit c2a2efb

Browse files
Eric Dumazetdavem330
authored andcommitted
net: remove bh disabling around percpu_counter accesses
Shaohua Li made percpu_counter irq safe in commit 098faf5 ("percpu_counter: make APIs irq safe") We can safely remove BH disable/enable sections around various percpu_counter manipulations. Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0a32788 commit c2a2efb

File tree

6 files changed

+3
-23
lines changed

6 files changed

+3
-23
lines changed

include/net/dst_ops.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,12 @@ static inline int dst_entries_get_fast(struct dst_ops *dst)
4646

4747
static inline int dst_entries_get_slow(struct dst_ops *dst)
4848
{
49-
int res;
50-
51-
local_bh_disable();
52-
res = percpu_counter_sum_positive(&dst->pcpuc_entries);
53-
local_bh_enable();
54-
return res;
49+
return percpu_counter_sum_positive(&dst->pcpuc_entries);
5550
}
5651

5752
static inline void dst_entries_add(struct dst_ops *dst, int val)
5853
{
59-
local_bh_disable();
6054
percpu_counter_add(&dst->pcpuc_entries, val);
61-
local_bh_enable();
6255
}
6356

6457
static inline int dst_entries_init(struct dst_ops *dst)

include/net/inet_frag.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,7 @@ static inline void add_frag_mem_limit(struct netns_frags *nf, int i)
164164

165165
static inline unsigned int sum_frag_mem_limit(struct netns_frags *nf)
166166
{
167-
unsigned int res;
168-
169-
local_bh_disable();
170-
res = percpu_counter_sum_positive(&nf->mem);
171-
local_bh_enable();
172-
173-
return res;
167+
return percpu_counter_sum_positive(&nf->mem);
174168
}
175169

176170
/* RFC 3168 support :

net/ipv4/inet_connection_sock.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -836,9 +836,8 @@ void inet_csk_destroy_sock(struct sock *sk)
836836

837837
sk_refcnt_debug_release(sk);
838838

839-
local_bh_disable();
840839
percpu_counter_dec(sk->sk_prot->orphan_count);
841-
local_bh_enable();
840+
842841
sock_put(sk);
843842
}
844843
EXPORT_SYMBOL(inet_csk_destroy_sock);

net/ipv4/proc.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,8 @@ static int sockstat_seq_show(struct seq_file *seq, void *v)
5757
unsigned int frag_mem;
5858
int orphans, sockets;
5959

60-
local_bh_disable();
6160
orphans = percpu_counter_sum_positive(&tcp_orphan_count);
6261
sockets = proto_sockets_allocated_sum_positive(&tcp_prot);
63-
local_bh_enable();
6462

6563
socket_seq_show(seq);
6664
seq_printf(seq, "TCP: inuse %d orphan %d tw %d alloc %d mem %ld\n",

net/ipv4/tcp.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,9 +420,7 @@ void tcp_init_sock(struct sock *sk)
420420
sk->sk_sndbuf = sysctl_tcp_wmem[1];
421421
sk->sk_rcvbuf = sysctl_tcp_rmem[1];
422422

423-
local_bh_disable();
424423
sk_sockets_allocated_inc(sk);
425-
local_bh_enable();
426424
}
427425
EXPORT_SYMBOL(tcp_init_sock);
428426

net/ipv4/tcp_ipv4.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,9 +1887,7 @@ void tcp_v4_destroy_sock(struct sock *sk)
18871887
tcp_free_fastopen_req(tp);
18881888
tcp_saved_syn_free(tp);
18891889

1890-
local_bh_disable();
18911890
sk_sockets_allocated_dec(sk);
1892-
local_bh_enable();
18931891
}
18941892
EXPORT_SYMBOL(tcp_v4_destroy_sock);
18951893

0 commit comments

Comments
 (0)