未验证 提交 de04fb11 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!1411 [sync] PR-1408: Replace the hulk patch with the lts patch

Merge Pull Request from: @openeuler-sync-bot 
 

Origin pull request: 
https://gitee.com/openeuler/kernel/pulls/1408 
 
PR sync from: Gaosheng Cui <cuigaosheng1@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/KDI6HM6ETZD4MQLPN2PXX7TI3XO7ZJC5/ 
Replace the hulk patch with the lts patch, thanks!

Gaosheng Cui (1):
  Revert "cgroup: Stop task iteration when rebinding subsystem"

Xiu Jianfeng (1):
  cgroup: Do not corrupt task iteration when rebinding subsystem


-- 
2.30.0
 
https://gitee.com/openeuler/kernel/issues/I7AZ85 
 
Link:https://gitee.com/openeuler/kernel/pulls/1411 

Reviewed-by: Jialin Zhang <zhangjialin11@huawei.com> 
Signed-off-by: Jialin Zhang <zhangjialin11@huawei.com> 
...@@ -47,7 +47,6 @@ struct kernel_clone_args; ...@@ -47,7 +47,6 @@ struct kernel_clone_args;
/* internal flags */ /* internal flags */
#define CSS_TASK_ITER_SKIPPED (1U << 16) #define CSS_TASK_ITER_SKIPPED (1U << 16)
#define CSS_TASK_ITER_STOPPED (1U << 17)
/* a css_task_iter should be treated as an opaque object */ /* a css_task_iter should be treated as an opaque object */
struct css_task_iter { struct css_task_iter {
......
...@@ -214,8 +214,6 @@ static int cgroup_apply_control(struct cgroup *cgrp); ...@@ -214,8 +214,6 @@ static int cgroup_apply_control(struct cgroup *cgrp);
static void cgroup_finalize_control(struct cgroup *cgrp, int ret); static void cgroup_finalize_control(struct cgroup *cgrp, int ret);
static void css_task_iter_skip(struct css_task_iter *it, static void css_task_iter_skip(struct css_task_iter *it,
struct task_struct *task); struct task_struct *task);
static void css_task_iter_stop(struct css_task_iter *it,
struct cgroup_subsys *ss);
static int cgroup_destroy_locked(struct cgroup *cgrp); static int cgroup_destroy_locked(struct cgroup *cgrp);
static struct cgroup_subsys_state *css_create(struct cgroup *cgrp, static struct cgroup_subsys_state *css_create(struct cgroup *cgrp,
struct cgroup_subsys *ss); struct cgroup_subsys *ss);
...@@ -856,19 +854,6 @@ static void css_set_skip_task_iters(struct css_set *cset, ...@@ -856,19 +854,6 @@ static void css_set_skip_task_iters(struct css_set *cset,
css_task_iter_skip(it, task); css_task_iter_skip(it, task);
} }
/*
* @cset is moving to other list, it's not safe to continue the iteration,
* because the cset_head of css_task_iter which is from the old list can
* not be used as the stop condition of iteration.
*/
static void css_set_stop_iters(struct css_set *cset, struct cgroup_subsys *ss)
{
struct css_task_iter *it, *pos;
list_for_each_entry_safe(it, pos, &cset->task_iters, iters_node)
css_task_iter_stop(it, ss);
}
/** /**
* css_set_move_task - move a task from one css_set to another * css_set_move_task - move a task from one css_set to another
* @task: task being moved * @task: task being moved
...@@ -1727,7 +1712,7 @@ int rebind_subsystems(struct cgroup_root *dst_root, u16 ss_mask) ...@@ -1727,7 +1712,7 @@ int rebind_subsystems(struct cgroup_root *dst_root, u16 ss_mask)
{ {
struct cgroup *dcgrp = &dst_root->cgrp; struct cgroup *dcgrp = &dst_root->cgrp;
struct cgroup_subsys *ss; struct cgroup_subsys *ss;
int ssid, i, ret; int ssid, ret;
u16 dfl_disable_ss_mask = 0; u16 dfl_disable_ss_mask = 0;
lockdep_assert_held(&cgroup_mutex); lockdep_assert_held(&cgroup_mutex);
...@@ -1771,7 +1756,8 @@ int rebind_subsystems(struct cgroup_root *dst_root, u16 ss_mask) ...@@ -1771,7 +1756,8 @@ int rebind_subsystems(struct cgroup_root *dst_root, u16 ss_mask)
struct cgroup_root *src_root = ss->root; struct cgroup_root *src_root = ss->root;
struct cgroup *scgrp = &src_root->cgrp; struct cgroup *scgrp = &src_root->cgrp;
struct cgroup_subsys_state *css = cgroup_css(scgrp, ss); struct cgroup_subsys_state *css = cgroup_css(scgrp, ss);
struct css_set *cset; struct css_set *cset, *cset_pos;
struct css_task_iter *it;
WARN_ON(!css || cgroup_css(dcgrp, ss)); WARN_ON(!css || cgroup_css(dcgrp, ss));
...@@ -1789,10 +1775,21 @@ int rebind_subsystems(struct cgroup_root *dst_root, u16 ss_mask) ...@@ -1789,10 +1775,21 @@ int rebind_subsystems(struct cgroup_root *dst_root, u16 ss_mask)
css->cgroup = dcgrp; css->cgroup = dcgrp;
spin_lock_irq(&css_set_lock); spin_lock_irq(&css_set_lock);
hash_for_each(css_set_table, i, cset, hlist) { WARN_ON(!list_empty(&dcgrp->e_csets[ss->id]));
css_set_stop_iters(cset, ss); list_for_each_entry_safe(cset, cset_pos, &scgrp->e_csets[ss->id],
e_cset_node[ss->id]) {
list_move_tail(&cset->e_cset_node[ss->id], list_move_tail(&cset->e_cset_node[ss->id],
&dcgrp->e_csets[ss->id]); &dcgrp->e_csets[ss->id]);
/*
* all css_sets of scgrp together in same order to dcgrp,
* patch in-flight iterators to preserve correct iteration.
* since the iterator is always advanced right away and
* finished when it->cset_pos meets it->cset_head, so only
* update it->cset_head is enough here.
*/
list_for_each_entry(it, &cset->task_iters, iters_node)
if (it->cset_head == &scgrp->e_csets[ss->id])
it->cset_head = &dcgrp->e_csets[ss->id];
} }
spin_unlock_irq(&css_set_lock); spin_unlock_irq(&css_set_lock);
...@@ -4681,16 +4678,6 @@ static void css_task_iter_skip(struct css_task_iter *it, ...@@ -4681,16 +4678,6 @@ static void css_task_iter_skip(struct css_task_iter *it,
} }
} }
static void css_task_iter_stop(struct css_task_iter *it,
struct cgroup_subsys *ss)
{
lockdep_assert_held(&css_set_lock);
if (it->ss == ss) {
it->flags |= CSS_TASK_ITER_STOPPED;
}
}
static void css_task_iter_advance(struct css_task_iter *it) static void css_task_iter_advance(struct css_task_iter *it)
{ {
struct task_struct *task; struct task_struct *task;
...@@ -4794,11 +4781,6 @@ struct task_struct *css_task_iter_next(struct css_task_iter *it) ...@@ -4794,11 +4781,6 @@ struct task_struct *css_task_iter_next(struct css_task_iter *it)
spin_lock_irq(&css_set_lock); spin_lock_irq(&css_set_lock);
if (it->flags & CSS_TASK_ITER_STOPPED) {
spin_unlock_irq(&css_set_lock);
return NULL;
}
/* @it may be half-advanced by skips, finish advancing */ /* @it may be half-advanced by skips, finish advancing */
if (it->flags & CSS_TASK_ITER_SKIPPED) if (it->flags & CSS_TASK_ITER_SKIPPED)
css_task_iter_advance(it); css_task_iter_advance(it);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册