aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memcontrol.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-03-15 20:16:22 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-15 20:16:22 -0400
commit0c4d0670f6e54f8507c30c01928cc9ff630ca497 (patch)
tree66a417d87d670f4068ac17c5ee19d21ddf7e95e1 /mm/memcontrol.c
parent7c32442ff846b7ea8804785e90b81c1118115a5c (diff)
parentcf2b94daab9f3d21b0a393bef91292622f6a8ca4 (diff)
Merge branch 'akpm' (Andrew's patch-bomb)
Merge patches from Andrew Morton: "Nine patches - some bug fixes and some MAINTAINERS fiddling." * emailed from Andrew Morton <akpm@linux-foundation.org>: drivers/video/backlight/s6e63m0.c: fix corruption storing gamma mode MAINTAINERS: add entry for exynos mipi display drivers MAINTAINERS: fix link to Gustavo Padovans tree MAINTAINERS: add Johan to Bluetooth maintainers MAINTAINERS: Gustavo has moved prctl: use CAP_SYS_RESOURCE for PR_SET_MM option rapidio/tsi721: fix bug in register offset definitions MAINTAINERS: update ST's Mailing list for SPEAr memcg: free mem_cgroup by RCU to fix oops
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r--mm/memcontrol.c53
1 files changed, 47 insertions, 6 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index d0e57a3cda18..58a08fc7414a 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -230,10 +230,30 @@ struct mem_cgroup {
230 * the counter to account for memory usage 230 * the counter to account for memory usage
231 */ 231 */
232 struct res_counter res; 232 struct res_counter res;
233 /* 233
234 * the counter to account for mem+swap usage. 234 union {
235 */ 235 /*
236 struct res_counter memsw; 236 * the counter to account for mem+swap usage.
237 */
238 struct res_counter memsw;
239
240 /*
241 * rcu_freeing is used only when freeing struct mem_cgroup,
242 * so put it into a union to avoid wasting more memory.
243 * It must be disjoint from the css field. It could be
244 * in a union with the res field, but res plays a much
245 * larger part in mem_cgroup life than memsw, and might
246 * be of interest, even at time of free, when debugging.
247 * So share rcu_head with the less interesting memsw.
248 */
249 struct rcu_head rcu_freeing;
250 /*
251 * But when using vfree(), that cannot be done at
252 * interrupt time, so we must then queue the work.
253 */
254 struct work_struct work_freeing;
255 };
256
237 /* 257 /*
238 * Per cgroup active and inactive list, similar to the 258 * Per cgroup active and inactive list, similar to the
239 * per zone LRU lists. 259 * per zone LRU lists.
@@ -4780,6 +4800,27 @@ out_free:
4780} 4800}
4781 4801
4782/* 4802/*
4803 * Helpers for freeing a vzalloc()ed mem_cgroup by RCU,
4804 * but in process context. The work_freeing structure is overlaid
4805 * on the rcu_freeing structure, which itself is overlaid on memsw.
4806 */
4807static void vfree_work(struct work_struct *work)
4808{
4809 struct mem_cgroup *memcg;
4810
4811 memcg = container_of(work, struct mem_cgroup, work_freeing);
4812 vfree(memcg);
4813}
4814static void vfree_rcu(struct rcu_head *rcu_head)
4815{
4816 struct mem_cgroup *memcg;
4817
4818 memcg = container_of(rcu_head, struct mem_cgroup, rcu_freeing);
4819 INIT_WORK(&memcg->work_freeing, vfree_work);
4820 schedule_work(&memcg->work_freeing);
4821}
4822
4823/*
4783 * At destroying mem_cgroup, references from swap_cgroup can remain. 4824 * At destroying mem_cgroup, references from swap_cgroup can remain.
4784 * (scanning all at force_empty is too costly...) 4825 * (scanning all at force_empty is too costly...)
4785 * 4826 *
@@ -4802,9 +4843,9 @@ static void __mem_cgroup_free(struct mem_cgroup *memcg)
4802 4843
4803 free_percpu(memcg->stat); 4844 free_percpu(memcg->stat);
4804 if (sizeof(struct mem_cgroup) < PAGE_SIZE) 4845 if (sizeof(struct mem_cgroup) < PAGE_SIZE)
4805 kfree(memcg); 4846 kfree_rcu(memcg, rcu_freeing);
4806 else 4847 else
4807 vfree(memcg); 4848 call_rcu(&memcg->rcu_freeing, vfree_rcu);
4808} 4849}
4809 4850
4810static void mem_cgroup_get(struct mem_cgroup *memcg) 4851static void mem_cgroup_get(struct mem_cgroup *memcg)