diff options
-rw-r--r-- | include/linux/cgroup.h | 1 | ||||
-rw-r--r-- | include/linux/rcupdate.h | 2 | ||||
-rw-r--r-- | kernel/cgroup.c | 16 | ||||
-rw-r--r-- | kernel/rcupdate.c | 11 | ||||
-rw-r--r-- | kernel/sched_debug.c | 2 | ||||
-rw-r--r-- | mm/memcontrol.c | 21 |
6 files changed, 43 insertions, 10 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index b8ad1ea99586..8f78073d7caa 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h | |||
@@ -530,6 +530,7 @@ static inline struct cgroup_subsys_state *task_subsys_state( | |||
530 | { | 530 | { |
531 | return rcu_dereference_check(task->cgroups->subsys[subsys_id], | 531 | return rcu_dereference_check(task->cgroups->subsys[subsys_id], |
532 | rcu_read_lock_held() || | 532 | rcu_read_lock_held() || |
533 | lockdep_is_held(&task->alloc_lock) || | ||
533 | cgroup_lock_is_held()); | 534 | cgroup_lock_is_held()); |
534 | } | 535 | } |
535 | 536 | ||
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index 07db2feb8572..db266bbed23f 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h | |||
@@ -190,6 +190,8 @@ static inline int rcu_read_lock_sched_held(void) | |||
190 | 190 | ||
191 | #ifdef CONFIG_PROVE_RCU | 191 | #ifdef CONFIG_PROVE_RCU |
192 | 192 | ||
193 | extern int rcu_my_thread_group_empty(void); | ||
194 | |||
193 | /** | 195 | /** |
194 | * rcu_dereference_check - rcu_dereference with debug checking | 196 | * rcu_dereference_check - rcu_dereference with debug checking |
195 | * @p: The pointer to read, prior to dereferencing | 197 | * @p: The pointer to read, prior to dereferencing |
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index e2769e13980c..3a53c771e503 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -1646,7 +1646,9 @@ static inline struct cftype *__d_cft(struct dentry *dentry) | |||
1646 | int cgroup_path(const struct cgroup *cgrp, char *buf, int buflen) | 1646 | int cgroup_path(const struct cgroup *cgrp, char *buf, int buflen) |
1647 | { | 1647 | { |
1648 | char *start; | 1648 | char *start; |
1649 | struct dentry *dentry = rcu_dereference(cgrp->dentry); | 1649 | struct dentry *dentry = rcu_dereference_check(cgrp->dentry, |
1650 | rcu_read_lock_held() || | ||
1651 | cgroup_lock_is_held()); | ||
1650 | 1652 | ||
1651 | if (!dentry || cgrp == dummytop) { | 1653 | if (!dentry || cgrp == dummytop) { |
1652 | /* | 1654 | /* |
@@ -1662,13 +1664,17 @@ int cgroup_path(const struct cgroup *cgrp, char *buf, int buflen) | |||
1662 | *--start = '\0'; | 1664 | *--start = '\0'; |
1663 | for (;;) { | 1665 | for (;;) { |
1664 | int len = dentry->d_name.len; | 1666 | int len = dentry->d_name.len; |
1667 | |||
1665 | if ((start -= len) < buf) | 1668 | if ((start -= len) < buf) |
1666 | return -ENAMETOOLONG; | 1669 | return -ENAMETOOLONG; |
1667 | memcpy(start, cgrp->dentry->d_name.name, len); | 1670 | memcpy(start, dentry->d_name.name, len); |
1668 | cgrp = cgrp->parent; | 1671 | cgrp = cgrp->parent; |
1669 | if (!cgrp) | 1672 | if (!cgrp) |
1670 | break; | 1673 | break; |
1671 | dentry = rcu_dereference(cgrp->dentry); | 1674 | |
1675 | dentry = rcu_dereference_check(cgrp->dentry, | ||
1676 | rcu_read_lock_held() || | ||
1677 | cgroup_lock_is_held()); | ||
1672 | if (!cgrp->parent) | 1678 | if (!cgrp->parent) |
1673 | continue; | 1679 | continue; |
1674 | if (--start < buf) | 1680 | if (--start < buf) |
@@ -4555,13 +4561,13 @@ static int alloc_css_id(struct cgroup_subsys *ss, struct cgroup *parent, | |||
4555 | { | 4561 | { |
4556 | int subsys_id, i, depth = 0; | 4562 | int subsys_id, i, depth = 0; |
4557 | struct cgroup_subsys_state *parent_css, *child_css; | 4563 | struct cgroup_subsys_state *parent_css, *child_css; |
4558 | struct css_id *child_id, *parent_id = NULL; | 4564 | struct css_id *child_id, *parent_id; |
4559 | 4565 | ||
4560 | subsys_id = ss->subsys_id; | 4566 | subsys_id = ss->subsys_id; |
4561 | parent_css = parent->subsys[subsys_id]; | 4567 | parent_css = parent->subsys[subsys_id]; |
4562 | child_css = child->subsys[subsys_id]; | 4568 | child_css = child->subsys[subsys_id]; |
4563 | depth = css_depth(parent_css) + 1; | ||
4564 | parent_id = parent_css->id; | 4569 | parent_id = parent_css->id; |
4570 | depth = parent_id->depth; | ||
4565 | 4571 | ||
4566 | child_id = get_new_cssid(ss, depth); | 4572 | child_id = get_new_cssid(ss, depth); |
4567 | if (IS_ERR(child_id)) | 4573 | if (IS_ERR(child_id)) |
diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c index 03a7ea1579f6..49d808e833b0 100644 --- a/kernel/rcupdate.c +++ b/kernel/rcupdate.c | |||
@@ -122,3 +122,14 @@ void wakeme_after_rcu(struct rcu_head *head) | |||
122 | rcu = container_of(head, struct rcu_synchronize, head); | 122 | rcu = container_of(head, struct rcu_synchronize, head); |
123 | complete(&rcu->completion); | 123 | complete(&rcu->completion); |
124 | } | 124 | } |
125 | |||
126 | #ifdef CONFIG_PROVE_RCU | ||
127 | /* | ||
128 | * wrapper function to avoid #include problems. | ||
129 | */ | ||
130 | int rcu_my_thread_group_empty(void) | ||
131 | { | ||
132 | return thread_group_empty(current); | ||
133 | } | ||
134 | EXPORT_SYMBOL_GPL(rcu_my_thread_group_empty); | ||
135 | #endif /* #ifdef CONFIG_PROVE_RCU */ | ||
diff --git a/kernel/sched_debug.c b/kernel/sched_debug.c index 9b49db144037..19be00ba6123 100644 --- a/kernel/sched_debug.c +++ b/kernel/sched_debug.c | |||
@@ -114,7 +114,9 @@ print_task(struct seq_file *m, struct rq *rq, struct task_struct *p) | |||
114 | { | 114 | { |
115 | char path[64]; | 115 | char path[64]; |
116 | 116 | ||
117 | rcu_read_lock(); | ||
117 | cgroup_path(task_group(p)->css.cgroup, path, sizeof(path)); | 118 | cgroup_path(task_group(p)->css.cgroup, path, sizeof(path)); |
119 | rcu_read_unlock(); | ||
118 | SEQ_printf(m, " %s", path); | 120 | SEQ_printf(m, " %s", path); |
119 | } | 121 | } |
120 | #endif | 122 | #endif |
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 6c755de385f7..0f711c213d2e 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -811,10 +811,12 @@ int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem) | |||
811 | * enabled in "curr" and "curr" is a child of "mem" in *cgroup* | 811 | * enabled in "curr" and "curr" is a child of "mem" in *cgroup* |
812 | * hierarchy(even if use_hierarchy is disabled in "mem"). | 812 | * hierarchy(even if use_hierarchy is disabled in "mem"). |
813 | */ | 813 | */ |
814 | rcu_read_lock(); | ||
814 | if (mem->use_hierarchy) | 815 | if (mem->use_hierarchy) |
815 | ret = css_is_ancestor(&curr->css, &mem->css); | 816 | ret = css_is_ancestor(&curr->css, &mem->css); |
816 | else | 817 | else |
817 | ret = (curr == mem); | 818 | ret = (curr == mem); |
819 | rcu_read_unlock(); | ||
818 | css_put(&curr->css); | 820 | css_put(&curr->css); |
819 | return ret; | 821 | return ret; |
820 | } | 822 | } |
@@ -2312,7 +2314,9 @@ mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent, bool swapout) | |||
2312 | 2314 | ||
2313 | /* record memcg information */ | 2315 | /* record memcg information */ |
2314 | if (do_swap_account && swapout && memcg) { | 2316 | if (do_swap_account && swapout && memcg) { |
2317 | rcu_read_lock(); | ||
2315 | swap_cgroup_record(ent, css_id(&memcg->css)); | 2318 | swap_cgroup_record(ent, css_id(&memcg->css)); |
2319 | rcu_read_unlock(); | ||
2316 | mem_cgroup_get(memcg); | 2320 | mem_cgroup_get(memcg); |
2317 | } | 2321 | } |
2318 | if (swapout && memcg) | 2322 | if (swapout && memcg) |
@@ -2369,8 +2373,10 @@ static int mem_cgroup_move_swap_account(swp_entry_t entry, | |||
2369 | { | 2373 | { |
2370 | unsigned short old_id, new_id; | 2374 | unsigned short old_id, new_id; |
2371 | 2375 | ||
2376 | rcu_read_lock(); | ||
2372 | old_id = css_id(&from->css); | 2377 | old_id = css_id(&from->css); |
2373 | new_id = css_id(&to->css); | 2378 | new_id = css_id(&to->css); |
2379 | rcu_read_unlock(); | ||
2374 | 2380 | ||
2375 | if (swap_cgroup_cmpxchg(entry, old_id, new_id) == old_id) { | 2381 | if (swap_cgroup_cmpxchg(entry, old_id, new_id) == old_id) { |
2376 | mem_cgroup_swap_statistics(from, false); | 2382 | mem_cgroup_swap_statistics(from, false); |
@@ -4038,11 +4044,16 @@ static int is_target_pte_for_mc(struct vm_area_struct *vma, | |||
4038 | put_page(page); | 4044 | put_page(page); |
4039 | } | 4045 | } |
4040 | /* throught */ | 4046 | /* throught */ |
4041 | if (ent.val && do_swap_account && !ret && | 4047 | if (ent.val && do_swap_account && !ret) { |
4042 | css_id(&mc.from->css) == lookup_swap_cgroup(ent)) { | 4048 | unsigned short id; |
4043 | ret = MC_TARGET_SWAP; | 4049 | rcu_read_lock(); |
4044 | if (target) | 4050 | id = css_id(&mc.from->css); |
4045 | target->ent = ent; | 4051 | rcu_read_unlock(); |
4052 | if (id == lookup_swap_cgroup(ent)) { | ||
4053 | ret = MC_TARGET_SWAP; | ||
4054 | if (target) | ||
4055 | target->ent = ent; | ||
4056 | } | ||
4046 | } | 4057 | } |
4047 | return ret; | 4058 | return ret; |
4048 | } | 4059 | } |