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 4CCC0C021B1 for ; Thu, 20 Feb 2025 15:51:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D28394401F1; Thu, 20 Feb 2025 10:51:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CD6E04401F0; Thu, 20 Feb 2025 10:51:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B9EB64401F1; Thu, 20 Feb 2025 10:51:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 9B3334401F0 for ; Thu, 20 Feb 2025 10:51:10 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id D85DCA52AB for ; Thu, 20 Feb 2025 15:51:08 +0000 (UTC) X-FDA: 83140761858.18.FCE3C8F Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf19.hostedemail.com (Postfix) with ESMTP id 8F0B41A0029 for ; Thu, 20 Feb 2025 15:51:06 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=aDv0FUkg; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf19.hostedemail.com: domain of tj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=tj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1740066666; a=rsa-sha256; cv=none; b=TlTKW59xHH0eQtvp1PgVoxH7YQWKZNGl9rspz4cWG+DfOAmFFqmUbaTZZi7KDQeijaZMKP 1vYCY/gBLSCnFqCOubHKkRk57Hbu69Kh5kMV1f7iQd/lthnwC3WcBNl3U5+mGr+5twQYXV v91ATFCci3RY/r16OiWcaFrbnD7zkwM= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=aDv0FUkg; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf19.hostedemail.com: domain of tj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=tj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1740066666; 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:in-reply-to:references:references:dkim-signature; bh=KnmMTMpV/MqEScgEaLiu+TqjuK05MJzyxL4oe0WPe/g=; b=ehCNQc05Hy7TcTuxwi47JodelAji8cs/NnK5uIOdzDB4CHmsg9zB6GMiZauXIo1nLFh8LA lvxv2lyj7qijZQo1nGCqnSqYJzAlGM45wr2owS+juXs/GRV3rpSP+Yd2XFV5ceHOor5DSC gpxqfLcDrv1VE54jizaBsyd2ToAUPk4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id A0D065C5E4D; Thu, 20 Feb 2025 15:50:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57281C4CEDD; Thu, 20 Feb 2025 15:51:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740066664; bh=74D4z/8LfODGfOhZKyP3pWUaQ47cVcZEFucwpuFpn2c=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=aDv0FUkgMQbpqiIVJ2jkiT71UOS7AohZ71hzvBNb0EKKVwqe0gufVDyGqAMo+E2k7 5qMRSZt6Ncq2fAqTYXSVlQCpZxggVaBVciwfeXNtTDz6a0K+cLtowf8AYnkAte7yd+ TxwdYRXHZeg49dpHn0cTlyg5z5DkPa4oiyA4ILykKPMiddmbyjjgx2Fr/gn8CKlDcD YpvATWMzzIZQlOsh2C3qR9rhorUxntKcO1NSS+c+QpF5cp7jnMYboEAeTRuF6gxm4j ETbnQDLteSLlgwHTW0425DaKyYt49d0jYV2cnj+Hrzu82F5Ai1XcMyHBYIJOcTDoVa jpGag1JNbipKQ== Date: Thu, 20 Feb 2025 05:51:03 -1000 From: Tejun Heo To: JP Kobryn Cc: shakeel.butt@linux.dev, mhocko@kernel.org, hannes@cmpxchg.org, yosryahmed@google.com, akpm@linux-foundation.org, linux-mm@kvack.org, cgroups@vger.kernel.org, kernel-team@meta.com Subject: Re: [PATCH 00/11] cgroup: separate rstat trees Message-ID: References: <20250218031448.46951-1-inwardvessel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250218031448.46951-1-inwardvessel@gmail.com> X-Rspam-User: X-Rspamd-Queue-Id: 8F0B41A0029 X-Rspamd-Server: rspam12 X-Stat-Signature: tpbzfwenb5fj7o1mzkp9onwwaihit5qn X-HE-Tag: 1740066666-541317 X-HE-Meta: U2FsdGVkX1+QOr8eHIAAbatEcgskIA8FYQ16pYzinNtTR83LVFjgFviCwl/Xxhg6QvgOP5T8gg/taURQxwwf1RulWeIco8h3l6KwxOBVMMzLFhxvqck7Q6oOxi6ZVIB9H3mX5S1MEYXdyiCFZxuYoNDuoXcTfM6jf/7kgnvOlwkW+KF1an/upktekvX2r9eCHRaH4SXj2RG3lpynQDbvx/eK4Q7Ni3t6B6AeUe6n08W389l5fwHL8SdBsLEySmYDVL/8+t8qnllSykMO5MkUx1OLXikR0SQKIlls3ZcS4aT9itOE0prWDrfmdVNqFcBq0QoQSxP0iwuoNFq4zvaePFsFQgdltg7WJzBib4B/rykNgz4koH6Yxk1b4MTOQFWzNeRbyWuq1Z5iFX0Y+YtMw8hpPZj0vs1gbMlp890p3o0/hohox4eEGpxCmg6PtLiwz5Z3ENystCGuuIcPDfMI9qgg5OQiRY/Q+ofahx/rgQ0hDsRMXXNs4dY8l3f+rBjGMyEw+OymdjUHiyR1pNkqVTLbYTJ4SyK0c5P7bJLTi/gb4u4w0tX2tm13ay/UTENnTZDmj9uffGsQE7lZvGU8Qyjhq3aMs4Xy3839iipErPGPeD5uLqDEbIXPugvdfhzkxORTPkQa4mDaybjOQgugNXyffNrIejVSyzDkdneJKZv/YeDW2tsg3JQUZrzXgyDu4FS29P9hWUZY6MCD8tuiiPgkzrL1uAGYhD33bx+/7PZD2ooopnFcgQODPLZBgRFAYiDCvfpDKZ2RReGkDf5hbjx0hp1B2f6zRCXxG9NlSea/XfNMYNs8TArbHysYtF/dilrOTANxSelfWGNmVUbZvMeyLHQUauAWtM40W9hUftSw4fMBIm0dps538z5XmZsycIWslwp5wF4z3+9/dJHuV5Ht6v248WMxOBVDwSXM8MCxbqzWSMw0DVwWsFQrCiJRDix35aKSZ7+u2++gWu/ 9m8x3bFY hDecNl6q8l94nMHknRls3ANbeg+WMNKHmTj8b5gE6miRXts34eh7smQ5O/zJnmIM6Kz13PVJ/oJpu+EecNlzZJ5KpXzAdLc1ZbWm2aOAooHUEEzVVjPNYCqk+8As1KQfexFhRWJswOF1nh3/+94BGNAEkSUcb5JsHpwjnJRC9MKgdgAWZdbei8kd7mohZs72Nvq6BQX9pyKpZXlPQXwtyInGRhrOSmRCdldUfoBfBwwjkdRohnIToQVjhzQ== 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: Hello, On Mon, Feb 17, 2025 at 07:14:37PM -0800, JP Kobryn wrote: ... > The first experiment consisted of a parent cgroup with memory.swap.max=0 > and memory.max=1G. On a 52-cpu machine, 26 child cgroups were created and > within each child cgroup a process was spawned to encourage the updating of > memory cgroup stats by creating and then reading a file of size 1T > (encouraging reclaim). These 26 tasks were run in parallel. While this was > going on, a custom program was used to open cpu.stat file of the parent > cgroup, read the entire file 1M times, then close it. The perf report for > the task performing the reading showed that most of the cycles (42%) were > spent on the function mem_cgroup_css_rstat_flush() of the control side. It > also showed a smaller but significant number of cycles spent in > __blkcg_rstat_flush. The perf report for patched kernel differed in that no > cycles were spent in these functions. Instead most cycles were spent on > cgroup_base_stat_flush(). Aside from the perf reports, the amount of time > spent running the program performing the reading of cpu.stats showed a gain > when comparing the control to the experimental kernel.The time in kernel > mode was reduced. > > before: > real 0m18.449s > user 0m0.209s > sys 0m18.165s > > after: > real 0m6.080s > user 0m0.170s > sys 0m5.890s > > Another experiment on the same host was setup using a parent cgroup with > two child cgroups. The same swap and memory max were used as the previous > experiment. In the two child cgroups, kernel builds were done in parallel, > each using "-j 20". The program from the previous experiment was used to > perform 1M reads of the parent cpu.stat file. The perf comparison showed > similar results as the previous experiment. For the control side, a > majority of cycles (42%) on mem_cgroup_css_rstat_flush() and significant > cycles in __blkcg_rstat_flush(). On the experimental side, most cycles were > spent on cgroup_base_stat_flush() and no cycles were spent flushing memory > or io. As for the time taken by the program reading cpu.stat, measurements > are shown below. > > before: > real 0m17.223s > user 0m0.259s > sys 0m16.871s > > after: > real 0m6.498s > user 0m0.237s > sys 0m6.220s > > For the final experiment, perf events were recorded during a kernel build > with the same host and cgroup setup. The builds took place in the child > node. Control and experimental sides both showed similar in cycles spent > on cgroup_rstat_updated() and appeard insignificant compared among the > events recorded with the workload. One of the reasons why the original design used one rstat tree is because readers, in addition to writers, can often be correlated too - e.g. You'd often have periodic monitoring tools which poll all the major stat files periodically. Splitting the trees will likely make those at least a bit worse. Can you test how much worse that'd be? ie. Repeat the above tests but read all the major stat files - cgroup.stat, cpu.stat, memory.stat and io.stat. Thanks. -- tejun