On Fri, 05 Jan 2024 03:45:02 -0600, Michal Koutný <mkoutny@xxxxxxxx> wrote:
On Mon, Oct 30, 2023 at 11:20:02AM -0700, Haitao Huang
<haitao.huang@xxxxxxxxxxxxxxx> wrote:
From: Kristen Carlson Accardi <kristen@xxxxxxxxxxxxxxx>
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
Sure I can do that. IIUC, you are suggesting something similar how
capacity is set via misc_cg_set_capacity for each resource type. Here we
make a misc_cg_set_ops() which stores the ops pointers in a static array,
then use them indexed with the resource type.
Thanks
Haitao