From patchwork Fri Dec 2 03:15:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yosry Ahmed X-Patchwork-Id: 13062113 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 2A5C3C4332F for ; Fri, 2 Dec 2022 03:15:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B88226B0078; Thu, 1 Dec 2022 22:15:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B37D16B007B; Thu, 1 Dec 2022 22:15:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9FF446B007D; Thu, 1 Dec 2022 22:15:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 8B69B6B0078 for ; Thu, 1 Dec 2022 22:15:37 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 74826121240 for ; Fri, 2 Dec 2022 03:15:37 +0000 (UTC) X-FDA: 80195901114.03.3ABA79F Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) by imf27.hostedemail.com (Postfix) with ESMTP id 2409A40009 for ; Fri, 2 Dec 2022 03:15:36 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=c5bVHWOV; spf=pass (imf27.hostedemail.com: domain of 32G2JYwoKCPs1rvu1dkphgjrrjoh.frpolqx0-ppnydfn.ruj@flex--yosryahmed.bounces.google.com designates 209.85.215.201 as permitted sender) smtp.mailfrom=32G2JYwoKCPs1rvu1dkphgjrrjoh.frpolqx0-ppnydfn.ruj@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669950937; 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=bNyz6y2Y8+pcZcYRhDrKnevmtY0/xVh2JMC54suzd2M=; b=u1lRHALytxLpfGr2ytcNOXrKKaqvjKLBg3fLmKUDE/3vFTbFtw1h+4fRs+OJmqo6mlzEIo Ii8jbe/lhvlkd5qHgafYTftZNLXIHm/J+AhjDLwyac8A+YvoYt644Yv2zt3SEG+RWvKLX5 glMQJqa/k1xzQD12rKOd4N+zhrJV86o= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=c5bVHWOV; spf=pass (imf27.hostedemail.com: domain of 32G2JYwoKCPs1rvu1dkphgjrrjoh.frpolqx0-ppnydfn.ruj@flex--yosryahmed.bounces.google.com designates 209.85.215.201 as permitted sender) smtp.mailfrom=32G2JYwoKCPs1rvu1dkphgjrrjoh.frpolqx0-ppnydfn.ruj@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1669950937; a=rsa-sha256; cv=none; b=zGgzx6ZfxwWyGSyKSKXtOlqWlqapPgAmykmtblKUZU214UqUNc53TMl0mAsK1dnUQqWGco o3J+G2qIkN6MOb+sH141v9nLsc15m56YTyTeTN61Cb602rs9hQgL0uM6C6SE/k7t++4pJQ rcMH5AW8MO+G4abELHVhAkNHn7BHK7I= Received: by mail-pg1-f201.google.com with SMTP id r126-20020a632b84000000b004393806c06eso3442766pgr.4 for ; Thu, 01 Dec 2022 19:15:36 -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=bNyz6y2Y8+pcZcYRhDrKnevmtY0/xVh2JMC54suzd2M=; b=c5bVHWOVWFxZh/IsKMqBecLiB8RmgVwYrX1GzaIQJrvdCmfUyfs8qg0W9hhScf5hH4 mG1HkIkP0USGP4r6R6YG/H5u+ozhVJBPbINAptVF+p7iL7Zdme2Si3JoPCUQg5PnuM8i 9sgrk6G5d9YLX23J/vJ2Mgm92LjuGfj+UUMBTfr4WknUpFkwvTonc3miyBG+12r8p9WO rKEJGNGnV/+QeTnBLn5B4wArNPSCesKqvyX6p+9fULbYoMK0hz3Mmtd+Zort4W8lRQ75 zHRyiG+ShUvq2dHWqAQo/BfIP9kKzWFVg6HrESVMYli7xM6bVzIBYa/ChJND9QG28tZc zf6A== 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=bNyz6y2Y8+pcZcYRhDrKnevmtY0/xVh2JMC54suzd2M=; b=C2/sWPdp4efw5rxNKNunSrzE4dC04Evogx1oSHjmteTjytjn+gKV48B8flY0HMwsrQ IoCTgfycKlMupwPoGQiohTQV56fk0pGtrC3xZlfmrWoyKl7rKyz6n2oke7B+oaiH5Jc7 i6tWy4JgzGHBgvPJOxAjJdfxV9up2hYD+ibl+eXobWPiCmPNcoLZeIhlCc/jfo3MUSnH QwQHs5YpqwZ35ebnTJcbGfwa/PNbp1IqTMkFBz01p3I2o2sDm0h1lGOw5RCfudRIBU1g q37Lm1AqTbZbVdtrE/rRKlAmrkvIyRawD6JpTC+T3fPlc+kKrxurbL/y8OIJEJVIRedH LYxQ== X-Gm-Message-State: ANoB5pnNP5dXqzIXw3FTRhehRYw2f65Pjv8j5lcElss/bzuxUHuZmjh1 i9LCoVWct++YtWyWRHV10sMl2F36Kov/xSJY X-Google-Smtp-Source: AA0mqf5+TNJlExQui1Z3kcvsElvim4BKI/6fNytWOv4a9T8n9JlH01lAtNxLgUNDVBfiWHcWgrDzDV9aKBY00gko X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2327]) (user=yosryahmed job=sendgmr) by 2002:a62:62c4:0:b0:575:e44e:3e0 with SMTP id w187-20020a6262c4000000b00575e44e03e0mr10149400pfb.53.1669950936154; Thu, 01 Dec 2022 19:15:36 -0800 (PST) Date: Fri, 2 Dec 2022 03:15:12 +0000 In-Reply-To: <20221202031512.1365483-1-yosryahmed@google.com> Mime-Version: 1.0 References: <20221202031512.1365483-1-yosryahmed@google.com> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog Message-ID: <20221202031512.1365483-4-yosryahmed@google.com> Subject: [PATCH v3 3/3] selftests: cgroup: make sure reclaim target memcg is unprotected From: Yosry Ahmed To: Andrew Morton , Shakeel Butt , Roman Gushchin , Johannes Weiner , Michal Hocko , Yu Zhao , Muchun Song , Tejun Heo Cc: "Matthew Wilcox (Oracle)" , Vasily Averin , Vlastimil Babka , Chris Down , David Rientjes , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Yosry Ahmed X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 2409A40009 X-Stat-Signature: mkfkhcgbk6dx17t7tptexyz64wi4bqdn X-Rspam-User: X-Spamd-Result: default: False [3.39 / 9.00]; SORBS_IRL_BL(3.00)[209.85.215.201:from]; BAYES_HAM(-1.51)[91.76%]; MID_CONTAINS_FROM(1.00)[]; MV_CASE(0.50)[]; FORGED_SENDER(0.30)[yosryahmed@google.com,32G2JYwoKCPs1rvu1dkphgjrrjoh.frpolqx0-ppnydfn.ruj@flex--yosryahmed.bounces.google.com]; RCVD_NO_TLS_LAST(0.10)[]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; PREVIOUSLY_DELIVERED(0.00)[linux-mm@kvack.org]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_DKIM_ALLOW(0.00)[google.com:s=20210112]; RCVD_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+]; R_SPF_ALLOW(0.00)[+ip4:209.85.128.0/17]; RCPT_COUNT_TWELVE(0.00)[17]; DKIM_TRACE(0.00)[google.com:+]; ARC_SIGNED(0.00)[hostedemail.com:s=arc-20220608:i=1]; DMARC_POLICY_ALLOW(0.00)[google.com,reject]; FROM_NEQ_ENVFROM(0.00)[yosryahmed@google.com,32G2JYwoKCPs1rvu1dkphgjrrjoh.frpolqx0-ppnydfn.ruj@flex--yosryahmed.bounces.google.com]; TO_MATCH_ENVRCPT_SOME(0.00)[]; ARC_NA(0.00)[] X-HE-Tag: 1669950936-331678 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, 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 a8f4700353a4..1e616a8c6a9c 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); + /* * 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;