From patchwork Thu Apr 3 05:25:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: xu.xin16@zte.com.cn X-Patchwork-Id: 14036748 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 289A0C3600C for ; Thu, 3 Apr 2025 05:25:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D297B280003; Thu, 3 Apr 2025 01:25:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CADF6280001; Thu, 3 Apr 2025 01:25:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B76CA280003; Thu, 3 Apr 2025 01:25:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 995B6280001 for ; Thu, 3 Apr 2025 01:25:47 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 0A34FC18A0 for ; Thu, 3 Apr 2025 05:25:48 +0000 (UTC) X-FDA: 83291595576.24.678B048 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35]) by imf17.hostedemail.com (Postfix) with ESMTP id B5C2140005 for ; Thu, 3 Apr 2025 05:25:44 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=zte.com.cn; spf=pass (imf17.hostedemail.com: domain of xu.xin16@zte.com.cn designates 63.216.63.35 as permitted sender) smtp.mailfrom=xu.xin16@zte.com.cn ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743657945; 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=c0Nghbs5IEU95q0XplbMg4Y8RJqLIGLn5QwzNnUF79M=; b=IgSKH5Cgzs5pWCgSFAgltYnMCWFhyOmG9LF+RBfyGFTdxK12Aj2L7lV1At+KKdJXFSvay0 YyhDkRibTMMi2g1vIhQKvNo/ym4jzRPUlcu0CljlpTYQNIKiQIWxqd6/DgLOpoFICm47m4 JB2WdHz/sbf3njZl/SLIwQeALcA3ZKs= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=zte.com.cn; spf=pass (imf17.hostedemail.com: domain of xu.xin16@zte.com.cn designates 63.216.63.35 as permitted sender) smtp.mailfrom=xu.xin16@zte.com.cn ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743657945; a=rsa-sha256; cv=none; b=o9z2JaTkBBpUswF3xrSJgix7hEdY4urNh82NgDmasFwJVLk5Sv7jd/TVKSTEvTyXmW17QD sNp8MhwMVzmMyKaI5Dv8nD8X9mxfygfUOWnJV7oNMWz6D1nlIgx7Z8Y/DkCnLSVHwJ+U+j c+BBOYQ7P1otkTDdDpAdSOP5tN6Ceyw= Received: from mse-fl2.zte.com.cn (unknown [10.5.228.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxhk.zte.com.cn (FangMail) with ESMTPS id 4ZSqvS4D7yz5B1Jb; Thu, 3 Apr 2025 13:25:40 +0800 (CST) Received: from xaxapp05.zte.com.cn ([10.99.98.109]) by mse-fl2.zte.com.cn with SMTP id 5335PWS5010892; Thu, 3 Apr 2025 13:25:33 +0800 (+08) (envelope-from xu.xin16@zte.com.cn) Received: from mapi (xaxapp05[null]) by mapi (Zmail) with MAPI id mid32; Thu, 3 Apr 2025 13:25:34 +0800 (CST) Date: Thu, 3 Apr 2025 13:25:34 +0800 (CST) X-Zmail-TransId: 2afc67ee1bceffffffffc76-6612a X-Mailer: Zmail v1.0 Message-ID: <20250403132534636XLwK7CWiCj1J4-FENz0vk@zte.com.cn> Mime-Version: 1.0 From: To: , Cc: , , , , , , , , , , Subject: =?utf-8?q?=5BPATCH_linux-next_0/6=5D_support_ksm=5Fstat_showing_at_?= =?utf-8?q?cgroup?= X-MAIL: mse-fl2.zte.com.cn 5335PWS5010892 X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 67EE1BD4.002/4ZSqvS4D7yz5B1Jb X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: B5C2140005 X-Stat-Signature: kt91nhjo1ba93yhj5q7ogo8dribkaz3u X-HE-Tag: 1743657944-801915 X-HE-Meta: U2FsdGVkX180iC6qJeZFcVxQzutXiRLgYHNnFU7gWkyIsO6sbaKP3N2HMfVnjUte/oSsUOHuwbGjM0mTrkXa1mZCUYnztCqmbRYmjdZF7QktQo7tYKNtirj/X2Vvjp4QLeouGoBbwm5MzLe1rb1kIFq1KPW8gd3QpZXwrvZTEYOF/xXj3aNVXMdQ65vxCPgilf7RhMg8Or250kp4Z9o+WWrrfHBNaWZ8K3fw72wr2g8URsRReKvoVlH8/7l9GjcHpr7BByLU309xLO/xut6d2wApiQualC9mVKSbCZXr/rBYXPQwb/UceCXiv/fDiqH5qjA4ur9QsI722QSmcLFAKK5Nkr/azTOUPZFLSOwI6A7kRsTIc//YHk3kiF1K95v8D/uCDYnuZNMF+hgvDV1usqCzaP9ymHofvUp6GxwpNtwIWiuE+DAQkljeiCSfwvWJqAp53Nfid2M94gLTNF7CbFIQOWTJ5tibI8vUCOtmqjkuVm1ndbZ3u3e2FY9BlBiJBNSn5+q22K2q2TG+VHq86JdQ/4RZFNimXnThF7M3cGoURiphl5YtkGAsACioCsAYU27A/+QWqD+C1cZXXO6C7ij/zuu7aYtj1esxcR9xzgt1iI3TYW7F9MPgbiO87k1EsDfPE2/Yv7/eyRla8s+Kw5RluhO2olnx7ZZuhuRYGX+VjZo3Y/2mYdz6Ocx11MP6Fm8GfxHLxetZGmIqIJ/uwXLHkMTTm2pNNLG5tFWuBQ0f4fK4R6iCtpAGmwXcALVnJJB9W8+j1BIcQiff3vttOjIuOXcczpP2bKYoidz17idf34JmLLtpkLvtS2AbCARFuijicQZzGobRGdpdzJjfyaokz/s8VHspH+TNvS1Jbrg3TS2oH/Sn2BSVHVbj6yEfF/dFwgI2N0rqmuQr8a0obJPUGdt7W/xfkCl8RVtDRQ07IqcITQTfQld9dDqSqoKvWPaqtPmOA2/QhEtX7e9 hKDfQZjr olyPYU5ZvtyIzt9GZIX1WGUFDGy8uKkjztPJzMgRZAeoMoP2mvrV79MN8tRI2MUw3W784LgF4sXJB8hoZ8QGqdOq9y/o+Vw1khW6O/4IN1KlH0dTMjeTPywHUBopIpJBJ3De+xX6MLTA0ldjOUqgv+SFQciI/2hSMsI9XaJKfPp7tTjVQa6CCRnnHWdapXw5WnJ/QZNeUgb23chdxrzKz1LO7IknU/SC/V/QhlfjA5tNSFc5qRaASNsNkQUlI8eh0WCaefjCv+Q0qgxQ= 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: List-Subscribe: List-Unsubscribe: From: xu xin With the enablement of container-level KSM (e.g., via prctl [1]), there is a growing demand for container-level observability of KSM behavior. However, current cgroup implementations lack support for exposing KSM-related metrics. This patch introduces a new interface named ksm_stat at the cgroup hierarchy level, enabling users to monitor KSM merging statistics specifically for containers where this feature has been activated, eliminating the need to manually inspect KSM information for each individual process within the cgroup. Users can obtain the KSM information of a cgroup just by: # cat /sys/fs/cgroup/memory.ksm_stat ksm_rmap_items 76800 ksm_zero_pages 0 ksm_merging_pages 76800 ksm_process_profit 309657600 Current implementation supports cgroup v1 temporarily; cgroup v2 compatibility is planned for future versions. --- [1] commit d7597f59d1d3 ("mm: add new api to enable ksm per process"). xu xin (6): memcontrol: rename mem_cgroup_scan_tasks() memcontrol: introduce the new mem_cgroup_scan_tasks() memcontrol-v1: introduce ksm_stat at cgroup level memcontrol-v1: add ksm_zero_pages in cgroup/memory.ksm_stat memcontrol-v1: add ksm_merging_pages in cgroup/memory.ksm_stat memcontrol-v1: add ksm_profit in cgroup/memory.ksm_stat include/linux/memcontrol.h | 7 ++++++ mm/memcontrol-v1.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++ mm/memcontrol.c | 28 +++++++++++++++++++++-- mm/oom_kill.c | 6 ++--- 4 files changed, 91 insertions(+), 5 deletions(-)