All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Weiner <hannes@cmpxchg.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Tejun Heo <tj@kernel.org>, Michal Hocko <mhocko@suse.com>,
	Roman Gushchin <guro@fb.com>, Shakeel Butt <shakeelb@google.com>,
	linux-mm@kvack.org, cgroups@vger.kernel.org,
	linux-kernel@vger.kernel.org, kernel-team@fb.com
Subject: [PATCH v3 8/8] kselftests: cgroup: update kmem test for new vmstat implementation
Date: Tue,  9 Feb 2021 11:33:04 -0500	[thread overview]
Message-ID: <20210209163304.77088-9-hannes@cmpxchg.org> (raw)
In-Reply-To: <20210209163304.77088-1-hannes@cmpxchg.org>

With memcg having switched to rstat, memory.stat output is precise.
Update the cgroup selftest to reflect the expectations and error
tolerances of the new implementation.

Also add newly tracked types of memory to the memory.stat side of the
equation, since they're included in memory.current and could throw
false positives.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: Shakeel Butt <shakeelb@google.com>
---
 tools/testing/selftests/cgroup/test_kmem.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/tools/testing/selftests/cgroup/test_kmem.c b/tools/testing/selftests/cgroup/test_kmem.c
index 0941aa16157e..22b31ebb3513 100644
--- a/tools/testing/selftests/cgroup/test_kmem.c
+++ b/tools/testing/selftests/cgroup/test_kmem.c
@@ -19,12 +19,12 @@
 
 
 /*
- * Memory cgroup charging and vmstat data aggregation is performed using
- * percpu batches 32 pages big (look at MEMCG_CHARGE_BATCH). So the maximum
- * discrepancy between charge and vmstat entries is number of cpus multiplied
- * by 32 pages multiplied by 2.
+ * Memory cgroup charging is performed using percpu batches 32 pages
+ * big (look at MEMCG_CHARGE_BATCH), whereas memory.stat is exact. So
+ * the maximum discrepancy between charge and vmstat entries is number
+ * of cpus multiplied by 32 pages.
  */
-#define MAX_VMSTAT_ERROR (4096 * 32 * 2 * get_nprocs())
+#define MAX_VMSTAT_ERROR (4096 * 32 * get_nprocs())
 
 
 static int alloc_dcache(const char *cgroup, void *arg)
@@ -162,7 +162,7 @@ static int cg_run_in_subcgroups(const char *parent,
  */
 static int test_kmem_memcg_deletion(const char *root)
 {
-	long current, slab, anon, file, kernel_stack, sum;
+	long current, slab, anon, file, kernel_stack, pagetables, percpu, sock, sum;
 	int ret = KSFT_FAIL;
 	char *parent;
 
@@ -184,11 +184,14 @@ static int test_kmem_memcg_deletion(const char *root)
 	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 ");
+	sock = cg_read_key_long(parent, "memory.stat", "sock ");
 	if (current < 0 || slab < 0 || anon < 0 || file < 0 ||
-	    kernel_stack < 0)
+	    kernel_stack < 0 || pagetables < 0 || percpu < 0 || sock < 0)
 		goto cleanup;
 
-	sum = slab + anon + file + kernel_stack;
+	sum = slab + anon + file + kernel_stack + pagetables + percpu + sock;
 	if (abs(sum - current) < MAX_VMSTAT_ERROR) {
 		ret = KSFT_PASS;
 	} else {
@@ -198,6 +201,9 @@ static int test_kmem_memcg_deletion(const char *root)
 		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("sock = %ld\n", sock);
 	}
 
 cleanup:
-- 
2.30.0


  parent reply	other threads:[~2021-02-09 16:35 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-09 16:32 [PATCH v3 0/8] mm: memcontrol: switch to rstat Johannes Weiner
2021-02-09 16:32 ` Johannes Weiner
2021-02-09 16:32 ` [PATCH v3 1/8] mm: memcontrol: fix cpuhotplug statistics flushing Johannes Weiner
2021-02-09 16:32   ` Johannes Weiner
2021-02-17 17:43   ` Michal Koutný
2021-02-17 17:43     ` Michal Koutný
2021-02-09 16:32 ` [PATCH v3 2/8] mm: memcontrol: kill mem_cgroup_nodeinfo() Johannes Weiner
2021-02-09 16:32   ` Johannes Weiner
2021-02-17 17:43   ` Michal Koutný
2021-02-17 17:43     ` Michal Koutný
2021-02-09 16:32 ` [PATCH v3 3/8] mm: memcontrol: privatize memcg_page_state query functions Johannes Weiner
2021-02-09 16:32   ` Johannes Weiner
2021-02-17 17:44   ` Michal Koutný
2021-02-17 17:44     ` Michal Koutný
2021-02-09 16:33 ` [PATCH v3 4/8] cgroup: rstat: support cgroup1 Johannes Weiner
2021-02-09 16:33   ` Johannes Weiner
2021-02-17 17:42   ` Michal Koutný
2021-02-17 17:42     ` Michal Koutný
2021-02-17 20:52     ` Johannes Weiner
2021-02-18 15:45       ` Michal Koutný
2021-02-18 15:45         ` Michal Koutný
2021-02-18 17:06         ` Johannes Weiner
2021-02-09 16:33 ` [PATCH v3 5/8] cgroup: rstat: punt root-level optimization to individual controllers Johannes Weiner
2021-02-09 16:33   ` Johannes Weiner
2021-02-09 16:33 ` [PATCH v3 6/8] mm: memcontrol: switch to rstat Johannes Weiner
2021-02-09 16:33   ` Johannes Weiner
2021-02-18 15:36   ` Michal Koutný
2021-02-18 15:36     ` Michal Koutný
2021-02-09 16:33 ` [PATCH v3 7/8] mm: memcontrol: consolidate lruvec stat flushing Johannes Weiner
2021-02-09 16:33   ` Johannes Weiner
2021-02-09 20:21   ` Roman Gushchin
2021-02-09 20:21     ` Roman Gushchin
2021-02-09 16:33 ` Johannes Weiner [this message]
2021-02-09 20:17   ` [PATCH v3 8/8] kselftests: cgroup: update kmem test for new vmstat implementation Roman Gushchin
2021-02-09 20:17     ` Roman Gushchin
2021-02-18 15:37   ` Michal Koutný
2021-02-18 15:37     ` 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=20210209163304.77088-9-hannes@cmpxchg.org \
    --to=hannes@cmpxchg.org \
    --cc=akpm@linux-foundation.org \
    --cc=cgroups@vger.kernel.org \
    --cc=guro@fb.com \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=shakeelb@google.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.