// SPDX-License-Identifier: GPL-2.0-only#include"cgroup-internal.h"#include<linux/ctype.h>#include<linux/kmod.h>#include<linux/sort.h>#include<linux/delay.h>#include<linux/mm.h>#include<linux/sched/signal.h>#include<linux/sched/task.h>#include<linux/magic.h>#include<linux/slab.h>#include<linux/string.h>#include<linux/vmalloc.h>#include<linux/delayacct.h>#include<linux/pid_namespace.h>#include<linux/cgroupstats.h>#include<linux/fs_parser.h>#include<trace/events/cgroup.h>/* * pidlists linger the following amount before being destroyed. The goal * is avoiding frequent destruction in the middle of consecutive read calls * Expiring in the middle is a performance problem not a correctness one. * 1 sec should be enough. */#define CGROUP_PIDLIST_DESTROY_DELAY HZ/* Controllers blocked by the commandline in v1 */staticu16cgroup_no_v1_mask;/* disable named v1 mounts */staticboolcgroup_no_v1_named;/* Show unavailable controllers in /proc/cgroups */staticboolproc_show_all;/* * pidlist destructions need to be flushed on cgroup destruction. Use a * separate workqueue as flush domain. */staticstructworkqueue_struct*cgroup_pidlist_destroy_wq;/* protects cgroup_subsys->release_agent_path */staticDEFINE_SPINLOCK(release_agent_path_lock);boolcgroup1_ssid_disabled(intssid){returncgroup_no_v1_mask&(1<<ssid);}staticboolcgroup1_subsys_absent(structcgroup_subsys*ss){/* Check also dfl_cftypes for file-less controllers, i.e. perf_event */returnss->legacy_cftypes==NULL&&ss->dfl_cftypes;}/** * cgroup_attach_task_all - attach task 'tsk' to all cgroups of task 'from' * @from: attach to all cgroups of a given task * @tsk: the task to be attached * * Return: %0 on success or a negative errno code on failure */intcgroup_attach_task_all(structtask_struct*from,structtask_struct*tsk){structcgroup_root*root;intretval=0;cgroup_lock();cgroup_attach_lock(CGRP_ATTACH_LOCK_GLOBAL,NULL);for_each_root(root){structcgroup*from_cgrp;spin_lock_irq(&css_set_lock);from_cgrp=task_cgroup_from_root(from,