linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Sedlak <daniel.sedlak@cdn77.com>
To: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>, Jonathan Corbet <corbet@lwn.net>,
	Neal Cardwell <ncardwell@google.com>,
	Kuniyuki Iwashima <kuniyu@google.com>,
	David Ahern <dsahern@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Shakeel Butt <shakeel.butt@linux.dev>,
	Yosry Ahmed <yosry.ahmed@linux.dev>,
	linux-mm@kvack.org, netdev@vger.kernel.org
Cc: Matyas Hurtik <matyas.hurtik@cdn77.com>,
	Daniel Sedlak <danie.sedlak@cdn77.com>
Subject: [PATCH v2 net-next 2/2] mm/vmpressure: add tracepoint for socket pressure detection
Date: Mon, 14 Jul 2025 16:36:13 +0200	[thread overview]
Message-ID: <20250714143613.42184-3-daniel.sedlak@cdn77.com> (raw)
In-Reply-To: <20250714143613.42184-1-daniel.sedlak@cdn77.com>

From: Matyas Hurtik <matyas.hurtik@cdn77.com>

When the vmpressure function marks all sockets within a particular
cgroup as under pressure, it can silently reduce network throughput
significantly. This socket pressure is not currently signaled in any way
to the users, and it is difficult to detect which cgroup is under socket
pressure.

This patch adds a new tracepoint that is called when a cgroup is under
socket pressure.

Signed-off-by: Matyas Hurtik <matyas.hurtik@cdn77.com>
Co-developed-by: Daniel Sedlak <danie.sedlak@cdn77.com>
Signed-off-by: Daniel Sedlak <danie.sedlak@cdn77.com>
---
 include/trace/events/memcg.h | 25 +++++++++++++++++++++++++
 mm/vmpressure.c              |  3 +++
 2 files changed, 28 insertions(+)

diff --git a/include/trace/events/memcg.h b/include/trace/events/memcg.h
index dfe2f51019b4..19a51db73913 100644
--- a/include/trace/events/memcg.h
+++ b/include/trace/events/memcg.h
@@ -100,6 +100,31 @@ TRACE_EVENT(memcg_flush_stats,
 		__entry->force, __entry->needs_flush)
 );
 
+TRACE_EVENT(memcg_socket_under_pressure,
+
+	TP_PROTO(const struct mem_cgroup *memcg, unsigned long scanned,
+		unsigned long reclaimed),
+
+	TP_ARGS(memcg, scanned, reclaimed),
+
+	TP_STRUCT__entry(
+		__field(u64, id)
+		__field(unsigned long, scanned)
+		__field(unsigned long, reclaimed)
+	),
+
+	TP_fast_assign(
+		__entry->id = cgroup_id(memcg->css.cgroup);
+		__entry->scanned = scanned;
+		__entry->reclaimed = reclaimed;
+	),
+
+	TP_printk("memcg_id=%llu scanned=%lu reclaimed=%lu",
+		__entry->id,
+		__entry->scanned,
+		__entry->reclaimed)
+);
+
 #endif /* _TRACE_MEMCG_H */
 
 /* This part must be outside protection */
diff --git a/mm/vmpressure.c b/mm/vmpressure.c
index bd5183dfd879..aa9583066731 100644
--- a/mm/vmpressure.c
+++ b/mm/vmpressure.c
@@ -21,6 +21,8 @@
 #include <linux/printk.h>
 #include <linux/vmpressure.h>
 
+#include <trace/events/memcg.h>
+
 /*
  * The window size (vmpressure_win) is the number of scanned pages before
  * we try to analyze scanned/reclaimed ratio. So the window is used as a
@@ -317,6 +319,7 @@ void vmpressure(gfp_t gfp, struct mem_cgroup *memcg, bool tree,
 			 * pressure events can occur.
 			 */
 			WRITE_ONCE(memcg->socket_pressure, jiffies + HZ);
+			trace_memcg_socket_under_pressure(memcg, scanned, reclaimed);
 		}
 	}
 }
-- 
2.39.5



  parent reply	other threads:[~2025-07-14 14:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-14 14:36 [PATCH v2 net-next 0/2] account for TCP memory pressure signaled by cgroup Daniel Sedlak
2025-07-14 14:36 ` [PATCH v2 net-next 1/2] tcp: account for " Daniel Sedlak
2025-07-16 16:49   ` Shakeel Butt
2025-07-16 18:07     ` Kuniyuki Iwashima
2025-07-16 18:37       ` Shakeel Butt
2025-07-17 15:31       ` Daniel Sedlak
2025-07-17 17:26         ` Kuniyuki Iwashima
2025-07-14 14:36 ` Daniel Sedlak [this message]
2025-07-14 18:02   ` [PATCH v2 net-next 2/2] mm/vmpressure: add tracepoint for socket pressure detection Kuniyuki Iwashima
2025-07-15  7:01     ` Daniel Sedlak
2025-07-15 17:17       ` Kuniyuki Iwashima
2025-07-15 17:46         ` Kuniyuki Iwashima
2025-07-16  8:47           ` Daniel Sedlak

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=20250714143613.42184-3-daniel.sedlak@cdn77.com \
    --to=daniel.sedlak@cdn77.com \
    --cc=akpm@linux-foundation.org \
    --cc=corbet@lwn.net \
    --cc=danie.sedlak@cdn77.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=linux-mm@kvack.org \
    --cc=matyas.hurtik@cdn77.com \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shakeel.butt@linux.dev \
    --cc=yosry.ahmed@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox