From: "Michal Koutný" <mkoutny@suse.com>
To: cgroups@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Cc: Tejun Heo <tj@kernel.org>, Zefan Li <lizefan.x@bytedance.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Jonathan Corbet <corbet@lwn.net>,
Michal Hocko <mhocko@kernel.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Shakeel Butt <shakeel.butt@linux.dev>,
Muchun Song <muchun.song@linux.dev>,
Andrew Morton <akpm@linux-foundation.org>,
"Jan Kratochvil (Azul)" <jkratochvil@azul.com>
Subject: [RFC PATCH v5 3/3] memcg: Notify on memory.max.effective changes
Date: Thu, 6 Jun 2024 17:22:32 +0200 [thread overview]
Message-ID: <20240606152232.20253-4-mkoutny@suse.com> (raw)
In-Reply-To: <20240606152232.20253-1-mkoutny@suse.com>
When users are interested in cgroup's effective limit, they typically
respond to the value somehow and therefore they should be notified when
the value changes. Use the standard menchanism of triggering a
modification of respective cgroup file.
Signed-off-by: Michal Koutný <mkoutny@suse.com>
---
include/linux/memcontrol.h | 2 ++
mm/memcontrol.c | 10 ++++++++++
2 files changed, 12 insertions(+)
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 030d34e9d117..79ecbbd87c4c 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -232,6 +232,8 @@ struct mem_cgroup {
/* memory.events and memory.events.local */
struct cgroup_file events_file;
struct cgroup_file events_local_file;
+ /* memory.max.effective */
+ struct cgroup_file mem_max_file;
/* handle for "memory.swap.events" */
struct cgroup_file swap_events_file;
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index a889385f6033..72c8e4693506 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -7022,6 +7022,7 @@ static ssize_t memory_max_write(struct kernfs_open_file *of,
char *buf, size_t nbytes, loff_t off)
{
struct mem_cgroup *memcg = mem_cgroup_from_css(of_css(of));
+ struct mem_cgroup *iter;
unsigned int nr_reclaims = MAX_RECLAIM_RETRIES;
bool drained = false;
unsigned long max;
@@ -7061,6 +7062,14 @@ static ssize_t memory_max_write(struct kernfs_open_file *of,
break;
}
+ /*
+ * Notification about limit tightening, not about coming OOMs, so it
+ * can be after reclaim.
+ */
+ for_each_mem_cgroup_tree(iter, memcg) {
+ cgroup_file_notify(&iter->mem_max_file);
+ }
+
memcg_wb_domain_size_changed(memcg);
return nbytes;
}
@@ -7275,6 +7284,7 @@ static struct cftype memory_files[] = {
{
.name = "max.effective",
.flags = CFTYPE_NOT_ON_ROOT,
+ .file_offset = offsetof(struct mem_cgroup, mem_max_file),
.seq_show = memory_max_effective_show,
},
{
--
2.45.1
next prev parent reply other threads:[~2024-06-06 15:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-06 15:22 [RFC PATCH v5 0/3] Add memory.max.effective for application's allocators Michal Koutný
2024-06-06 15:22 ` [RFC PATCH v5 1/3] memcg: Add memory.max.effective attribute Michal Koutný
2024-06-06 15:22 ` [RFC PATCH v5 2/3] memcg: Add memory.swap.max.effective like hierarchical_memsw_limit Michal Koutný
2024-06-06 15:22 ` Michal Koutný [this message]
2024-06-06 18:15 ` [RFC PATCH v5 0/3] Add memory.max.effective for application's allocators Roman Gushchin
2024-08-17 6:00 ` Jan Kratochvil
2024-08-19 16:42 ` Michal Koutný
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=20240606152232.20253-4-mkoutny@suse.com \
--to=mkoutny@suse.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=corbet@lwn.net \
--cc=hannes@cmpxchg.org \
--cc=jkratochvil@azul.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lizefan.x@bytedance.com \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=tj@kernel.org \
/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