[PATCH mptcp-next v2 1/3] tcp: define macros for a couple reclaim thresholds

Paolo Abeni posted 3 patches 4 years, 3 months ago
Maintainers: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>, Jamal Hadi Salim <jhs@mojatatu.com>, "David S. Miller" <davem@davemloft.net>, Matthieu Baerts <matthieu.baerts@tessares.net>, Jiri Pirko <jiri@resnulli.us>, Cong Wang <xiyou.wangcong@gmail.com>, Jakub Kicinski <kuba@kernel.org>, Mat Martineau <mathew.j.martineau@linux.intel.com>, David Ahern <dsahern@kernel.org>
[PATCH mptcp-next v2 1/3] tcp: define macros for a couple reclaim thresholds
Posted by Paolo Abeni 4 years, 3 months ago
A following patch is going to implment for the MPTCP protocol
a similar reclaim schema, with different locking.

Let's define a couple of macros for the used thresholds, so
that the latter code will be more easily maintainable.

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 include/net/sock.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/include/net/sock.h b/include/net/sock.h
index d08ab55fa4a0..9c5d0502090f 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1568,6 +1568,12 @@ static inline void sk_mem_charge(struct sock *sk, int size)
 	sk->sk_forward_alloc -= size;
 }
 
+/* the following macros control control memory reclaiming in
+ * sk_mem_uncharge()
+ */
+#define SK_RECLAIM_THRESHOLD	(1 << 21)
+#define SK_RECLAIM_CHUNK	(1 << 20)
+
 static inline void sk_mem_uncharge(struct sock *sk, int size)
 {
 	int reclaimable;
@@ -1584,8 +1590,8 @@ static inline void sk_mem_uncharge(struct sock *sk, int size)
 	 * If we reach 2 MBytes, reclaim 1 MBytes right now, there is
 	 * no need to hold that much forward allocation anyway.
 	 */
-	if (unlikely(reclaimable >= 1 << 21))
-		__sk_mem_reclaim(sk, 1 << 20);
+	if (unlikely(reclaimable >= SK_RECLAIM_THRESHOLD))
+		__sk_mem_reclaim(sk, SK_RECLAIM_CHUNK);
 }
 
 static inline void sk_wmem_free_skb(struct sock *sk, struct sk_buff *skb)
-- 
2.26.3


Re: [PATCH mptcp-next v2 1/3] tcp: define macros for a couple reclaim thresholds
Posted by Mat Martineau 4 years, 3 months ago
On Fri, 15 Oct 2021, Paolo Abeni wrote:

> A following patch is going to implment for the MPTCP protocol
> a similar reclaim schema, with different locking.
>
> Let's define a couple of macros for the used thresholds, so
> that the latter code will be more easily maintainable.
>
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
> ---
> include/net/sock.h | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)

Acked-by: Mat Martineau <mathew.j.martineau@linux.intel.com>

--
Mat Martineau
Intel