diff options
Diffstat (limited to 'mm')
-rw-r--r-- | mm/memcontrol.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 6a0007965e31..bf35bff282fc 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -366,13 +366,6 @@ mem_cgroup_zone_zoneinfo(struct mem_cgroup *memcg, struct zone *zone) | |||
366 | * | 366 | * |
367 | * If memcg is bound to a traditional hierarchy, the css of root_mem_cgroup | 367 | * If memcg is bound to a traditional hierarchy, the css of root_mem_cgroup |
368 | * is returned. | 368 | * is returned. |
369 | * | ||
370 | * XXX: The above description of behavior on the default hierarchy isn't | ||
371 | * strictly true yet as replace_page_cache_page() can modify the | ||
372 | * association before @page is released even on the default hierarchy; | ||
373 | * however, the current and planned usages don't mix the the two functions | ||
374 | * and replace_page_cache_page() will soon be updated to make the invariant | ||
375 | * actually true. | ||
376 | */ | 369 | */ |
377 | struct cgroup_subsys_state *mem_cgroup_css_from_page(struct page *page) | 370 | struct cgroup_subsys_state *mem_cgroup_css_from_page(struct page *page) |
378 | { | 371 | { |
@@ -5464,7 +5457,8 @@ void mem_cgroup_uncharge_list(struct list_head *page_list) | |||
5464 | void mem_cgroup_replace_page(struct page *oldpage, struct page *newpage) | 5457 | void mem_cgroup_replace_page(struct page *oldpage, struct page *newpage) |
5465 | { | 5458 | { |
5466 | struct mem_cgroup *memcg; | 5459 | struct mem_cgroup *memcg; |
5467 | int isolated; | 5460 | unsigned int nr_pages; |
5461 | bool compound; | ||
5468 | 5462 | ||
5469 | VM_BUG_ON_PAGE(!PageLocked(oldpage), oldpage); | 5463 | VM_BUG_ON_PAGE(!PageLocked(oldpage), oldpage); |
5470 | VM_BUG_ON_PAGE(!PageLocked(newpage), newpage); | 5464 | VM_BUG_ON_PAGE(!PageLocked(newpage), newpage); |
@@ -5484,11 +5478,21 @@ void mem_cgroup_replace_page(struct page *oldpage, struct page *newpage) | |||
5484 | if (!memcg) | 5478 | if (!memcg) |
5485 | return; | 5479 | return; |
5486 | 5480 | ||
5487 | lock_page_lru(oldpage, &isolated); | 5481 | /* Force-charge the new page. The old one will be freed soon */ |
5488 | oldpage->mem_cgroup = NULL; | 5482 | compound = PageTransHuge(newpage); |
5489 | unlock_page_lru(oldpage, isolated); | 5483 | nr_pages = compound ? hpage_nr_pages(newpage) : 1; |
5484 | |||
5485 | page_counter_charge(&memcg->memory, nr_pages); | ||
5486 | if (do_memsw_account()) | ||
5487 | page_counter_charge(&memcg->memsw, nr_pages); | ||
5488 | css_get_many(&memcg->css, nr_pages); | ||
5490 | 5489 | ||
5491 | commit_charge(newpage, memcg, true); | 5490 | commit_charge(newpage, memcg, true); |
5491 | |||
5492 | local_irq_disable(); | ||
5493 | mem_cgroup_charge_statistics(memcg, newpage, compound, nr_pages); | ||
5494 | memcg_check_events(memcg, newpage); | ||
5495 | local_irq_enable(); | ||
5492 | } | 5496 | } |
5493 | 5497 | ||
5494 | DEFINE_STATIC_KEY_FALSE(memcg_sockets_enabled_key); | 5498 | DEFINE_STATIC_KEY_FALSE(memcg_sockets_enabled_key); |