Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4270050rdb; Thu, 14 Sep 2023 18:09:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEbkGpSy9tZN+oapmiJsmpWJrL05YabIE2G/nMNc+M1l8ZXH1gFxIGlKK3pAiRLd44kg3Uu X-Received: by 2002:a05:6359:a03:b0:13c:b9a8:fe5b with SMTP id el3-20020a0563590a0300b0013cb9a8fe5bmr401698rwb.3.1694740170008; Thu, 14 Sep 2023 18:09:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1694740169; cv=pass; d=google.com; s=arc-20160816; b=FOjI3jzpVRpNYdgq6zg8Z29QDFM9yxDbfXW15QXumPqchyGy19pl37/tzt82Y96TLp pmq3hsy724eAj+72JKn5aBFf/yleBgPPXxsufX6jNcPIGfAguGgi15yv/vxSZJ2kreM8 TmwrgoIlGw0NydqnZ40en7HxV28Zxc9dJy6kOhjXOqNF6UC9NfLmUZTMp4S60KgecZrL rfrCH1pdhsK/uqaZk306QdiwKArofuH+V2qs3pKktIaMgLCPly43OOOhxhkCpXJIrf7l uytQNx4SO91NSkodVvrr54DFVKR0VR7OjguLkgDoaCfUdN1YKYZ7eO1Su8DgUaxdT4it tlDg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=p/tUvI0rO/fZsEmr+L76aouRqGSfQ9Vy9Ur+y7I0tJI=; fh=5Wq4X/cX1CJLwLGhbTuXJAeCNZUDkPlnwOfm961dQnI=; b=ZcicJfjOt9E5pKyLAmbUtde8zNuJugguyXV3W5zgSpolTptRQWDQNvniCLTu0zNO3h aPVR3b1/1kRqPYOiwVEeMaSiC8OP4TdVu1lkgdd004Yin1yi/otaoQlGsczy0r3khMaQ 58Lo4NDcQ0lmsWrT+ILm5yItRJYmt+C0/L3EKRVHvoxcllwpO4dajEIFMc+00IkUtAFW PPn76ml1GXSeFF/SNRzufWoHPN2UiWvOlTa5QV2kxOeco45EQdY42BsXWlqrxPdj5xNM kMpN/6EhYlcBJmDi6cajYlvNf+OwxwIw+tdHOPlD6RJV36e4g24o1F94dfLMhvJDgVBk cELA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nebius.com header.s=selector1 header.b=HBFjKf+l; arc=pass (i=1 spf=pass spfdomain=nebius.com dkim=pass dkdomain=nebius.com dmarc=pass fromdomain=nebius.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nebius.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id t185-20020a6381c2000000b0057414c0fc48si2269518pgd.638.2023.09.14.18.09.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 18:09:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@nebius.com header.s=selector1 header.b=HBFjKf+l; arc=pass (i=1 spf=pass spfdomain=nebius.com dkim=pass dkdomain=nebius.com dmarc=pass fromdomain=nebius.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nebius.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id AE3F0807799F; Wed, 13 Sep 2023 03:35:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239701AbjIMKf2 (ORCPT + 99 others); Wed, 13 Sep 2023 06:35:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239703AbjIMKf0 (ORCPT ); Wed, 13 Sep 2023 06:35:26 -0400 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2120.outbound.protection.outlook.com [40.107.241.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 881CAD3; Wed, 13 Sep 2023 03:35:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MrXv8dgSIfG8atc7eQAOe5NxYgAMyHeysj76Kf60dW5pJXPTqB+foqOapQihAhn0C7xuaF1APNnKhoJ3kp4SMWYYUDrFs/p2z1NTtygMNiowcgtXCeNtdZ9gnT31LU3gdPJZkQnJaBr2XW1NbyS3ms2d3J+Fjy/MeU0zzGScrLJhpKSg7wUUX/b4B6FXwFCcjAtzfbtpjeGiBdWbHyeEMFL5Eq17ZMAsW9MBzrULN8T6dVSPXUkgeCWl5nhrDuirS3mOugzc6S18QEaPAOcJGgpBhlhYRoRl2gl6RuWFyRJ0D5NPrW7ufnYjNPT+s5YS1V0uyecdSHTW/BZKnoYUGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=p/tUvI0rO/fZsEmr+L76aouRqGSfQ9Vy9Ur+y7I0tJI=; b=VYBzR3OVyDyzEOEi6UE2lrwrYFqy/7cPSkamQ1/FcTebc01lwkEsHvhec7Dr+j1Rb4vckIwZpkoihEjHfuUo6VzahE/yRz3pqLuFK7wqc+HSqIV8S/WAqrx3q6dQZQcrEpiDmYPevh9A2l7mfaAVAs33zXoPQAx4+cyqywxodNfpsb0LmrRKcud2vH97XozEove/nIoiBjd+ai+B/mJSKLnafxFRQqK5FrsjYgpywAPBRvZzoyZMe3sow3PDARmmRfQHkiAROeJ1akSfYRUmF5/Hoguo98zEzdOFRbgRkLxkiq8Iz86R04YTnHw6DK3vFIHTFLHGz4m5S5kBpKHM7w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nebius.com; dmarc=pass action=none header.from=nebius.com; dkim=pass header.d=nebius.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nebius.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=p/tUvI0rO/fZsEmr+L76aouRqGSfQ9Vy9Ur+y7I0tJI=; b=HBFjKf+lqbgZahi4GtYOmIJAhbgsmlroTn/BhlyfoKVYpahgfUrvnoxCpHzHY/6clGw1BibC0lKl3/OLNc3kj4xgC7wrhp5bnNYSXiZLv1aspGL2zKfurX9NDlImM0mJXa+tH3T+wlQK6VkEuJ49+Q/tplyGwiv6mbIbnfSL9cJDBxfEBI8WTE0P3Z+DiKeSu9Duc9Rk9Ui8HQTZ4D/E7keeGmZsfp81YOYP3nXSCdk3eitLzcSRWWBlPIc9uojNCy5XrrGcUTLgGyyCquakjOrS8ZUp8xewAS81nTFQKoueiclOkhnbhaqZ2ySdxSuVn95etkJTx0gRAJK6vzMQ+w== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nebius.com; Received: from DU0P190MB1860.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:3a4::9) by DB9P190MB1771.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:33f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.34; Wed, 13 Sep 2023 10:35:19 +0000 Received: from DU0P190MB1860.EURP190.PROD.OUTLOOK.COM ([fe80::1dc2:35fa:896c:8ca3]) by DU0P190MB1860.EURP190.PROD.OUTLOOK.COM ([fe80::1dc2:35fa:896c:8ca3%5]) with mapi id 15.20.6768.029; Wed, 13 Sep 2023 10:35:19 +0000 Message-ID: <870aa2af-62b7-48ba-b1a0-77b651352211@nebius.com> Date: Wed, 13 Sep 2023 12:35:15 +0200 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH 1/3] cgroup: list all subsystem states in debugfs files Content-Language: ru To: Yosry Ahmed Cc: "cgroups@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , NB-Core Team , "tj@kernel.org" , "hannes@cmpxchg.org" , "mhocko@kernel.org" , Konstantin Khlebnikov , Andrey Ryabinin References: <20230911075437.74027-1-zeil@nebius.com> <20230911075437.74027-2-zeil@nebius.com> From: Dmitry Yakunin In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: FR0P281CA0003.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:15::8) To DU0P190MB1860.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:3a4::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0P190MB1860:EE_|DB9P190MB1771:EE_ X-MS-Office365-Filtering-Correlation-Id: 48a16aad-4184-4f4d-22b2-08dbb4451faa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PLXH4zsvyHerIu+SZS1aRJY8KmVpHnDzV8Y5J7WdCi7rSURfDiulEFUIv2a0MSyt8W15L4zjWiP0kDn9Q4Wl7VFE4TozVjaeE2dGUvqVOLIKx9r/JZWOBaIFapDEkSoro1WDqrnHMIqLXIzu8f3fDFJ0rLxrq6rUO6q4wGc2bvPhE+lmko5QtZ7tnuMybV1apCuUF5tuWSZ0vdqjhG6v2nSAPp5a2BMGFE9UOeFsij3N3ItD3o3DoYfvSR8JSMXGD0X3tx07PCJorpr7Bl/q+UVn8W6Uk7Y9iKdClM0GgQE3v8TQZsTd74oTfQyTKvKWPn48QVSuw2RO8GMwXuC+nA3ykni7w7girxSZGI0z9EPtWa8oyID6yhiZRy2tw7RnkrAbcM8Tw+7/6QTusrRifBS75Is+wTagaXnWUZ3IzxoWUkRUhpPuKNysasVd0/A+1OVMXYRXInVHLHV7IJtWphjhUhRDfnqOTGTrxmMg2I4utFLtuP2Q2NWLUePhV0GWc/tc7kNN4/pqxH3zo0Pa8AWEGz8gF7J7/fiQ8jwMxx8t5GjwP8suxxbNxqgrnt5bPzzApQWfRXiosUZLCTxS+xB/7gwTxRDEnEUNzBnAxH0vA1zlS4cPtyAHufZCDKYl7Zv/W499Xh40XkhCt8HgNQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0P190MB1860.EURP190.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230031)(376002)(136003)(346002)(396003)(366004)(39850400004)(1800799009)(186009)(451199024)(41300700001)(83380400001)(53546011)(6486002)(6506007)(478600001)(6512007)(2616005)(966005)(2906002)(66946007)(66556008)(6916009)(26005)(54906003)(4326008)(8936002)(66476007)(8676002)(6666004)(36756003)(31696002)(38100700002)(86362001)(316002)(5660300002)(31686004)(45980500001)(43740500002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?SDFDMkZEYVZwME1FL24zQ3R4azk0NkxVYy9weDM2Y1ArWVlnS0JyWENsU1Qr?= =?utf-8?B?SHlaN2JTdXcyZnhMNVQwWGJBckt1SmhuZTR0NTBhUzgwZlNETzJFTzczUldE?= =?utf-8?B?ZnhHY0gxeDVLRmRIeTVmZlRQVkNxSmx1Q214dnRFSWkvbnpiUE5sbnZkQmI0?= =?utf-8?B?NG5SbC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qVktUblNCTkUy?= =?utf-8?B?c1ZQajhsMkVVVW9aaWR1Vzk3dDRHdDRPTmZVNG1CWS9CVlEvYmVCUVlDVFp2?= =?utf-8?B?R3FQMEdhWWppd2ZaSzJQTlRTNUNTQkowRjJTUU9JS1AxbmhLSFpPZ1UxTjRh?= =?utf-8?Q?4XseSAjUbGIORDvqewBoE1a6w?= X-OriginatorOrg: nebius.com X-MS-Exchange-CrossTenant-Network-Message-Id: 48a16aad-4184-4f4d-22b2-08dbb4451faa X-MS-Exchange-CrossTenant-AuthSource: DU0P190MB1860.EURP190.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2023 10:35:18.8682 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4eb23c52-f3a5-49bc-b555-0b061267a984 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: VNj0YvdN73fdODAO9WdEMKnRHzDnkmxmXxZ4cbpKl3a6X5tjJHbRjYTUO+fEkmbI X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9P190MB1771 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 (snail.vger.email [0.0.0.0]); Wed, 13 Sep 2023 03:35:26 -0700 (PDT) Sure, if you can share you work it would be nice. Thank you. On 12.09.2023 00:16, Yosry Ahmed wrote: > On Mon, Sep 11, 2023 at 12:55 AM Yakunin, Dmitry (Nebius) > wrote: >> After removing cgroup subsystem state could leak or live in background >> forever because it is pinned by some reference. For example memory cgroup >> could be pinned by pages in cache or tmpfs. >> >> This patch adds common debugfs interface for listing basic state for each >> controller. Controller could define callback for dumping own attributes. >> >> In file /sys/kernel/debug/cgroup/ each line shows state in >> format: =... [-- =... ] >> >> Common attributes: >> >> css - css pointer >> cgroup - cgroup pointer >> id - css id >> ino - cgroup inode >> flags - css flags >> refcnt - css atomic refcount, for online shows huge bias >> path - cgroup path >> >> This patch adds memcg attributes: >> >> mem_id - 16-bit memory cgroup id >> memory - charged pages >> memsw - charged memory+swap for v1 and swap for v2 >> kmem - charged kernel pages >> tcpmem - charged tcp pages >> shmem - shmem/tmpfs pages >> >> Link: https://lore.kernel.org/lkml/153414348591.737150.14229960913953276515.stgit@buzz >> Suggested-by: Konstantin Khlebnikov >> Reviewed-by: Andrey Ryabinin >> Signed-off-by: Dmitry Yakunin > FWIW, I was just recently working on a debugfs directly that exposes a > list of all zombie memcgs as well as the "memory.stat" output for all > of them. > > This entails a file at /sys/kernel/debug/zombie_memcgs/all that > contains a list of zombie memcgs (with indentation to reflect the > hierarchy) and an id for each of them. > > This id can be used to index per-memcg directories at > /sys/kernel/debug/zombie_memcgs//, which include debug files. The > only one we have so far is > /sys/kernel/debug/zombie_memcgs//memory.stat. > > If there is interest in this, I can share more information. > >> --- >> include/linux/cgroup-defs.h | 1 + >> kernel/cgroup/cgroup.c | 101 ++++++++++++++++++++++++++++++++++++ >> mm/memcontrol.c | 14 +++++ >> 3 files changed, 116 insertions(+) >> >> diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h >> index 8a0d5466c7be..810bd300cbee 100644 >> --- a/include/linux/cgroup-defs.h >> +++ b/include/linux/cgroup-defs.h >> @@ -673,6 +673,7 @@ struct cgroup_subsys { >> void (*exit)(struct task_struct *task); >> void (*release)(struct task_struct *task); >> void (*bind)(struct cgroup_subsys_state *root_css); >> + void (*css_dump)(struct cgroup_subsys_state *css, struct seq_file *m); >> >> bool early_init:1; >> >> diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c >> index 625d7483951c..fb9931ff7570 100644 >> --- a/kernel/cgroup/cgroup.c >> +++ b/kernel/cgroup/cgroup.c >> @@ -40,6 +40,7 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -7068,3 +7069,103 @@ static int __init cgroup_sysfs_init(void) >> subsys_initcall(cgroup_sysfs_init); >> >> #endif /* CONFIG_SYSFS */ >> + >> +#ifdef CONFIG_DEBUG_FS >> +void *css_debugfs_seqfile_start(struct seq_file *m, loff_t *pos) >> +{ >> + struct cgroup_subsys *ss = m->private; >> + struct cgroup_subsys_state *css; >> + int id = *pos; >> + >> + rcu_read_lock(); >> + css = idr_get_next(&ss->css_idr, &id); >> + *pos = id; >> + return css; >> +} >> + >> +void *css_debugfs_seqfile_next(struct seq_file *m, void *v, loff_t *pos) >> +{ >> + struct cgroup_subsys *ss = m->private; >> + struct cgroup_subsys_state *css; >> + int id = *pos + 1; >> + >> + css = idr_get_next(&ss->css_idr, &id); >> + *pos = id; >> + return css; >> +} >> + >> +void css_debugfs_seqfile_stop(struct seq_file *m, void *v) >> +{ >> + rcu_read_unlock(); >> +} >> + >> +int css_debugfs_seqfile_show(struct seq_file *m, void *v) >> +{ >> + struct cgroup_subsys *ss = m->private; >> + struct cgroup_subsys_state *css = v; >> + /* data is NULL for root cgroup_subsys_state */ >> + struct percpu_ref_data *data = css->refcnt.data; >> + size_t buflen; >> + char *buf; >> + int len; >> + >> + seq_printf(m, "css=%pK cgroup=%pK id=%d ino=%lu flags=%#x refcnt=%lu path=", >> + css, css->cgroup, css->id, cgroup_ino(css->cgroup), >> + css->flags, data ? atomic_long_read(&data->count) : 0); >> + >> + buflen = seq_get_buf(m, &buf); >> + if (buf) { >> + len = cgroup_path(css->cgroup, buf, buflen); >> + seq_commit(m, len < buflen ? len : -1); >> + } >> + >> + if (ss->css_dump) { >> + seq_puts(m, " -- "); >> + ss->css_dump(css, m); >> + } >> + >> + seq_putc(m, '\n'); >> + return 0; >> +} >> + >> +static const struct seq_operations css_debug_seq_ops = { >> + .start = css_debugfs_seqfile_start, >> + .next = css_debugfs_seqfile_next, >> + .stop = css_debugfs_seqfile_stop, >> + .show = css_debugfs_seqfile_show, >> +}; >> + >> +static int css_debugfs_open(struct inode *inode, struct file *file) >> +{ >> + int ret = seq_open(file, &css_debug_seq_ops); >> + struct seq_file *m = file->private_data; >> + >> + if (!ret) >> + m->private = inode->i_private; >> + return ret; >> +} >> + >> +static const struct file_operations css_debugfs_fops = { >> + .open = css_debugfs_open, >> + .read = seq_read, >> + .llseek = seq_lseek, >> + .release = seq_release, >> +}; >> + >> +static int __init css_debugfs_init(void) >> +{ >> + struct cgroup_subsys *ss; >> + struct dentry *dir; >> + int ssid; >> + >> + dir = debugfs_create_dir("cgroup", NULL); >> + if (dir) { >> + for_each_subsys(ss, ssid) >> + debugfs_create_file(ss->name, 0644, dir, ss, >> + &css_debugfs_fops); >> + } >> + >> + return 0; >> +} >> +late_initcall(css_debugfs_init); >> +#endif /* CONFIG_DEBUG_FS */ >> diff --git a/mm/memcontrol.c b/mm/memcontrol.c >> index 4b27e245a055..7b3d4a10ac63 100644 >> --- a/mm/memcontrol.c >> +++ b/mm/memcontrol.c >> @@ -5654,6 +5654,20 @@ static void mem_cgroup_css_rstat_flush(struct cgroup_subsys_state *css, int cpu) >> } >> } >> >> +static void mem_cgroup_css_dump(struct cgroup_subsys_state *css, >> + struct seq_file *m) >> +{ >> + struct mem_cgroup *memcg = mem_cgroup_from_css(css); >> + >> + seq_printf(m, "mem_id=%u memory=%lu memsw=%lu kmem=%lu tcpmem=%lu shmem=%lu", >> + mem_cgroup_id(memcg), >> + page_counter_read(&memcg->memory), >> + page_counter_read(&memcg->memsw), >> + page_counter_read(&memcg->kmem), >> + page_counter_read(&memcg->tcpmem), >> + memcg_page_state(memcg, NR_SHMEM)); >> +} >> + >> #ifdef CONFIG_MMU >> /* Handlers for move charge at task migration. */ >> static int mem_cgroup_do_precharge(unsigned long count) >> -- >> 2.25.1 >> >>