From: Tejun Heo <tj@kernel.org>
To: Natalie Vock <natalie.vock@gmx.de>
Cc: Maarten Lankhorst <dev@lankhorst.se>,
Maxime Ripard <mripard@kernel.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Koutny <mkoutny@suse.com>,
Christian Koenig <christian.koenig@amd.com>,
Huang Rui <ray.huang@amd.com>,
Matthew Auld <matthew.auld@intel.com>,
Matthew Brost <matthew.brost@intel.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
Tvrtko Ursulin <tursulin@ursulin.net>,
cgroups@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v4 2/6] cgroup/dmem: Add dmem_cgroup_common_ancestor helper
Date: Wed, 25 Feb 2026 07:16:00 -1000 [thread overview]
Message-ID: <a9027a23743a2ec1511d8555ce3ef382@kernel.org> (raw)
In-Reply-To: <20260225-dmemcg-aggressive-protect-v4-2-de847ab35184@gmx.de>
Each cgroup already knows all its ancestors in cgrp->ancestors[] along with
its depth in cgrp->level (see cgroup_is_descendant() and cgroup_ancestor()).
This can be used to implement a generic cgroup_common_ancestor() a lot more
efficiently. Something like:
static inline struct cgroup *cgroup_common_ancestor(struct cgroup *a,
struct cgroup *b)
{
int level;
for (level = min(a->level, b->level); level >= 0; level--)
if (a->ancestors[level] == b->ancestors[level])
return a->ancestors[level];
return NULL;
}
This is O(depth) instead of O(n*m). Can you add a helper like the above in
include/linux/cgroup.h and use it here?
Thanks.
--
tejun
next prev parent reply other threads:[~2026-02-25 17:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-25 12:10 [PATCH v4 0/6] cgroup/dmem,drm/ttm: Improve protection in contended cases Natalie Vock
2026-02-25 12:10 ` [PATCH v4 1/6] cgroup/dmem: Add queries for protection values Natalie Vock
2026-02-25 12:10 ` [PATCH v4 2/6] cgroup/dmem: Add dmem_cgroup_common_ancestor helper Natalie Vock
2026-02-25 17:16 ` Tejun Heo [this message]
2026-02-25 12:10 ` [PATCH v4 3/6] drm/ttm: Extract code for attempting allocation in a place Natalie Vock
2026-02-25 15:18 ` Tvrtko Ursulin
2026-02-25 15:27 ` Tvrtko Ursulin
2026-02-26 8:56 ` Tvrtko Ursulin
2026-02-25 12:10 ` [PATCH v4 4/6] drm/ttm: Split cgroup charge and resource allocation Natalie Vock
2026-02-25 15:33 ` Tvrtko Ursulin
2026-02-25 16:01 ` Tvrtko Ursulin
2026-02-25 12:10 ` [PATCH v4 5/6] drm/ttm: Be more aggressive when allocating below protection limit Natalie Vock
2026-02-25 12:10 ` [PATCH v4 6/6] drm/ttm: Use common ancestor of evictor and evictee as limit pool Natalie Vock
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=a9027a23743a2ec1511d8555ce3ef382@kernel.org \
--to=tj@kernel.org \
--cc=airlied@gmail.com \
--cc=cgroups@vger.kernel.org \
--cc=christian.koenig@amd.com \
--cc=dev@lankhorst.se \
--cc=dri-devel@lists.freedesktop.org \
--cc=hannes@cmpxchg.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=matthew.auld@intel.com \
--cc=matthew.brost@intel.com \
--cc=mkoutny@suse.com \
--cc=mripard@kernel.org \
--cc=natalie.vock@gmx.de \
--cc=ray.huang@amd.com \
--cc=simona@ffwll.ch \
--cc=tursulin@ursulin.net \
--cc=tzimmermann@suse.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.