aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorVladimir Davydov <vdavydov@parallels.com>2015-09-09 18:35:35 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-09-10 16:29:01 -0400
commite993d905c81e2c0f669f2f8e8327df86738baebe (patch)
treef37d6e76025164efc2944e7afe9d54e66a38cbc3 /mm
parent94a59fb36ee91b3f977a9b914ec701efe40041de (diff)
memcg: zap try_get_mem_cgroup_from_page
It is only used in mem_cgroup_try_charge, so fold it in and zap it. Signed-off-by: Vladimir Davydov <vdavydov@parallels.com> Reviewed-by: Andres Lagar-Cavilla <andreslc@google.com> Cc: Minchan Kim <minchan@kernel.org> Cc: Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Michal Hocko <mhocko@suse.cz> Cc: Greg Thelen <gthelen@google.com> Cc: Michel Lespinasse <walken@google.com> Cc: David Rientjes <rientjes@google.com> Cc: Pavel Emelyanov <xemul@parallels.com> Cc: Cyrill Gorcunov <gorcunov@openvz.org> Cc: Jonathan Corbet <corbet@lwn.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/memcontrol.c48
1 files changed, 12 insertions, 36 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 01009726d412..6ddaeba34e09 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2099,40 +2099,6 @@ static void cancel_charge(struct mem_cgroup *memcg, unsigned int nr_pages)
2099 css_put_many(&memcg->css, nr_pages); 2099 css_put_many(&memcg->css, nr_pages);
2100} 2100}
2101 2101
2102/*
2103 * try_get_mem_cgroup_from_page - look up page's memcg association
2104 * @page: the page
2105 *
2106 * Look up, get a css reference, and return the memcg that owns @page.
2107 *
2108 * The page must be locked to prevent racing with swap-in and page
2109 * cache charges. If coming from an unlocked page table, the caller
2110 * must ensure the page is on the LRU or this can race with charging.
2111 */
2112struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page)
2113{
2114 struct mem_cgroup *memcg;
2115 unsigned short id;
2116 swp_entry_t ent;
2117
2118 VM_BUG_ON_PAGE(!PageLocked(page), page);
2119
2120 memcg = page->mem_cgroup;
2121 if (memcg) {
2122 if (!css_tryget_online(&memcg->css))
2123 memcg = NULL;
2124 } else if (PageSwapCache(page)) {
2125 ent.val = page_private(page);
2126 id = lookup_swap_cgroup_id(ent);
2127 rcu_read_lock();
2128 memcg = mem_cgroup_from_id(id);
2129 if (memcg && !css_tryget_online(&memcg->css))
2130 memcg = NULL;
2131 rcu_read_unlock();
2132 }
2133 return memcg;
2134}
2135
2136static void lock_page_lru(struct page *page, int *isolated) 2102static void lock_page_lru(struct page *page, int *isolated)
2137{ 2103{
2138 struct zone *zone = page_zone(page); 2104 struct zone *zone = page_zone(page);
@@ -5329,8 +5295,20 @@ int mem_cgroup_try_charge(struct page *page, struct mm_struct *mm,
5329 * the page lock, which serializes swap cache removal, which 5295 * the page lock, which serializes swap cache removal, which
5330 * in turn serializes uncharging. 5296 * in turn serializes uncharging.
5331 */ 5297 */
5298 VM_BUG_ON_PAGE(!PageLocked(page), page);
5332 if (page->mem_cgroup) 5299 if (page->mem_cgroup)
5333 goto out; 5300 goto out;
5301
5302 if (do_swap_account) {
5303 swp_entry_t ent = { .val = page_private(page), };
5304 unsigned short id = lookup_swap_cgroup_id(ent);
5305
5306 rcu_read_lock();
5307 memcg = mem_cgroup_from_id(id);
5308 if (memcg && !css_tryget_online(&memcg->css))
5309 memcg = NULL;
5310 rcu_read_unlock();
5311 }
5334 } 5312 }
5335 5313
5336 if (PageTransHuge(page)) { 5314 if (PageTransHuge(page)) {
@@ -5338,8 +5316,6 @@ int mem_cgroup_try_charge(struct page *page, struct mm_struct *mm,
5338 VM_BUG_ON_PAGE(!PageTransHuge(page), page); 5316 VM_BUG_ON_PAGE(!PageTransHuge(page), page);
5339 } 5317 }
5340 5318
5341 if (do_swap_account && PageSwapCache(page))
5342 memcg = try_get_mem_cgroup_from_page(page);
5343 if (!memcg) 5319 if (!memcg)
5344 memcg = get_mem_cgroup_from_mm(mm); 5320 memcg = get_mem_cgroup_from_mm(mm);
5345 5321