From patchwork Tue Jul 13 16:13:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 1504710 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=UJ/A4a+L; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GPQfy05SCz9sXN for ; Wed, 14 Jul 2021 02:13:44 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 2B6903C9C9A for ; Tue, 13 Jul 2021 18:13:41 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [IPv6:2001:4b78:1:20::5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id C8A103C675A for ; Tue, 13 Jul 2021 18:13:38 +0200 (CEST) Received: from smtp-relay-canonical-1.canonical.com (smtp-relay-canonical-1.canonical.com [185.125.188.121]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id 0977E600787 for ; Tue, 13 Jul 2021 18:13:37 +0200 (CEST) Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPS id 1C480401B9 for ; Tue, 13 Jul 2021 16:13:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1626192813; bh=Ycn3/hsNOGzDsdJtDbKx5/Setyml7cicfp9qLeb0M/4=; h=From:To:Subject:Date:Message-Id:MIME-Version:Content-Type; b=UJ/A4a+LE6HAKU+FPG7NPTsxgk0rfBTkSlpHwd/cdQ5fv1zfAFSE3b0SB+KfShEo+ IIMfNKcT3LTRv+fTSglMNgVH+Ui+o0QBQJzWrmQv9ZZyS6W50S+pRQyn252ACo7PDm /U8Q3tfyYmnQV8CHc8fE56azf0FDlmt5WZDCKGvREW+7A2SjnFmg9/kg5sw16CWOSG 4c3kidd9Xov5pAq9AUOg8AH5eyGjpGETjkXwO2XG/gnLBuML27NGk/0DKh2PfEG4NN ChQdIWKWObYp6HxHZtCnbvkGuVWq7VZWl/tbK2KdE9rDZ0LBsd9R95tcxu1hYzRN6w bzqCWO014DEiQ== Received: by mail-ej1-f70.google.com with SMTP id nc15-20020a1709071c0fb029052883e9de3eso762197ejc.19 for ; Tue, 13 Jul 2021 09:13:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ycn3/hsNOGzDsdJtDbKx5/Setyml7cicfp9qLeb0M/4=; b=UXIio7z1aSq+E7BxEJTzK2DFvC+C/+vVqk8EScuO60kpVzkpy77AhwGxhnrBLPpLjl tvxA5No2HwObxIK1y8Y/L3l6nxjmWshSUWTzmUbYf257vNbKNKVbVN6me0i0stZavz3I G/Jlgef8Z2MeKybdar2byvJ6MU1ZTOB/tnUl7U3hY0hgtVWeRlQ2dRuEjLq0xG7sa6Yj QREyLQThr9RcYRLdVoR7SKXvtyL1fYSoi8fI74Jd93ZKAIIS6dabVj5fNePq8sYsIDJU M5Fvaj4WM1wwbDM2o0XAUUiNyZGPrDatEBBgZcBq4yc2rX8SE2eyNxNO/xcr14ss1zCL 1DWg== X-Gm-Message-State: AOAM5313ytiD4rQOgLT3Xux83Z/OgShpJ/mYnvKrqfG3uLF7JROrpvau GTr4rhKZQ/DU5U+3Up/XIS6POc2fWvVyVwo7Yb5GOgw3zCTU6OMc01ZW7fN0Gmuj20E60R8qhYo XLdRD7tvwXnNYCST3XD9d9GBJ9B/5 X-Received: by 2002:a17:906:a98e:: with SMTP id jr14mr6569533ejb.450.1626192812562; Tue, 13 Jul 2021 09:13:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzaYhehqtKRArM/too03456u5tm7JaismHM8+R+bdZcbn24LgxwThsqzbWfJnBovyJ2I/i/kQ== X-Received: by 2002:a17:906:a98e:: with SMTP id jr14mr6569509ejb.450.1626192812373; Tue, 13 Jul 2021 09:13:32 -0700 (PDT) Received: from kozik-lap.lan (xdsl-188-155-177-222.adslplus.ch. [188.155.177.222]) by smtp.gmail.com with ESMTPSA id qp12sm8331122ejb.90.2021.07.13.09.13.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jul 2021 09:13:31 -0700 (PDT) From: Krzysztof Kozlowski To: ltp@lists.linux.it Date: Tue, 13 Jul 2021 18:13:25 +0200 Message-Id: <20210713161328.62560-2-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210713161328.62560-1-krzysztof.kozlowski@canonical.com> References: <20210713161328.62560-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-5.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-5.smtp.seeweb.it Subject: [LTP] [PATCH 1/4] controllers/memcg: account per-node kernel memory X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Recent Linux kernels () charge groups also with kernel memory. This is not limited only to process-allocated memory but also cgroup-handling code memory as well. For example since kernel v5.9 with commit 3e38e0aaca9e ("mm: memcg: charge memcg percpu memory to the parent cgroup") creating a subgroup causes several kernel allocations towards this group. These additional kernel memory allocations are proportional to number of CPUs and number of nodes. On c4.8xlarge AWS instance with 36 cores in two nodes with v5.11 Linux kernel the memcg_subgroup_charge and memcg_use_hierarchy_test tests were failing: memcg_use_hierarchy_test 1 TINFO: timeout per run is 0h 5m 0s memcg_use_hierarchy_test 1 TINFO: set /dev/memcg/memory.use_hierarchy to 0 failed memcg_use_hierarchy_test 1 TINFO: test if one of the ancestors goes over its limit, the proces will be killed mkdir: cannot create directory ‘subgroup’: Cannot allocate memory /home/ubuntu/ltp-install/testcases/bin/memcg_use_hierarchy_test.sh: 26: cd: can't cd to subgroup memcg_use_hierarchy_test 1 TINFO: Running memcg_process --mmap-lock1 -s 8192 memcg_use_hierarchy_test 1 TFAIL: process is not killed rmdir: failed to remove 'subgroup': No such file or directory The kernel was unable to create the subgroup (mkdir returned -ENOMEM) due to this additional per-node kernel memory allocations. Signed-off-by: Krzysztof Kozlowski --- .../controllers/memcg/functional/memcg_lib.sh | 44 +++++++++++++++++++ .../memcg/functional/memcg_subgroup_charge.sh | 8 +--- .../functional/memcg_use_hierarchy_test.sh | 8 +++- 3 files changed, 52 insertions(+), 8 deletions(-) diff --git a/testcases/kernel/controllers/memcg/functional/memcg_lib.sh b/testcases/kernel/controllers/memcg/functional/memcg_lib.sh index dad66c798e19..700e9e367bff 100755 --- a/testcases/kernel/controllers/memcg/functional/memcg_lib.sh +++ b/testcases/kernel/controllers/memcg/functional/memcg_lib.sh @@ -63,6 +63,50 @@ memcg_require_hierarchy_disabled() fi } +# Kernel memory allocated for the process is also charged. It might depend on +# the number of CPUs and number of nodes. For example on kernel v5.11 +# additionally total_cpus (plus 1 or 2) pages are charged to the group via +# kernel memory. For a two-node machine, additional 108 pages kernel memory +# are charged to the group. +# +# Adjust the limit to account such per-CPU and per-node kernel memory. +# $1 - variable name with limit to adjust +memcg_adjust_limit_for_kmem() +{ + [ $# -ne 1 ] && tst_brk TBROK "memcg_adjust_limit_for_kmem expects 1 parameter" + eval "local _limit=\$$1" + + # Total number of CPUs + local total_cpus=`tst_ncpus` + + # Get the number of NODES + if [ -f "/sys/devices/system/node/has_high_memory" ]; then + local mem_string="`cat /sys/devices/system/node/has_high_memory`" + else + local mem_string="`cat /sys/devices/system/node/has_normal_memory`" + fi + + local total_nodes="`echo $mem_string | tr ',' ' '`" + local count=0 + for item in $total_nodes; do + local delta=1 + if [ "${item#*-*}" != "$item" ]; then + delta=$((${item#*-*} - ${item%*-*} + 1)) + fi + count=$((count + $delta)) + done + total_nodes=$count + # Additional nodes impose charging the kmem, not having regular one node + local node_mem=0 + if [ $total_nodes -gt 1 ]; then + node_mem=$((total_nodes - 1)) + node_mem=$((node_mem * PAGESIZE * 128)) + fi + + eval "$1='$((_limit + 4 * PAGESIZE + total_cpus * PAGESIZE + node_mem))'" + return 0 +} + memcg_setup() { if ! is_cgroup_subsystem_available_and_enabled "memory"; then diff --git a/testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh b/testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh index 0d2b235aff7c..7650128e3605 100755 --- a/testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh +++ b/testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh @@ -24,16 +24,12 @@ test_subgroup() { local limit_parent=$1 local limit_subgroup=$2 - local total_cpus=`tst_ncpus` - # Kernel memory allocated for the process is also charged. - # It might depend on the number of CPUs. For example on kernel v5.11 - # additionally total_cpus plus 1-2 pages are charged to the group. if [ $limit_parent -ne 0 ]; then - limit_parent=$((limit_parent + 4 * PAGESIZE + total_cpus * PAGESIZE)) + memcg_adjust_limit_for_kmem limit_parent fi if [ $limit_subgroup -ne 0 ]; then - limit_subgroup=$((limit_subgroup + 4 * PAGESIZE + total_cpus * PAGESIZE)) + memcg_adjust_limit_for_kmem limit_subgroup fi mkdir subgroup diff --git a/testcases/kernel/controllers/memcg/functional/memcg_use_hierarchy_test.sh b/testcases/kernel/controllers/memcg/functional/memcg_use_hierarchy_test.sh index 8be342499ece..b645f9b44a86 100755 --- a/testcases/kernel/controllers/memcg/functional/memcg_use_hierarchy_test.sh +++ b/testcases/kernel/controllers/memcg/functional/memcg_use_hierarchy_test.sh @@ -14,13 +14,17 @@ TST_CNT=3 test1() { tst_res TINFO "test if one of the ancestors goes over its limit, the proces will be killed" + local total_cpus=`tst_ncpus` + + local limit=$PAGESIZE + memcg_adjust_limit_for_kmem limit echo 1 > memory.use_hierarchy - echo $PAGESIZE > memory.limit_in_bytes + echo $limit > memory.limit_in_bytes mkdir subgroup cd subgroup - test_proc_kill $((PAGESIZE * 3)) "--mmap-lock1" $((PAGESIZE * 2)) 0 + test_proc_kill $((limit + PAGESIZE * 3)) "--mmap-lock1" $((limit + PAGESIZE * 2)) 0 cd .. rmdir subgroup From patchwork Tue Jul 13 16:13:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 1504714 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=dNAv/aZd; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GPQgq2sWMz9t1r for ; Wed, 14 Jul 2021 02:14:31 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 066B13C9D17 for ; Tue, 13 Jul 2021 18:14:28 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [217.194.8.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 3AE4D3C9CBF for ; Tue, 13 Jul 2021 18:13:39 +0200 (CEST) Received: from smtp-relay-canonical-0.canonical.com (smtp-relay-canonical-0.canonical.com [185.125.188.120]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-7.smtp.seeweb.it (Postfix) with ESMTPS id 1ACA9200972 for ; Tue, 13 Jul 2021 18:13:37 +0200 (CEST) Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPS id D294E40596 for ; Tue, 13 Jul 2021 16:13:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1626192813; bh=TUydvIL4WCw9DF//PsH7ynbDUp2wosd+9HFcZHRyLV0=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=dNAv/aZdjh53p99DNyywQu07HyUsypaRCTefK7+NTLqXapEUmSXQ2MhxsqKb8Tych YJYzuElFl7mUv5KmD89dXO5mrgBD6BCVXl9r8yv1XcYvkFLOr2Nb7vW1nM8AFSilQa NxRKspl8zb2uSxOnLJ+YeT07HKlKkpPO4NEIfz3nb+6qUkcsQkW6R4Hk2mRmM5bcqX 91+q/wRRtkqeH7Pp+O/xNYvPSlVFBOKeZVb/31ZFtH+nV0sWtFv/X6wKZHGCL5b9Mg 8uTObrKLaP71zxg3K+s0GIkAMalf3xEdYLgGB6xDoqvDDG7blAb2umNX+23Hjobx3S otgsF9JsK9V1Q== Received: by mail-ed1-f71.google.com with SMTP id c21-20020aa7d6150000b02903ab03a06e86so359478edr.14 for ; Tue, 13 Jul 2021 09:13:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TUydvIL4WCw9DF//PsH7ynbDUp2wosd+9HFcZHRyLV0=; b=OwG1dYKOKDvIZla3ZEM0rSxlaBWgzJdvCnQKqGJqTD9iULnlJalBBwPVwc8pK7M0Td 7uNfb8FfAUduHUnaNIyVjg/7J79RLOLf/n2dmY3vI2AnktQqzIb7NdgnVqU0WXEUTeM4 bjZmRZ+BxknR9c2pZC+THEVSuwIy/73AA7qyo55loyI9hcAYguQMMp4CzFJ9J+l/PqCq 91f4XetdsKpgWbAKqunFf5z/sRNHX69z5A9zS6UauKzFJ4VUazBkdQn9qqz1dThvs9yF 3WwS/Kv6j7Fmtxv3isslMIW40hJpIlcVlswZb9RrowGRI61KGJijHn9hseCnMIi2zGO9 6agg== X-Gm-Message-State: AOAM53153/+3VGXBdQIOmqNxmBorALqmaC8BjIR7ue91TQqVQXsMpHst nN5Sr2MB/kjYzz3UcnwFxUrf+RwqIawcSmrW91isbRbfr/W+fhajLGZ/RCPRcHDb41aHYfEO7TA 740rfuxSpqhCdRZS9QJkM2kbJQZhV X-Received: by 2002:a17:906:3693:: with SMTP id a19mr6736891ejc.237.1626192813440; Tue, 13 Jul 2021 09:13:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx99G8HvXYFuRC8hiMvGLneTwPBbIUQrLInz2EwtudLr6W+fVtGLVzN3Nfxo2GzadZwPiNqcQ== X-Received: by 2002:a17:906:3693:: with SMTP id a19mr6736880ejc.237.1626192813333; Tue, 13 Jul 2021 09:13:33 -0700 (PDT) Received: from kozik-lap.lan (xdsl-188-155-177-222.adslplus.ch. [188.155.177.222]) by smtp.gmail.com with ESMTPSA id qp12sm8331122ejb.90.2021.07.13.09.13.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jul 2021 09:13:32 -0700 (PDT) From: Krzysztof Kozlowski To: ltp@lists.linux.it Date: Tue, 13 Jul 2021 18:13:26 +0200 Message-Id: <20210713161328.62560-3-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210713161328.62560-1-krzysztof.kozlowski@canonical.com> References: <20210713161328.62560-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-7.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-7.smtp.seeweb.it Subject: [LTP] [PATCH 2/4] controllers/memcg: fix memcg_stat_test on two node machines X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Recent Linux kernels charge groups also with kernel memory. This is not limited only to process-allocated memory but also cgroup-handling code memory as well. For example since kernel v5.9 with commit 3e38e0aaca9e ("mm: memcg: charge memcg percpu memory to the parent cgroup") creating a subgroup causes several kernel allocations towards this group. These additional kernel memory allocations are proportional to number of CPUs and number of nodes. On c4.8xlarge AWS instance with 36 cores in two nodes with v5.11 Linux kernel the memcg_stat_test was failing because of unable to set memory limit lower than current kernel memory accounted to the group: memcg_stat_test 5 TINFO: Test hierarchical_memory_limit with enabling hierarchical accounting shell code from test: > mkdir subgroup > cat memory.kmem.usage_in_bytes > 442368 > echo $PAGESIZE > memory.limit_in_bytes /home/ubuntu/ltp-install/testcases/bin/memcg_stat_test.sh: 47: echo: echo: I/O error memcg_stat_test 5 TFAIL: hierarchical_memory_limit is 270336, 135168 expected Signed-off-by: Krzysztof Kozlowski --- .../controllers/memcg/functional/memcg_stat_test.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh b/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh index e5eb7e5d0001..f6b5aa84e31e 100755 --- a/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh +++ b/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh @@ -43,12 +43,15 @@ test5() tst_res TINFO "Test hierarchical_memory_limit with enabling hierarchical accounting" echo 1 > memory.use_hierarchy + local limit=$PAGESIZES + memcg_adjust_limit_for_kmem limit + mkdir subgroup - echo $PAGESIZES > memory.limit_in_bytes - echo $((PAGESIZES * 2)) > subgroup/memory.limit_in_bytes + echo $limit > memory.limit_in_bytes + echo $((limit + PAGESIZES * 2)) > subgroup/memory.limit_in_bytes cd subgroup - check_mem_stat "hierarchical_memory_limit" $PAGESIZES + check_mem_stat "hierarchical_memory_limit" $limit cd .. rmdir subgroup From patchwork Tue Jul 13 16:13:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 1504713 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=lxluVbeF; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GPQgc2PmRz9sfG for ; Wed, 14 Jul 2021 02:14:20 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id DE5B03C9D74 for ; Tue, 13 Jul 2021 18:14:16 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [IPv6:2001:4b78:1:20::6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 661EA3C9CA1 for ; Tue, 13 Jul 2021 18:13:39 +0200 (CEST) Received: from smtp-relay-canonical-0.canonical.com (smtp-relay-canonical-0.canonical.com [185.125.188.120]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 077031400BC3 for ; Tue, 13 Jul 2021 18:13:37 +0200 (CEST) Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPS id EDBCE405D2 for ; Tue, 13 Jul 2021 16:13:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1626192814; bh=2I0FurmoYZjFwtYwB65QA4iJS+6uIb1s1FR/5RtfDyU=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=lxluVbeFMJ4FnmWoVkhwseMJR5WkROmhCqcoGA/wjgQBbmef8axClmDSoKLgydg2O gnA7arFxqvDk8/1DOpttUcG/qPFVK4mZRucCfYfUjei6BsvTy+9Pmgmfcp4f9dCTL6 Sx4ZH6bX+qUz3QtiuWu0/9xXVmSb6JfkmKZtkbYm2Y0L09n+HrBp5x9Yg+y9DwoG4t lSf0LSjxSXz6DkSHR8w3bx5w4X1OiCczjCY/aUtb7qjGAOSk8INz8dtW1XMqpP6wY6 efgMyTYgzQshiy88KNiXaoJ1kF6qLL3BzgzEvowtVtdDAxvkfBdPHYRQwvZdP4z9j+ 8l2Y+jlC8RJ/A== Received: by mail-ej1-f72.google.com with SMTP id t8-20020a1709063e48b0290501cd965554so5333645eji.8 for ; Tue, 13 Jul 2021 09:13:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2I0FurmoYZjFwtYwB65QA4iJS+6uIb1s1FR/5RtfDyU=; b=N5d2LDqX3VVtiRwwOslE/RduIbIsm6htb9Vbq8cHMNOWkf8Xe8mTgdI1iX1q+jkpvN uJs6tVOKFyFj5g+/Wl5sKWuIOTghTd8iQHJ+ynQtR6XrF8IHmfx0aa0cZDrbpHeWZroB I8eVsq+XOeCTkvUAkQCUnmP3yJf/SRQKgzKSRQJJTCQh5LJQJclHwNJ+DwcWJ+qbiSNx X/OX6x7HE8208vRjdemp733aKi+6B6HmL7N2tTNi6ISae1Qjnk9GHpgaWpXGO+GJdFbp Fn5Fh3tKUsHmoZ10jx1ZyKAtAtTza0ISeusvFQTIegeLojEOdkSnqt5hYYtPBb5V8B+3 f6DQ== X-Gm-Message-State: AOAM532wFSJ4gYXuuiswLOwNzGelRyONAgjQa0aUW6Ah7/qimLg63cPV TGdL2lIT6FWFwkAF6yCMMv2qBchV+DSSoFgXCatZZddA1MuzeL4TFTv+yFvtemhuKDrIkRj7KSk bsi5ge10QUiQJltRDxQXh8CvdfjR9 X-Received: by 2002:a17:906:498b:: with SMTP id p11mr6634964eju.295.1626192814426; Tue, 13 Jul 2021 09:13:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpjdnDx9qNHXeFXaAUUUjC0xLqDcoV2MtrKOH2iOvXCMoJXuqkFDI8lBO8FRoPPeuRPvs2PQ== X-Received: by 2002:a17:906:498b:: with SMTP id p11mr6634956eju.295.1626192814291; Tue, 13 Jul 2021 09:13:34 -0700 (PDT) Received: from kozik-lap.lan (xdsl-188-155-177-222.adslplus.ch. [188.155.177.222]) by smtp.gmail.com with ESMTPSA id qp12sm8331122ejb.90.2021.07.13.09.13.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jul 2021 09:13:34 -0700 (PDT) From: Krzysztof Kozlowski To: ltp@lists.linux.it Date: Tue, 13 Jul 2021 18:13:27 +0200 Message-Id: <20210713161328.62560-4-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210713161328.62560-1-krzysztof.kozlowski@canonical.com> References: <20210713161328.62560-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH 3/4] controllers/memcg: fail early to avoid possible false-positives X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Tests require certain prerequisites. If these fail, there is no point to continue with the test. Trying to continue might lead to false positives, as seen on memcg_subgroup_charge which failed to set proper limit and did not catch actual failure: memcg_subgroup_charge 1 TINFO: set /dev/memcg/memory.use_hierarchy to 0 failed memcg_subgroup_charge 1 TINFO: Test that group and subgroup have no relationship /home/ubuntu/ltp-install/testcases/bin/memcg_subgroup_charge.sh: 36: echo: echo: I/O error memcg_subgroup_charge 1 TINFO: Running memcg_process --mmap-anon -s 270336 memcg_subgroup_charge 1 TINFO: Warming up pid: 13496 memcg_subgroup_charge 1 TINFO: Process is still here after warm up: 13496 Signed-off-by: Krzysztof Kozlowski --- .../controllers/memcg/functional/memcg_failcnt.sh | 4 ++-- .../memcg/functional/memcg_max_usage_in_bytes_test.sh | 2 +- .../functional/memcg_memsw_limit_in_bytes_test.sh | 8 ++++---- .../functional/memcg_move_charge_at_immigrate_test.sh | 4 ++-- .../controllers/memcg/functional/memcg_stat_test.sh | 10 +++++----- .../memcg/functional/memcg_subgroup_charge.sh | 2 +- .../memcg/functional/memcg_use_hierarchy_test.sh | 10 +++++----- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/testcases/kernel/controllers/memcg/functional/memcg_failcnt.sh b/testcases/kernel/controllers/memcg/functional/memcg_failcnt.sh index ce0885b73fe7..65ad82e0a2a0 100755 --- a/testcases/kernel/controllers/memcg/functional/memcg_failcnt.sh +++ b/testcases/kernel/controllers/memcg/functional/memcg_failcnt.sh @@ -18,10 +18,10 @@ MEMORY_TO_ALLOCATE=$((MEMORY_LIMIT * 2)) test() { - echo $MEMORY_LIMIT > memory.limit_in_bytes + ROD echo $MEMORY_LIMIT \> memory.limit_in_bytes start_memcg_process $2 -s ${MEMORY_TO_ALLOCATE} - echo $MEMCG_PROCESS_PID > tasks + ROD echo $MEMCG_PROCESS_PID \> tasks signal_memcg_process ${MEMORY_TO_ALLOCATE} signal_memcg_process ${MEMORY_TO_ALLOCATE} diff --git a/testcases/kernel/controllers/memcg/functional/memcg_max_usage_in_bytes_test.sh b/testcases/kernel/controllers/memcg/functional/memcg_max_usage_in_bytes_test.sh index 24e9d115c19e..a0c4dd17f0f3 100755 --- a/testcases/kernel/controllers/memcg/functional/memcg_max_usage_in_bytes_test.sh +++ b/testcases/kernel/controllers/memcg/functional/memcg_max_usage_in_bytes_test.sh @@ -33,7 +33,7 @@ test_max_usage_in_bytes() return fi - echo $MEMCG_PROCESS_PID > tasks + ROD echo $MEMCG_PROCESS_PID \> tasks signal_memcg_process $MEM_TO_ALLOC signal_memcg_process $MEM_TO_ALLOC diff --git a/testcases/kernel/controllers/memcg/functional/memcg_memsw_limit_in_bytes_test.sh b/testcases/kernel/controllers/memcg/functional/memcg_memsw_limit_in_bytes_test.sh index e9950a0df322..ab26cb3d1768 100755 --- a/testcases/kernel/controllers/memcg/functional/memcg_memsw_limit_in_bytes_test.sh +++ b/testcases/kernel/controllers/memcg/functional/memcg_memsw_limit_in_bytes_test.sh @@ -55,7 +55,7 @@ test9() { memcg_require_memsw - echo 10M > memory.limit_in_bytes + ROD echo 10M \> memory.limit_in_bytes if tst_kvcmp -lt "2.6.31"; then EXPECT_FAIL echo -1 \> memory.memsw.limit_in_bytes @@ -68,7 +68,7 @@ test10() { memcg_require_memsw - echo 10M > memory.limit_in_bytes + ROD echo 10M \> memory.limit_in_bytes EXPECT_FAIL echo 1.0 \> memory.memsw.limit_in_bytes } @@ -76,7 +76,7 @@ test11() { memcg_require_memsw - echo 10M > memory.limit_in_bytes + ROD echo 10M \> memory.limit_in_bytes EXPECT_FAIL echo 1xx \> memory.memsw.limit_in_bytes } @@ -84,7 +84,7 @@ test12() { memcg_require_memsw - echo 10M > memory.limit_in_bytes + ROD echo 10M \> memory.limit_in_bytes EXPECT_FAIL echo xx \> memory.memsw.limit_in_bytes } diff --git a/testcases/kernel/controllers/memcg/functional/memcg_move_charge_at_immigrate_test.sh b/testcases/kernel/controllers/memcg/functional/memcg_move_charge_at_immigrate_test.sh index 272d7779770d..3c1b3394bd71 100755 --- a/testcases/kernel/controllers/memcg/functional/memcg_move_charge_at_immigrate_test.sh +++ b/testcases/kernel/controllers/memcg/functional/memcg_move_charge_at_immigrate_test.sh @@ -34,10 +34,10 @@ test_move_charge() return fi - echo $MEMCG_PROCESS_PID > subgroup_a/tasks + ROD echo $MEMCG_PROCESS_PID \> subgroup_a/tasks signal_memcg_process $total_size "subgroup_a/" - mkdir subgroup_b + ROD mkdir subgroup_b echo $move_charge_mask > subgroup_b/memory.move_charge_at_immigrate echo $MEMCG_PROCESS_PID > subgroup_b/tasks diff --git a/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh b/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh index f6b5aa84e31e..b86331f0fc26 100755 --- a/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh +++ b/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh @@ -46,7 +46,7 @@ test5() local limit=$PAGESIZES memcg_adjust_limit_for_kmem limit - mkdir subgroup + ROD mkdir subgroup echo $limit > memory.limit_in_bytes echo $((limit + PAGESIZES * 2)) > subgroup/memory.limit_in_bytes @@ -62,9 +62,9 @@ test6() tst_res TINFO "Test hierarchical_memory_limit with disabling hierarchical accounting" memcg_require_hierarchy_disabled - echo 0 > memory.use_hierarchy + ROD echo 0 \> memory.use_hierarchy - mkdir subgroup + ROD mkdir subgroup echo $PAGESIZES > memory.limit_in_bytes echo $((PAGESIZES * 2)) > subgroup/memory.limit_in_bytes @@ -82,7 +82,7 @@ test7() ROD echo 1 \> memory.use_hierarchy - mkdir subgroup + ROD mkdir subgroup echo $PAGESIZES > memory.limit_in_bytes echo $PAGESIZES > memory.memsw.limit_in_bytes echo $((PAGESIZES * 2)) > subgroup/memory.limit_in_bytes @@ -103,7 +103,7 @@ test8() ROD echo 0 \> memory.use_hierarchy - mkdir subgroup + ROD mkdir subgroup echo $PAGESIZES > memory.limit_in_bytes echo $PAGESIZES > memory.memsw.limit_in_bytes echo $((PAGESIZES * 2)) > subgroup/memory.limit_in_bytes diff --git a/testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh b/testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh index 7650128e3605..e831097dab3e 100755 --- a/testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh +++ b/testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh @@ -32,7 +32,7 @@ test_subgroup() memcg_adjust_limit_for_kmem limit_subgroup fi - mkdir subgroup + ROD mkdir subgroup echo $limit_parent > memory.limit_in_bytes echo $limit_subgroup > subgroup/memory.limit_in_bytes diff --git a/testcases/kernel/controllers/memcg/functional/memcg_use_hierarchy_test.sh b/testcases/kernel/controllers/memcg/functional/memcg_use_hierarchy_test.sh index b645f9b44a86..4b19480b2ff9 100755 --- a/testcases/kernel/controllers/memcg/functional/memcg_use_hierarchy_test.sh +++ b/testcases/kernel/controllers/memcg/functional/memcg_use_hierarchy_test.sh @@ -19,10 +19,10 @@ test1() local limit=$PAGESIZE memcg_adjust_limit_for_kmem limit - echo 1 > memory.use_hierarchy - echo $limit > memory.limit_in_bytes + ROD echo 1 \> memory.use_hierarchy + ROD echo $limit \> memory.limit_in_bytes - mkdir subgroup + ROD mkdir subgroup cd subgroup test_proc_kill $((limit + PAGESIZE * 3)) "--mmap-lock1" $((limit + PAGESIZE * 2)) 0 @@ -36,7 +36,7 @@ test2() memcg_require_hierarchy_disabled - mkdir subgroup + ROD mkdir subgroup EXPECT_FAIL echo 1 \> memory.use_hierarchy rmdir subgroup @@ -48,7 +48,7 @@ test3() memcg_require_hierarchy_disabled - echo 1 > memory.use_hierarchy + ROD echo 1 > memory.use_hierarchy mkdir subgroup EXPECT_FAIL echo 0 \> subgroup/memory.use_hierarchy From patchwork Tue Jul 13 16:13:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 1504712 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=RAPTDjLY; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GPQgL1gW3z9sXM for ; Wed, 14 Jul 2021 02:14:06 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 47CE43C9CBB for ; Tue, 13 Jul 2021 18:14:02 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [IPv6:2001:4b78:1:20::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id CF7A83C759E for ; Tue, 13 Jul 2021 18:13:38 +0200 (CEST) Received: from smtp-relay-canonical-1.canonical.com (smtp-relay-canonical-1.canonical.com [185.125.188.121]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id 0DF947CEC74 for ; Tue, 13 Jul 2021 18:13:37 +0200 (CEST) Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPS id D7E734060B for ; Tue, 13 Jul 2021 16:13:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1626192815; bh=7CTPtmwoU9X7aP73MH1LZOzX7VEPJ1EGhRyCdFa3aP0=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=RAPTDjLYrKmNWhfF46LLA2vfhMS+wpbNpSTCpZlyTK2o7JXOqD0hCy70d8uNbl9vQ 9+mld2DXLCMZQ8/B/ym7IghSTQUmAzzAubaCS1N9F0yZt3iLZH17Ba6GUF2K07bLVo 3iP/kSi+pbeHSvqCb8E+wqGPzbutnFw8yrOTarbD2kpy+NE6PNIGqgkbn8zMjykSvu pR33W7B2QRZhsBrgAYOxQRpWEoVPjIcAqbOofYHP3CLmZG+G2GVwGyV7t9aHD8REdO apow9BQbkeq7pDh3zlu8rPt9oMyQrImdGnaKLWs9yCS7et66Yu0QGxVmn3ZGa8UgXn MbCOVO7HnbXdw== Received: by mail-ej1-f69.google.com with SMTP id r10-20020a170906350ab02904f12f4a8c69so6966674eja.12 for ; Tue, 13 Jul 2021 09:13:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7CTPtmwoU9X7aP73MH1LZOzX7VEPJ1EGhRyCdFa3aP0=; b=HmVH0zaH59oNzNOPtgO8p84YR/zhDryL7gw7zmK9atV3OFtwV09BnfUZa9FiS+8wo/ 1zyXhUv6TRTw54Q7Vb6M6VnHQAaA0uq5KsdHv0LfC9rJY2ppqKNKi+ZvN97SFdov4P2q 1B3ymAGnq/aIQCdquILxU3cmmvMjicqgVsNGtufgFr3rMozORwNMB0rnEeypTTXePzp3 ZvvXYyM76xjChVm6IobxLHUdQ9qhS2eXxLSR/OfuIfa42c90vbzRTmj56e7ZM/9F6Eeo Ey0/h+Zi1nHW6HaLIPV/0mqXaNFU9ksLRCkRuJ5OS4y+ArKcuZNeH7fP5J/jHJwk0B1B uu/w== X-Gm-Message-State: AOAM532s8ej3vR4502qQweyKbMY+QKJ5k01IyGuK2NR0ObF9GWN6vMgd F6EoS6ilf7mGyH1UlUk0oeInWvWiEiudIhWKg/icgZmdrVSTqVmeIqbiT7IlcWznjMmnEvPc08X 0NfXNfWgFR1NnARp7eKaoN0lAEbB+ X-Received: by 2002:a17:907:e9e:: with SMTP id ho30mr6855280ejc.114.1626192815447; Tue, 13 Jul 2021 09:13:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyG0pTHk9l6o4HTPU1WvZhdPiMU/4EHVBHZPGIsnVPpVH1ZXmdZRcOse6jTKdjhgd0/xv/DBw== X-Received: by 2002:a17:907:e9e:: with SMTP id ho30mr6855273ejc.114.1626192815290; Tue, 13 Jul 2021 09:13:35 -0700 (PDT) Received: from kozik-lap.lan (xdsl-188-155-177-222.adslplus.ch. [188.155.177.222]) by smtp.gmail.com with ESMTPSA id qp12sm8331122ejb.90.2021.07.13.09.13.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jul 2021 09:13:34 -0700 (PDT) From: Krzysztof Kozlowski To: ltp@lists.linux.it Date: Tue, 13 Jul 2021 18:13:28 +0200 Message-Id: <20210713161328.62560-5-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210713161328.62560-1-krzysztof.kozlowski@canonical.com> References: <20210713161328.62560-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-2.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-2.smtp.seeweb.it Subject: [LTP] [PATCH 4/4] controllers/memcg: check status of commands using interface X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Most of the cgroups interface returns some valid and meaningful error code (e.g. ENOMEM if creating subgroup failed). Check these to be sure that all errors are caught, like in this example: memcg_subgroup_charge 1 TINFO: set /dev/memcg/memory.use_hierarchy to 0 failed memcg_subgroup_charge 1 TINFO: Test that group and subgroup have no relationship /home/ubuntu/ltp-install/testcases/bin/memcg_subgroup_charge.sh: 36: echo: echo: I/O error memcg_subgroup_charge 1 TINFO: Running memcg_process --mmap-anon -s 270336 memcg_subgroup_charge 1 TINFO: Warming up pid: 13496 memcg_subgroup_charge 1 TINFO: Process is still here after warm up: 13496 Signed-off-by: Krzysztof Kozlowski --- .../controllers/memcg/functional/memcg_lib.sh | 2 +- .../memcg_max_usage_in_bytes_test.sh | 8 +++---- .../memcg/functional/memcg_stat_test.sh | 24 +++++++++---------- .../memcg/functional/memcg_subgroup_charge.sh | 4 ++-- .../functional/memcg_usage_in_bytes_test.sh | 4 ++-- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/testcases/kernel/controllers/memcg/functional/memcg_lib.sh b/testcases/kernel/controllers/memcg/functional/memcg_lib.sh index 700e9e367bff..3d04c3a60700 100755 --- a/testcases/kernel/controllers/memcg/functional/memcg_lib.sh +++ b/testcases/kernel/controllers/memcg/functional/memcg_lib.sh @@ -389,7 +389,7 @@ test_limit_in_bytes() local use_memsw=$2 local elimit - echo $limit > memory.limit_in_bytes + EXPECT_PASS echo $limit \> memory.limit_in_bytes if [ $use_memsw -eq 1 ]; then memcg_require_memsw echo $limit > memory.memsw.limit_in_bytes diff --git a/testcases/kernel/controllers/memcg/functional/memcg_max_usage_in_bytes_test.sh b/testcases/kernel/controllers/memcg/functional/memcg_max_usage_in_bytes_test.sh index a0c4dd17f0f3..6a2607c4333b 100755 --- a/testcases/kernel/controllers/memcg/functional/memcg_max_usage_in_bytes_test.sh +++ b/testcases/kernel/controllers/memcg/functional/memcg_max_usage_in_bytes_test.sh @@ -67,8 +67,8 @@ test2() tst_res TINFO "Test memory.memsw.max_usage_in_bytes" memcg_require_memsw - echo $MEM_LIMIT > memory.limit_in_bytes - echo $MEM_LIMIT > memory.memsw.limit_in_bytes + EXPECT_PASS echo $MEM_LIMIT \> memory.limit_in_bytes + EXPECT_PASS echo $MEM_LIMIT \> memory.memsw.limit_in_bytes test_max_usage_in_bytes 1 0 } @@ -83,8 +83,8 @@ test4() tst_res TINFO "Test reset memory.memsw.max_usage_in_bytes" memcg_require_memsw - echo $MEM_LIMIT > memory.limit_in_bytes - echo $MEM_LIMIT > memory.memsw.limit_in_bytes + EXPECT_PASS echo $MEM_LIMIT \> memory.limit_in_bytes + EXPECT_PASS echo $MEM_LIMIT \> memory.memsw.limit_in_bytes test_max_usage_in_bytes 1 1 } diff --git a/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh b/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh index b86331f0fc26..5fb52bb1d24c 100755 --- a/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh +++ b/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh @@ -47,8 +47,8 @@ test5() memcg_adjust_limit_for_kmem limit ROD mkdir subgroup - echo $limit > memory.limit_in_bytes - echo $((limit + PAGESIZES * 2)) > subgroup/memory.limit_in_bytes + EXPECT_PASS echo $limit \> memory.limit_in_bytes + EXPECT_PASS echo $((limit + PAGESIZES * 2)) \> subgroup/memory.limit_in_bytes cd subgroup check_mem_stat "hierarchical_memory_limit" $limit @@ -65,8 +65,8 @@ test6() ROD echo 0 \> memory.use_hierarchy ROD mkdir subgroup - echo $PAGESIZES > memory.limit_in_bytes - echo $((PAGESIZES * 2)) > subgroup/memory.limit_in_bytes + EXPECT_PASS echo $PAGESIZES \> memory.limit_in_bytes + EXPECT_PASS echo $((PAGESIZES * 2)) \> subgroup/memory.limit_in_bytes cd subgroup check_mem_stat "hierarchical_memory_limit" $((PAGESIZES * 2)) @@ -83,10 +83,10 @@ test7() ROD echo 1 \> memory.use_hierarchy ROD mkdir subgroup - echo $PAGESIZES > memory.limit_in_bytes - echo $PAGESIZES > memory.memsw.limit_in_bytes - echo $((PAGESIZES * 2)) > subgroup/memory.limit_in_bytes - echo $((PAGESIZES * 2)) > subgroup/memory.memsw.limit_in_bytes + EXPECT_PASS echo $PAGESIZES \> memory.limit_in_bytes + EXPECT_PASS echo $PAGESIZES \> memory.memsw.limit_in_bytes + EXPECT_PASS echo $((PAGESIZES * 2)) \> subgroup/memory.limit_in_bytes + EXPECT_PASS echo $((PAGESIZES * 2)) \> subgroup/memory.memsw.limit_in_bytes cd subgroup check_mem_stat "hierarchical_memsw_limit" $PAGESIZES @@ -104,10 +104,10 @@ test8() ROD echo 0 \> memory.use_hierarchy ROD mkdir subgroup - echo $PAGESIZES > memory.limit_in_bytes - echo $PAGESIZES > memory.memsw.limit_in_bytes - echo $((PAGESIZES * 2)) > subgroup/memory.limit_in_bytes - echo $((PAGESIZES * 2)) > subgroup/memory.memsw.limit_in_bytes + EXPECT_PASS echo $PAGESIZES \> memory.limit_in_bytes + EXPECT_PASS echo $PAGESIZES \> memory.memsw.limit_in_bytes + EXPECT_PASS echo $((PAGESIZES * 2)) \> subgroup/memory.limit_in_bytes + EXPECT_PASS echo $((PAGESIZES * 2)) \> subgroup/memory.memsw.limit_in_bytes cd subgroup check_mem_stat "hierarchical_memsw_limit" $((PAGESIZES * 2)) diff --git a/testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh b/testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh index e831097dab3e..4434168a7a6c 100755 --- a/testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh +++ b/testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh @@ -33,8 +33,8 @@ test_subgroup() fi ROD mkdir subgroup - echo $limit_parent > memory.limit_in_bytes - echo $limit_subgroup > subgroup/memory.limit_in_bytes + EXPECT_PASS echo $limit_parent \> memory.limit_in_bytes + EXPECT_PASS echo $limit_subgroup \> subgroup/memory.limit_in_bytes start_memcg_process --mmap-anon -s $MEM_TO_ALLOC diff --git a/testcases/kernel/controllers/memcg/functional/memcg_usage_in_bytes_test.sh b/testcases/kernel/controllers/memcg/functional/memcg_usage_in_bytes_test.sh index 9140fd9d1fd7..6c1b365057f8 100755 --- a/testcases/kernel/controllers/memcg/functional/memcg_usage_in_bytes_test.sh +++ b/testcases/kernel/controllers/memcg/functional/memcg_usage_in_bytes_test.sh @@ -28,8 +28,8 @@ test2() tst_res TINFO "Test memory.memsw.usage_in_bytes" memcg_require_memsw - echo $MEM_LIMIT > memory.limit_in_bytes - echo $MEM_LIMIT > memory.memsw.limit_in_bytes + EXPECT_PASS echo $MEM_LIMIT \> memory.limit_in_bytes + EXPECT_PASS echo $MEM_LIMIT \> memory.memsw.limit_in_bytes test_mem_stat "--mmap-anon" $MEM_TO_ALLOC $MEM_TO_ALLOC \ "memory.memsw.usage_in_bytes" $MEM_TO_ALLOC \ $MEM_EXPECTED_UPPER false