From patchwork Fri Aug 26 01:15:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lu Jialin X-Patchwork-Id: 12955419 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 2C223ECAAA3 for ; Fri, 26 Aug 2022 01:18:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 77565940008; Thu, 25 Aug 2022 21:18:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 723796B0075; Thu, 25 Aug 2022 21:18:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5EB7D940008; Thu, 25 Aug 2022 21:18:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 511E16B0074 for ; Thu, 25 Aug 2022 21:18:38 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 2620FC0173 for ; Fri, 26 Aug 2022 01:18:38 +0000 (UTC) X-FDA: 79839983916.23.EBC796A Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf29.hostedemail.com (Postfix) with ESMTP id 6831712000A for ; Fri, 26 Aug 2022 01:18:37 +0000 (UTC) Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MDMM926bQzkWft; Fri, 26 Aug 2022 09:15:01 +0800 (CST) Received: from kwepemm600003.china.huawei.com (7.193.23.202) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 26 Aug 2022 09:18:33 +0800 Received: from ubuntu1804.huawei.com (10.67.174.175) by kwepemm600003.china.huawei.com (7.193.23.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 26 Aug 2022 09:18:32 +0800 From: Lu Jialin To: Zefan Li , Tejun Heo , "Johannes Weiner" , Andrew Morton , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song CC: Lu Jialin , Xiu Jianfeng , , , Subject: [RFC 0/2] Introduce cgroup.top interface Date: Fri, 26 Aug 2022 09:15:01 +0800 Message-ID: <20220826011503.103894-1-lujialin4@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.67.174.175] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600003.china.huawei.com (7.193.23.202) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661476717; a=rsa-sha256; cv=none; b=B+dfYCM2SXprZmUdno1sFDIehMvKu3DrDIlAwE8Dtph9pQaFcwh4iUXZNH5av6D02N8aqD I5Unf4GX4ZSUAvJdBKsQhkQk5l2vkGREct0pDmpedSwFnWf9N2gHJ5/6onjHMFxydMDop3 N035atPGJfbjVXyK6yF+VoXryGCKFfQ= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; spf=pass (imf29.hostedemail.com: domain of lujialin4@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=lujialin4@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661476717; 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; bh=egMVUeSYggnbHPLM3C1e58kEk4/D8pu3nK9c37OrPV0=; b=P+PzMustVBVGkvEQBOxBrZEsLr7ffDUCP/3uzEE0u4F07Pyv1JEEPzeHmJ9UAqUYgtjpMU LA89YMntsXqQrUhNZUVAO/CrdKzXjMitpjuI1oonTnu67IE/BvNIx+pSkNfE4YH8Gu3Hii +nFK2wVfuGayDp/NxJc/YTXdLLa6lGc= Authentication-Results: imf29.hostedemail.com; dkim=none; spf=pass (imf29.hostedemail.com: domain of lujialin4@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=lujialin4@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: sucs344bdnp6sqsfommhn694xojawxam X-Rspamd-Queue-Id: 6831712000A X-HE-Tag: 1661476717-296264 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: Cgroup is used to organize and manage resource available processes. Currently there are no handy tool for gathering reousrce usage information for each and every child cgroups, makes it hard to detect resource outage and debug resource issues. To overcome this, we present the cgroup.top interface. Just like the top command, user is able to easily gather resource usage information , allowing user to detect and respond to resource outage in child cgroups Show case: / # mount -t cgroup2 none /sys/fs/cgroup / # cd /sys/fs/cgroup/ /sys/fs/cgroup # echo "+memory" > cgroup.subtree_control /sys/fs/cgroup # mkdir test1 /sys/fs/cgroup # mkdir test2 /sys/fs/cgroup # mkdir test3 /sys/fs/cgroup # echo $$ > test2/cgroup.procs /sys/fs/cgroup # cd /test /test # ./memcg_malloc 512000 & /test # ./memcg_malloc 512000 & /test # ./memcg_malloc 512000 & /test # cd /sys/fs/cgroup /sys/fs/cgroup # echo $$ > test1/cgroup.procs /sys/fs/cgroup # cd /test /test # ./memcg_malloc 512000 & /test # cd /sys/fs/cgroup /sys/fs/cgroup # echo $$ > test3/cgroup.procs /sys/fs/cgroup # cat cgroup.top memory top: name usage anon file kernel test2 1974272 1671168 0 270336 test1 700416 569344 0 94208 test3 196608 86016 0 86016 Lu Jialin (1): memcg: Adapt cgroup.top into per-memcg Xiu Jianfeng (1): cgroup: Introduce per-cgroup resource top show interface include/linux/cgroup-defs.h | 1 + kernel/cgroup/cgroup.c | 20 +++++++++ mm/memcontrol.c | 87 +++++++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+)