Revert "tcp: switch orphan_count to bare per-cpu counters"

This reverts commit a342cb4772 which is
commit 19757cebf0c5016a1f36f7fe9810a9f0b33c0832 upstream.

The commit breaks the abi and we don't really need to worry about
Android on systems with greater than 256 CPUs at this point in time.

Bug: 161946584
Fixes: a342cb4772 ("tcp: switch orphan_count to bare per-cpu counters")
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Ifeb445b4490db185eacc379fbcab2a3ed3b966fb
This commit is contained in:
Greg Kroah-Hartman
2021-11-19 14:21:03 +01:00
parent e101be336e
commit 971945b722
11 changed files with 38 additions and 49 deletions

View File

@@ -48,9 +48,7 @@
extern struct inet_hashinfo tcp_hashinfo;
DECLARE_PER_CPU(unsigned int, tcp_orphan_count);
int tcp_orphan_count_sum(void);
extern struct percpu_counter tcp_orphan_count;
void tcp_time_wait(struct sock *sk, int state, int timeo);
#define MAX_TCP_HEADER L1_CACHE_ALIGN(128 + MAX_HEADER)
@@ -292,6 +290,19 @@ static inline bool tcp_out_of_memory(struct sock *sk)
void sk_forced_mem_schedule(struct sock *sk, int size);
static inline bool tcp_too_many_orphans(struct sock *sk, int shift)
{
struct percpu_counter *ocp = sk->sk_prot->orphan_count;
int orphans = percpu_counter_read_positive(ocp);
if (orphans << shift > sysctl_tcp_max_orphans) {
orphans = percpu_counter_sum_positive(ocp);
if (orphans << shift > sysctl_tcp_max_orphans)
return true;
}
return false;
}
bool tcp_check_oom(struct sock *sk, int shift);