All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: mptcp@lists.linux.dev
Subject: [PATCH mptcp-next 1/3] tcp: define macros for a couple reclaim thresholds
Date: Fri, 15 Oct 2021 11:25:23 +0200	[thread overview]
Message-ID: <0d3f747f3a1dcdc67e71fc93cc1d64eee9e6b803.1634289695.git.pabeni@redhat.com> (raw)
In-Reply-To: <cover.1634289695.git.pabeni@redhat.com>

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


  reply	other threads:[~2021-10-15  9:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-15  9:25 [PATCH mptcp-next 0/3] mptcp: refactor memory accounting Paolo Abeni
2021-10-15  9:25 ` Paolo Abeni [this message]
2021-10-15  9:25 ` [PATCH mptcp-next 2/3] net: introduce sk_forward_alloc_get() Paolo Abeni
2021-10-15  9:25 ` [PATCH mptcp-next 3/3] mptcp: allocate fwd memory separatelly on the rx and tx path Paolo Abeni
2021-10-15 10:33   ` mptcp: allocate fwd memory separatelly on the rx and tx path: Tests Results MPTCP CI
2021-10-15 11:47   ` [PATCH mptcp-next 3/3] mptcp: allocate fwd memory separatelly on the rx and tx path Paolo Abeni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0d3f747f3a1dcdc67e71fc93cc1d64eee9e6b803.1634289695.git.pabeni@redhat.com \
    --to=pabeni@redhat.com \
    --cc=mptcp@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.