* [PATCH 1/3] mem-hotplug: call isolate_lru_page with elevated refcount
@ 2011-04-21 13:12 Konstantin Khlebnikov
2011-04-21 13:12 ` [PATCH 2/3] mem-hwpoison: fix page refcount around isolate_lru_page() Konstantin Khlebnikov
2011-04-21 13:12 ` [PATCH 3/3] mm: strictly require elevated page refcount in isolate_lru_page() Konstantin Khlebnikov
0 siblings, 2 replies; 3+ messages in thread
From: Konstantin Khlebnikov @ 2011-04-21 13:12 UTC (permalink / raw)
To: linux-mm, Andrew Morton; +Cc: Andi Kleen, linux-kernel
isolate_lru_page() must be called only with stable reference to page.
So, let's grab normal page reference.
Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
---
mm/memory_hotplug.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 9ca1d60..0a19109 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -705,7 +705,7 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn)
if (!pfn_valid(pfn))
continue;
page = pfn_to_page(pfn);
- if (!page_count(page))
+ if (!get_page_unless_zero(page))
continue;
/*
* We can skip free pages. And we can only deal with pages on
@@ -713,6 +713,7 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn)
*/
ret = isolate_lru_page(page);
if (!ret) { /* Success */
+ put_page(page);
list_add_tail(&page->lru, &source);
move_pages--;
inc_zone_page_state(page, NR_ISOLATED_ANON +
@@ -724,6 +725,7 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn)
pfn);
dump_page(page);
#endif
+ put_page(page);
/* Because we don't have big zone->lock. we should
check this again here. */
if (page_count(page)) {
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/3] mem-hwpoison: fix page refcount around isolate_lru_page()
2011-04-21 13:12 [PATCH 1/3] mem-hotplug: call isolate_lru_page with elevated refcount Konstantin Khlebnikov
@ 2011-04-21 13:12 ` Konstantin Khlebnikov
2011-04-21 13:12 ` [PATCH 3/3] mm: strictly require elevated page refcount in isolate_lru_page() Konstantin Khlebnikov
1 sibling, 0 replies; 3+ messages in thread
From: Konstantin Khlebnikov @ 2011-04-21 13:12 UTC (permalink / raw)
To: linux-mm, Andrew Morton; +Cc: Andi Kleen, linux-kernel
Drop first page reference only after calling isolate_lru_page()
to keep page stable reference while isolating.
Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
---
mm/memory-failure.c | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 2b9a5ee..a17d31e 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1440,16 +1440,12 @@ int soft_offline_page(struct page *page, int flags)
*/
ret = invalidate_inode_page(page);
unlock_page(page);
-
/*
- * Drop count because page migration doesn't like raised
- * counts. The page could get re-allocated, but if it becomes
- * LRU the isolation will just fail.
* RED-PEN would be better to keep it isolated here, but we
* would need to fix isolation locking first.
*/
- put_page(page);
if (ret == 1) {
+ put_page(page);
ret = 0;
pr_info("soft_offline: %#lx: invalidated\n", pfn);
goto done;
@@ -1461,6 +1457,11 @@ int soft_offline_page(struct page *page, int flags)
* handles a large number of cases for us.
*/
ret = isolate_lru_page(page);
+ /*
+ * Drop page reference which is came from get_any_page()
+ * successful isolate_lru_page() already took another one.
+ */
+ put_page(page);
if (!ret) {
LIST_HEAD(pagelist);
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 3/3] mm: strictly require elevated page refcount in isolate_lru_page()
2011-04-21 13:12 [PATCH 1/3] mem-hotplug: call isolate_lru_page with elevated refcount Konstantin Khlebnikov
2011-04-21 13:12 ` [PATCH 2/3] mem-hwpoison: fix page refcount around isolate_lru_page() Konstantin Khlebnikov
@ 2011-04-21 13:12 ` Konstantin Khlebnikov
1 sibling, 0 replies; 3+ messages in thread
From: Konstantin Khlebnikov @ 2011-04-21 13:12 UTC (permalink / raw)
To: linux-mm, Andrew Morton; +Cc: Andi Kleen, linux-kernel
isolate_lru_page() must be called only with stable reference to the page,
this is what is written in the comment above it, this is reasonable.
current isolate_lru_page() users and its page extra reference sources:
mm/huge_memory.c
__collapse_huge_page_isolate() - reference from pte
mm/memcontrol.c
mem_cgroup_move_parent() - get_page_unless_zero()
mem_cgroup_move_charge_pte_range() - reference from pte
mm/memory-failure.c
soft_offline_page() - fixed, reference from get_any_page()
delete_from_lru_cache() - reference from caller or get_page_unless_zero()
[seems like there bug, because __memory_failure() can call page_action() for
hpages tail, but it is ok for isolate_lru_page(), tail getted and not in lru]
mm/memory_hotplug.c
do_migrate_range() - fixed, get_page_unless_zero()
mm/mempolicy.c
migrate_page_add() - reference from pte
mm/migrate.c
do_move_page_to_node_array() - reference from follow_page()
mlock.c - various external references
mm/vmscan.c
putback_lru_page() - reference from isolate_lru_page()
It seems that all isolate_lru_page() users are ready now for this restriction.
So, let's replace redundant get_page_unless_zero() with get_page() and
add page initial reference count check with VM_BUG_ON()
Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
---
mm/vmscan.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index f6b435c..0175f39 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1201,13 +1201,16 @@ int isolate_lru_page(struct page *page)
{
int ret = -EBUSY;
+ VM_BUG_ON(!page_count(page));
+
if (PageLRU(page)) {
struct zone *zone = page_zone(page);
spin_lock_irq(&zone->lru_lock);
- if (PageLRU(page) && get_page_unless_zero(page)) {
+ if (PageLRU(page)) {
int lru = page_lru(page);
ret = 0;
+ get_page(page);
ClearPageLRU(page);
del_page_from_lru_list(zone, page, lru);
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-04-21 13:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-21 13:12 [PATCH 1/3] mem-hotplug: call isolate_lru_page with elevated refcount Konstantin Khlebnikov
2011-04-21 13:12 ` [PATCH 2/3] mem-hwpoison: fix page refcount around isolate_lru_page() Konstantin Khlebnikov
2011-04-21 13:12 ` [PATCH 3/3] mm: strictly require elevated page refcount in isolate_lru_page() Konstantin Khlebnikov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).