[patch 16/20] non-reclaimable mlocked pages

Previous thread: [patch 17/20] mlock vma pages under mmap_sem held for read by Rik van Riel on Tuesday, March 4, 2008 - 6:52 pm. (1 message)

Next thread: [patch 06/20] split LRU lists into anon & file sets by Rik van Riel on Tuesday, March 4, 2008 - 6:52 pm. (1 message)
To: <linux-kernel@...>
Cc: <linux-mm@...>, KOSAKI Motohiro <kosaki.motohiro@...>, Lee Schermerhorn <Lee.Schermerhorn@...>
Date: Tuesday, March 4, 2008 - 6:52 pm

V2 -> V3:
+ rebase to 23-mm1 atop RvR's split lru series
+ fix page flags macros for *PageMlocked() when not configured.
+ ensure lru_add_drain_all() runs on all cpus when NORECLAIM_MLOCK
configured. Was just for NUMA.

V1 -> V2:
+ moved this patch [and related patches] up to right after
ramdisk/ramfs and SHM_LOCKed patches.
+ add [back] missing put_page() in putback_lru_page().
This solved page leakage as seen by stats in previous
version.
+ fix up munlock_vma_page() to isolate page from lru
before calling try_to_unlock(). Think I detected a
race here.
+ use TestClearPageMlock() on old page in migrate.c's
migrate_page_copy() to clean up old page.
+ live dangerously: remove TestSetPageLocked() in
is_mlocked_vma()--should only be called on new pages in
the fault path--iff we chose to cull there [later patch].
+ Add PG_mlocked to free_pages_check() etc to detect mlock
state mismanagement.
NOTE: temporarily [???] commented out--tripping over it
under load. Why?

Rework of a patch by Nick Piggin -- part 1 of 2.

This patch:

1) defines the [CONFIG_]NORECLAIM_MLOCK sub-option and the
stub version of the mlock/noreclaim APIs when it's
not configured. Depends on [CONFIG_]NORECLAIM.

2) add yet another page flag--PG_mlocked--to indicate that
the page is locked for efficient testing in vmscan and,
optionally, fault path. This allows early culling of
nonreclaimable pages, preventing them from getting to
page_referenced()/try_to_unmap(). Also allows separate
accounting of mlock'd pages, as Nick's original patch
did.

Uses a bit available only to 64-bit systems.

Note: Nick's original mlock patch used a PG_mlocked
flag. I had removed this in favor of the PG_noreclaim
flag + an mlock_count [new page struct member]. I
restored the PG_mlocked flag to eliminate the new
count field.

3) add the mlock/noreclaim infrastructure to mm/mlock.c,
with internal APIs in mm/internal.h. This is a rework
...

To: Rik van Riel <riel@...>
Cc: <linux-kernel@...>, <linux-mm@...>, KOSAKI Motohiro <kosaki.motohiro@...>, Lee Schermerhorn <Lee.Schermerhorn@...>
Date: Tuesday, March 4, 2008 - 8:28 pm

Hi, Rik.

There is a some trivial mistake.
It can cause compile error.

>@@ -665,7 +677,12 @@ static int prep_new_page(struct page *pa
>
> page->flags &= ~(1 << PG_uptodate | 1 << PG_error | 1 << PG_readahead |
> 1 << PG_referenced | 1 << PG_arch_1 |
>- 1 << PG_owner_priv_1 | 1 << PG_mappedtodisk);
>+ 1 << PG_owner_priv_1 | 1 << PG_mappedtodisk |
>+#ifdef CONFIG_NORECLAIM_MLOCK
>+//TODO take care of it here, for now.
>+ 1 << PG_mlocked
>+#endif
>+ );
> set_page_private(page, 0);
> set_page_refcounted(page);

we need to fix it.

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 78c3f94..f6d535f 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -677,10 +677,10 @@ static int prep_new_page(struct page *page, int
order, gfp_t gfp_flags)

page->flags &= ~(1 << PG_uptodate | 1 << PG_error | 1 << PG_readahead |
1 << PG_referenced | 1 << PG_arch_1 |
- 1 << PG_owner_priv_1 | 1 << PG_mappedtodisk |
+ 1 << PG_owner_priv_1 | 1 << PG_mappedtodisk
#ifdef CONFIG_NORECLAIM_MLOCK
//TODO take care of it here, for now.
- 1 << PG_mlocked
+ | 1 << PG_mlocked
#endif
);
set_page_private(page, 0);

Thanks,
barrios.
--

To: minchan Kim <minchan.kim@...>
Cc: <linux-kernel@...>, <linux-mm@...>, KOSAKI Motohiro <kosaki.motohiro@...>, Lee Schermerhorn <Lee.Schermerhorn@...>
Date: Wednesday, March 5, 2008 - 12:18 am

On Wed, 05 Mar 2008 09:28:21 +0900

Thank you. I have applied your fix.

--
All rights reversed.
--

Previous thread: [patch 17/20] mlock vma pages under mmap_sem held for read by Rik van Riel on Tuesday, March 4, 2008 - 6:52 pm. (1 message)

Next thread: [patch 06/20] split LRU lists into anon & file sets by Rik van Riel on Tuesday, March 4, 2008 - 6:52 pm. (1 message)