提交 4abad746 编写于 作者: J Johannes Weiner 提交者: Zheng Zengkai

kselftests: cgroup: update kmem test for new vmstat implementation

mainline inclusion
from mainline-v5.13-rc1
commit 4bbcc5a4
category: feature
bugzilla: 185803 https://gitee.com/openeuler/kernel/issues/I4JOG9?from=project-issue
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=4bbcc5a41c54

------------------------------------------------------------------

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.

Link: https://lkml.kernel.org/r/20210209163304.77088-9-hannes@cmpxchg.orgSigned-off-by: NJohannes Weiner <hannes@cmpxchg.org>
Reviewed-by: NShakeel Butt <shakeelb@google.com>
Reviewed-by: NMichal Koutný <mkoutny@suse.com>
Acked-by: NRoman Gushchin <guro@fb.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: NLu Jialin <lujialin4@huawei.com>
Reviewed-by: NXiu Jianfeng <xiujianfeng@huawei.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 c6963baf
......@@ -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:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册