Re: [PATCH v6 01/12] cgroup/misc: Add per resource callbacks for CSS events

Michal Koutný
2024-01-05T09:45:09Z

[-- Attachment #1: Type: text/plain, Size: 1223 bytes --]

On Mon, Oct 30, 2023 at 11:20:02AM -0700, Haitao Huang <haitao.huang@linux.intel.com> wrote:
> From: Kristen Carlson Accardi <kristen@linux.intel.com>
>
> The misc cgroup controller (subsystem) currently does not perform
> resource type specific action for Cgroups Subsystem State (CSS) events:
> the 'css_alloc' event when a cgroup is created and the 'css_free' event
> when a cgroup is destroyed.
>
> Define callbacks for those events and allow resource providers to
> register the callbacks per resource type as needed. This will be
> utilized later by the EPC misc cgroup support implemented in the SGX
> driver.

I notice now that the callbacks are per resource and per cgroup.
I think that is an overkill that complicates misc_cg allocation code
with parent's callbacks while freeing is done by own callbacks.
It's possibly too much liberal to keep objects' lifecycle understandable
in the long term too.

For some uniformity, I'd suggest struct blkcg_policy array in
block/blk-cgroup.c as the precedent. (Perhaps indexed with static enum
misc_res_type instead of dynamic index assignment as
blkcg_policy_registeer() does.)

I hope you don't really need per-cgroup callbacks :-)

Michal

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]