From: "Jan Kratochvil (Azul)" <jkratochvil@azul.com>
To: Waiman Long <longman@redhat.com>
Cc: cgroups@vger.kernel.org
Subject: [PATCH v2] Port hierarchical_{memory,swap}_limit cgroup1->cgroup2
Date: Sun, 11 Feb 2024 20:49:32 +0800 [thread overview]
Message-ID: <ZcjCXH8HJvshxUGb@host1.jankratochvil.net> (raw)
In-Reply-To: <284aefe1-fe85-48e9-b0f1-25e28be77198@redhat.com>
Hello Waiman,
On Fri, 09 Feb 2024 23:51:54 +0800, Waiman Long wrote:
> I don't think we use mi->memsw in cgroup v2, only memory and swap should
> be used.
you are right, thanks:
struct mem_cgroup {
...
union {
struct page_counter swap; /* v2 only */
struct page_counter memsw; /* v1 only */
};
Jan Kratochvil
Signed-off-by: Jan Kratochvil (Azul) <jkratochvil@azul.com>
mm/memcontrol.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 46d8d0211..2631dd810 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1636,6 +1636,8 @@ static inline unsigned long memcg_page_state_local_output(
static void memcg_stat_format(struct mem_cgroup *memcg, struct seq_buf *s)
{
int i;
+ unsigned long memory, swap;
+ struct mem_cgroup *mi;
/*
* Provide statistics on the state of the memory subsystem as
@@ -1682,6 +1684,17 @@ static void memcg_stat_format(struct mem_cgroup *memcg, struct seq_buf *s)
memcg_events(memcg, memcg_vm_event_stat[i]));
}
+ /* Hierarchical information */
+ memory = swap = PAGE_COUNTER_MAX;
+ for (mi = memcg; mi; mi = parent_mem_cgroup(mi)) {
+ memory = min(memory, READ_ONCE(mi->memory.max));
+ swap = min(swap, READ_ONCE(mi->swap.max));
+ }
+ seq_buf_printf(s, "hierarchical_memory_limit %llu\n",
+ (u64)memory * PAGE_SIZE);
+ seq_buf_printf(s, "hierarchical_swap_limit %llu\n",
+ (u64)swap * PAGE_SIZE);
+
/* The above should easily fit into one page */
WARN_ON_ONCE(seq_buf_has_overflowed(s));
}
next prev parent reply other threads:[~2024-02-11 12:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-09 14:48 [PATCH] Port hierarchical_mem{ory,sw}_limit cgroup1->cgroup2 Jan Kratochvil (Azul)
2024-02-09 15:51 ` Waiman Long
2024-02-11 12:49 ` Jan Kratochvil (Azul) [this message]
2024-02-11 18:01 ` [PATCH v2] Port hierarchical_{memory,swap}_limit cgroup1->cgroup2 Waiman Long
-- strict thread matches above, loose matches on Subject: below --
2024-02-12 4:10 Jan Kratochvil (Azul)
2024-02-12 15:00 ` Michal Koutný
2024-02-12 15:26 ` Waiman Long
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=ZcjCXH8HJvshxUGb@host1.jankratochvil.net \
--to=jkratochvil@azul.com \
--cc=cgroups@vger.kernel.org \
--cc=longman@redhat.com \
/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