Skip to contentSkip to conversation

mm-damon-sysfs-schemes-move-memcg_path_to_id-to-sysfs-common.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Jun 2

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm/damon/sysfs-schemes: move memcg_path_to_id() to sysfs-common
has been removed from the -mm tree. Its filename was
mm-damon-sysfs-schemes-move-memcg_path_to_id-to-sysfs-common.patch

This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: SeongJae Park <[email protected]>
Subject: mm/damon/sysfs-schemes: move memcg_path_to_id() to sysfs-common
Date: Mon, 18 May 2026 16:41:13 -0700

The next commit will need to find the memcg id from the user-passed path to the memory cgroup, from sysfs.c. memcg_path_to_id() is doing that, but defined in sysfs-schemes.c as a static function. Move the function to sysfs-common.c and mark it as non-static, so that the next commit can reuse the function.

Cc David Hildenbrand <[email protected]>
Cc Jonathan Corbet <[email protected]>
Cc Liam R. Howlett <[email protected]>
Cc Lorenzo Stoakes <[email protected]>
Cc "Masami Hiramatsu (Google)" <[email protected]>
Cc Mathieu Desnoyers <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc Shuah Khan <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Suren Baghdasaryan <[email protected]>
Cc Vlastimil Babka <[email protected]>

---

 mm/damon/sysfs-common.c  |   41 +++++++++++++++++++++++++++++++++++++
 mm/damon/sysfs-common.h  |    2 +
 mm/damon/sysfs-schemes.c |   41 -------------------------------------
 3 files changed, 43 insertions(+), 41 deletions(-)
mm/damon/sysfs-common.c renamed from mm/damon/sysfs-common.c~mm-damon-sysfs-schemes-move-memcg_path_to_id-to-sysfs-common +41 -0
@@ -104,3 +104,44 @@ const struct kobj_type damon_sysfs_ul_ra
 	.default_groups = damon_sysfs_ul_range_groups,
 };
 
+
+static bool damon_sysfs_memcg_path_eq(struct mem_cgroup *memcg,
+		char *memcg_path_buf, char *path)
+{
+#ifdef CONFIG_MEMCG
+	cgroup_path(memcg->css.cgroup, memcg_path_buf, PATH_MAX);
+	if (sysfs_streq(memcg_path_buf, path))
+		return true;
+#endif /* CONFIG_MEMCG */
+	return false;
+}
+
+int damon_sysfs_memcg_path_to_id(char *memcg_path, u64 *id)
+{
+	struct mem_cgroup *memcg;
+	char *path;
+	bool found = false;
+
+	if (!memcg_path)
+		return -EINVAL;
+
+	path = kmalloc_array(PATH_MAX, sizeof(*path), GFP_KERNEL);
+	if (!path)
+		return -ENOMEM;
+
+	for (memcg = mem_cgroup_iter(NULL, NULL, NULL); memcg;
+			memcg = mem_cgroup_iter(NULL, memcg, NULL)) {
+		/* skip offlined memcg */
+		if (!mem_cgroup_online(memcg))
+			continue;
+		if (damon_sysfs_memcg_path_eq(memcg, path, memcg_path)) {
+			*id = mem_cgroup_id(memcg);
+			found = true;
+			mem_cgroup_iter_break(NULL, memcg);
+			break;
+		}
+	}
+
+	kfree(path);
+	return found ? 0 : -EINVAL;
+}
mm/damon/sysfs-common.h renamed from mm/damon/sysfs-common.h~mm-damon-sysfs-schemes-move-memcg_path_to_id-to-sysfs-common +2 -0
@@ -59,3 +59,5 @@ int damos_sysfs_set_quota_scores(struct
 void damos_sysfs_update_effective_quotas(
 		struct damon_sysfs_schemes *sysfs_schemes,
 		struct damon_ctx *ctx);
+
+int damon_sysfs_memcg_path_to_id(char *memcg_path, u64 *id);
mm/damon/sysfs-schemes.c renamed from mm/damon/sysfs-schemes.c~mm-damon-sysfs-schemes-move-memcg_path_to_id-to-sysfs-common +0 -41

47 lines not on this page · raw message

_

Patches currently in -mm which might be from [email protected] are

mm-damon-reclaim-handle-ctx-allocation-failure.patch mm-damonn-lru_sort-handle-ctx-allocation-failure.patch maintainers-add-testing-abi-documents-for-mm.patch