All of lore.kernel.org
 help / color / mirror / Atom feed
* Question on damon_sysfs_memcg_path_to_id() path resolution
@ 2026-07-15  6:35 Song Hu
  2026-07-15 13:51 ` SJ Park
  0 siblings, 1 reply; 2+ messages in thread
From: Song Hu @ 2026-07-15  6:35 UTC (permalink / raw)
  To: sj; +Cc: damon, Song Hu

Hi SeongJae,

I've been reading the memcg path->id resolution used by DAMOS filters
and quota goals, and I'd like to ask about a design choice before
suggesting any change.

damon_sysfs_memcg_path_to_id() (mm/damon/sysfs-common.c) resolves the
user-written cgroup path by iterating all memcgs with
mem_cgroup_iter() and comparing each one's cgroup_path() to the
target.  It could instead call cgroup_get_from_path() directly, but
the two don't resolve the path the same way:

  - current code: cgroup_path(memcg->css.cgroup) is just kernfs_path(),
    i.e. the absolute path in the cgroup hierarchy, independent of the
    caller's cgroup namespace;

  - cgroup_get_from_path(): resolves the path against
    current_cgns_cgroup_dfl(), i.e. relative to the caller's cgroup
    namespace.

So in a cgroup-namespaced (container) setup the two disagree: today
the lookup is absolute; switching to cgroup_get_from_path() would make
it namespace-relative.  On the host / init namespace they agree.

I ask because the iteration has already needed one stable fix
(d4e7b5c4cc35, a missing mem_cgroup_iter_break() that leaked a cgroup
reference), and cgroup_get_from_path() is a matched get/put pair that
would avoid that whole class of mistake -- but only if the namespace
behavior change is acceptable.

Is the absolute-path behavior intentional?  If namespace-relative
resolution is fine, I'm happy to send a patch (keeping the
mem_cgroup_online() skip).  If not, I'll leave it as is.

Thanks,
Song

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-15 13:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-15  6:35 Question on damon_sysfs_memcg_path_to_id() path resolution Song Hu
2026-07-15 13:51 ` SJ Park

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.