[PATCH RFC 11/15] mm: handle book relock in memory controller

Konstantin Khlebnikov
2012-02-15T22:57:50Z

Carefully relock book lru lock at page memory cgroup change.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
---
mm/memcontrol.c | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 84e04ae..90e21d2 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2535,7 +2535,6 @@ __mem_cgroup_commit_charge_lrucare(struct page *page, struct mem_cgroup *memcg,
enum charge_type ctype)
{
struct page_cgroup *pc = lookup_page_cgroup(page);
- struct zone *zone = page_zone(page);
struct book *book;
unsigned long flags;
bool removed = false;
@@ -2545,20 +2544,19 @@ __mem_cgroup_commit_charge_lrucare(struct page *page, struct mem_cgroup *memcg,
* is already on LRU. It means the page may on some other page_cgroup's
* LRU. Take care of it.
*/
- spin_lock_irqsave(&zone->lru_lock, flags);
+ book = lock_page_book(page, &flags);
if (PageLRU(page)) {
- book = page_book(page);
del_page_from_lru_list(book, page, page_lru(page));
ClearPageLRU(page);
removed = true;
}
__mem_cgroup_commit_charge(memcg, page, 1, pc, ctype);
if (removed) {
- book = page_book(page);
+ book = __relock_page_book(book, page);
add_page_to_lru_list(book, page, page_lru(page));
SetPageLRU(page);
}
- spin_unlock_irqrestore(&zone->lru_lock, flags);
+ unlock_book(book, &flags);
return;
}