From patchwork Fri Apr 22 15:57:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Vernet X-Patchwork-Id: 12823694 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A400C433F5 for ; Fri, 22 Apr 2022 15:57:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 280E76B009E; Fri, 22 Apr 2022 11:57:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 238A76B009F; Fri, 22 Apr 2022 11:57:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E65F76B00A0; Fri, 22 Apr 2022 11:57:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id D12BF6B009E for ; Fri, 22 Apr 2022 11:57:50 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id AF155208AF for ; Fri, 22 Apr 2022 15:57:50 +0000 (UTC) X-FDA: 79384970700.27.C530C50 Received: from mail-qv1-f46.google.com (mail-qv1-f46.google.com [209.85.219.46]) by imf18.hostedemail.com (Postfix) with ESMTP id EA6051C0029 for ; Fri, 22 Apr 2022 15:57:47 +0000 (UTC) Received: by mail-qv1-f46.google.com with SMTP id b17so6317551qvf.12 for ; Fri, 22 Apr 2022 08:57:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=B3B1dGnzOmkr3L8TkEmHq2fqLk42IndbueuBAtAlDZs=; b=jFWlhvPBTBAyS5KerO36UBpbLIAqoXGB/dEqZisvMRY10A+rxABrCaacZDkrwJJf6l Pa+2B2wb4eaxsjwca4czScmJKmDBzx8JLrY2hKw/r318JXxnbnad3DAnma/Qeudr9u/9 Gfprnc2C+5o+VWAiXjGHwoj+BEk24hji8HVFp+GzCyuns01AbPMGSZbQ5n3hjGmudti+ vVdj7mtQkcxaP+RSbTS5MFd3PCR+lGdRKJWonpNGsX739/iAap6s79B0A0ykm+1vqhRz S/fqIn0oygQp8aj3FF0BSaSoOnLn2Zpp8pzc8rchdFUgTqxZzcttzjnprlsPKR046L+6 FP/A== X-Gm-Message-State: AOAM533Msy5qHGO/JaRsceo9s7xzyTtUnAWlbLf0iF28JtYOxqQ4zBjz m5qmubhQ3IUlHsxf1nsPJPE= X-Google-Smtp-Source: ABdhPJwkKpkXUXCGxEyQQ7dOCDVgeo3GrLKYQUje6jc+8FcwPX60dYm6Q9j05eHfCzT3CfeDA+rTMQ== X-Received: by 2002:a05:6214:2a8e:b0:443:8a10:c1ca with SMTP id jr14-20020a0562142a8e00b004438a10c1camr3917627qvb.88.1650643069480; Fri, 22 Apr 2022 08:57:49 -0700 (PDT) Received: from localhost (fwdproxy-ash-011.fbsv.net. [2a03:2880:20ff:b::face:b00c]) by smtp.gmail.com with ESMTPSA id f11-20020a05620a12eb00b0069c88d15b6asm1043746qkl.68.2022.04.22.08.57.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 08:57:49 -0700 (PDT) From: David Vernet To: akpm@linux-foundation.org Cc: tj@kernel.org, roman.gushchin@linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, hannes@cmpxchg.org, mhocko@kernel.org, shakeelb@google.com, kernel-team@fb.com, void@manifault.com Subject: [PATCH 3/5] cgroup: Account for memory_localevents in test_memcg_oom_group_leaf_events() Date: Fri, 22 Apr 2022 08:57:27 -0700 Message-Id: <20220422155728.3055914-4-void@manifault.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220422155728.3055914-1-void@manifault.com> References: <20220422155728.3055914-1-void@manifault.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: EA6051C0029 X-Stat-Signature: s9picsyh8eon7s6x1jd8ykeyx7kp4z7t Authentication-Results: imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of dcvernet@gmail.com designates 209.85.219.46 as permitted sender) smtp.mailfrom=dcvernet@gmail.com; dmarc=none X-HE-Tag: 1650643067-440397 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000091, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The test_memcg_oom_group_leaf_events() testcase in the cgroup memcg tests validates that processes in a group that perform allocations exceeding memory.oom.group are killed. It also validates that the memory.events.oom_kill events are properly propagated in this case. Commit 06e11c907ea4 ("kselftests: memcg: update the oom group leaf events test") fixed test_memcg_oom_group_leaf_events() to account for the fact that the memory.events.oom_kill events in a child cgroup is propagated up to its parent. This behavior can actually be configured by the memory_localevents mount option, so this patch updates the testcase to properly account for the possible presence of this mount option. Signed-off-by: David Vernet Acked-by: Roman Gushchin --- .../testing/selftests/cgroup/test_memcontrol.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c b/tools/testing/selftests/cgroup/test_memcontrol.c index ea2fd27e52df..d88e0ca3f3d1 100644 --- a/tools/testing/selftests/cgroup/test_memcontrol.c +++ b/tools/testing/selftests/cgroup/test_memcontrol.c @@ -21,6 +21,7 @@ #include "../kselftest.h" #include "cgroup_util.h" +static bool has_localevents; static bool has_recursiveprot; /* @@ -1091,6 +1092,7 @@ static int test_memcg_oom_group_leaf_events(const char *root) { int ret = KSFT_FAIL; char *parent, *child; + long parent_oom_events; parent = cg_name(root, "memcg_test_0"); child = cg_name(root, "memcg_test_0/memcg_test_1"); @@ -1128,7 +1130,15 @@ static int test_memcg_oom_group_leaf_events(const char *root) if (cg_read_key_long(child, "memory.events", "oom_kill ") <= 0) goto cleanup; - if (cg_read_key_long(parent, "memory.events", "oom_kill ") <= 0) + parent_oom_events = cg_read_key_long( + parent, "memory.events", "oom_kill "); + // If memory_localevents is not enabled (the default), the parent should + // count OOM events in its children groups. Otherwise, it should not + // have observed any events. + if (has_localevents) { + if (parent_oom_events != 0) + goto cleanup; + } else if (parent_oom_events <= 0) goto cleanup; ret = KSFT_PASS; @@ -1298,6 +1308,11 @@ int main(int argc, char **argv) ksft_exit_skip("Failed to query cgroup mount option\n"); has_recursiveprot = proc_status; + proc_status = proc_mount_contains("memory_localevents"); + if (proc_status < 0) + ksft_exit_skip("Failed to query cgroup mount option\n"); + has_localevents = proc_status; + for (i = 0; i < ARRAY_SIZE(tests); i++) { switch (tests[i].fn(root)) { case KSFT_PASS: