From patchwork Mon Aug 13 06:58:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Khlebnikov X-Patchwork-Id: 10563903 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 345C81515 for ; Mon, 13 Aug 2018 06:58:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 29B4028EC6 for ; Mon, 13 Aug 2018 06:58:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1D77628F1E; Mon, 13 Aug 2018 06:58:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B52128EC6 for ; Mon, 13 Aug 2018 06:58:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 315816B0005; Mon, 13 Aug 2018 02:58:13 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2C3FA6B0006; Mon, 13 Aug 2018 02:58:13 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 18D436B0007; Mon, 13 Aug 2018 02:58:13 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by kanga.kvack.org (Postfix) with ESMTP id 9AAFE6B0005 for ; Mon, 13 Aug 2018 02:58:12 -0400 (EDT) Received: by mail-lf1-f72.google.com with SMTP id v14-v6so3044868lfe.9 for ; Sun, 12 Aug 2018 23:58:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:dkim-signature:subject:from:to:cc :date:message-id:user-agent:mime-version:content-transfer-encoding; bh=8ZtFv2UZmB81xn7HuqqAyGejETJ7l+kWbtMQf+KmMIc=; b=os5XGOi/vmVpq+hFX1AFk2wXDoFi0TDwH8TbgRgjreg8WeFcSOXDlwPQQdsO3duw3z RsAOQ0hoLRmmSp0mpOzWv2OGM46IutRuXn+RhJjh7DjuHeVLcoQRH/RRj2mu0e/Ay7BY b5rH9AYTD60/FILs+5H839onnMOvbIgQ/YH8BsVKH6YTqu7qQPwoFq0eNZcRr6igVLvZ Cvnf/AJo1+tnzjnjIF/qGPYFXHOTRzzYK/XvH/v8UDBzUaLSn1z+CJiawH9WBevXGVAK ZI18g9u7PlN5gaw2B7TnjbyjycLCLyAqnYGRgRyuDxX0UT1uP5pqND8oWFN85RiyVrys iCjg== X-Gm-Message-State: AOUpUlHV4Hqh2w8WXHaa/FhTenYJLmEBEzgrY/oYTzF7iGiaJ6FNk4XT yPphgTOnUuTNpISJbfF/WWqcnHZWAl3me3ruW13RIj4sxgwpYxGi9zClJmIFdjvkYdnMDsYIaJJ nO9Kx1JbmYqnQFGGcloy21TLTSYYyZ+mPQ4PYu3BOjYqS7O8x0fi/a2KAFFyJw6Zesg== X-Received: by 2002:a2e:9144:: with SMTP id q4-v6mr10754068ljg.121.1534143491951; Sun, 12 Aug 2018 23:58:11 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwwSsYG2us9iAQ2p0wtN6ZAUs33n1/SrMSFW/VYqBLfVPY2+MgZRmj8B4gFGXNXMSlGteKj X-Received: by 2002:a2e:9144:: with SMTP id q4-v6mr10754022ljg.121.1534143490868; Sun, 12 Aug 2018 23:58:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534143490; cv=none; d=google.com; s=arc-20160816; b=ENuFxYxoY0+qKGHNLjaD5zRRlmiQqWSc3Ki/W72pPx9eTYXvuudFoSmbhZuYyeJVLu SwL4cBIQE6Ob3+CW1YCTTp65mLrSLex/FBDziC3ZOfowgYD3P3jHUv1XxMrd1I0kJ1k5 ZpHOmddKCKGuxp1AzHcHaQCjAztpsb2W+MHu+4DObUKvtleon7vm5skQTllfJTpN2Gg2 ED2GPx1q+vJfuwU+XebLIYdMxyG8fK+08ughJK370VHRAhZrEZNqk3mGWWUNR1AZXVbB 1rCopoQz/oH30UIAYTnVGJeX0QaRbna5FZpvuLnEEluEPmCBgiufseA65v64LzQ5bnTg 0gxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:message-id:date :cc:to:from:subject:dkim-signature:dkim-signature :arc-authentication-results; bh=8ZtFv2UZmB81xn7HuqqAyGejETJ7l+kWbtMQf+KmMIc=; b=ZKoASSGAMaiFwZJGAEu8VLcpEZTyhkE2QU3IvgljXoKplzGU8km5l4XFWf9KNHzkSK cNQRmInDoRTCVCAujfGFge7FUG9IfkyKfZT7nUhuGYYM6qiOC0jlkJTQZFdigXY6Nwxq SHr9qY/NqtEIAtyBmHYUxqN+9RmrpZq+a0vsylVwfHSSCBxVSS2ZAvUAOVzthLk+B+Te Y/b4wBdyxQcqPjnxj2qhp9PfKGUtB2Yu4ihZ1IAjGzu9tr5Ap9+eyNwIZ5ki23mtLVb7 aPOT1gHc/FDRhEMQWuxwCCWWXyxtLFivxUdjUTKWn/fabf57kw3aD92y3EU6Gtwrtofj g0nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=Trt2gfZs; dkim=pass header.i=@yandex-team.ru header.s=default header.b=Trt2gfZs; spf=pass (google.com: domain of khlebnikov@yandex-team.ru designates 2a02:6b8:0:1a72::290 as permitted sender) smtp.mailfrom=khlebnikov@yandex-team.ru; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Received: from forwardcorp1o.cmail.yandex.net (forwardcorp1o.cmail.yandex.net. [2a02:6b8:0:1a72::290]) by mx.google.com with ESMTPS id z5-v6si8337469lje.386.2018.08.12.23.58.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Aug 2018 23:58:10 -0700 (PDT) Received-SPF: pass (google.com: domain of khlebnikov@yandex-team.ru designates 2a02:6b8:0:1a72::290 as permitted sender) client-ip=2a02:6b8:0:1a72::290; Authentication-Results: mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=Trt2gfZs; dkim=pass header.i=@yandex-team.ru header.s=default header.b=Trt2gfZs; spf=pass (google.com: domain of khlebnikov@yandex-team.ru designates 2a02:6b8:0:1a72::290 as permitted sender) smtp.mailfrom=khlebnikov@yandex-team.ru; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Received: from mxbackcorp1g.mail.yandex.net (mxbackcorp1g.mail.yandex.net [IPv6:2a02:6b8:0:1402::301]) by forwardcorp1o.cmail.yandex.net (Yandex) with ESMTP id 0D23B20E7E; Mon, 13 Aug 2018 09:58:10 +0300 (MSK) Received: from smtpcorp1p.mail.yandex.net (smtpcorp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:10]) by mxbackcorp1g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id YYu3dH7YBb-w9Nimf5Z; Mon, 13 Aug 2018 09:58:09 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1534143489; bh=8ZtFv2UZmB81xn7HuqqAyGejETJ7l+kWbtMQf+KmMIc=; h=Subject:From:To:Cc:Date:Message-ID; b=Trt2gfZsIhydfpZMDowuOOUH4YLMQcag6yAMewYSM7zY5U4ozfAooEeaAMedsZC7m aiYb0jgfwTFNKMKGzXV6o3bKHKWPgj9BCBHqxgyfJQByx7Zch19DDPGmXvI6QFHAYw J3WVR+/GFEeMpYY6dioCl9Eife8g28hQ1HS3KyaY= Received: from dynamic-red.dhcp.yndx.net (dynamic-red.dhcp.yndx.net [2a02:6b8:0:40c:854c:7dcd:9203:76a5]) by smtpcorp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 2thuRniehf-w98eXtFY; Mon, 13 Aug 2018 09:58:09 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1534143489; bh=8ZtFv2UZmB81xn7HuqqAyGejETJ7l+kWbtMQf+KmMIc=; h=Subject:From:To:Cc:Date:Message-ID; b=Trt2gfZsIhydfpZMDowuOOUH4YLMQcag6yAMewYSM7zY5U4ozfAooEeaAMedsZC7m aiYb0jgfwTFNKMKGzXV6o3bKHKWPgj9BCBHqxgyfJQByx7Zch19DDPGmXvI6QFHAYw J3WVR+/GFEeMpYY6dioCl9Eife8g28hQ1HS3KyaY= Authentication-Results: smtpcorp1p.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Subject: [PATCH RFC 1/3] cgroup: list all subsystem states in debugfs files From: Konstantin Khlebnikov To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org Cc: Tejun Heo , Michal Hocko , Vladimir Davydov , Roman Gushchin , Johannes Weiner Date: Mon, 13 Aug 2018 09:58:05 +0300 Message-ID: <153414348591.737150.14229960913953276515.stgit@buzz> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP 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 swap - charged swap Signed-off-by: Konstantin Khlebnikov --- include/linux/cgroup-defs.h | 1 kernel/cgroup/cgroup.c | 99 +++++++++++++++++++++++++++++++++++++++++++ mm/memcontrol.c | 12 +++++ 3 files changed, 112 insertions(+) diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h index c0e68f903011..c828820e160f 100644 --- a/include/linux/cgroup-defs.h +++ b/include/linux/cgroup-defs.h @@ -595,6 +595,7 @@ struct cgroup_subsys { void (*exit)(struct task_struct *task); void (*free)(struct task_struct *task); void (*bind)(struct cgroup_subsys_state *root_css); + void (*css_dump)(struct cgroup_subsys_state *css, struct seq_file *); bool early_init:1; diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 077370bf8964..b7be190daffe 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -5978,3 +5979,101 @@ 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; + 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, atomic_long_read(&css->refcnt.count)); + + 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_puts(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 b2173f7e5164..19a4348974a4 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4345,6 +4345,17 @@ static void mem_cgroup_css_reset(struct cgroup_subsys_state *css) memcg_wb_domain_size_changed(memcg); } +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 swap=%lu", + mem_cgroup_id(memcg), + page_counter_read(&memcg->memory), + page_counter_read(&memcg->swap)); +} + #ifdef CONFIG_MMU /* Handlers for move charge at task migration. */ static int mem_cgroup_do_precharge(unsigned long count) @@ -5386,6 +5397,7 @@ struct cgroup_subsys memory_cgrp_subsys = { .css_released = mem_cgroup_css_released, .css_free = mem_cgroup_css_free, .css_reset = mem_cgroup_css_reset, + .css_dump = mem_cgroup_css_dump, .can_attach = mem_cgroup_can_attach, .cancel_attach = mem_cgroup_cancel_attach, .post_attach = mem_cgroup_move_task, From patchwork Mon Aug 13 06:58:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Khlebnikov X-Patchwork-Id: 10563905 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 35B6017E1 for ; Mon, 13 Aug 2018 06:58:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A18A28EC6 for ; Mon, 13 Aug 2018 06:58:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1DA1D28F1E; Mon, 13 Aug 2018 06:58:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DD3828EC6 for ; Mon, 13 Aug 2018 06:58:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 473426B0007; Mon, 13 Aug 2018 02:58:17 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 449BD6B0008; Mon, 13 Aug 2018 02:58:17 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3150B6B000A; Mon, 13 Aug 2018 02:58:17 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by kanga.kvack.org (Postfix) with ESMTP id AF1D06B0007 for ; Mon, 13 Aug 2018 02:58:16 -0400 (EDT) Received: by mail-lf1-f69.google.com with SMTP id w8-v6so3039812lfe.15 for ; Sun, 12 Aug 2018 23:58:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:dkim-signature:subject:from:to:cc :date:message-id:in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=RCjJcduRfJ1tqg5OczeRsjSyUm49buizoP+lV7kD+TU=; b=JZJIUnfNlDRyAZ6jVYrWm+bJ5O0nM/lTxR5cePbexcnEBxaJaDtn2PJQ5gO0wmp9q8 lwJH1JCPGVUychO+VJ7obzyVWqJqzCvcSjNggjUY/GGs0c7r8xQ74DdVfoEZSOyUSj8E 1LLsze2vOg4LR10tpGJQQi6w+5ky/YUHu6yxYD7HTV5O/umVyt6DgFi2hu8AzvD1xiaB M5Q2f5Cr6u+HT5wFVJlZcAtpIkgLtoV3Qnpv4K4YR5r+fkO68osL2YC+c/YtB3cC5+AE La6+bai1YEc4HQIrEa7I2dMYqlZxchCahHyoapP04+OlE5epK5FGYZPDAV2nBcluEKBy J4mA== X-Gm-Message-State: AOUpUlGcEzmkouN1ch1bY1OilAYZyy23GAyJnGEz/CAZxwsG1zmDChU7 9ua9otfKDA6/c6knM7Of6bnpxNB3Hf2uTag7UhtWXvPXoIToH7wqAM1kmMabOFz/QgjaaZlccjp 7dQ3JTDmczPw9ppQced5eTZIEGldzwGi57Do1opPD5t2KIqOciuUsmTK+W+wfCnO1Og== X-Received: by 2002:a19:73c9:: with SMTP id h70-v6mr9930803lfk.61.1534143496022; Sun, 12 Aug 2018 23:58:16 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzHFPDagf8hq8M9DhqgJwhjZKEEqOFdGTdl8RN0urLs0B/19YHi3xjFFLSvXluLT69gyyGJ X-Received: by 2002:a19:73c9:: with SMTP id h70-v6mr9930776lfk.61.1534143494915; Sun, 12 Aug 2018 23:58:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534143494; cv=none; d=google.com; s=arc-20160816; b=fiwlwisZy2R4SQ/eaWMgExv4PT9UWpNu5f+wahWKVv5atC08pxi+v/NnenN7GyunKj UheVFn0yOB19LRgq5/BsoTSJU0W45WQhyN2dClBxrfEp4VKFfP9xtvVoYMs1LT+KUaSJ i/qrZuqHDXlSrrkoJpPnjGTA3aPQ1h4qiZkM/DAL2k8gDhaf3/uvn6csJ4edheVOciNv cSXpIAPlE8u1/d7l444FEg3T5JCntuey/lf7/P0OwKXzDlk9RRBLCvenYru9/oKvL3zQ kdNYNGEXh88WytpNLsgOIdZf5xYEQnag1q0HRThXHaLrUVfXbPdGoNCQwXaGBlWa3Zyz f55g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject:dkim-signature :dkim-signature:arc-authentication-results; bh=RCjJcduRfJ1tqg5OczeRsjSyUm49buizoP+lV7kD+TU=; b=BrCxVj1Txt0n7VTg7cMW7BPtNS7CIRCMf7wKXbmK6CN5iqe+0wzUmKidfEttg738ky SmNOxA/QN2msULN4QrE3wkRhh6sKpdzpEdNSQTyq/9R4BGrTBdySGKkfN17WW7nuWV7k xzO6MmYsGnb3ZJ8sEJQENh6fcrIPjnW7D14OBWZdUCabQg4xOrJ+z96qpKALw+hAA9Mc DqMGX4SHZSEIZdDhyjlCJQn0fWZy8Ywa1G9MSjM9vaCzk6KhtRuFPtRVcGqNNLCMlmE5 mDS5YawJhF47A57o7zwQjypmMOTn+tMnpekI2zqlelwOpCXnCFamlSPLV4F8Jfxetwxi AJEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=dpyb+wtL; dkim=pass header.i=@yandex-team.ru header.s=default header.b="lSMv/8I3"; spf=pass (google.com: domain of khlebnikov@yandex-team.ru designates 2a02:6b8:0:1465::fd as permitted sender) smtp.mailfrom=khlebnikov@yandex-team.ru; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Received: from forwardcorp1g.cmail.yandex.net (forwardcorp1g.cmail.yandex.net. [2a02:6b8:0:1465::fd]) by mx.google.com with ESMTPS id p16-v6si6927774lji.224.2018.08.12.23.58.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Aug 2018 23:58:14 -0700 (PDT) Received-SPF: pass (google.com: domain of khlebnikov@yandex-team.ru designates 2a02:6b8:0:1465::fd as permitted sender) client-ip=2a02:6b8:0:1465::fd; Authentication-Results: mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=dpyb+wtL; dkim=pass header.i=@yandex-team.ru header.s=default header.b="lSMv/8I3"; spf=pass (google.com: domain of khlebnikov@yandex-team.ru designates 2a02:6b8:0:1465::fd as permitted sender) smtp.mailfrom=khlebnikov@yandex-team.ru; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Received: from mxbackcorp1o.mail.yandex.net (mxbackcorp1o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::301]) by forwardcorp1g.cmail.yandex.net (Yandex) with ESMTP id 487FE2072D; Mon, 13 Aug 2018 09:58:14 +0300 (MSK) Received: from smtpcorp1p.mail.yandex.net (smtpcorp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:10]) by mxbackcorp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 769TnBkkZv-wDiWXWPD; Mon, 13 Aug 2018 09:58:14 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1534143494; bh=RCjJcduRfJ1tqg5OczeRsjSyUm49buizoP+lV7kD+TU=; h=Subject:From:To:Cc:Date:Message-ID:In-Reply-To:References; b=dpyb+wtLeTpIzv9emF93Vlna7I+zDWtx0lll70Gj5rKAJLiFthfjKDtvRUXZ3/1Mf bFp3H2iJPUyKcNbkrTig780qtVSaO6btFsjPpby7/TC76JgKoaMsh9annPKJpSZ3hM US9He5eboS9PEWfKy36brnib/n7ypGb/5gQtyDmk= Received: from dynamic-red.dhcp.yndx.net (dynamic-red.dhcp.yndx.net [2a02:6b8:0:40c:854c:7dcd:9203:76a5]) by smtpcorp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id DkUuBRmSwn-wD8GErpp; Mon, 13 Aug 2018 09:58:13 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1534143493; bh=RCjJcduRfJ1tqg5OczeRsjSyUm49buizoP+lV7kD+TU=; h=Subject:From:To:Cc:Date:Message-ID:In-Reply-To:References; b=lSMv/8I3VpsmZJUc8bZq6a6hmbdgRQgA0+AbmiT0l1bbAhjcAw/aR8lgvIYvGXJP5 1+mHLhFQ8CH3egth+zwM/LW6EA3QYn/q274T3D6eKL7bhpZxLjKCwpHdUpdba2nnm8 bUAuxDyYOqx9M9RiLelpbDKagWBz4nsYDwzmQBq8= Authentication-Results: smtpcorp1p.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Subject: [PATCH RFC 2/3] proc/kpagecgroup: report also inode numbers of offline cgroups From: Konstantin Khlebnikov To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org Cc: Tejun Heo , Michal Hocko , Vladimir Davydov , Roman Gushchin , Johannes Weiner Date: Mon, 13 Aug 2018 09:58:10 +0300 Message-ID: <153414348994.737150.10057219558779418929.stgit@buzz> In-Reply-To: <153414348591.737150.14229960913953276515.stgit@buzz> References: <153414348591.737150.14229960913953276515.stgit@buzz> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP By default this interface reports inode number of closest online ancestor if cgroups is offline (removed). Information about real owner is required for detecting which pages keep removed cgroup. This patch adds per-file mode which is changed by writing 64-bit flags into opened /proc/kpagecgroup. For now only first bit is used. Signed-off-by: Konstantin Khlebnikov --- Documentation/admin-guide/mm/pagemap.rst | 3 +++ fs/proc/page.c | 24 ++++++++++++++++++++++-- include/linux/memcontrol.h | 2 +- mm/memcontrol.c | 5 +++-- mm/memory-failure.c | 2 +- 5 files changed, 30 insertions(+), 6 deletions(-) diff --git a/Documentation/admin-guide/mm/pagemap.rst b/Documentation/admin-guide/mm/pagemap.rst index 577af85beb41..b39d841ac560 100644 --- a/Documentation/admin-guide/mm/pagemap.rst +++ b/Documentation/admin-guide/mm/pagemap.rst @@ -80,6 +80,9 @@ There are four components to pagemap: memory cgroup each page is charged to, indexed by PFN. Only available when CONFIG_MEMCG is set. + For offline (removed) cgroup this returnes inode number of closest online + ancestor. Write 64-bit flag 1 into opened file for getting real owners. + Short descriptions to the page flags ==================================== diff --git a/fs/proc/page.c b/fs/proc/page.c index 792c78a49174..337f526fcc27 100644 --- a/fs/proc/page.c +++ b/fs/proc/page.c @@ -248,6 +248,7 @@ static const struct file_operations proc_kpageflags_operations = { static ssize_t kpagecgroup_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { + unsigned long flags = (unsigned long)file->private_data; u64 __user *out = (u64 __user *)buf; struct page *ppage; unsigned long src = *ppos; @@ -267,7 +268,7 @@ static ssize_t kpagecgroup_read(struct file *file, char __user *buf, ppage = NULL; if (ppage) - ino = page_cgroup_ino(ppage); + ino = page_cgroup_ino(ppage, !(flags & 1)); else ino = 0; @@ -289,9 +290,28 @@ static ssize_t kpagecgroup_read(struct file *file, char __user *buf, return ret; } +static ssize_t kpagecgroup_write(struct file *file, const char __user *buf, + size_t count, loff_t *ppos) +{ + u64 flags; + + if (count != 8) + return -EINVAL; + + if (get_user(flags, buf)) + return -EFAULT; + + if (flags > 1) + return -EINVAL; + + file->private_data = (void *)(unsigned long)flags; + return count; +} + static const struct file_operations proc_kpagecgroup_operations = { .llseek = mem_lseek, .read = kpagecgroup_read, + .write = kpagecgroup_write, }; #endif /* CONFIG_MEMCG */ @@ -300,7 +320,7 @@ static int __init proc_page_init(void) proc_create("kpagecount", S_IRUSR, NULL, &proc_kpagecount_operations); proc_create("kpageflags", S_IRUSR, NULL, &proc_kpageflags_operations); #ifdef CONFIG_MEMCG - proc_create("kpagecgroup", S_IRUSR, NULL, &proc_kpagecgroup_operations); + proc_create("kpagecgroup", 0600, NULL, &proc_kpagecgroup_operations); #endif return 0; } diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 6c6fb116e925..a7c40522bef0 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -444,7 +444,7 @@ static inline bool mm_match_cgroup(struct mm_struct *mm, } struct cgroup_subsys_state *mem_cgroup_css_from_page(struct page *page); -ino_t page_cgroup_ino(struct page *page); +ino_t page_cgroup_ino(struct page *page, bool online); static inline bool mem_cgroup_online(struct mem_cgroup *memcg) { diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 19a4348974a4..7ef6ea9d5e4a 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -333,6 +333,7 @@ struct cgroup_subsys_state *mem_cgroup_css_from_page(struct page *page) /** * page_cgroup_ino - return inode number of the memcg a page is charged to * @page: the page + * @online: return closest online ancestor * * Look up the closest online ancestor of the memory cgroup @page is charged to * and return its inode number or 0 if @page is not charged to any cgroup. It @@ -343,14 +344,14 @@ struct cgroup_subsys_state *mem_cgroup_css_from_page(struct page *page) * after page_cgroup_ino() returns, so it only should be used by callers that * do not care (such as procfs interfaces). */ -ino_t page_cgroup_ino(struct page *page) +ino_t page_cgroup_ino(struct page *page, bool online) { struct mem_cgroup *memcg; unsigned long ino = 0; rcu_read_lock(); memcg = READ_ONCE(page->mem_cgroup); - while (memcg && !(memcg->css.flags & CSS_ONLINE)) + while (memcg && online && !(memcg->css.flags & CSS_ONLINE)) memcg = parent_mem_cgroup(memcg); if (memcg) ino = cgroup_ino(memcg->css.cgroup); diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 9d142b9b86dc..bd09c447e0ec 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -139,7 +139,7 @@ static int hwpoison_filter_task(struct page *p) if (!hwpoison_filter_memcg) return 0; - if (page_cgroup_ino(p) != hwpoison_filter_memcg) + if (page_cgroup_ino(p, true) != hwpoison_filter_memcg) return -EINVAL; return 0; From patchwork Mon Aug 13 06:58:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Khlebnikov X-Patchwork-Id: 10563907 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2201E17E1 for ; Mon, 13 Aug 2018 06:58:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 182CA28EC6 for ; Mon, 13 Aug 2018 06:58:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C82628F1E; Mon, 13 Aug 2018 06:58:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89CE628EC6 for ; Mon, 13 Aug 2018 06:58:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2C9A76B000A; Mon, 13 Aug 2018 02:58:20 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 229E36B000C; Mon, 13 Aug 2018 02:58:20 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 11A0A6B000D; Mon, 13 Aug 2018 02:58:20 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by kanga.kvack.org (Postfix) with ESMTP id 8F9E36B000A for ; Mon, 13 Aug 2018 02:58:19 -0400 (EDT) Received: by mail-lj1-f200.google.com with SMTP id v23-v6so2436739ljc.8 for ; Sun, 12 Aug 2018 23:58:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:dkim-signature:subject:from:to:cc :date:message-id:in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=g8KK2eY9Qx5mtXYPtyrNv99QbkJY/jwtgDsrn4/1FV0=; b=OdBs3DCBwNwVkTScX3eKE+U32e6VQ6ko+EL9xS/S0yqMO+bezy7FDxaSBE0Miht8Cd R3qZ7yoE4hcrjl8T6+tC2BGhLpT2Gz15MF4ZRhcCKMZqZku5eOxe6zoipYkrSCMyD0Bg lT2xdWZvsDa4tGFZLOk8FCZa55O6BrRgXATBDl7x4NjmsIGP4uiEK9MpxAMlMikn1dXP 48ERqErpx3OmkuoHD1/pURnsaIwpObXGAGZiIAgNdV/W/J7YhZVRJtjwzhBVcupaL7Sm Kl1FJfKyTmWhv6HkjFfdxNSefvpoDoJiir+BGS50UcrNoqCZIHdnYJF9wAuj7Qj6mlMo qgyg== X-Gm-Message-State: AOUpUlGnNiC6H06ZBqltPx5NVaPdVRCjHnqinOMBJj2g7+MFTdEBfX+C cNDFlE+SkWHWK/+17CaKWWxX5mtKkmn50cuspT3TXQ81SU0CECmLVLfuvN04KnXeo20lQreo8f/ W90Snh/t73v6snij5XRNOchmm3ZGlAltl5/BG2GW+CblTyAnzSY46+6oggPdhWv3PAg== X-Received: by 2002:a2e:1953:: with SMTP id p80-v6mr5875781lje.127.1534143498987; Sun, 12 Aug 2018 23:58:18 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzlEVwccILzy5YvzxJNiiy9CUK7AqfpALhMV86v2bDrrm5ON0UeqreNxua/YwzGktPMuIZR X-Received: by 2002:a2e:1953:: with SMTP id p80-v6mr5875748lje.127.1534143498070; Sun, 12 Aug 2018 23:58:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534143498; cv=none; d=google.com; s=arc-20160816; b=Fm8LURX9jOa44DX1N+bsrpDcO+eaU4PvPJju1Pzg/radZesCiQumw9sypk5YlQKJBN 2NHNirVG3NT104SzTcDVlolRIv9qeIfQbP5XRGSGL6dbqeanSXgiHXXTzwmIl846Tm1c W3kiEVUe6O77H8zoW+y0lLXnOIxqSjn86Cg/FrrWt04yyaKujwA0vffhHiu9qVxfAHRC K8QfpWrz+jNS5SFpqczoR+N+wISvBIZE5V3R+lUtn7Wd2y5KkTLEH31Hr0/GBmQirdHJ mrrFudsO+0d02VgLZxIWo2BFFmkDQJlTugDtOihRshMUnms3GnZs73Lu84cNEIuXdJEH fmMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject:dkim-signature :dkim-signature:arc-authentication-results; bh=g8KK2eY9Qx5mtXYPtyrNv99QbkJY/jwtgDsrn4/1FV0=; b=Q8wTER/dREoQc60V26H8QbwLNFeWCMFJLbSrpsUd81TziIBk0s7iy3uMZQuBBDF7im S3ZLrOrv+5trUwcfZ7nLAPFLpbIeWOiOEeNRESME5irRRs9uRXRggPOjSDAfioJJzOF/ NhIbxCMUAlUdvhV5g0sv9PTqOkT7tgwbG2Iny/CEUMwUeqalKn83f3TnZs98HNEIpES5 618kfoYTEt93Cmz4fWJ7qKlEFVi3/b6HKl7nPDgDQb4Nsloodd+XwRjVJJCAJauCh53l ylAfC/jn0WavZ48qXL/Qaabx94O3/D+pBk+DnzzcA70SdmzJrigSSxA5utl7urrGeHso prLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=utZfwDI5; dkim=pass header.i=@yandex-team.ru header.s=default header.b=utZfwDI5; spf=pass (google.com: domain of khlebnikov@yandex-team.ru designates 2a02:6b8:0:1630::190 as permitted sender) smtp.mailfrom=khlebnikov@yandex-team.ru; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Received: from forwardcorp1j.cmail.yandex.net (forwardcorp1j.cmail.yandex.net. [2a02:6b8:0:1630::190]) by mx.google.com with ESMTPS id o10-v6si6123471ljd.100.2018.08.12.23.58.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Aug 2018 23:58:18 -0700 (PDT) Received-SPF: pass (google.com: domain of khlebnikov@yandex-team.ru designates 2a02:6b8:0:1630::190 as permitted sender) client-ip=2a02:6b8:0:1630::190; Authentication-Results: mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=utZfwDI5; dkim=pass header.i=@yandex-team.ru header.s=default header.b=utZfwDI5; spf=pass (google.com: domain of khlebnikov@yandex-team.ru designates 2a02:6b8:0:1630::190 as permitted sender) smtp.mailfrom=khlebnikov@yandex-team.ru; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Received: from mxbackcorp1g.mail.yandex.net (mxbackcorp1g.mail.yandex.net [IPv6:2a02:6b8:0:1402::301]) by forwardcorp1j.cmail.yandex.net (Yandex) with ESMTP id 7141A21233; Mon, 13 Aug 2018 09:58:17 +0300 (MSK) Received: from smtpcorp1p.mail.yandex.net (smtpcorp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:10]) by mxbackcorp1g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id EpZ3JuQNfW-wHN8cpY2; Mon, 13 Aug 2018 09:58:17 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1534143497; bh=g8KK2eY9Qx5mtXYPtyrNv99QbkJY/jwtgDsrn4/1FV0=; h=Subject:From:To:Cc:Date:Message-ID:In-Reply-To:References; b=utZfwDI5V7wYbwnn/A+RSPxNxnyD2iS620obLp2CZK3EA/KM+PHruewO6HeEW9qac +Qe7/DWhS2MSFVUOwzfIXALFixLVtQOynBF30jLP1/zIw17LVqnGcfWcp9HPqj4B0m 6ZZsWQPI7xx3bCGXIIs+3BoLG837I0PvIA9hNzgE= Received: from dynamic-red.dhcp.yndx.net (dynamic-red.dhcp.yndx.net [2a02:6b8:0:40c:854c:7dcd:9203:76a5]) by smtpcorp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 2msfYMj7CI-wH8StnEP; Mon, 13 Aug 2018 09:58:17 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1534143497; bh=g8KK2eY9Qx5mtXYPtyrNv99QbkJY/jwtgDsrn4/1FV0=; h=Subject:From:To:Cc:Date:Message-ID:In-Reply-To:References; b=utZfwDI5V7wYbwnn/A+RSPxNxnyD2iS620obLp2CZK3EA/KM+PHruewO6HeEW9qac +Qe7/DWhS2MSFVUOwzfIXALFixLVtQOynBF30jLP1/zIw17LVqnGcfWcp9HPqj4B0m 6ZZsWQPI7xx3bCGXIIs+3BoLG837I0PvIA9hNzgE= Authentication-Results: smtpcorp1p.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Subject: [PATCH RFC 3/3] tools/vm/page-types: add flag for showing inodes of offline cgroups From: Konstantin Khlebnikov To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org Cc: Tejun Heo , Michal Hocko , Vladimir Davydov , Roman Gushchin , Johannes Weiner Date: Mon, 13 Aug 2018 09:58:14 +0300 Message-ID: <153414349419.737150.8224164787883146532.stgit@buzz> In-Reply-To: <153414348591.737150.14229960913953276515.stgit@buzz> References: <153414348591.737150.14229960913953276515.stgit@buzz> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP With flag -R|--real-cgroup page-types will report real owner. Signed-off-by: Konstantin Khlebnikov --- tools/vm/page-types.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tools/vm/page-types.c b/tools/vm/page-types.c index cce853dca691..453dbbb9fe8b 100644 --- a/tools/vm/page-types.c +++ b/tools/vm/page-types.c @@ -173,6 +173,7 @@ static pid_t opt_pid; /* process to walk */ const char *opt_file; /* file or directory path */ static uint64_t opt_cgroup; /* cgroup inode */ static int opt_list_cgroup;/* list page cgroup */ +static int opt_real_cgroup;/* real offline cgroup */ static const char *opt_kpageflags;/* kpageflags file to parse */ #define MAX_ADDR_RANGES 1024 @@ -789,6 +790,7 @@ static void usage(void) " -l|--list Show page details in ranges\n" " -L|--list-each Show page details one by one\n" " -C|--list-cgroup Show cgroup inode for pages\n" +" -R|--real-cgroup Show real offline cgroups\n" " -N|--no-summary Don't show summary info\n" " -X|--hwpoison hwpoison pages\n" " -x|--unpoison unpoison pages\n" @@ -1193,6 +1195,7 @@ static const struct option opts[] = { { "list" , 0, NULL, 'l' }, { "list-each" , 0, NULL, 'L' }, { "list-cgroup", 0, NULL, 'C' }, + { "real-cgroup", 0, NULL, 'R' }, { "no-summary", 0, NULL, 'N' }, { "hwpoison" , 0, NULL, 'X' }, { "unpoison" , 0, NULL, 'x' }, @@ -1208,7 +1211,7 @@ int main(int argc, char *argv[]) page_size = getpagesize(); while ((c = getopt_long(argc, argv, - "rp:f:a:b:d:c:ClLNXxF:h", opts, NULL)) != -1) { + "rp:f:a:b:d:c:CRlLNXxF:h", opts, NULL)) != -1) { switch (c) { case 'r': opt_raw = 1; @@ -1231,6 +1234,9 @@ int main(int argc, char *argv[]) case 'C': opt_list_cgroup = 1; break; + case 'R': + opt_real_cgroup = 1; + break; case 'd': describe_flags(optarg); exit(0); @@ -1266,7 +1272,15 @@ int main(int argc, char *argv[]) if (!opt_kpageflags) opt_kpageflags = PROC_KPAGEFLAGS; - if (opt_cgroup || opt_list_cgroup) + if (opt_real_cgroup) { + uint64_t flags = 1; + + kpagecgroup_fd = checked_open(PROC_KPAGECGROUP, O_RDWR); + if (write(kpagecgroup_fd, &flags, sizeof(flags)) < 0) { + perror(PROC_KPAGECGROUP); + exit(EXIT_FAILURE); + } + } else if (opt_cgroup || opt_list_cgroup) kpagecgroup_fd = checked_open(PROC_KPAGECGROUP, O_RDONLY); if (opt_list && opt_pid)