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 v4 2/3] cgroup/rstat: Optimize cgroup_rstat_updated_list()
Date: Tue, 28 Nov 2023 06:43:38 -1000 [thread overview]
Message-ID: <ZWYYrJVMUOrl9r2g@slm.duckdns.org> (raw)
In-Reply-To: <a9aa2809-95f5-4f60-b936-0d857c971fea@redhat.com>
On Mon, Nov 27, 2023 at 11:01:22PM -0500, Waiman Long wrote:
...
> > + * Recursively traverse down the cgroup_rstat_cpu updated tree and push
> > + * parent first before its children into a singly linked list built from
> > + * the tail backward like "pushing" cgroups into a stack. The parent is
> > + * pushed by the caller. The recursion depth is the depth of the current
> > + * updated subtree.
> > + */
> > +static struct cgroup *cgroup_rstat_push_children(struct cgroup *head,
> > + struct cgroup_rstat_cpu *prstatc, int cpu)
> > +{
> > + struct cgroup *child, *parent;
> > + struct cgroup_rstat_cpu *crstatc;
> > +
> > + parent = head;
> > + child = prstatc->updated_children;
> > + prstatc->updated_children = parent;
> > +
> > + /* updated_next is parent cgroup terminated */
> > + while (child != parent) {
> > + child->rstat_flush_next = head;
> > + head = child;
> > + crstatc = cgroup_rstat_cpu(child, cpu);
> > + if (crstatc->updated_children != child)
> > + head = cgroup_rstat_push_children(head, crstatc, cpu);
> > + child = crstatc->updated_next;
> > + crstatc->updated_next = NULL;
> > + }
> > + return head;
The recursion bothers me. We don't really have a hard limit on nesting
depth. We might need to add another pointer field but can make this
iterative, right?
Thanks.
--
tejun
next prev parent reply other threads:[~2023-11-28 16:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-06 21:05 [PATCH v4 0/3] cgroup/rstat: Reduce cpu_lock hold time in cgroup_rstat_flush_locked() Waiman Long
2023-11-06 21:05 ` [PATCH v4 1/3] " Waiman Long
2023-11-06 21:05 ` [PATCH v4 2/3] cgroup/rstat: Optimize cgroup_rstat_updated_list() Waiman Long
2023-11-28 4:01 ` Waiman Long
2023-11-28 16:43 ` Tejun Heo [this message]
2023-11-28 16:46 ` Waiman Long
2023-11-06 21:05 ` [PATCH v4 3/3] cgroup: Avoid false cacheline sharing of read mostly rstat_cpu Waiman Long
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=ZWYYrJVMUOrl9r2g@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
all inboxes | Powered by JetHome®