Revert "tcp: reduce POLLOUT events caused by TCP_NOTSENT_LOWAT"

This reverts commit 0d70e638ab.  It is
part of a series that breaks the kernel abi for Android.  For this
kernel tree, we do not care so much about KASAN, so it's not a big issue
to revert.  If it is needed in the future, it can be brought back in an
abi-safe way.

Bug: 161946584
Change-Id: Ie4c15028abda17a6ea6e023fb046c7b2e3ca6827
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
Greg Kroah-Hartman
2023-06-12 17:29:04 +00:00
parent 7432a5ca33
commit 2d7501f8af
3 changed files with 8 additions and 22 deletions

View File

@@ -1148,7 +1148,7 @@ struct proto {
unsigned int inuse_idx;
#endif
bool (*stream_memory_free)(const struct sock *sk, int wake);
bool (*stream_memory_free)(const struct sock *sk);
bool (*stream_memory_read)(const struct sock *sk);
/* Memory pressure */
void (*enter_memory_pressure)(struct sock *sk);
@@ -1230,29 +1230,19 @@ static inline void sk_refcnt_debug_release(const struct sock *sk)
#define sk_refcnt_debug_release(sk) do { } while (0)
#endif /* SOCK_REFCNT_DEBUG */
static inline bool __sk_stream_memory_free(const struct sock *sk, int wake)
static inline bool sk_stream_memory_free(const struct sock *sk)
{
if (sk->sk_wmem_queued >= sk->sk_sndbuf)
return false;
return sk->sk_prot->stream_memory_free ?
sk->sk_prot->stream_memory_free(sk, wake) : true;
}
static inline bool sk_stream_memory_free(const struct sock *sk)
{
return __sk_stream_memory_free(sk, 0);
}
static inline bool __sk_stream_is_writeable(const struct sock *sk, int wake)
{
return sk_stream_wspace(sk) >= sk_stream_min_wspace(sk) &&
__sk_stream_memory_free(sk, wake);
sk->sk_prot->stream_memory_free(sk) : true;
}
static inline bool sk_stream_is_writeable(const struct sock *sk)
{
return __sk_stream_is_writeable(sk, 0);
return sk_stream_wspace(sk) >= sk_stream_min_wspace(sk) &&
sk_stream_memory_free(sk);
}
static inline int sk_under_cgroup_hierarchy(struct sock *sk,

View File

@@ -1882,16 +1882,12 @@ static inline u32 tcp_notsent_lowat(const struct tcp_sock *tp)
return tp->notsent_lowat ?: READ_ONCE(net->ipv4.sysctl_tcp_notsent_lowat);
}
/* @wake is one when sk_stream_write_space() calls us.
* This sends EPOLLOUT only if notsent_bytes is half the limit.
* This mimics the strategy used in sock_def_write_space().
*/
static inline bool tcp_stream_memory_free(const struct sock *sk, int wake)
static inline bool tcp_stream_memory_free(const struct sock *sk)
{
const struct tcp_sock *tp = tcp_sk(sk);
u32 notsent_bytes = READ_ONCE(tp->write_seq) - tp->snd_nxt;
return (notsent_bytes << wake) < tcp_notsent_lowat(tp);
return notsent_bytes < tcp_notsent_lowat(tp);
}
#ifdef CONFIG_PROC_FS

View File

@@ -32,7 +32,7 @@ void sk_stream_write_space(struct sock *sk)
struct socket *sock = sk->sk_socket;
struct socket_wq *wq;
if (__sk_stream_is_writeable(sk, 1) && sock) {
if (sk_stream_is_writeable(sk) && sock) {
clear_bit(SOCK_NOSPACE, &sock->flags);
rcu_read_lock();