linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] selftests: cgroup: fix test_kmem_memcg_deletion kernel mem check
@ 2023-08-17 19:57 Lucas Karpinski
  2023-08-17 20:02 ` Shakeel Butt
  2023-08-17 22:09 ` Roman Gushchin
  0 siblings, 2 replies; 3+ messages in thread
From: Lucas Karpinski @ 2023-08-17 19:57 UTC (permalink / raw)
  To: Andrew Morton, Johannes Weiner, Michal Hocko, Roman Gushchin,
	Shakeel Butt, Muchun Song, Tejun Heo, Zefan Li, Shuah Khan
  Cc: Muchun Song, cgroups, linux-mm, linux-kselftest, linux-kernel

Currently, not all kernel memory usage is being accounted for. This
commit switches to using the kernel entry within memory.stat which
already includes kernel_stack, pagetables, and slab. The kernel entry
also includes vmalloc and other additional kernel memory use cases which
were missing.

Signed-off-by: Lucas Karpinski <lkarpins@redhat.com>
---
Changes in v3:
    - Fixed test case description
    - Included anon, file, and sock as mentioned by Shakeel.

 tools/testing/selftests/cgroup/test_kmem.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/tools/testing/selftests/cgroup/test_kmem.c b/tools/testing/selftests/cgroup/test_kmem.c
index ed2e50bb1e76..c82f974b85c9 100644
--- a/tools/testing/selftests/cgroup/test_kmem.c
+++ b/tools/testing/selftests/cgroup/test_kmem.c
@@ -162,11 +162,11 @@ static int cg_run_in_subcgroups(const char *parent,
  * allocates some slab memory (mostly negative dentries) using 2 * NR_CPUS
  * threads. Then it checks the sanity of numbers on the parent level:
  * the total size of the cgroups should be roughly equal to
- * anon + file + slab + kernel_stack.
+ * anon + file + kernel + sock.
  */
 static int test_kmem_memcg_deletion(const char *root)
 {
-	long current, slab, anon, file, kernel_stack, pagetables, percpu, sock, sum;
+	long current, anon, file, kernel, sock, sum;
 	int ret = KSFT_FAIL;
 	char *parent;
 
@@ -184,29 +184,22 @@ static int test_kmem_memcg_deletion(const char *root)
 		goto cleanup;
 
 	current = cg_read_long(parent, "memory.current");
-	slab = cg_read_key_long(parent, "memory.stat", "slab ");
 	anon = cg_read_key_long(parent, "memory.stat", "anon ");
 	file = cg_read_key_long(parent, "memory.stat", "file ");
-	kernel_stack = cg_read_key_long(parent, "memory.stat", "kernel_stack ");
-	pagetables = cg_read_key_long(parent, "memory.stat", "pagetables ");
-	percpu = cg_read_key_long(parent, "memory.stat", "percpu ");
+	kernel = cg_read_key_long(parent, "memory.stat", "kernel ");
 	sock = cg_read_key_long(parent, "memory.stat", "sock ");
-	if (current < 0 || slab < 0 || anon < 0 || file < 0 ||
-	    kernel_stack < 0 || pagetables < 0 || percpu < 0 || sock < 0)
+	if (current < 0 || anon < 0 || file < 0 || kernel < 0 || sock < 0)
 		goto cleanup;
 
-	sum = slab + anon + file + kernel_stack + pagetables + percpu + sock;
+	sum = anon + file + kernel + sock;
 	if (abs(sum - current) < MAX_VMSTAT_ERROR) {
 		ret = KSFT_PASS;
 	} else {
 		printf("memory.current = %ld\n", current);
-		printf("slab + anon + file + kernel_stack = %ld\n", sum);
-		printf("slab = %ld\n", slab);
+		printf("anon + file + kernel + sock = %ld\n", sum);
 		printf("anon = %ld\n", anon);
 		printf("file = %ld\n", file);
-		printf("kernel_stack = %ld\n", kernel_stack);
-		printf("pagetables = %ld\n", pagetables);
-		printf("percpu = %ld\n", percpu);
+		printf("kernel = %ld\n", kernel);
 		printf("sock = %ld\n", sock);
 	}
 
-- 
2.41.0



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] selftests: cgroup: fix test_kmem_memcg_deletion kernel mem check
  2023-08-17 19:57 [PATCH v3] selftests: cgroup: fix test_kmem_memcg_deletion kernel mem check Lucas Karpinski
@ 2023-08-17 20:02 ` Shakeel Butt
  2023-08-17 22:09 ` Roman Gushchin
  1 sibling, 0 replies; 3+ messages in thread
From: Shakeel Butt @ 2023-08-17 20:02 UTC (permalink / raw)
  To: Lucas Karpinski
  Cc: Andrew Morton, Johannes Weiner, Michal Hocko, Roman Gushchin,
	Muchun Song, Tejun Heo, Zefan Li, Shuah Khan, cgroups, linux-mm,
	linux-kselftest, linux-kernel

On Thu, Aug 17, 2023 at 12:58 PM Lucas Karpinski <lkarpins@redhat.com> wrote:
>
> Currently, not all kernel memory usage is being accounted for. This
> commit switches to using the kernel entry within memory.stat which
> already includes kernel_stack, pagetables, and slab. The kernel entry
> also includes vmalloc and other additional kernel memory use cases which
> were missing.
>
> Signed-off-by: Lucas Karpinski <lkarpins@redhat.com>

Acked-by: Shakeel Butt <shakeelb@google.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] selftests: cgroup: fix test_kmem_memcg_deletion kernel mem check
  2023-08-17 19:57 [PATCH v3] selftests: cgroup: fix test_kmem_memcg_deletion kernel mem check Lucas Karpinski
  2023-08-17 20:02 ` Shakeel Butt
@ 2023-08-17 22:09 ` Roman Gushchin
  1 sibling, 0 replies; 3+ messages in thread
From: Roman Gushchin @ 2023-08-17 22:09 UTC (permalink / raw)
  To: Lucas Karpinski
  Cc: Andrew Morton, Johannes Weiner, Michal Hocko, Shakeel Butt,
	Muchun Song, Tejun Heo, Zefan Li, Shuah Khan, cgroups, linux-mm,
	linux-kselftest, linux-kernel

On Thu, Aug 17, 2023 at 03:57:48PM -0400, Lucas Karpinski wrote:
> Currently, not all kernel memory usage is being accounted for. This
> commit switches to using the kernel entry within memory.stat which
> already includes kernel_stack, pagetables, and slab. The kernel entry
> also includes vmalloc and other additional kernel memory use cases which
> were missing.
> 
> Signed-off-by: Lucas Karpinski <lkarpins@redhat.com>

Acked-by: Roman Gushchin <roman.gushchin@linux.dev>

Thanks!


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-08-17 22:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-17 19:57 [PATCH v3] selftests: cgroup: fix test_kmem_memcg_deletion kernel mem check Lucas Karpinski
2023-08-17 20:02 ` Shakeel Butt
2023-08-17 22:09 ` Roman Gushchin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox