From patchwork Thu Aug 17 12:47:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Karpinski X-Patchwork-Id: 13356392 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 C82A2C2FC14 for ; Thu, 17 Aug 2023 12:47:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 010D0940020; Thu, 17 Aug 2023 08:47:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EDBD9940009; Thu, 17 Aug 2023 08:47:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D558D940020; Thu, 17 Aug 2023 08:47:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id C123F940009 for ; Thu, 17 Aug 2023 08:47:43 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 841784076C for ; Thu, 17 Aug 2023 12:47:43 +0000 (UTC) X-FDA: 81133573206.03.B2651F1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf18.hostedemail.com (Postfix) with ESMTP id 64ADD1C0027 for ; Thu, 17 Aug 2023 12:47:41 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hoKVbqsI; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf18.hostedemail.com: domain of lkarpins@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=lkarpins@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692276461; 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: references:dkim-signature; bh=27yOpoFS3kI6hX/wnm/PheNvRJtvVh2pmNTKVNiCv/U=; b=VjEt6652OCfXalaJz9ahniIQjgHvmZ20CH6Y6F6NQsmPmNyoE7vXRDSC3STRagfVBZdszD sYBGXEfuQw3cERjJ9PyIwxrkh+zGNJ641l/Hv/vRCQc1kMjHpXT/qhXd5qp6DPi/JKALMt 6NpTKaEgydp9r6i4adKLxepyIzLDZpk= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hoKVbqsI; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf18.hostedemail.com: domain of lkarpins@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=lkarpins@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692276461; a=rsa-sha256; cv=none; b=3A7Ge7wkJ5j1DhB8QIAPcUUJFeJGGJ377welge/AzK5a6WqPDHuJ/ecCOnbJvrZqAs41q1 0/vY2msDT5hOjzTnKo9a8Zkd8jHk/1vn3YxwSBhJH0Y3hxy3m/oqm0cwebbhaCijzXemWd aK2m1MuhazaOa72xNvZWX3kva1pBD5s= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692276460; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=27yOpoFS3kI6hX/wnm/PheNvRJtvVh2pmNTKVNiCv/U=; b=hoKVbqsIHBqJ75llbKQhlPtZYWp27dkacL5zP7pKAOxOxHBkKWW7mTu4NXM/Bt4hhfforJ wcPRPFf2rYCriJXqTGjPu6umkkkjACIQ3YRbSRxFiNye5zIB/lIB+PyfxtmM5WbMbJIvBy NBhX0qYOiQEosD5Jq/No11I1mU3af8U= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-353-gE5Q-b76P0ubeI8ZNtSAdg-1; Thu, 17 Aug 2023 08:47:37 -0400 X-MC-Unique: gE5Q-b76P0ubeI8ZNtSAdg-1 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-76ce59841d5so1055698885a.3 for ; Thu, 17 Aug 2023 05:47:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692276457; x=1692881257; h=user-agent:content-disposition:mime-version:message-id:subject:cc :to:from:date:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=27yOpoFS3kI6hX/wnm/PheNvRJtvVh2pmNTKVNiCv/U=; b=bYMAOvIqlpzAUc3OCEaJVZM4nkbxkKIqP96lXfkX7R8vvK+smcUyzQqjgIl014yAE/ HMvjodPOI3V6XLTMD4tJ+0HO0N+g0n0141OA5KcEXotpBygpYZ370P7nyI04hZ7Z87lA dhGTpM/jDwlLAyB5vEvH11pzbGTqsK5SD2J3kineGyL+52bmDd7gNYovuMLrJIDSj5Df fNjcFlr5yUD34cfrwzLi7a99UkR0y1o8cX2AIePPQfp5Hz20zpzPBCCvG55f6b1aGYA1 tGPHlyD1JR+YrvbdG28OtzuNIWC6Dj0Fws20z9rdoikqoM2+1DInuoSdmQF72rv/tMnO mY3Q== X-Gm-Message-State: AOJu0YymjdDlNP+RX1887uR3O40ZSsiAXmVVE0roHFrJlAK+0CGes+ll 1u5/QNupnNyeLrBYZu0nxJj365JdDuKUtNsDgB2F5yXFHuwbWFqMNbLT+rNwgLYAFXBKkTbiMUG C9Fn27nsmLeU= X-Received: by 2002:a05:620a:45a6:b0:76c:b43e:8f1d with SMTP id bp38-20020a05620a45a600b0076cb43e8f1dmr5898052qkb.25.1692276456902; Thu, 17 Aug 2023 05:47:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHWut8Xykqo3qs/+z94GUgQ9h0MTPjPde/T7jPTNAC5kZOXlJnFvxDHlaQ9P4SPc1KB12mEfA== X-Received: by 2002:a05:620a:45a6:b0:76c:b43e:8f1d with SMTP id bp38-20020a05620a45a600b0076cb43e8f1dmr5898038qkb.25.1692276456669; Thu, 17 Aug 2023 05:47:36 -0700 (PDT) Received: from fedora ([174.89.37.104]) by smtp.gmail.com with ESMTPSA id j7-20020a37c247000000b0076cc4610d0asm5128353qkm.85.2023.08.17.05.47.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Aug 2023 05:47:36 -0700 (PDT) Date: Thu, 17 Aug 2023 08:47:26 -0400 From: Lucas Karpinski To: Andrew Morton , Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Tejun Heo , Zefan Li , Shuah Khan Cc: Muchun Song , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] selftests: cgroup: fix test_kmem_memcg_deletion kernel mem check Message-ID: MIME-Version: 1.0 User-Agent: NeoMutt/20230517 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 64ADD1C0027 X-Stat-Signature: agetpggft8s4c58arx98e6tqjpypps9q X-Rspam-User: X-HE-Tag: 1692276461-984131 X-HE-Meta: U2FsdGVkX1+tP1Xjwhmjo7BtI8ZFJKNpOS7bla+4QS10OL3b4PhjsUBPGiAHam7qTZ1+bQBCt91p705mqjxvCp1gjbn/3rYAl/R71itNiO32ELEXflgmutoNxTDwhFxgc8RdqRh6hGrdZEr/G4fhaZtztW/2h1Lq9UchimWG6v5mXjGj8mYp9Gu9LB8mVuSmuRzTkvDomawmmpIXK/DdKuY/BmTr5EMC5IoS3et1sq/jju9W8xPGHBT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xmeut1kDajlP6T13mMnxfGaDdKt4pw61+HuJCYigJmkvBq0RIu8DDVrWInDlS2cGJn9JbjDVZkCfONRAbcBK0LlF4e5KYuojRGo8LvuYYi9MZi0MRIdgNyCoO3YPzyvTyt4toCltF49tshuEIF1Us8CDnoLn/r0FUj1vISx5AjT8D4= X-Bogosity: Ham, tests=bogofilter, spamicity=0.001233, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The combination of using slab, anon, file, kernel_stack, and percpu is not accurate for total kernel memory utilization. Checking kernel within memory.stat provides a more accurate measurement. Signed-off-by: Lucas Karpinski --- v1: https://lore.kernel.org/all/eex2vdlg4ow2j5bybmav73nbfzuspkk4zobnk7svua4jaypqb5@7ie6e4mci43t/ tools/testing/selftests/cgroup/test_kmem.c | 25 +++++----------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/tools/testing/selftests/cgroup/test_kmem.c b/tools/testing/selftests/cgroup/test_kmem.c index ed2e50bb1e76..3ef979ee0edf 100644 --- a/tools/testing/selftests/cgroup/test_kmem.c +++ b/tools/testing/selftests/cgroup/test_kmem.c @@ -166,7 +166,7 @@ static int cg_run_in_subcgroups(const char *parent, */ static int test_kmem_memcg_deletion(const char *root) { - long current, slab, anon, file, kernel_stack, pagetables, percpu, sock, sum; + long current, kernel; int ret = KSFT_FAIL; char *parent; @@ -184,30 +184,15 @@ static int test_kmem_memcg_deletion(const char *root) goto cleanup; current = cg_read_long(parent, "memory.current"); - slab = cg_read_key_long(parent, "memory.stat", "slab "); - anon = cg_read_key_long(parent, "memory.stat", "anon "); - file = cg_read_key_long(parent, "memory.stat", "file "); - kernel_stack = cg_read_key_long(parent, "memory.stat", "kernel_stack "); - pagetables = cg_read_key_long(parent, "memory.stat", "pagetables "); - percpu = cg_read_key_long(parent, "memory.stat", "percpu "); - sock = cg_read_key_long(parent, "memory.stat", "sock "); - if (current < 0 || slab < 0 || anon < 0 || file < 0 || - kernel_stack < 0 || pagetables < 0 || percpu < 0 || sock < 0) + kernel = cg_read_key_long(parent, "memory.stat", "kernel "); + if (current < 0 || kernel < 0) goto cleanup; - sum = slab + anon + file + kernel_stack + pagetables + percpu + sock; - if (abs(sum - current) < MAX_VMSTAT_ERROR) { + if (abs(kernel - current) < MAX_VMSTAT_ERROR) { ret = KSFT_PASS; } else { printf("memory.current = %ld\n", current); - printf("slab + anon + file + kernel_stack = %ld\n", sum); - printf("slab = %ld\n", slab); - printf("anon = %ld\n", anon); - printf("file = %ld\n", file); - printf("kernel_stack = %ld\n", kernel_stack); - printf("pagetables = %ld\n", pagetables); - printf("percpu = %ld\n", percpu); - printf("sock = %ld\n", sock); + printf("kernel = %ld\n", kernel); } cleanup: