From patchwork Wed Nov 23 09:21:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yosry Ahmed X-Patchwork-Id: 13053289 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 82BEAC4332F for ; Wed, 23 Nov 2022 09:21:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E4ADA8E0003; Wed, 23 Nov 2022 04:21:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DD4198E0001; Wed, 23 Nov 2022 04:21:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C4E168E0003; Wed, 23 Nov 2022 04:21:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id B5B1F8E0001 for ; Wed, 23 Nov 2022 04:21:48 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 90A51A10DB for ; Wed, 23 Nov 2022 09:21:48 +0000 (UTC) X-FDA: 80164164696.14.8C80DF3 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf20.hostedemail.com (Postfix) with ESMTP id 4513F1C0006 for ; Wed, 23 Nov 2022 09:21:47 +0000 (UTC) Received: by mail-yb1-f202.google.com with SMTP id v189-20020a252fc6000000b006e7396ee2c3so15544662ybv.9 for ; Wed, 23 Nov 2022 01:21:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=wv2KXXYxhgmiwiwKTV3Llr06CSap+0UqOMvMPP82Z+U=; b=d/rtyAMOztdMTDBjXLhp+iK6iUvN4N9zc37scM2toboxh4tk1p4sCS10UBQdR4N3qD 5ze2ZpOfEEFYscj7wiB8Ugseb4cQQM/uJ4nqiUFppNlb+jUaaH7Ra4gBBobPGJ+MtlrL l4OSPfSUX70myNYZ0QWyiCku2BlYtAWqMjxZA4mnibWQ6/pknMLv+6ygUQfQtkEWgxAC JAtp93YrJbt0CZrdzKM7ss1ntR+8fufAN6h8qscMZMKMP/1LgkHNnxCz5O2YMMIMAv9O YiGzeYNmP7lLNDM3YplOWbNjmb/9MZlcx+TEI26B5TV0+3OFk1q8lSVhVH5VJN7YtJEI e6iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wv2KXXYxhgmiwiwKTV3Llr06CSap+0UqOMvMPP82Z+U=; b=yLB3cxmj1SZexHlrxFH8PyLCtEuu7lvV3BXqOAEkeHZMzWlAkllffpt/3sGmvToPD7 WeF4s+ecr7nHg3JnYkINMgifm96kQf8nAt4RnTvsOLMueDRWxVJvS7pHMRKeqSoNC/+a gw1RMMuojfF76l6/K6BkZixU0KK/2Hnxdsfxab1vTT4yvpJARj3EWsRWgod1V1naKtC8 J+1Em+d09Qs9QhQHhsGkk/ofLRKl2qKKcCJIB8vTnCiwZvMjcWXXtHl3ARSRe4XbMc3Y GQvy5Q56SQpX1+ELqPBacu5oVCPwKGZAkArWtwTjDVmorGJDiaB/fK/aDsI/Y8VhfU35 5/qQ== X-Gm-Message-State: ANoB5pnY8Oqg2j6uk9Z0/sbGJTjWJQSbah8EG2BoKMdntLzBUy0FlHTj bDP/zwc4U1wta5nJ92nGwDpf7dQUQAoyOu5w X-Google-Smtp-Source: AA0mqf6sGopFfR1Aoda1Zdzt1YJ6XFFAb/E4mCK0N9ulMBl/Uu/0CQNXAGVehsabcRRiBRWhaT2ftO3U35pybhbT X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2327]) (user=yosryahmed job=sendgmr) by 2002:a0d:e507:0:b0:390:3cd1:cb16 with SMTP id o7-20020a0de507000000b003903cd1cb16mr10405812ywe.307.1669195307300; Wed, 23 Nov 2022 01:21:47 -0800 (PST) Date: Wed, 23 Nov 2022 09:21:32 +0000 In-Reply-To: <20221123092132.2521764-1-yosryahmed@google.com> Mime-Version: 1.0 References: <20221123092132.2521764-1-yosryahmed@google.com> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog Message-ID: <20221123092132.2521764-4-yosryahmed@google.com> Subject: [PATCH v2 3/3] selftests: cgroup: make sure reclaim target memcg is unprotected From: Yosry Ahmed To: Shakeel Butt , Roman Gushchin , Johannes Weiner , Michal Hocko , Yu Zhao , Muchun Song Cc: "Matthew Wilcox (Oracle)" , Vasily Averin , Vlastimil Babka , Chris Down , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Yosry Ahmed ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="d/rtyAMO"; spf=pass (imf20.hostedemail.com: domain of 3K-Z9YwoKCBIG6A9Gsz4wvy66y3w.u64305CF-442Dsu2.69y@flex--yosryahmed.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3K-Z9YwoKCBIG6A9Gsz4wvy66y3w.u64305CF-442Dsu2.69y@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1669195308; a=rsa-sha256; cv=none; b=wVVvfbCStb8EX5NwHF/eTKdxqpaAIiRkhPZsTr9YXYQq6mjiOLfZ0QTis4u5mtJUGh281o 2RyINdnbXVZCxYgospQOJa1q3HznShFYCNp58LamjwVfEDaxVrIsOgzIFNwrIqh/buhCsl V/Vs77tSiRqsLTx9KiSfzySjCN1O8jk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669195308; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=wv2KXXYxhgmiwiwKTV3Llr06CSap+0UqOMvMPP82Z+U=; b=DMsHORIhAx+QLswGa1fE55j/MV+oPUS27Os3I5qmzY/y3GiQcN6N+2GVswrKZ4w/3wnsb7 FDYilZz6TSFCfehGyBLNXFeTQMIkltmH8IO0Pu9IytYjiNY8/L3/uF5px1RDDj3kFMeIl0 3+JhYnz3e02ksSbVkDok2+D9FYd3wqE= X-Rspamd-Queue-Id: 4513F1C0006 X-Rspam-User: Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="d/rtyAMO"; spf=pass (imf20.hostedemail.com: domain of 3K-Z9YwoKCBIG6A9Gsz4wvy66y3w.u64305CF-442Dsu2.69y@flex--yosryahmed.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3K-Z9YwoKCBIG6A9Gsz4wvy66y3w.u64305CF-442Dsu2.69y@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam06 X-Stat-Signature: 7don3h993qh36m6azeznfi51medghzik X-HE-Tag: 1669195307-985987 X-Bogosity: Ham, tests=bogofilter, spamicity=0.001795, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Make sure that we ignore protection of a memcg that is the target of memcg reclaim. Signed-off-by: Yosry Ahmed Reviewed-by: Roman Gushchin --- tools/testing/selftests/cgroup/test_memcontrol.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c b/tools/testing/selftests/cgroup/test_memcontrol.c index d4182e94945e..bac3b91f1579 100644 --- a/tools/testing/selftests/cgroup/test_memcontrol.c +++ b/tools/testing/selftests/cgroup/test_memcontrol.c @@ -238,6 +238,8 @@ static int cg_test_proc_killed(const char *cgroup) return -1; } +static bool reclaim_until(const char *memcg, long goal_usage); + /* * First, this test creates the following hierarchy: * A memory.min = 0, memory.max = 200M @@ -266,6 +268,12 @@ static int cg_test_proc_killed(const char *cgroup) * unprotected memory in A available, and checks that: * a) memory.min protects pagecache even in this case, * b) memory.low allows reclaiming page cache with low events. + * + * Then we try to reclaim from A/B/C using memory.reclaim until its + * usage reaches 10M. + * This makes sure that: + * (a) We ignore the protection of the reclaim target memcg. + * (b) The previously calculated emin value (~29M) should be dismissed. */ static int test_memcg_protection(const char *root, bool min) { @@ -385,6 +393,9 @@ static int test_memcg_protection(const char *root, bool min) if (!values_close(cg_read_long(parent[1], "memory.current"), MB(50), 3)) goto cleanup; + if (!reclaim_until(children[0], MB(10))) + goto cleanup; + if (min) { ret = KSFT_PASS; goto cleanup;