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 A289FC36002 for ; Thu, 20 Mar 2025 21:31:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D9988280002; Thu, 20 Mar 2025 17:31:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D2109280001; Thu, 20 Mar 2025 17:31:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BC274280002; Thu, 20 Mar 2025 17:31:21 -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 99BA9280001 for ; Thu, 20 Mar 2025 17:31:21 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 8F8E11A190B for ; Thu, 20 Mar 2025 21:31:22 +0000 (UTC) X-FDA: 83243225604.04.5C03226 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf16.hostedemail.com (Postfix) with ESMTP id 9D84B18000E for ; Thu, 20 Mar 2025 21:31:19 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=I2ZfbHR6; spf=pass (imf16.hostedemail.com: domain of tj@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=tj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1742506279; 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=ak3bZWgYjZ3/1AgFov61bF6NRGF5q2qICytz+Bit2CE=; b=ya9jjPNVqFtRV7fGawYSHp+76V9oN0m4Ro4PBoGYdcPHwnBwowi48CFNrbDnyz3b8S7NDU 6onPSUJZcJBgLVhYtW+rfZQFnb+ooR9jsEohTkqDIoQZWfEjGM0/M3Huxst0KRI5pDa3H9 HIPs/VfkQ7M1nEGEqU0UVoZ4oOwAL74= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=I2ZfbHR6; spf=pass (imf16.hostedemail.com: domain of tj@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=tj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1742506279; a=rsa-sha256; cv=none; b=e3PqmUlSjgXnAJgFADBxew983y8Jw2++UQzK8L9iK5VLlF9JXay//Ia0HHDbr2TXRT5juB Db3H5FcW3hpBWkf0iMJ5yu6m7iMLuraBc2gkRGZMGyngFj70kaadaZcINr27TDgwU1s/8S x6qUaZMhmqvnGyg4hO7JGBBLwuC/VoM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 50935A495A7; Thu, 20 Mar 2025 21:25:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40BD7C4CEE3; Thu, 20 Mar 2025 21:31:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1742506278; bh=TPM4zkiUpof4BVgPmG5PxOWmeP2hLPon50K+AdUyKpM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=I2ZfbHR6u0WcrJcn82rbUZPK5etGLQrXd5aVw1M+gVKDoVZeClexxLOpy3xlDv/XS 0NSnByR4yqWQ1pQHjaLF75EjAzAYfD8KsjT6F8YVr9juacmjrYLU6yEBT8ohhMJ6gC /bij1Ifg/agzKTyY06sN3ZvaFFtiryQi9FSd8bqBradr5V84nrMsIowmpNi3fD5RQs wYPptFmYg255U0eOM6ybVafxEjHPdn2+1+OPYft9JpqT9V+MSQZd2NKxngh7Q6isWy 8fma4kQIQgnKGOSXEiUvwr2igRwxj5nYd9TQHHhKMySr6tC3RXqnqdMLx5ujCHVTtO X/hUk03zZUE0g== Date: Thu, 20 Mar 2025 11:31:17 -1000 From: Tejun Heo To: JP Kobryn Cc: shakeel.butt@linux.dev, yosryahmed@google.com, mkoutny@suse.com, hannes@cmpxchg.org, akpm@linux-foundation.org, linux-mm@kvack.org, cgroups@vger.kernel.org, kernel-team@meta.com Subject: Re: [PATCH 2/4 v3] cgroup: use separate rstat trees for each subsystem Message-ID: References: <20250319222150.71813-1-inwardvessel@gmail.com> <20250319222150.71813-3-inwardvessel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250319222150.71813-3-inwardvessel@gmail.com> X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 9D84B18000E X-Stat-Signature: b7h4kc6xn4734mgts46wji576sna96k6 X-HE-Tag: 1742506279-321373 X-HE-Meta: U2FsdGVkX19gjt3mViT+/AuIpI8zrjm+35RZUq55xvHcwkrXTcAgTdhZGrVcmVWzibFoe1wrUfqqGd+2WAfvNJm7qCR2JHsy36OiF9q7z/o1I+zUzswO3/CYvFUOGhnI+qQb+h3/+gGDv3YGGTB9rfAkQvvShvALhrG7B20JLyiqQe83Re5RdVD3JNQ2FQSGu2cbLsJqSglFDDGLtiDhD6iL3uaAOzC2DKo7JXImNMReKxyaNrS7gpw7sI9Vej/OWt8dn+SkGAXsarKzjMAN+Mux3mq4pftmlWbhQSdlTYXtrX5xd56fe/Kgbj4p5JDM/j3nn7gk9efx+jXT81REZnnKaPhFARitgc/oZ5r7XndyoqytMQbibKIWSc4WM8IjomfzUAJQxkvB2GafpBw/Ab7C8K5NJAywkZfoVK0uF4SGxQVtt1UhnjTqzqwunwjs1ushLXKILqktCL4lqN+Z94oTdt2KU3LHlPpH9K3cbTO4qIhY+luhOXuuLB0ZdH7dkX4d5hUURl+dmPBtHr332uYhkH9v+7BWfFZo3SG1tk9Y4UFYz+nIVbWcqiSV/as5GaNyP+y9CO1IFQ1ymTjO/DAHwe7Vom5DDTwL/iC1XONy9pi7qTdiSQW/uSwFsMN3y+JGk9YLvNgH+ZPJIv5YzFyBREq3+uuIvH55klfQF3uPIS9zJ8Nw7tQVVUsBNMiAO2LFt226xYCbM4ye+aQ7gjIBp7tUBUx7bch8lKa3SRon8zV5wZP03VTkUjZCxqrSbzT80uoQKwCAqXLPlNkjDhbS46tLT85vDA1mhN1HzE2bn8J6b41SseHGSlW0uT5c+V3KrbYasfrCEkj0oiPM9fKf78aAwKiWqP8KxFmVvTONtOhjNezZ9Rz+rTJ72Y42IhTMzm2W5fAHs97TgjVmOm/LcgsWZRa8j0YbXxg22klThuBSTuv05ygtAeaXXS6eSeLEtm6S9cACTyzHtOT GckaOXKb 9NlEbQOczU1BsicZ9LxKGw+FIoc9NHOce5eSuI+CFMVZ9mFXyVT0LYO5c4dvAaVnXyVc2wmjhXs1zUVpWDMQ4Psf3Xg87lb5BPwwoWlantdhZJBlHVq0YKn20CwhruI++skxNbMu/FL9CesrfbT9A4rmWTg52CQcOQvPyGliRFtrEs1VEGLXmm6L3PGiUPv65245mF6zB/hUSvHx1XZwiONdrFw== 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 Wed, Mar 19, 2025 at 03:21:48PM -0700, JP Kobryn wrote: > Different subsystems may call cgroup_rstat_updated() within the same > cgroup, resulting in a tree of pending updates from multiple subsystems. > When one of these subsystems is flushed via cgroup_rstat_flushed(), all > other subsystems with pending updates on the tree will also be flushed. > > Change the paradigm of having a single rstat tree for all subsystems to > having separate trees for each subsystem. This separation allows for > subsystems to perform flushes without the side effects of other subsystems. > As an example, flushing the cpu stats will no longer cause the memory stats > to be flushed and vice versa. > > In order to achieve subsystem-specific trees, change the tree node type > from cgroup to cgroup_subsys_state pointer. Then remove those pointers from > the cgroup and instead place them on the css. Finally, change the > updated/flush API's to accept a reference to a css instead of a cgroup. > This allows a specific subsystem to be associated with an update or flush. > Separate rstat trees will now exist for each unique subsystem. > > Since updating/flushing will now be done at the subsystem level, there is > no longer a need to keep track of updated css nodes at the cgroup level. > The list management of these nodes done within the cgroup (rstat_css_list > and related) has been removed accordingly. There was also padding in the > cgroup to keep rstat_css_list on a cacheline different from > rstat_flush_next and the base stats. This padding has also been removed. Overall, this looks okay but I think the patch should be split further. There's too much cgroup -> css renames mixed with actual changes which makes it difficult to understand what the actual changes are. Can you please separate it into a patch which makes everything css based but the actual queueing and flushing is still only on the cgroup css and then the next patch to actually split out linking and flushing to each css? > diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h > index 13fd82a4336d..4e71ae9858d3 100644 > --- a/include/linux/cgroup.h > +++ b/include/linux/cgroup.h > @@ -346,6 +346,11 @@ static inline bool css_is_dying(struct cgroup_subsys_state *css) > return !(css->flags & CSS_NO_REF) && percpu_ref_is_dying(&css->refcnt); > } > > +static inline bool css_is_cgroup(struct cgroup_subsys_state *css) > +{ > + return css->ss == NULL; > +} Maybe introduce this in a prep patch and replace existing users? ... > @@ -6082,11 +6077,16 @@ static void __init cgroup_init_subsys(struct cgroup_subsys *ss, bool early) > css->flags |= CSS_NO_REF; > > if (early) { > - /* allocation can't be done safely during early init */ > + /* allocation can't be done safely during early init. > + * defer idr and rstat allocations until cgroup_init(). > + */ Nit: Please use fully winged comment blocks for multilines with captalizations. Thanks. -- tejun