From: Hugh Dickins <hugh@veritas.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Balbir Singh <balbir@linux.vnet.ibm.com>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
linux-mm@kvack.org, containers@lists.osdl.org
Subject: [PATCH 5/6 mm] memcgroup: fix zone isolation OOM
Date: Fri, 9 Nov 2007 07:13:22 +0000 (GMT) [thread overview]
Message-ID: <Pine.LNX.4.64.0711090712180.21663@blonde.wat.veritas.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0711090700530.21638@blonde.wat.veritas.com>
mem_cgroup_charge_common shows a tendency to OOM without good reason,
when a memhog goes well beyond its rss limit but with plenty of swap
available. Seen on x86 but not on PowerPC; seen when the next patch
omits swapcache from memcgroup, but we presume it can happen without.
mem_cgroup_isolate_pages is not quite satisfying reclaim's criteria
for OOM avoidance. Already it has to scan beyond the nr_to_scan limit
when it finds a !LRU page or an active page when handling inactive or
an inactive page when handling active. It needs to do exactly the same
when it finds a page from the wrong zone (the x86 tests had two zones,
the PowerPC tests had only one).
Don't increment scan and then decrement it in these cases, just move
the incrementation down. Fix recent off-by-one when checking against
nr_to_scan. Cut out "Check if the meta page went away from under us",
presumably left over from early debugging: no amount of such checks
could save us if this list really were being updated without locking.
This change does make the unlimited scan while holding two spinlocks
even worse - bad for latency and bad for containment; but that's a
separate issue which is better left to be fixed a little later.
Signed-off-by: Hugh Dickins <hugh@veritas.com>
---
Insert just after bugfix-for-memory-cgroup-controller-avoid-pagelru-page-in-mem_cgroup_isolate_pages-fix.patch
or just before memory-cgroup-enhancements
mm/memcontrol.c | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)
--- patch4/mm/memcontrol.c 2007-11-08 16:03:33.000000000 +0000
+++ patch5/mm/memcontrol.c 2007-11-08 16:51:39.000000000 +0000
@@ -260,24 +260,20 @@ unsigned long mem_cgroup_isolate_pages(u
spin_lock(&mem_cont->lru_lock);
scan = 0;
list_for_each_entry_safe_reverse(pc, tmp, src, lru) {
- if (scan++ > nr_to_scan)
+ if (scan >= nr_to_scan)
break;
page = pc->page;
VM_BUG_ON(!pc);
- if (unlikely(!PageLRU(page))) {
- scan--;
+ if (unlikely(!PageLRU(page)))
continue;
- }
if (PageActive(page) && !active) {
__mem_cgroup_move_lists(pc, true);
- scan--;
continue;
}
if (!PageActive(page) && active) {
__mem_cgroup_move_lists(pc, false);
- scan--;
continue;
}
@@ -288,13 +284,8 @@ unsigned long mem_cgroup_isolate_pages(u
if (page_zone(page) != z)
continue;
- /*
- * Check if the meta page went away from under us
- */
- if (!list_empty(&pc->lru))
- list_move(&pc->lru, &pc_list);
- else
- continue;
+ scan++;
+ list_move(&pc->lru, &pc_list);
if (__isolate_lru_page(page, mode) == 0) {
list_move(&page->lru, dst);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2007-11-09 7:13 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-09 7:08 [PATCH 1/6 mm] swapoff: scan ptes preemptibly Hugh Dickins
2007-11-09 7:10 ` [PATCH 2/6 mm] memcgroup: temporarily revert swapoff mod Hugh Dickins
2007-11-09 7:11 ` [PATCH 3/6 mm] memcgroup: fix try_to_free order Hugh Dickins
2007-11-12 5:05 ` Balbir Singh
2007-11-09 7:12 ` [PATCH 4/6 mm] memcgroup: reinstate swapoff mod Hugh Dickins
2007-11-12 5:08 ` Balbir Singh
2007-11-09 7:13 ` Hugh Dickins [this message]
2007-11-09 9:27 ` [PATCH 5/6 mm] memcgroup: fix zone isolation OOM KAMEZAWA Hiroyuki
2007-11-12 6:42 ` Balbir Singh
2007-11-09 7:14 ` [PATCH 6/6 mm] memcgroup: revert swap_state mods Hugh Dickins
2007-11-09 9:21 ` KAMEZAWA Hiroyuki
2007-11-12 4:57 ` Hugh Dickins
2007-11-12 5:17 ` KAMEZAWA Hiroyuki
2007-11-12 6:56 ` Balbir Singh
2007-11-12 5:04 ` [PATCH 1/6 mm] swapoff: scan ptes preemptibly Balbir Singh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.64.0711090712180.21663@blonde.wat.veritas.com \
--to=hugh@veritas.com \
--cc=akpm@linux-foundation.org \
--cc=balbir@linux.vnet.ibm.com \
--cc=containers@lists.osdl.org \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox