From 0adc5bfd84939d11d3c172eab0a00bfab4aadb46 Mon Sep 17 00:00:00 2001 From: Arjan van de Ven Date: Fri, 28 Aug 2015 11:00:36 -0500 Subject: [PATCH 107/114] cgroup Author: Arjan van de Ven Signed-off-by: Miguel Bernal Marin Signed-off-by: Jose Carlos Venegas Munoz --- include/linux/cgroup-defs.h | 2 +- kernel/cgroup.c | 24 ++++++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h index 861b4677fc5b..5d3c345ee60c 100644 --- a/include/linux/cgroup-defs.h +++ b/include/linux/cgroup-defs.h @@ -137,7 +137,7 @@ struct cgroup_subsys_state { /* percpu_ref killing and RCU release */ struct rcu_head rcu_head; - struct work_struct destroy_work; + struct delayed_work destroy_work; }; /* diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 53bbca7c4859..6de39d8213ed 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c @@ -73,7 +73,7 @@ * Expiring in the middle is a performance problem not a correctness one. * 1 sec should be enough. */ -#define CGROUP_PIDLIST_DESTROY_DELAY HZ +#define CGROUP_PIDLIST_DESTROY_DELAY round_jiffies_relative(HZ) #define CGROUP_FILE_NAME_MAX (MAX_CGROUP_TYPE_NAMELEN + \ MAX_CFTYPE_NAME + 2) @@ -4986,8 +4986,9 @@ static struct cftype cgroup_legacy_base_files[] = { */ static void css_free_work_fn(struct work_struct *work) { + struct delayed_work *dwork = to_delayed_work(work); struct cgroup_subsys_state *css = - container_of(work, struct cgroup_subsys_state, destroy_work); + container_of(dwork, struct cgroup_subsys_state, destroy_work); struct cgroup_subsys *ss = css->ss; struct cgroup *cgrp = css->cgroup; @@ -5036,14 +5037,15 @@ static void css_free_rcu_fn(struct rcu_head *rcu_head) struct cgroup_subsys_state *css = container_of(rcu_head, struct cgroup_subsys_state, rcu_head); - INIT_WORK(&css->destroy_work, css_free_work_fn); - queue_work(cgroup_destroy_wq, &css->destroy_work); + INIT_DELAYED_WORK(&css->destroy_work, css_free_work_fn); + queue_delayed_work(cgroup_destroy_wq, &css->destroy_work, CGROUP_PIDLIST_DESTROY_DELAY); } static void css_release_work_fn(struct work_struct *work) { + struct delayed_work *dwork = to_delayed_work(work); struct cgroup_subsys_state *css = - container_of(work, struct cgroup_subsys_state, destroy_work); + container_of(dwork, struct cgroup_subsys_state, destroy_work); struct cgroup_subsys *ss = css->ss; struct cgroup *cgrp = css->cgroup; @@ -5088,8 +5090,9 @@ static void css_release(struct percpu_ref *ref) struct cgroup_subsys_state *css = container_of(ref, struct cgroup_subsys_state, refcnt); - INIT_WORK(&css->destroy_work, css_release_work_fn); - queue_work(cgroup_destroy_wq, &css->destroy_work); + INIT_DELAYED_WORK(&css->destroy_work, css_release_work_fn); + queue_delayed_work(cgroup_destroy_wq, &css->destroy_work, CGROUP_PIDLIST_DESTROY_DELAY); + } static void init_and_link_css(struct cgroup_subsys_state *css, @@ -5371,8 +5374,9 @@ static int cgroup_mkdir(struct kernfs_node *parent_kn, const char *name, */ static void css_killed_work_fn(struct work_struct *work) { + struct delayed_work *dwork = to_delayed_work(work); struct cgroup_subsys_state *css = - container_of(work, struct cgroup_subsys_state, destroy_work); + container_of(dwork, struct cgroup_subsys_state, destroy_work); mutex_lock(&cgroup_mutex); @@ -5393,8 +5397,8 @@ static void css_killed_ref_fn(struct percpu_ref *ref) container_of(ref, struct cgroup_subsys_state, refcnt); if (atomic_dec_and_test(&css->online_cnt)) { - INIT_WORK(&css->destroy_work, css_killed_work_fn); - queue_work(cgroup_destroy_wq, &css->destroy_work); + INIT_DELAYED_WORK(&css->destroy_work, css_killed_work_fn); + queue_delayed_work(cgroup_destroy_wq, &css->destroy_work, CGROUP_PIDLIST_DESTROY_DELAY); } } -- 2.11.1