[patch] mm: memcontrol: uncharge pages on swapout fix
From: Johannes Weiner
Date: Tue Oct 21 2014 - 16:53:14 EST
Vladimir notes:
> > + local_irq_disable();
> > + mem_cgroup_charge_statistics(memcg, page, -1);
> > + memcg_check_events(memcg, page);
> > + local_irq_enable();
>
> AFAICT mem_cgroup_swapout() is called under mapping->tree_lock with irqs
> disabled, so we should use irq_save/restore here.
But this function doesn't actually need to be called under the tree
lock. So for now, simply remove the irq-disabling altogether and rely
on the caller's IRQ state. Later on, we'll move it out from there and
add back the simple, non-saving IRQ-disabling.
Reported-by: Vladimir Davydov <vdavydov@xxxxxxxxxxxxx>
Signed-off-by: Johannes Weiner <hannes@xxxxxxxxxxx>
---
mm/memcontrol.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 8dc46aa9ae8f..c688fb73ff35 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5806,6 +5806,9 @@ void mem_cgroup_swapout(struct page *page, swp_entry_t entry)
VM_BUG_ON_PAGE(PageLRU(page), page);
VM_BUG_ON_PAGE(page_count(page), page);
+ /* XXX: caller holds IRQ-safe mapping->tree_lock */
+ VM_BUG_ON(!irqs_disabled());
+
if (!do_swap_account)
return;
@@ -5827,10 +5830,8 @@ void mem_cgroup_swapout(struct page *page, swp_entry_t entry)
if (!mem_cgroup_is_root(memcg))
page_counter_uncharge(&memcg->memory, 1);
- local_irq_disable();
mem_cgroup_charge_statistics(memcg, page, -1);
memcg_check_events(memcg, page);
- local_irq_enable();
}
/**
--
2.1.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/