From patchwork Thu Aug 17 19:57:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Karpinski X-Patchwork-Id: 13356885 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 5938BC531DF for ; Thu, 17 Aug 2023 19:58:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B45C9280045; Thu, 17 Aug 2023 15:58:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AF408280042; Thu, 17 Aug 2023 15:58:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9BCDB280045; Thu, 17 Aug 2023 15:58:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 8D677280042 for ; Thu, 17 Aug 2023 15:58:03 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 589A0407C3 for ; Thu, 17 Aug 2023 19:58:03 +0000 (UTC) X-FDA: 81134657646.04.9A2934C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf15.hostedemail.com (Postfix) with ESMTP id 41B59A000F for ; Thu, 17 Aug 2023 19:58:01 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TLwweBo8; spf=pass (imf15.hostedemail.com: domain of lkarpins@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=lkarpins@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692302281; 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=M+cHwSXYqzyiBAs9LYfm9bQki8Ktpzfnu45rfgTUfPw=; b=TnUy58u9mHVZ1eGlTFzPUXDT8y7lmSAWt2U55T4nqiieQSQL3OYfHAiAwJg+SMj2ahRde9 n/hRXQPCw+Di/j4IIIDBR3NCZF+E1WClBmgD9qdsWJE8o+av7HL5u8g4Tdvv/SwmLnSVGN xoFCon5w+9TXbPkj1aqn1tYylHuhbpI= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TLwweBo8; spf=pass (imf15.hostedemail.com: domain of lkarpins@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=lkarpins@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692302281; a=rsa-sha256; cv=none; b=cc3W6W2HtC50uImrn5XSxYrCKhmvS0IXl+jLzw9w7gKuK/Lw5obsMSnerouEljS95m2hzE r4gwrH3Krm3mDBKCvtNNqFTuc800xRA1m9C/mMfZ3qVSFhoyQCyw49YEMXQ2/y7fwIsVpH wSLnoy5d6waYU0dX6wqqrLaGLDJfUQA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692302280; 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=M+cHwSXYqzyiBAs9LYfm9bQki8Ktpzfnu45rfgTUfPw=; b=TLwweBo8vhcHQPXVebA4cRIYmiGacO/t78+g+Tcl+8KxHB+jqxAv3A1TNsHp/MtfZ+uwxo tNeYCKbiZ3PdniFuUVs0dUhQK5kjbptq2u3Nwic1BmwhUe9GKrK8RFkDdN+BA3TC7bThmB R/qZe2BQrRPiVheFpXjrpGq+udakLcc= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-86-0G8gDExyNbGJrhfOlcAdTw-1; Thu, 17 Aug 2023 15:57:59 -0400 X-MC-Unique: 0G8gDExyNbGJrhfOlcAdTw-1 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-76d845cb4cfso23225785a.0 for ; Thu, 17 Aug 2023 12:57:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692302278; x=1692907078; 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=M+cHwSXYqzyiBAs9LYfm9bQki8Ktpzfnu45rfgTUfPw=; b=e7sNFJC1rhQL/1iDFv7p/I9jmNBqMJyMqtUHsJ18VHxpD2QqKxRaSf9l9TZ3IDT/sp vg2MY4FCBppatv8fdJz0E2+9YtX/RhO3LtNsmFY049p0tECHde1AhTCgHh+8SfGffHLp hcF/qm1AKHu7PB9k9VjZH7KbofyrrvlC9PlLhRxiTYpnRdBrjZ0put+fbYlF+KP4hQpT G3K3LWQJsCcQEhGNFjkL+PDfMywN4NiAm2PWLLocmcfb23EwRwnIlRHq/NZlRGtvoLhz DTGFyrVadIBKGor6gOtK6VjGWujNAfu2DMQkdrw8dl5jqnYkrHjrm2ZmxIBJgKX+oLdb BQfA== X-Gm-Message-State: AOJu0YyMsYrkTi7vc0izFD99QgFg4zfSO0UvYNNnn1z6lzJWNRpq2G/G gUzJfeO01kFqVUQD7HiUVnXVH6JRa234l2fa5yPO6q57ccVsctRGl2QVzqWtv3zYRPgnnDuwy94 2DrfaGLiUxmY= X-Received: by 2002:a05:620a:258e:b0:765:7d7b:7197 with SMTP id x14-20020a05620a258e00b007657d7b7197mr645103qko.31.1692302278591; Thu, 17 Aug 2023 12:57:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEQgXuoDpTI5a32rf3ve8W0aO5TbiD9EyI1QuhXrP4vNvyIDNys5Ml/PftOW0Uy323gwFC5NQ== X-Received: by 2002:a05:620a:258e:b0:765:7d7b:7197 with SMTP id x14-20020a05620a258e00b007657d7b7197mr645085qko.31.1692302278329; Thu, 17 Aug 2023 12:57:58 -0700 (PDT) Received: from fedora ([174.89.37.104]) by smtp.gmail.com with ESMTPSA id o10-20020a05620a130a00b00767c961eb47sm37865qkj.43.2023.08.17.12.57.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Aug 2023 12:57:58 -0700 (PDT) Date: Thu, 17 Aug 2023 15:57:48 -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 v3] 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-Queue-Id: 41B59A000F X-Rspam-User: X-Stat-Signature: tihrukez7hg7rm3ni4szqa9g9iy5wu3i X-Rspamd-Server: rspam01 X-HE-Tag: 1692302281-183213 X-HE-Meta: U2FsdGVkX189Zz6uLUH17eyXcyUTVkP8XryBl/cGnt67/N8IMKVcrSMA8dok4P0w3QEcgx9rhH6bJXv9sHjuSHqCOcD8F5J6Q5cVXRYy4Uh/tuUD8WbMo87oWlZUYY3VSalx9aH5Ka0aq6xuY52/jYF5BH2Qf3znha0Qt1yORGe440EDHbJfm4b4epUS5B+VYhn5igrbM40wjkpv0jAYPAvP4G/Z3e2yYGJPsHpfvb0+pC5LFLqG4YdO7ngS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ZapvPXH8MF7j/w5/1koZ/CqqfbUI6aTi2SjGxmfi8IvJW6TQ/advCY4XsKYat/TfHiBbgSuQryTjXXMCF4wvaq7ica5agcy/A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.001252, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Currently, not all kernel memory usage is being accounted for. This commit switches to using the kernel entry within memory.stat which already includes kernel_stack, pagetables, and slab. The kernel entry also includes vmalloc and other additional kernel memory use cases which were missing. Signed-off-by: Lucas Karpinski Acked-by: Shakeel Butt Acked-by: Roman Gushchin --- Changes in v3: - Fixed test case description - Included anon, file, and sock as mentioned by Shakeel. tools/testing/selftests/cgroup/test_kmem.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/tools/testing/selftests/cgroup/test_kmem.c b/tools/testing/selftests/cgroup/test_kmem.c index ed2e50bb1e76..c82f974b85c9 100644 --- a/tools/testing/selftests/cgroup/test_kmem.c +++ b/tools/testing/selftests/cgroup/test_kmem.c @@ -162,11 +162,11 @@ static int cg_run_in_subcgroups(const char *parent, * allocates some slab memory (mostly negative dentries) using 2 * NR_CPUS * threads. Then it checks the sanity of numbers on the parent level: * the total size of the cgroups should be roughly equal to - * anon + file + slab + kernel_stack. + * anon + file + kernel + sock. */ static int test_kmem_memcg_deletion(const char *root) { - long current, slab, anon, file, kernel_stack, pagetables, percpu, sock, sum; + long current, anon, file, kernel, sock, sum; int ret = KSFT_FAIL; char *parent; @@ -184,29 +184,22 @@ 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 "); + kernel = cg_read_key_long(parent, "memory.stat", "kernel "); 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) + if (current < 0 || anon < 0 || file < 0 || kernel < 0 || sock < 0) goto cleanup; - sum = slab + anon + file + kernel_stack + pagetables + percpu + sock; + sum = anon + file + kernel + sock; if (abs(sum - 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 + file + kernel + sock = %ld\n", sum); 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("kernel = %ld\n", kernel); printf("sock = %ld\n", sock); }