diff options
author | Paolo Abeni <pabeni@redhat.com> | 2021-10-26 16:29:14 -0700 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2021-10-27 18:20:29 -0700 |
commit | 292e6077b04091d138bae6010fb9fdc958170d64 (patch) | |
tree | 70c8a775138f862290e0eebd741bc8a7358da601 /include/net | |
parent | 5823fc96d754d824bb298622055e8dd5e1252122 (diff) | |
download | linux-292e6077b04091d138bae6010fb9fdc958170d64.tar.gz linux-292e6077b04091d138bae6010fb9fdc958170d64.tar.bz2 linux-292e6077b04091d138bae6010fb9fdc958170d64.zip |
net: introduce sk_forward_alloc_get()
A later patch will change the MPTCP memory accounting schema
in such a way that MPTCP sockets will encode the total amount of
forward allocated memory in two separate fields (one for tx and
one for rx).
MPTCP sockets will use their own helper to provide the accurate
amount of fwd allocated memory.
To allow the above, this patch adds a new, optional, sk method to
fetch the fwd memory, wrap the call in a new helper and use it
where it is appropriate.
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'include/net')
-rw-r--r-- | include/net/sock.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/net/sock.h b/include/net/sock.h index df0e0efb1882..4f0280ad6c23 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -1210,6 +1210,8 @@ struct proto { unsigned int inuse_idx; #endif + int (*forward_alloc_get)(const struct sock *sk); + bool (*stream_memory_free)(const struct sock *sk, int wake); bool (*stream_memory_read)(const struct sock *sk); /* Memory pressure */ @@ -1217,6 +1219,7 @@ struct proto { void (*leave_memory_pressure)(struct sock *sk); atomic_long_t *memory_allocated; /* Current allocated memory. */ struct percpu_counter *sockets_allocated; /* Current number of sockets. */ + /* * Pressure flag: try to collapse. * Technical note: it is used by multiple contexts non atomically. @@ -1294,6 +1297,14 @@ static inline void sk_refcnt_debug_release(const struct sock *sk) INDIRECT_CALLABLE_DECLARE(bool tcp_stream_memory_free(const struct sock *sk, int wake)); +static inline int sk_forward_alloc_get(const struct sock *sk) +{ + if (!sk->sk_prot->forward_alloc_get) + return sk->sk_forward_alloc; + + return sk->sk_prot->forward_alloc_get(sk); +} + static inline bool __sk_stream_memory_free(const struct sock *sk, int wake) { if (READ_ONCE(sk->sk_wmem_queued) >= READ_ONCE(sk->sk_sndbuf)) |