cgroup: refactor hierarchy_id handling