public inbox for cgroups@vger.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Waiman Long <longman@redhat.com>
Cc: Zefan Li <lizefan.x@bytedance.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
	Joe Mario <jmario@redhat.com>, Sebastian Jug <sejug@redhat.com>,
	Yosry Ahmed <yosryahmed@google.com>
Subject: Re: [PATCH-cgroup v5 1/2] cgroup/rstat: Optimize cgroup_rstat_updated_list()
Date: Fri, 1 Dec 2023 07:37:49 -1000	[thread overview]
Message-ID: <ZWoZ7U8f5NNwimej@slm.duckdns.org> (raw)
In-Reply-To: <20231130204327.494249-2-longman@redhat.com>

On Thu, Nov 30, 2023 at 03:43:26PM -0500, Waiman Long wrote:
> The current design of cgroup_rstat_cpu_pop_updated() is to traverse
> the updated tree in a way to pop out the leaf nodes first before
> their parents. This can cause traversal of multiple nodes before a
> leaf node can be found and popped out. IOW, a given node in the tree
> can be visited multiple times before the whole operation is done. So
> it is not very efficient and the code can be hard to read.
> 
> With the introduction of cgroup_rstat_updated_list() to build a list
> of cgroups to be flushed first before any flushing operation is being
> done, we can optimize the way the updated tree nodes are being popped
> by pushing the parents first to the tail end of the list before their
> children. In this way, most updated tree nodes will be visited only
> once with the exception of the subtree root as we still need to go
> back to its parent and popped it out of its updated_children list.
> This also makes the code easier to read.
> 
> Signed-off-by: Waiman Long <longman@redhat.com>

Applied to cgroup/for-6.8 with a small comment edit.

...
> + * Iteratively traverse down the cgroup_rstat_cpu updated tree level by
> + * level and push all the parents first before their next level children
> + * into a singly linked list built from the tail backward like "pushing"
> + * cgroups into a stack. The parent is by the caller.

I found the last sentence a bit difficult to understand and changed it to
"The root is pushed by the caller." That's what you meant, right?

Thanks.

-- 
tejun

  reply	other threads:[~2023-12-01 17:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-30 20:43 [PATCH-cgroup v5 0/2] cgroup/rstat: Further reduce cpu_lock hold time in cgroup_rstat_flush_locked Waiman Long
2023-11-30 20:43 ` [PATCH-cgroup v5 1/2] cgroup/rstat: Optimize cgroup_rstat_updated_list() Waiman Long
2023-12-01 17:37   ` Tejun Heo [this message]
2023-12-01 18:09     ` Waiman Long
2023-11-30 20:43 ` [PATCH-cgroup v5 2/2] cgroup: Avoid false cacheline sharing of read mostly rstat_cpu Waiman Long
2023-12-01 17:38   ` Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZWoZ7U8f5NNwimej@slm.duckdns.org \
    --to=tj@kernel.org \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=jmario@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan.x@bytedance.com \
    --cc=longman@redhat.com \
    --cc=sejug@redhat.com \
    --cc=yosryahmed@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox