From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CD94C433E1 for ; Fri, 5 Jun 2020 20:07:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 18D2320810 for ; Fri, 5 Jun 2020 20:07:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 18D2320810 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BBE3B80007; Fri, 5 Jun 2020 16:07:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B6EBD8E0006; Fri, 5 Jun 2020 16:07:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A84FC80007; Fri, 5 Jun 2020 16:07:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0122.hostedemail.com [216.40.44.122]) by kanga.kvack.org (Postfix) with ESMTP id 92A4E8E0006 for ; Fri, 5 Jun 2020 16:07:55 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 4DBFFAAB16 for ; Fri, 5 Jun 2020 20:07:55 +0000 (UTC) X-FDA: 76896244110.24.metal29_16097e326da2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin24.hostedemail.com (Postfix) with ESMTP id 2CB082BA80 for ; Fri, 5 Jun 2020 20:07:55 +0000 (UTC) X-HE-Tag: metal29_16097e326da2 X-Filterd-Recvd-Size: 5230 Received: from mail-ua1-f66.google.com (mail-ua1-f66.google.com [209.85.222.66]) by imf09.hostedemail.com (Postfix) with ESMTP for ; Fri, 5 Jun 2020 20:07:54 +0000 (UTC) Received: by mail-ua1-f66.google.com with SMTP id z47so3444869uad.5 for ; Fri, 05 Jun 2020 13:07:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=FlJgMKQQXIjXwSqXj5h10emSVIeCQTIajZGC2MB8JjA=; b=MZgGjKeLroNjwsxB/55/onFXzRh1G3VSL0h9BK2b4ep/XoFOPlWD2IGQfvvI6/3TRn lOdOOIpxlETzNGpfQLHqxESSU9N6G29IkgXpLNnLciVKiIxjNgOeFfwDEnETtt7qLmF6 QMWwvfeTS1h44STrGoDi3fN5U0gB6TkWaf9Q0SblhPj4u9o983vGcA18BQON2GkKYv0M IwlE73YejRsL4LaL/ni5sTvbkGjtqP0b911VBtD5LUqplBTP5KLcapDQNwkYVqiPmBEQ y5vXr8ba0MNHZagFoGGefsC8BAhxkGTLlI9OhPO4LSWrZiyfIQmmLhsRwhV/3+cpQdqt QZgA== X-Gm-Message-State: AOAM533o6OyYUNXMzQy6Z4MHHNyeQnRSXdqoadCBs4FQ8y0zNZLu240o U4KKekmN+VnIQ8agnra9Twg= X-Google-Smtp-Source: ABdhPJw2l/VjBLOkpzld267CPB7R0he7pKlOB8RlXtO+VYr1sXSYV3JTe1BH+5DnadIphpFZAvMLHA== X-Received: by 2002:ab0:300c:: with SMTP id f12mr8511736ual.76.1591387674083; Fri, 05 Jun 2020 13:07:54 -0700 (PDT) Received: from google.com (239.145.196.35.bc.googleusercontent.com. [35.196.145.239]) by smtp.gmail.com with ESMTPSA id i18sm956312vsp.22.2020.06.05.13.07.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2020 13:07:53 -0700 (PDT) Date: Fri, 5 Jun 2020 20:07:51 +0000 From: Dennis Zhou To: Roman Gushchin Cc: Andrew Morton , Tejun Heo , Christoph Lameter , Johannes Weiner , Michal Hocko , Shakeel Butt , linux-mm@kvack.org, kernel-team@fb.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 5/5] kselftests: cgroup: add perpcu memory accounting test Message-ID: <20200605200751.GE224745@google.com> References: <20200528232508.1132382-1-guro@fb.com> <20200528232508.1132382-6-guro@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200528232508.1132382-6-guro@fb.com> X-Rspamd-Queue-Id: 2CB082BA80 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, May 28, 2020 at 04:25:08PM -0700, Roman Gushchin wrote: > Add a simple test to check the percpu memory accounting. > The test creates a cgroup tree with 1000 child cgroups > and checks values of memory.current and memory.stat::percpu. > > Signed-off-by: Roman Gushchin > --- > tools/testing/selftests/cgroup/test_kmem.c | 59 ++++++++++++++++++++++ > 1 file changed, 59 insertions(+) > > diff --git a/tools/testing/selftests/cgroup/test_kmem.c b/tools/testing/selftests/cgroup/test_kmem.c > index 5224dae216e5..a0d4f1a3137d 100644 > --- a/tools/testing/selftests/cgroup/test_kmem.c > +++ b/tools/testing/selftests/cgroup/test_kmem.c > @@ -331,6 +331,64 @@ static int test_kmem_dead_cgroups(const char *root) > return ret; > } > > +/* > + * This test creates a sub-tree with 1000 memory cgroups. > + * Then it checks that the memory.current on the parent level > + * is greater than 0 and approximates matches the percpu value > + * from memory.stat. > + */ > +static int test_percpu_basic(const char *root) > +{ > + int ret = KSFT_FAIL; > + char *parent, *child; > + long current, percpu; > + int i; > + > + parent = cg_name(root, "percpu_basic_test"); > + if (!parent) > + goto cleanup; > + > + if (cg_create(parent)) > + goto cleanup; > + > + if (cg_write(parent, "cgroup.subtree_control", "+memory")) > + goto cleanup; > + > + for (i = 0; i < 1000; i++) { > + child = cg_name_indexed(parent, "child", i); > + if (!child) > + return -1; > + > + if (cg_create(child)) > + goto cleanup_children; > + > + free(child); > + } > + > + current = cg_read_long(parent, "memory.current"); > + percpu = cg_read_key_long(parent, "memory.stat", "percpu "); > + > + if (current > 0 && percpu > 0 && abs(current - percpu) < > + 4096 * 32 * get_nprocs()) So this is checking that we've allocated less than 32 pages per cpu over 1000 child cgroups that's not percpu memory? Is there a more definitive measurement or at least a comment we can leave saying why this limit was chosen. > + ret = KSFT_PASS; > + else > + printf("memory.current %ld\npercpu %ld\n", > + current, percpu); > + > +cleanup_children: > + for (i = 0; i < 1000; i++) { > + child = cg_name_indexed(parent, "child", i); > + cg_destroy(child); > + free(child); > + } > + > +cleanup: > + cg_destroy(parent); > + free(parent); > + > + return ret; > +} > + > #define T(x) { x, #x } > struct kmem_test { > int (*fn)(const char *root); > @@ -341,6 +399,7 @@ struct kmem_test { > T(test_kmem_proc_kpagecgroup), > T(test_kmem_kernel_stacks), > T(test_kmem_dead_cgroups), > + T(test_percpu_basic), > }; > #undef T > > -- > 2.25.4 > >