From patchwork Sat Apr 23 15:56:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Vernet X-Patchwork-Id: 12824633 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 AED9DC4332F for ; Sat, 23 Apr 2022 15:57:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4704B6B007B; Sat, 23 Apr 2022 11:57:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3D1FB6B007D; Sat, 23 Apr 2022 11:57:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1FC096B007E; Sat, 23 Apr 2022 11:57:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id 113976B007B for ; Sat, 23 Apr 2022 11:57:13 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B9366190B for ; Sat, 23 Apr 2022 15:57:12 +0000 (UTC) X-FDA: 79388597904.20.158C38F Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) by imf16.hostedemail.com (Postfix) with ESMTP id 1B24D18003D for ; Sat, 23 Apr 2022 15:57:09 +0000 (UTC) Received: by mail-qt1-f173.google.com with SMTP id d14so7602565qtw.5 for ; Sat, 23 Apr 2022 08:57:12 -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=3Tpzhq0+TI5H5bdvK5Vbm+VLYv/+B/98xqWutaPHg68=; b=R/ehp81/YcYWX39bL3RrSH7FPgMwJ0eaIucNZOB3VdNvPRDNUVSaNOEAKXFhICZGYn 9Awd+SRz3XN3Qx+Gcb9XQVmcs2hajTpXDkk+Q/u61GRieSHN0AETarttaU5xIf/zARFw M7M/xKRs+c+doFHzk1E5Gj7QtH54kYtKeblxhdOHiHAa+0fRy4mpCsfuTCRPc/dIFWEW BKlaYQdICryWxZDTnuYx/Nldrtb4uhQUbQ/HSc284NrGuiJafOpklOrSgRLyfnGMx3mo XNjfuyvN9uwrUIm50Cyz9v7wI7x4o+YSRuN0HPEPJV9XJ+v2PfFQrxIACNtknZRVGLlQ ldug== X-Gm-Message-State: AOAM531sDjCoaTZsBwuRCYxR4c1srubFi+H5GZr7PJFp6nGQ8GJS8kBr eDOs+/or8Wx64Vl4PO/2ogE= X-Google-Smtp-Source: ABdhPJy3crThvLR/oO0Mz5YJCL0+y4Sy/Jx7i2E9UGDNE2Y8oLiSfFfMWXH4+Nf8j3wVjv8GhAHcBA== X-Received: by 2002:ac8:7a8a:0:b0:2f1:de6a:c044 with SMTP id x10-20020ac87a8a000000b002f1de6ac044mr6873334qtr.243.1650729431500; Sat, 23 Apr 2022 08:57:11 -0700 (PDT) Received: from localhost (fwdproxy-ash-006.fbsv.net. [2a03:2880:20ff:6::face:b00c]) by smtp.gmail.com with ESMTPSA id w15-20020ac857cf000000b002f33f220c76sm2959583qta.32.2022.04.23.08.57.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Apr 2022 08:57:11 -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 v2 3/5] cgroup: Account for memory_localevents in test_memcg_oom_group_leaf_events() Date: Sat, 23 Apr 2022 08:56:20 -0700 Message-Id: <20220423155619.3669555-4-void@manifault.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220423155619.3669555-1-void@manifault.com> References: <20220423155619.3669555-1-void@manifault.com> MIME-Version: 1.0 X-Stat-Signature: tmr3whxypmuftinjtg6sqpxoqudinbdy Authentication-Results: imf16.hostedemail.com; dkim=none; spf=pass (imf16.hostedemail.com: domain of dcvernet@gmail.com designates 209.85.160.173 as permitted sender) smtp.mailfrom=dcvernet@gmail.com; dmarc=none X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 1B24D18003D X-HE-Tag: 1650729429-645276 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000004, 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 --- .../selftests/cgroup/test_memcontrol.c | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c b/tools/testing/selftests/cgroup/test_memcontrol.c index d37e8dfb1248..e899b3f28c22 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,10 +1130,16 @@ 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) - goto cleanup; - - ret = KSFT_PASS; + 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 && parent_oom_events == 0) || + parent_oom_events > 0) + ret = KSFT_PASS; cleanup: if (child) @@ -1298,6 +1306,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: