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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85E47C433F5 for ; Thu, 10 Mar 2022 20:22:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 077A28D0002; Thu, 10 Mar 2022 15:22:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F41DC8D0001; Thu, 10 Mar 2022 15:22:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE2FE8D0002; Thu, 10 Mar 2022 15:22:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id D28B88D0001 for ; Thu, 10 Mar 2022 15:22:22 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 86E5F60FB4 for ; Thu, 10 Mar 2022 20:22:22 +0000 (UTC) X-FDA: 79229598924.10.1365AE4 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by imf13.hostedemail.com (Postfix) with ESMTP id 14B8120018 for ; Thu, 10 Mar 2022 20:22:21 +0000 (UTC) Received: by mail-pl1-f170.google.com with SMTP id m2so5936370pll.0 for ; Thu, 10 Mar 2022 12:22:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:from:date:message-id:subject:to:cc; bh=FyNyA5DUX7v3DX8+JWLmMeNtUiohWR1k5no3twouIA4=; b=Nv/ok3kWBaK2iYkkFxmsXC9QpLFO1dPi0s0GCJLESXN529m5amcxUHQXV0st4WiBQy 8AJLBtkorQKW+nNvgoQ2jSEi/5ZbSvNqyAqctI2uqIEKRXxoeAc49IEF9dNysPHNJjt1 RvrkyQG4jCgtakQMwxbS2sFjjqibHt4Eun6Cbz+ecznBhp15oDrf4QURvRdJk74PgBg2 le5flOIHUjB0bLRPkSlx6gyUEugyYUCWimdkhb0RozJYqvyTMepL4xkCNj6bPO2UYhn0 VMy5WYMYU4I25yxhT1zKM2uR+NaABlrWDffS1HQLYETwohWm30Rpy3mzIXXX2rAlZxIF +Kvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=FyNyA5DUX7v3DX8+JWLmMeNtUiohWR1k5no3twouIA4=; b=OBDyJgihJYRl7mJI4ykLIF0o5OND6LjtTiLMh9R5892ftYXjn3soHm9zWk3vBGhb2m w1l9LmBO/dM/r4ZPuHd5PojhaR3Y86G99uPJWiWw2BMX6qS46B3wdL10B54NIFQhL6FA hHz0ki76gaxOVIyg7yXeNxdowa5DO3TCU7Qg4hjBQRnHl1tygAWfWR0poBPXzgud81Uh GJNGKEi+7bdBe7KGl7ftDxoW0p6AKS+U3XmaxQr08jE8yzCakdOxbeFwXo6uYxEzWjkH 0odzpVZz1Cu4wpkufLBwkj99lZajwu+nflZ6+ET+9YU1SHNyakgB7Awgl/hUgWS0gt2P W2VA== X-Gm-Message-State: AOAM533x1FccszPfelu2RliRT3ypkG17YqL6g/DQIX6nPwE4S5DVlTcJ 565XPP4YtJ0ISH5PlacYdmraGwuuCCNlNf/n/4/39BelfAxVlQ== X-Google-Smtp-Source: ABdhPJxrTB2H5rcO2LCzhe2pwua86bqzLkN70cP3q/bnZFzCa7zrDvZAXcOcN138sh4HfCYQ0OBhRVWRvkzU2fw0bD0= X-Received: by 2002:a17:90a:cce:b0:1bf:6387:30d9 with SMTP id 14-20020a17090a0cce00b001bf638730d9mr18123922pjt.196.1646943740588; Thu, 10 Mar 2022 12:22:20 -0800 (PST) MIME-Version: 1.0 From: Yosry Ahmed Date: Thu, 10 Mar 2022 12:21:44 -0800 Message-ID: Subject: Questions about memcg_slabinfo.py drgn script To: guro@fb.com, vvs@virtuozzo.com Cc: Michal Hocko , Andrew Morton , Shakeel Butt , Johannes Weiner , cl@linux.com, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 14B8120018 X-Rspam-User: Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="Nv/ok3kW"; spf=pass (imf13.hostedemail.com: domain of yosryahmed@google.com designates 209.85.214.170 as permitted sender) smtp.mailfrom=yosryahmed@google.com; dmarc=pass (policy=reject) header.from=google.com X-Stat-Signature: oihm9t8nj5hj4asfdkrpmhcno3rhaest X-HE-Tag: 1646943741-234608 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000490, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Hi everyone, I was looking at the memcg_slabinfo.py drgn script that offers a replacement to the deprecated memory.kmem.slabinfo. I had some questions about how it collects the memcg slab stats: 1. Why does the script loop through all struct pages on the system? Wouldn't it be more efficient to loop for every kmem_cache, for every online kmem_cache_node, then loop through slabs_free, slabs_full, and slabs_partial lists? This seems more consistent with how /proc/slabinfo works, and more efficient. I tested this on SLAB using a crash script as I am unable to run drgn on my current setup. I am not sure how correct this would be for SLUB though. 2. Before looping through pages, why does the script collect all objcgs belonging to the desired memcg in a set, and then test every objcg in a slab page to see whether it belongs to that memcg. Wouldn't it be easier to just check objcg->memcg? AFAICT this gets updated as well when the objcg is reparented. Sorry for my ignorance if any of the assumptions I made are incorrect. I just wanted to get more understanding of the implementation decisions taken while writing the script. Thanks.