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: 24818 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2681666wrr; Wed, 23 Nov 2022 01:23:12 -0800 (PST) X-Google-Smtp-Source: AA0mqf43AVFDUUd+fMI9WCsW17iHic+oJPwQQ/0FLfGX8vDzWCR0HWngWwcSNrwkY7CZwSwzOqX9 X-Received: by 2002:a17:90b:683:b0:213:cfb4:719 with SMTP id m3-20020a17090b068300b00213cfb40719mr8026183pjz.188.1669195392361; Wed, 23 Nov 2022 01:23:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669195392; cv=none; d=google.com; s=arc-20160816; b=kYRBqDz5jHOKEQycLm5eoQTem9UxYupQXF/UdXDrBsUKwJzfH2mOdZ9M6v7+RXLJKA VWkEprOejx61z79TSxJqiJ+qfP8l+AWiRqncbpyuQTL90LK7FM4KE7yqyt+wa6IMI7WB UlSIpZ5MNllazq86cmN3+e6oJL4Wbm5IrN2mcCK5WuIJj+YL9EAlw+e9GeMFakHEruhL dFOS8B3CU/Yq6tMlZYxhvcDq3dfu11qElZIzUaq6l6R8Bl8imHOsUDofX9SLiPZM2xL1 Kv7W8QMvrFEVUNyMqCd+kA0FPj9hJFfLyoC1uKIZblLC/nLiRsicjfy9qc0W5A3ZarBJ GLEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=wv2KXXYxhgmiwiwKTV3Llr06CSap+0UqOMvMPP82Z+U=; b=ZMHN1JWWsTPPOWhhAlHESLYdSCcgA2Va+Z65GErG0fbM0RfsXCn5X/K3TdsiBzN0Wt LvzxdYwUocna7Ni/iV+aFRjZv7N5stc5iVflN4+aPSpokCXG/TukJWAyCg+OfQrF4LkT Jy84a6YOp/ai9cuumlIOpansV+ji6GHa3f3EcYTD/xpwL09ZZGTnXxqCNeU7XPXuwAdv aMs39qKNS19LOP3lMPXNyArpdPRdeUKOGl8q6NXAoxhQ5l9u8Y+6JyNbraQmCCxBVMP0 DlEeSIxVgcXn5kHPpvkc/ohDW57bBRHgNV6NZQVR7s5v+o85vGzLcEK9OyZCvQ5EiW0o f4cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="d/rtyAMO"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g38-20020a635666000000b004541962a9basi3378496pgm.701.2022.11.23.01.22.59; Wed, 23 Nov 2022 01:23:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="d/rtyAMO"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237580AbiKWJWf (ORCPT + 99 others); Wed, 23 Nov 2022 04:22:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237639AbiKWJWD (ORCPT ); Wed, 23 Nov 2022 04:22:03 -0500 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A9A91095BF for ; Wed, 23 Nov 2022 01:21:48 -0800 (PST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-38f92b4b3f2so161804367b3.1 for ; Wed, 23 Nov 2022 01:21:48 -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=epK85SEOCS9LxPqD366CrrzetCI2OvMnY9Jj8aICqhlpa2qAakNRor4sjiL+x5SmhR tV+m+WF09UsCX88YrIu9/X4/LC8PzrfLm0jTxGE9WZf2rMJgzDRWrL+HN2aIBwjek6Gk 3o1EF4YQ5rEA+joP70SUMtnppISwBcGqy980wCtG+qs4rXp95qj6+0MkipUgcRuLWeuc sgrbzBrKx6Ut81vKVd/DAwbaZmq6EuGmj8r0cxx5+4dnydqkEtSDeuetQBfQb2VG99Q6 FToPSFe5iY03LC1BDmG8Xfa3SZdfSGlCiNL8lE6flEDyh93GwgXptkszKuroRIr75fqL Lvyw== X-Gm-Message-State: ANoB5plz5pufGSsDAQYpQI4XOP63HkejfYyZbW1TkjRSUiq20pzQIGwa vx0t4X7al8elDFdi/jGm707mDd5Nz7FFjtJa 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 X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750278227869791736?= X-GMAIL-MSGID: =?utf-8?q?1750278227869791736?= 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;