Skip to contentSkip to conversation

selftests-cgroup-fix-alloc_anon_noexit-instantly-freeing-memory.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message May 10, 2022

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: selftests: cgroup: fix alloc_anon_noexit() instantly freeing memory
has been removed from the -mm tree. Its filename was
selftests-cgroup-fix-alloc_anon_noexit-instantly-freeing-memory.patch

This patch was dropped because it was merged into mm-stable

------------------------------------------------------
From: Yosry Ahmed <[email protected]>
Subject: selftests: cgroup: fix alloc_anon_noexit() instantly freeing memory

Currently, alloc_anon_noexit() calls alloc_anon() which instantly frees the allocated memory. alloc_anon_noexit() is usually used with cg_run_nowait() to run a process in the background that allocates memory. It makes sense for the background process to keep the memory allocated and not instantly free it (otherwise there is no point of running it in the background).

---

 tools/testing/selftests/cgroup/test_memcontrol.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
tools/testing/selftests/cgroup/test_memcontrol.c renamed from tools/testing/selftests/cgroup/test_memcontrol.c~selftests-cgroup-fix-alloc_anon_noexit-instantly-freeing-memory +6 -2
@@ -211,13 +211,17 @@ static int alloc_pagecache_50M_noexit(co
 static int alloc_anon_noexit(const char *cgroup, void *arg)
 {
 	int ppid = getppid();
+	size_t size = (unsigned long)arg;
+	char *buf, *ptr;
 
-	if (alloc_anon(cgroup, arg))
-		return -1;
+	buf = malloc(size);
+	for (ptr = buf; ptr < buf + size; ptr += PAGE_SIZE)
+		*ptr = 0;
 
 	while (getppid() == ppid)
 		sleep(1);
 
+	free(buf);
 	return 0;
 }
 

_

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