From patchwork Thu Aug 12 08:02:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 1516175 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=IYWd2Tb5; 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 4GlfMN1QbXz9sX3 for ; Thu, 12 Aug 2021 18:03:28 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 978D03C6C12 for ; Thu, 12 Aug 2021 10:03:25 +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 86A173C2E09 for ; Thu, 12 Aug 2021 10:03:23 +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-2.smtp.seeweb.it (Postfix) with ESMTPS id E0D66600198 for ; Thu, 12 Aug 2021 10:03:22 +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 36C083F04D for ; Thu, 12 Aug 2021 08:03:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1628755402; bh=UhjchgatRmk5OThF4z1T03ITOSL2vufMdD6HgyJmkqM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=IYWd2Tb5zMfx4k0aZlO0aLKmMQ5CqEoVhVULFTwEsazDO+8YIOILgtqB2UVkU9SUR hOZ150/iE5zgLa5CI6bCUHGXQ1XoNozRZmiTuANSByOEkdXaKp4H4QbqtvgGmWpTFn M4MtM3PMaGEjYGAmb7JZp/8jWt3fFfJBewWL4rB3HMqRsLCZ8e2VylVYfMgTnx1L/4 WOYrHLIxyZFMv3JE0V6sCVmorYqfdET+JM3vjM64RiLU7NOsXTNJU6g9o++wskuzSH bgKPFmcHFJUSI23+jLxHBM0SPXKQLEJA3qCd2mO1r5QafkS+/7P6ExwrUA4pZvWac7 SXbtVXN7mCQiw== Received: by mail-ed1-f71.google.com with SMTP id v20-20020aa7d9d40000b02903be68450bf3so2661682eds.23 for ; Thu, 12 Aug 2021 01:03:22 -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=UhjchgatRmk5OThF4z1T03ITOSL2vufMdD6HgyJmkqM=; b=OLG/ttaat+tQBXPZf6yE/j4BiZHlsH2ZaGHQPJFVdQ99Fcl5tzsefubhti1/E7Co9e fEhc9GuXTHw8xTZqDFnLovzoSYD+KULi9JRwwpkJE89T51MG70aTctQDPCNKpmpkdAWS 1ei21FT2b/gtbZgPwZs7tIGn1Yfhjz1crzicgsDxvWxNgeQiE8RGgqGPR4vT6OmdBnOz tPM8NcMP1XESydyjHUzxlLQNQc4DPICN58o6+yPS/SEoyadKo4B0D04ibT7frquy9LQS 5tlXIqvuTyv40rNLEnQkaadlb8Mc8KrxkqavTH1Y6sxLXs9Hb4e2SyQQcTD5JvS/UtXY sMxA== X-Gm-Message-State: AOAM533fLZCO0eEj0BzgeJf0Ka2ptDtoLcxdmN3Sed0OyiVwgOrKBeAA CO2PcJ1xStIWig4lLUFEgPgDrGkHQhXdvACnmiKjjNlHpzmS+xn4zAUV5zWTzWzt1FEqEK+/bec vDSvSqob63udltotjGljmcOTQiYcH X-Received: by 2002:a17:906:5d06:: with SMTP id g6mr2424774ejt.96.1628755401689; Thu, 12 Aug 2021 01:03:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTX69X8II3Spa8cBebRjkPDbeI5LVOh0LnZP4Fu64b1UMZ63S0rODQ5HcI91Y68N/p0vo3ig== X-Received: by 2002:a17:906:5d06:: with SMTP id g6mr2424758ejt.96.1628755401490; Thu, 12 Aug 2021 01:03:21 -0700 (PDT) Received: from localhost.localdomain ([86.32.42.198]) by smtp.gmail.com with ESMTPSA id r2sm759114edv.78.2021.08.12.01.03.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Aug 2021 01:03:21 -0700 (PDT) From: Krzysztof Kozlowski To: ltp@lists.linux.it Date: Thu, 12 Aug 2021 10:02:39 +0200 Message-Id: <20210812080242.16972-2-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210812080242.16972-1-krzysztof.kozlowski@canonical.com> References: <20210812080242.16972-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_PASS 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 v2 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 Reviewed-by: Richard Palethorpe --- .../controllers/memcg/functional/memcg_lib.sh | 35 +++++++++++++++++++ .../memcg/functional/memcg_subgroup_charge.sh | 8 ++--- .../functional/memcg_use_hierarchy_test.sh | 6 ++-- 3 files changed, 41 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..c8b5df2b45f7 100755 --- a/testcases/kernel/controllers/memcg/functional/memcg_lib.sh +++ b/testcases/kernel/controllers/memcg/functional/memcg_lib.sh @@ -63,6 +63,41 @@ 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 - expected cgroup memory limit value to adjust +memcg_adjust_limit_for_kmem() +{ + [ $# -ne 1 ] && tst_brk TBROK "memcg_adjust_limit_for_kmem expects 1 parameter" + + local limit=$1 + + # Total number of CPUs + local total_cpus=`tst_ncpus` + + # Total number of nodes + if [ ! -d /sys/devices/system/node/node0 ]; then + total_nodes=1 + else + total_nodes=`ls /sys/devices/system/node/ | grep -c "node[0-9][0-9]*"` + fi + + local node_mem=0 + if [ $total_nodes -gt 1 ]; then + node_mem=$((total_nodes - 1)) + node_mem=$((node_mem * PAGESIZE * 128)) + fi + + limit=$((limit + 4 * PAGESIZE + total_cpus * PAGESIZE + node_mem)) + + echo $limit +} + 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..44fc7370eeff 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)) + limit_parent=$(memcg_adjust_limit_for_kmem $limit_parent) fi if [ $limit_subgroup -ne 0 ]; then - limit_subgroup=$((limit_subgroup + 4 * PAGESIZE + total_cpus * PAGESIZE)) + limit_subgroup=$(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..129f91b14c0a 100755 --- a/testcases/kernel/controllers/memcg/functional/memcg_use_hierarchy_test.sh +++ b/testcases/kernel/controllers/memcg/functional/memcg_use_hierarchy_test.sh @@ -15,12 +15,14 @@ test1() { tst_res TINFO "test if one of the ancestors goes over its limit, the proces will be killed" + local limit=$(memcg_adjust_limit_for_kmem $PAGESIZE) + 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 Thu Aug 12 08:02:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 1516176 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=Bz2p7QLv; 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 4GlfMb5DtJz9sX3 for ; Thu, 12 Aug 2021 18:03:39 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 4D0ED3C6BC1 for ; Thu, 12 Aug 2021 10:03:37 +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 [217.194.8.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 3A1623C2E09 for ; Thu, 12 Aug 2021 10:03:24 +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)) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id B9800600198 for ; Thu, 12 Aug 2021 10:03:23 +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 50A853F04E for ; Thu, 12 Aug 2021 08:03:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1628755403; bh=ynJX/i4iLC0nwj6Xb7ZVbzAkSC4MKYe1O4P/gJuOy5Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Bz2p7QLvkinyWL/xDY1T4ko49zP/do6/NvGUzAOZ2SaKfGm3Cozqx0iu9SPdSeYM9 J7W9hpfhzXy34e02viP0whDndDoKG/D6cJkxtVjm5RR8nXw0pxvFXzL7pMkN+cemYt aIEfViBGFImhocxYT44vVhX1Mg1dkgfZcEReihYfkastTCbLl8qnWKRfMMuaJfZ/dq fCDgq9NVgP8fY2nwnrm5hKpGpLmfeZPamRiO10CAbP0XNigyyOhh/Heb/j9uBSr4XZ JGoKfFhcmpe+cjrv5b3HHM5MoeoDNrf9GM78zOybVjUhfGXWebzvijohIWvfp+VTcL jEMgz32kbwLvw== Received: by mail-ed1-f71.google.com with SMTP id dh21-20020a0564021d35b02903be0aa37025so2674031edb.7 for ; Thu, 12 Aug 2021 01:03:23 -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=ynJX/i4iLC0nwj6Xb7ZVbzAkSC4MKYe1O4P/gJuOy5Y=; b=r+Vt1qxsLj8eRxVp96X6vu1RlJubuu6HV2dtOVif3UXM0TAgRrQ6+jByQpVnWKc+g7 JHI3T7b1y2eBkLTfU0YNAHIqTyFmLSs/Kexyq7j7DtkH4xaW4yHGQOxxFdkGZu3SclWs BI6ugqzpuTRqOU6AwL8Ixu5F6Fd52zUfm38pUczMfOYilMA82zcG3esZp3ruZAegEdbD pFUKC/FyYqrlWwcYZucBnED1e4+9j2YbovKerOJAnBblsRjNNhMmtij9uR7nWcN5/2UK 5nfWDz7Q8IvPAbM0rFKJuQnKewjgtgPhKpSVtnv8p18ENvXz685vL81BcZ4YQXIPYbxp lqMw== X-Gm-Message-State: AOAM531IfAMnNDO9zg/k0n72JbJm7K4L/l7hIoQD8O23/6WUyKhddcHb tyXcKXUw7iUOQDiUTwe8UfDxjpAsIYrRUmV+4VGZgxWS3IqttcIGxibTW0DAIsLpNxeOJnucQbO Kr+i3M98wAy6S0w8q8Wn9zvvgYp0K X-Received: by 2002:aa7:c7c2:: with SMTP id o2mr4018543eds.166.1628755402610; Thu, 12 Aug 2021 01:03:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwD6UuDyZoZ1rvjVmkhNJ5Gl+s7crVbw7UO5Z/s5vQ9mh53xvUbERtY/QBcRvuJrzz1Xb/QlA== X-Received: by 2002:aa7:c7c2:: with SMTP id o2mr4018534eds.166.1628755402499; Thu, 12 Aug 2021 01:03:22 -0700 (PDT) Received: from localhost.localdomain ([86.32.42.198]) by smtp.gmail.com with ESMTPSA id r2sm759114edv.78.2021.08.12.01.03.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Aug 2021 01:03:21 -0700 (PDT) From: Krzysztof Kozlowski To: ltp@lists.linux.it Date: Thu, 12 Aug 2021 10:02:40 +0200 Message-Id: <20210812080242.16972-3-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210812080242.16972-1-krzysztof.kozlowski@canonical.com> References: <20210812080242.16972-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_PASS 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 v2 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 Reviewed-by: Richard Palethorpe --- .../controllers/memcg/functional/memcg_stat_test.sh | 8 +++++--- 1 file changed, 5 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..94eaa45ce0d8 100755 --- a/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh +++ b/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh @@ -43,12 +43,14 @@ test5() tst_res TINFO "Test hierarchical_memory_limit with enabling hierarchical accounting" echo 1 > memory.use_hierarchy + local limit=$(memcg_adjust_limit_for_kmem $PAGESIZES) + 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 Thu Aug 12 08:02:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 1516178 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=eotXwSeW; 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 4GlfMz13KKz9sX3 for ; Thu, 12 Aug 2021 18:03:59 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 1CE3D3C6B53 for ; Thu, 12 Aug 2021 10:03:56 +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 B3A633C6B1B for ; Thu, 12 Aug 2021 10:03:25 +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)) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id 36710601485 for ; Thu, 12 Aug 2021 10:03:24 +0200 (CEST) Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.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 837863F0F8 for ; Thu, 12 Aug 2021 08:03:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1628755404; bh=WnbDGIS+NTForXDYjb/XnsB5jMW8WW/5CuRwbmUxDhA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=eotXwSeWDU8vpP6h010pME/zEGjdwqSaKq4s66rwdBWW20YKeKwl2/mBf+WD+Izdt QoD8pZsf4Za/cFrwqts4AYjMrF/GJi4/Oy6ou7KYLwyazRT5kCMz6VtqCNx3isSzXa DHgXL2ZXXr9VDa1rIKG3ECB0AwrSKTjAWCvWpYferJEDZ9JchYo/YmAd3uW3N9XNx/ 9LLmMKnnKc8yx0o+HnFho33Oc5banuV5ej9/yGLnVvXHnIRyGN9KEnSCeTsxs/9QeR q+KIhm6PhREmL1AIHKVOd+ubl/Ep0BvqsPo8rplnmIH/tlLiu8j6Vl1yMjfAC6QQen t1RVqUbb4Qgkg== Received: by mail-ed1-f69.google.com with SMTP id p2-20020a50c9420000b02903a12bbba1ebso2660480edh.6 for ; Thu, 12 Aug 2021 01:03:24 -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=WnbDGIS+NTForXDYjb/XnsB5jMW8WW/5CuRwbmUxDhA=; b=rlK9ba8ZrxXQcgZ5l2QwnmZMMHq9ZRu8KicGK1zPQTA3GD1c0VsxJr9pf7IxRg3lBj JjPLB4C8B634N2F2ZaBGfI3nBuUiITL4/q07Q7gSOajmfenwBdEG9AUzYb60CupBKdKc aGwAKYCB4hGlRuQlqQX/YDWG6K/k0eP3HWFrFaZjNnK6olirh8/kgsOyO72vwpo2ki7S teXtsgyOv4TsqADAq16Wvh/madwApS8R+qURkYfQxdCC5SxcqgImBGIqN4qOvLOPmye3 nrkLlF9FXaxeH7EsOlqK0NVGucw2vV9Paiovyvw4gf20FzkGb/qopKjt6dxEc2/Mrrsl dS5Q== X-Gm-Message-State: AOAM5338WHadN5Ouy6a39E70pSJe1GIXUceadrVW258msjc9HU884j2C 6Ikd/4KmiNFJ+TvUrRZ6J3yN5Mu9ifAZumzqrctD7qCazMWtY6hlShbnzh0Uc/vAgtBJMHGvLZB ormKj866Egjucjw3nvJwx9eFvfrhS X-Received: by 2002:a17:906:a298:: with SMTP id i24mr2404536ejz.151.1628755404010; Thu, 12 Aug 2021 01:03:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySnI3exVMfenA+iF688MktaPhOnT7hL+Hex75bkPeoXZE+I8cUOzPlRO/sPO10uCh90aWHng== X-Received: by 2002:a17:906:a298:: with SMTP id i24mr2404527ejz.151.1628755403856; Thu, 12 Aug 2021 01:03:23 -0700 (PDT) Received: from localhost.localdomain ([86.32.42.198]) by smtp.gmail.com with ESMTPSA id r2sm759114edv.78.2021.08.12.01.03.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Aug 2021 01:03:23 -0700 (PDT) From: Krzysztof Kozlowski To: ltp@lists.linux.it Date: Thu, 12 Aug 2021 10:02:41 +0200 Message-Id: <20210812080242.16972-4-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210812080242.16972-1-krzysztof.kozlowski@canonical.com> References: <20210812080242.16972-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_PASS 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 v2 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 Reviewed-by: Richard Palethorpe --- .../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 94eaa45ce0d8..c9034f7d4b41 100755 --- a/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh +++ b/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh @@ -45,7 +45,7 @@ test5() local limit=$(memcg_adjust_limit_for_kmem $PAGESIZES) - mkdir subgroup + ROD mkdir subgroup echo $limit > memory.limit_in_bytes echo $((limit + PAGESIZES * 2)) > subgroup/memory.limit_in_bytes @@ -61,9 +61,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 @@ -81,7 +81,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 @@ -102,7 +102,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 44fc7370eeff..c28c39cf4387 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() limit_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 129f91b14c0a..e219823841a5 100755 --- a/testcases/kernel/controllers/memcg/functional/memcg_use_hierarchy_test.sh +++ b/testcases/kernel/controllers/memcg/functional/memcg_use_hierarchy_test.sh @@ -17,10 +17,10 @@ test1() local limit=$(memcg_adjust_limit_for_kmem $PAGESIZE) - 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 @@ -34,7 +34,7 @@ test2() memcg_require_hierarchy_disabled - mkdir subgroup + ROD mkdir subgroup EXPECT_FAIL echo 1 \> memory.use_hierarchy rmdir subgroup @@ -46,7 +46,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 Thu Aug 12 08:02:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 1516182 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=jREKHoHR; 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GlfN82nZdz9t0Z for ; Thu, 12 Aug 2021 18:04:08 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 48AC73C6C84 for ; Thu, 12 Aug 2021 10:04:06 +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 B42EF3C6CFE for ; Thu, 12 Aug 2021 10:03:26 +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)) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id 296E7601476 for ; Thu, 12 Aug 2021 10:03:26 +0200 (CEST) Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.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 AF7883F0F8 for ; Thu, 12 Aug 2021 08:03:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1628755405; bh=gK8KS+1hDI1KxvtHtUTK2atRKa2k34jPI5Hkl5VdTx4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jREKHoHRH0Tt2HaaJqmoF6/8W887VuBZK7okLIRAWKDMtLfg8nVN976xeNyudKQQ7 ZoFGedikDIoqbxY0tT/KxXdMy4I1gRhuyaENmIyuM4/fIxZEg0YubiisMLkG6bcmrs AcObiZtVqpbagRTGl+7TwFNr4VhNa5d/2LbYwUBbuWDUDvSAx6k6obAcojRgwBJmP0 zQlQY4BpeIp4cObDD4pd4jpu9FNdIocQH+C2OTSuxDeCWKWOiaEYNq+YFJNQrQuVLf Ay5nsJ9MpMB9TaQSrhHIhIvgeIvUGL5frRVJIGvPUePrKXJCHAHfrX20YfZCJmcwQa ivR1y+LUXbFGA== Received: by mail-ed1-f69.google.com with SMTP id p2-20020a50c9420000b02903a12bbba1ebso2660523edh.6 for ; Thu, 12 Aug 2021 01:03:25 -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=gK8KS+1hDI1KxvtHtUTK2atRKa2k34jPI5Hkl5VdTx4=; b=pf4yGsp8aDwkHnWAacgYtMJX4AB0fZ0bCuolcxi64RhLDxdVSTHQgM9sAHaXNbOhkJ yhqVPYmD6Z4XEFV903PXkWRsoEvYfNhlVAmhS7Px9CktOF/fuxXhIuV7dXGNRITaMy6h Gnyvm3PDEVIKE5bw0cXepyw3wR333Sh/W+31aqcYOBkO2Ld15cEtnnHczKSTi59st1MH 2jYiaW7t5UJgL5pK8eda9dy7RO1YXeMP3kT5hzTarr5qIiL56GwkxQze0hRkz0DqSYrl fRDBlrJaIlFCVdW7rWX3uie+LqPm5MF007vucX3Sj5sPbQLVGP7hl6V26btjTWKqXHfG NWwg== X-Gm-Message-State: AOAM532Hec9phC4okplmkhk55I1rgbvFBXNrHmAr/S8u/zr2w1ueDzKK QZDpat66M1s7zwzLgmdUNiRE0dKque2i9GftYWTNlgJSIiiv40yE/FUTMbyYkHRbbcqIe716cVf PsdS3ZCffODWoe8JAy9SG812evd6K X-Received: by 2002:a17:906:85cc:: with SMTP id i12mr2379896ejy.405.1628755404951; Thu, 12 Aug 2021 01:03:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWNZ7aXlCQguJlKCO4Ef/UBOmqubMD/CW9vG+Tnz4YLksWWaWR2UiS1/EldkoYpGlG2BcqhA== X-Received: by 2002:a17:906:85cc:: with SMTP id i12mr2379888ejy.405.1628755404759; Thu, 12 Aug 2021 01:03:24 -0700 (PDT) Received: from localhost.localdomain ([86.32.42.198]) by smtp.gmail.com with ESMTPSA id r2sm759114edv.78.2021.08.12.01.03.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Aug 2021 01:03:24 -0700 (PDT) From: Krzysztof Kozlowski To: ltp@lists.linux.it Date: Thu, 12 Aug 2021 10:02:42 +0200 Message-Id: <20210812080242.16972-5-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210812080242.16972-1-krzysztof.kozlowski@canonical.com> References: <20210812080242.16972-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_PASS 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 v2 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 Reviewed-by: Richard Palethorpe --- .../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 c8b5df2b45f7..ee14a29fae81 100755 --- a/testcases/kernel/controllers/memcg/functional/memcg_lib.sh +++ b/testcases/kernel/controllers/memcg/functional/memcg_lib.sh @@ -380,7 +380,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 c9034f7d4b41..0308b40bab53 100755 --- a/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh +++ b/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh @@ -46,8 +46,8 @@ test5() local limit=$(memcg_adjust_limit_for_kmem $PAGESIZES) 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 @@ -64,8 +64,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)) @@ -82,10 +82,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 @@ -103,10 +103,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 c28c39cf4387..3fa016102151 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