Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2177474rdh; Tue, 26 Sep 2023 15:17:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGyYNyTVwA8N55ahmwmaB9ZifVBVGIni2iqVUgqEGJWzgoJZOL8x0AvOrqAXrv8CoqxZWPP X-Received: by 2002:a17:90a:49c7:b0:273:efde:2ea4 with SMTP id l7-20020a17090a49c700b00273efde2ea4mr16170pjm.42.1695766668756; Tue, 26 Sep 2023 15:17:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695766668; cv=none; d=google.com; s=arc-20160816; b=Zjwbq7yULwOZgPFWWiWbe4fzi3gXdaoTmlow/T6456Brvuq3okUCN2vMBX6MtpBSDm wDdAFEmiCcOnnSys4edfzmDAWvLnGZbijQqEoY+ibHhtL5jnn4qYvN4Jpm8c7mufjp82 XyK+QVeZjK8I3+SmOwKZHJ2+/FbWxr5H2MGbY53Kqb6lLKGkJ0R4igBAdqEs3x6jXWGU mKMvStFWp4KnFpYxx2HHcfNYSbTyRnFG33twHYLUoEX3Srl09DkAdws6K+l1Tq0DDBOZ HtIdXShJWTlQ6SaoktPf4rLfMNe2eenlzQdgapnAV4F9KPffaP3FjolxxskDBvDgQbIP BDgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qDGh2bfYFEdmujy/uEQ8v6m9bD4HO3qMXiBWaHUJXwQ=; fh=dr01barU9xhgfmkh9W9wZxPUiBGNGqZfFlS6t/GIbLY=; b=zSjUAPQOATuse2pdp0CEvkt/SGHF+mR+bnCpN7vd+OaaQlV3/1odPsNUVsBlzx9Vyu 2lRFrkBKGZBo1lrtAuUjAXkajtDk0NDH8ReVxQzBYSFMUUTBsHeL5cLNLrUIFbVJ1gZQ K5yhCfyNOVxHKv4VweCpNTKZBIi5IwoAzq46EyCKfZ8+9hfuo8gFsmLU6rDN6Lqp9cBC V0oJfbzJ3N/KJsVVaOSe2NJVURxRNk2VkP2q72mGiF0R+5xawPSBbVVGlQm5ZSE4LLpl dcEJNhGlG59mc+249gu/k6m4j4j+kiMSPqj6Uv8v8HRe9a4rgkjN94uAQGo76L44DeFu yJrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=iizb+0mM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id u15-20020a17090a6a8f00b0026b0c3f1506si15562854pjj.155.2023.09.26.15.17.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 15:17:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=iizb+0mM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 80F7180D88E6; Tue, 26 Sep 2023 13:41:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235898AbjIZUlT (ORCPT + 99 others); Tue, 26 Sep 2023 16:41:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235891AbjIZUlR (ORCPT ); Tue, 26 Sep 2023 16:41:17 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 381429F; Tue, 26 Sep 2023 13:41:11 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1c5cd27b1acso86300785ad.2; Tue, 26 Sep 2023 13:41:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695760870; x=1696365670; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qDGh2bfYFEdmujy/uEQ8v6m9bD4HO3qMXiBWaHUJXwQ=; b=iizb+0mMo9pfx/eNixNWYm1ja6dmk5maQzuDvr8w4wwRA7/AHwWdCZJmGMmFgaeu0G DZJLLbJyWGTaJHcLe9eubfySTHYcJcPP8tboOeVYaKlcV4t6PkX8cgw3jTtWLvmRv3sb t/eoVr1g+VZaNZTTA+EbspUF3B2tKTaN0gaT0aBmZ1cpfeJ67GQsn7UVmS92t9K/Ff4i XjcrchteOxBSPvqg/MCBMZ5z34rtUl8JQ0ZnlPY+mJCy3qQKy+/sxEjKuPr05+8y5nNC jrY0EDTPT+2yx61028z8GYKnv9lgLjl2J/jFawQMHM2CumoBsDpbegqFqVeNmjW8kFTa 1g+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695760870; x=1696365670; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qDGh2bfYFEdmujy/uEQ8v6m9bD4HO3qMXiBWaHUJXwQ=; b=Z9pHfCxh71Ym+1cLhRR1sjQptycP99HIxG8lKv5lL0YtAPkCztunc0CircmCciVnmh CVBP/fc7s9xLuQi97s0OEwdBvlo0/eVNOtqS8PcPG8JIlF6qSgtO3zikKRIYzvPscZ9x 3eWizc7RBLI1Ohsce2GKqZq6ZvV3jgZ55s9aOfkMu3KeBEvzMQHZXxWh7uXIJuSdyGoO 3fg4d3CcLq6ah/Ll6YSGrCKmOVrG/3HCGcbuD1TWRcHN/m9dB6X3qE4VzQB4pKaPiaj7 L3bmBLDspauOXnLDZEl75Xu7pxWYiWvU9lvO92f1p9x0VBwwhhnQltLmdr6D6wCDq+yN rtsQ== X-Gm-Message-State: AOJu0YyaVybxA792uMKZjUvtx7PjKsGEdvLIRMq6OT9mqMvoRlWzQx9o u5QVTP2n8JCe0uysvFf1crk= X-Received: by 2002:a17:903:110d:b0:1b8:4f93:b210 with SMTP id n13-20020a170903110d00b001b84f93b210mr12673893plh.45.1695760869764; Tue, 26 Sep 2023 13:41:09 -0700 (PDT) Received: from localhost (fwdproxy-prn-002.fbsv.net. [2a03:2880:ff:2::face:b00c]) by smtp.gmail.com with ESMTPSA id z9-20020a170903018900b001bd99fd1114sm4198499plg.288.2023.09.26.13.41.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 13:41:09 -0700 (PDT) From: Nhat Pham To: akpm@linux-foundation.org Cc: riel@surriel.com, hannes@cmpxchg.org, mhocko@kernel.org, roman.gushchin@linux.dev, shakeelb@google.com, muchun.song@linux.dev, tj@kernel.org, lizefan.x@bytedance.com, shuah@kernel.org, mike.kravetz@oracle.com, yosryahmed@google.com, linux-mm@kvack.org, kernel-team@meta.com, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org Subject: Re: [PATCH 2/2] selftests: add a selftest to verify hugetlb usage in memcg Date: Tue, 26 Sep 2023 13:41:08 -0700 Message-Id: <20230926204108.2931076-1-nphamcs@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230926194949.2637078-3-nphamcs@gmail.com> References: <20230926194949.2637078-3-nphamcs@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 26 Sep 2023 13:41:34 -0700 (PDT) Ooops I forgot to commit this change. Basically just moving the nr_hugepages check inside the test program run within the cgroup. This should apply cleanly: diff --git a/tools/testing/selftests/cgroup/test_hugetlb_memcg.c b/tools/testing/selftests/cgroup/test_hugetlb_memcg.c index 9651f6af6914..436522257cd2 100644 --- a/tools/testing/selftests/cgroup/test_hugetlb_memcg.c +++ b/tools/testing/selftests/cgroup/test_hugetlb_memcg.c @@ -100,6 +100,14 @@ static int hugetlb_test_program(const char *cgroup, void *arg) int ret = EXIT_FAILURE; old_current = cg_read_long(test_group, "memory.current"); + set_nr_hugepages(20); + current = cg_read_long(test_group, "memory.current"); + expected_current = old_current; + if (!values_close(expected_current, current, 10)) { + ksft_print_msg( + "memory usage should not increase after setting nr_hugepages.\n"); + return EXIT_FAILURE; + } addr = mmap(ADDR, LENGTH, PROTECTION, FLAGS, 0, 0); if (addr == MAP_FAILED) { @@ -152,10 +160,8 @@ static int test_hugetlb_memcg(char *root) { int ret = KSFT_FAIL; char *test_group; - long old_current, expected_current, current; test_group = cg_name(root, "hugetlb_memcg_test"); - if (!test_group || cg_create(test_group)) { ksft_print_msg("fail to create cgroup.\n"); goto out; @@ -171,16 +177,6 @@ static int test_hugetlb_memcg(char *root) ksft_print_msg("fail to disable swap.\n"); goto out; } - old_current = cg_read_long(test_group, "memory.current"); - - set_nr_hugepages(20); - current = cg_read_long(test_group, "memory.current"); - expected_current = old_current; - if (!values_close(expected_current, current, 10)) { - ksft_print_msg( - "memory usage should not increase after setting nr_hugepages.\n"); - goto out; - } if (!cg_run(test_group, hugetlb_test_program, (void *)test_group)) ret = KSFT_PASS;