Unverified Commit d9b08051 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!3537 backport cgroup bugs from olk5.10

Merge Pull Request from: @chenridong 
 
backport cgroup bugs from olk5.10
related issue: 
https://gitee.com/openeuler/kernel/issues/I8QLND 
 
Link:https://gitee.com/openeuler/kernel/pulls/3537

 

Reviewed-by: default avatarLu Jialin <lujialin4@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parents 980dd57a 4a57426e
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -320,9 +320,9 @@ the amount of kernel memory used by the system. Kernel memory is fundamentally
different than user memory, since it can't be swapped out, which makes it
possible to DoS the system by consuming too much of this precious resource.

Kernel memory accounting is enabled for all memory cgroups by default. But
it can be disabled system-wide by passing cgroup.memory=nokmem to the kernel
at boot time. In this case, kernel memory will not be accounted at all.
Kernel memory accounting is disabled for all memory cgroups by default. But
it can be enabled system-wide by passing cgroup.memory=kmem to the kernel
at boot time. In this case, kernel memory will all be accounted.

Kernel memory limits are not imposed for the root cgroup. Usage for the root
cgroup may or may not be accounted. The memory used is accumulated into
+1 −0
Original line number Diff line number Diff line
@@ -584,6 +584,7 @@
			Format: <string>
			nosocket -- Disable socket memory accounting.
			nokmem -- Disable kernel memory accounting.
			kmem -- Enable kernel memory accounting.
			nobpf -- Disable BPF memory accounting.

	checkreqprot=	[SELINUX] Set initial checkreqprot flag value.
+3 −0
Original line number Diff line number Diff line
@@ -556,6 +556,9 @@ struct cgroup_root {
	/* Number of cgroups in the hierarchy, used only for /proc/cgroups */
	atomic_t nr_cgrps;

	/* Wait while cgroups are being destroyed */
	wait_queue_head_t wait;

	/* A list running through the active hierarchies */
	struct list_head root_list;

+6 −3
Original line number Diff line number Diff line
@@ -675,6 +675,7 @@ int proc_cgroupstats_show(struct seq_file *m, void *v)
{
	struct cgroup_subsys *ss;
	int i;
	bool dead;

	seq_puts(m, "#subsys_name\thierarchy\tnum_cgroups\tenabled\n");
	/*
@@ -682,11 +683,13 @@ int proc_cgroupstats_show(struct seq_file *m, void *v)
	 * cgroup_mutex contention.
	 */

	for_each_subsys(ss, i)
	for_each_subsys(ss, i) {
		dead = percpu_ref_is_dying(&ss->root->cgrp.self.refcnt);
		seq_printf(m, "%s\t%d\t%d\t%d\n",
			   ss->legacy_name, ss->root->hierarchy_id,
			   atomic_read(&ss->root->nr_cgrps),
			   ss->legacy_name, dead ? 0 : ss->root->hierarchy_id,
			   dead ? 0 : atomic_read(&ss->root->nr_cgrps),
			   cgroup_ssid_enabled(i));
	}

	return 0;
}
+21 −2
Original line number Diff line number Diff line
@@ -2018,6 +2018,7 @@ void init_cgroup_root(struct cgroup_fs_context *ctx)
	atomic_set(&root->nr_cgrps, 1);
	cgrp->root = root;
	init_cgroup_housekeeping(cgrp);
	init_waitqueue_head(&root->wait);

	/* DYNMODS must be modified through cgroup_favor_dynmods() */
	root->flags = ctx->flags & ~CGRP_ROOT_FAVOR_DYNMODS;
@@ -2254,6 +2255,17 @@ static void cgroup_kill_sb(struct super_block *sb)
	struct kernfs_root *kf_root = kernfs_root_from_sb(sb);
	struct cgroup_root *root = cgroup_root_from_kf(kf_root);

	/*
	* Wait if there are cgroups being destroyed, because the destruction
	* is asynchronous. On the other hand some controllers like memcg
	* may pin cgroups for a very long time, so don't wait forever.
	*/
	if (root != &cgrp_dfl_root) {
		wait_event_timeout(root->wait,
				   list_empty(&root->cgrp.self.children),
				   msecs_to_jiffies(500));
	}

	/*
	 * If @root doesn't have any children, start killing it.
	 * This prevents new mounts by disabling percpu_ref_tryget_live().
@@ -2806,6 +2818,7 @@ int cgroup_migrate(struct task_struct *leader, bool threadgroup,
		   struct cgroup_mgctx *mgctx)
{
	struct task_struct *task;
	int err = 0;

	/*
	 * The following thread iteration should be inside an RCU critical
@@ -2816,12 +2829,15 @@ int cgroup_migrate(struct task_struct *leader, bool threadgroup,
	task = leader;
	do {
		cgroup_migrate_add_task(task, mgctx);
		if (!threadgroup)
		if (!threadgroup) {
			if (task->flags & PF_EXITING)
				err = -ESRCH;
			break;
		}
	} while_each_thread(leader, task);
	spin_unlock_irq(&css_set_lock);

	return cgroup_migrate_execute(mgctx);
	return err ? err : cgroup_migrate_execute(mgctx);
}

/**
@@ -5445,6 +5461,9 @@ static void css_release_work_fn(struct work_struct *work)
		if (cgrp->kn)
			RCU_INIT_POINTER(*(void __rcu __force **)&cgrp->kn->priv,
					 NULL);
		if (css->parent && !css->parent->parent &&
		    list_empty(&css->parent->children))
			wake_up(&cgrp->root->wait);
	}

	cgroup_unlock();
Loading