Skip to contentSkip to conversation

cleanup of use-once

RFC In review Rik van Riel 7 participants 10 messages May 3, 2005 – May 20, 2005

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

RFC 1/1 cleanup of use-once

The special cases in the use-once code have annoyed me for a while, and I'd like to see if replacing them with something simpler could be worthwhile.

I haven't actually benchmarked (or even tested) this code yet, but the basic idea is that we want to ignore multiple references to the same page if they happen really close to each other, and only keep a page on the active list if it got accessed again on a time scale that matters to the pageout code. In other words, filtering out correlated references in a simpler way.

Opinions ?

 include/linux/page-flags.h |    7 +++++++
 mm/filemap.c               |   11 ++---------
 mm/shmem.c                 |    7 ++-----
 mm/swap.c                  |   11 ++---------
 mm/vmscan.c                |   29 ++++++-----------------------
 5 files changed, 19 insertions(+), 46 deletions(-)
include/linux/page-flags.h +7 -0
Index: linux-2.6.11/include/linux/page-flags.h
===================================================================
@@ -77,6 +77,8 @@
 #define PG_nosave_free		19	/* Free, should not be written */
 #define PG_uncached		20	/* Page has been mapped as uncached */
 
+#define PG_new			21	/* Newly allocated page */
+
 /*
  * Global page accounting.  One instance per CPU.  Only unsigned longs are
  * allowed.
@@ -305,6 +307,11 @@ extern void __mod_page_state(unsigned of
 #define SetPageUncached(page)	set_bit(PG_uncached, &(page)->flags)
 #define ClearPageUncached(page)	clear_bit(PG_uncached, &(page)->flags)
 
+#define PageNew(page)		test_bit(PG_new, &(page)->flags)
+#define SetPageNew(page)	set_bit(PG_new, &(page)->flags)
+#define ClearPageNew(page)	clear_bit(PG_new, &(page)->flags)
+#define TestClearPageNew(page)	test_and_clear_bit(PG_new, &(page)->flags)
+
 struct page;	/* forward declaration */
 
 int test_clear_page_dirty(struct page *page);
mm/filemap.c +2 -9
Index: linux-2.6.11/mm/filemap.c
===================================================================
@@ -370,6 +370,7 @@ int add_to_page_cache(struct page *page,
 		if (!error) {
 			page_cache_get(page);
 			SetPageLocked(page);
+			SetPageNew(page);
 			page->mapping = mapping;
 			page->index = offset;
 			mapping->nrpages++;
@@ -710,7 +711,6 @@ void do_generic_mapping_read(struct addr
 	unsigned long offset;
 	unsigned long last_index;
 	unsigned long next_index;
-	unsigned long prev_index;
 	loff_t isize;
 	struct page *cached_page;
 	int error;
@@ -719,7 +719,6 @@ void do_generic_mapping_read(struct addr
 	cached_page = NULL;
 	index = *ppos >> PAGE_CACHE_SHIFT;
 	next_index = index;
-	prev_index = ra.prev_page;
 	last_index = (*ppos + desc->count + PAGE_CACHE_SIZE-1) >> PAGE_CACHE_SHIFT;
 	offset = *ppos & ~PAGE_CACHE_MASK;
 
@@ -776,13 +775,7 @@ page_ok:
 		if (mapping_writably_mapped(mapping))
 			flush_dcache_page(page);
 
-		/*
-		 * When (part of) the same page is read multiple times
-		 * in succession, only mark it as accessed the first time.
-		 */
-		if (prev_index != index)
-			mark_page_accessed(page);
-		prev_index = index;
+		mark_page_accessed(page);
 
 		/*
 		 * Ok, we have the page, and it's up-to-date, so
mm/swap.c +2 -9
Index: linux-2.6.11/mm/swap.c
===================================================================
@@ -115,19 +115,11 @@ void fastcall activate_page(struct page 
 
 /*
  * Mark a page as having seen activity.
- *
- * inactive,unreferenced	->	inactive,referenced
- * inactive,referenced		->	active,unreferenced
- * active,unreferenced		->	active,referenced
  */
 void fastcall mark_page_accessed(struct page *page)
 {
-	if (!PageActive(page) && PageReferenced(page) && PageLRU(page)) {
-		activate_page(page);
-		ClearPageReferenced(page);
-	} else if (!PageReferenced(page)) {
+	if (!PageReferenced(page))
 		SetPageReferenced(page);
-	}
 }
 
 EXPORT_SYMBOL(mark_page_accessed);
@@ -157,6 +149,7 @@ void fastcall lru_cache_add_active(struc
 	if (!pagevec_add(pvec, page))
 		__pagevec_lru_add_active(pvec);
 	put_cpu_var(lru_add_active_pvecs);
+	ClearPageNew(page);
 }
 
 void lru_add_drain(void)
mm/shmem.c +2 -5
Index: linux-2.6.11/mm/shmem.c
===================================================================
@@ -1525,11 +1525,8 @@ static void do_shmem_file_read(struct fi
 			 */
 			if (mapping_writably_mapped(mapping))
 				flush_dcache_page(page);
-			/*
-			 * Mark the page accessed if we read the beginning.
-			 */
-			if (!offset)
-				mark_page_accessed(page);
+
+			mark_page_accessed(page);
 		} else
 			page = ZERO_PAGE(0);
 
mm/vmscan.c +6 -23
Index: linux-2.6.11/mm/vmscan.c
===================================================================
@@ -225,27 +225,6 @@ static int shrink_slab(unsigned long sca
 	return 0;
 }
 
-/* Called without lock on whether page is mapped, so answer is unstable */
-static inline int page_mapping_inuse(struct page *page)
-{
-	struct address_space *mapping;
-
-	/* Page is in somebody's page tables. */
-	if (page_mapped(page))
-		return 1;
-
-	/* Be more reluctant to reclaim swapcache than pagecache */
-	if (PageSwapCache(page))
-		return 1;
-
-	mapping = page_mapping(page);
-	if (!mapping)
-		return 0;
-
-	/* File is mmap'd by somebody? */
-	return mapping_mapped(mapping);
-}
-
 static inline int is_page_cache_freeable(struct page *page)
 {
 	return page_count(page) - !!PagePrivate(page) == 2;
@@ -398,9 +377,13 @@ static int shrink_list(struct list_head 
 			goto keep_locked;
 
 		referenced = page_referenced(page, 1, sc->priority <= 0);
-		/* In active use or really unfreeable?  Activate it. */
-		if (referenced && page_mapping_inuse(page))
+
+		if (referenced) {
+			/* New page. Let's see if it'll get used again... */
+			if (TestClearPageNew(page))
+				goto keep_locked;
 			goto activate_locked;
+		}
 
 #ifdef CONFIG_SWAP
 		/*

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#1 lore raw

RFC 1/1 how do we move the VM forward? (was Re: [RFC] cleanup of use-once)

Quoted 4 lines · Rik van Riel

The special cases in the use-once code have annoyed me for a while, and I'd like to see if replacing them with something simpler could be worthwhile.

Quoted 9 lines

I haven't actually benchmarked (or even tested) this code yet, but the basic idea is that we want to ignore multiple references to the same page if they happen really close to each other, and only keep a page on the active list if it got accessed again on a time scale that matters to the pageout code. In other words, filtering out correlated references in a simpler way.

Opinions ?

I've had some patches around that do basically exactly the same thing. I'll attach them just for reference, but they're pretty messy and depend on other private patches I have here.

I think the biggest problem with our twine and duct tape page reclaim scheme is that somehow *works* (for some value of works).

And intermediate steps like this are likely to upset its fragile workings even though they really should be better solutions.

I think we branch a new tree for all interested VM developers to work on and try to get performing well. Probably try to restrict it to page reclaim and related fundamentals so it stays as small as possible and worth testing.

I would be interested in helping to maintain such a tree (we would have it track 2.6, of course). I have a whole load of patches and things here that I need to do something with some day (many of them are probabably crap!).

Any thoughts? If positive, any ideas about what sort of format? Maybe an akpm style tree (although probably not tracking Linus' head quite so fast)? Names? Same style as -mm trees? -vm?

Nick

Signature · 1 line
SUSE Labs, Novell Inc.

Changes mark_page_accessed to only set the PageAccessed bit, and not move pages around the LRUs. This means we don't have to take the lru_lock, and it also makes page ageing and scanning more consistient and all handled in mm/vmscan.c

---

 linux-2.6-npiggin/include/linux/swap.h |    8 +++++--
 linux-2.6-npiggin/mm/filemap.c         |   16 ++------------
 linux-2.6-npiggin/mm/shmem.c           |    6 -----
 linux-2.6-npiggin/mm/swap.c            |   36 ---------------------------------
 linux-2.6-npiggin/mm/swapfile.c        |    6 ++---
 5 files changed, 13 insertions(+), 59 deletions(-)
mm/filemap.c renamed from mm/filemap.c~vm-mark_page_accessed +3 -13
diff -puN mm/filemap.c~vm-mark_page_accessed mm/filemap.c
@@ -438,10 +438,8 @@ EXPORT_SYMBOL(unlock_page);
  */
 void end_page_writeback(struct page *page)
 {
-	if (!TestClearPageReclaim(page) || rotate_reclaimable_page(page)) {
-		if (!test_clear_page_writeback(page))
-			BUG();
-	}
+	if (!test_clear_page_writeback(page))
+		BUG();
 	smp_mb__after_clear_bit();
 	wake_up_page(page, PG_writeback);
 }
@@ -693,7 +691,6 @@ void do_generic_mapping_read(struct addr
 	unsigned long offset;
 	unsigned long req_size;
 	unsigned long next_index;
-	unsigned long prev_index;
 	loff_t isize;
 	struct page *cached_page;
 	int error;
@@ -702,7 +699,6 @@ void do_generic_mapping_read(struct addr
 	cached_page = NULL;
 	index = *ppos >> PAGE_CACHE_SHIFT;
 	next_index = index;
-	prev_index = ra.prev_page;
 	req_size = (desc->count + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
 	offset = *ppos & ~PAGE_CACHE_MASK;
 
@@ -752,13 +748,7 @@ page_ok:
 		if (mapping_writably_mapped(mapping))
 			flush_dcache_page(page);
 
-		/*
-		 * When (part of) the same page is read multiple times
-		 * in succession, only mark it as accessed the first time.
-		 */
-		if (prev_index != index)
-			mark_page_accessed(page);
-		prev_index = index;
+		mark_page_accessed(page);
 
 		/*
 		 * Ok, we have the page, and it's up-to-date, so
mm/swap.c renamed from mm/swap.c~vm-mark_page_accessed +0 -36
diff -puN mm/swap.c~vm-mark_page_accessed mm/swap.c
@@ -96,42 +96,6 @@ int rotate_reclaimable_page(struct page 
 	return 0;
 }
 
-/*
- * FIXME: speed this up?
- */
-void fastcall activate_page(struct page *page)
-{
-	struct zone *zone = page_zone(page);
-
-	spin_lock_irq(&zone->lru_lock);
-	if (PageLRU(page) && !PageActive(page)) {
-		del_page_from_inactive_list(zone, page);
-		SetPageActive(page);
-		add_page_to_active_list(zone, page);
-		inc_page_state(pgactivate);
-	}
-	spin_unlock_irq(&zone->lru_lock);
-}
-
-/*
- * Mark a page as having seen activity.
- *
- * inactive,unreferenced	->	inactive,referenced
- * inactive,referenced		->	active,unreferenced
- * active,unreferenced		->	active,referenced
- */
-void fastcall mark_page_accessed(struct page *page)
-{
-	if (!PageActive(page) && PageReferenced(page) && PageLRU(page)) {
-		activate_page(page);
-		ClearPageReferenced(page);
-	} else if (!PageReferenced(page)) {
-		SetPageReferenced(page);
-	}
-}
-
-EXPORT_SYMBOL(mark_page_accessed);
-
 /**
  * lru_cache_add: add a page to the page lists
  * @page: the page to add
include/linux/swap.h renamed from include/linux/swap.h~vm-mark_page_accessed +6 -2
diff -puN include/linux/swap.h~vm-mark_page_accessed include/linux/swap.h
@@ -165,12 +165,16 @@ extern unsigned int nr_free_pagecache_pa
 /* linux/mm/swap.c */
 extern void FASTCALL(lru_cache_add(struct page *));
 extern void FASTCALL(lru_cache_add_active(struct page *));
-extern void FASTCALL(activate_page(struct page *));
-extern void FASTCALL(mark_page_accessed(struct page *));
 extern void lru_add_drain(void);
 extern int rotate_reclaimable_page(struct page *page);
 extern void swap_setup(void);
 
+/* Mark a page as having seen activity. */
+#define mark_page_accessed(page)	\
+do {					\
+	SetPageReferenced(page);	\
+} while (0)
+
 /* linux/mm/vmscan.c */
 extern int try_to_free_pages(struct zone **, unsigned int, unsigned int);
 extern int shrink_all_memory(int);

diff -puN include/linux/mm_inline.h~vm-mark_page_accessed include/linux/mm_inline.h diff -puN mm/memory.c~vm-mark_page_accessed mm/memory.c

mm/shmem.c renamed from mm/shmem.c~vm-mark_page_accessed +1 -5
diff -puN mm/shmem.c~vm-mark_page_accessed mm/shmem.c
@@ -1523,11 +1523,7 @@ static void do_shmem_file_read(struct fi
 			 */
 			if (mapping_writably_mapped(mapping))
 				flush_dcache_page(page);
-			/*
-			 * Mark the page accessed if we read the beginning.
-			 */
-			if (!offset)
-				mark_page_accessed(page);
+			mark_page_accessed(page);
 		} else
 			page = ZERO_PAGE(0);
 

diff -puN include/linux/buffer_head.h~vm-mark_page_accessed include/linux/buffer_head.h

mm/swapfile.c renamed from mm/swapfile.c~vm-mark_page_accessed +3 -3
diff -puN mm/swapfile.c~vm-mark_page_accessed mm/swapfile.c
@@ -467,10 +467,10 @@ static unsigned long unuse_pmd(struct vm
 			pte_unmap(pte);
 
 			/*
-			 * Move the page to the active list so it is not
-			 * immediately swapped out again after swapon.
+			 * Touch the page so it is not immediately swapped
+			 * out again after swapon.
 			 */
-			activate_page(page);
+			mark_page_accessed(page);
 
 			/* add 1 since address may be 0 */
 			return 1 + address;

_

---

 linux-2.6-npiggin/include/linux/mm_inline.h  |    1 
 linux-2.6-npiggin/include/linux/page-flags.h |    8 +++
 linux-2.6-npiggin/mm/swap.c                  |    2 
 linux-2.6-npiggin/mm/vmscan.c                |   62 ++++++++++++++++-----------
 mm/page_alloc.c                              |    0 
 5 files changed, 49 insertions(+), 24 deletions(-)
mm/vmscan.c renamed from mm/vmscan.c~vm-page-skipped +38 -24

111 lines not on this page · raw message

include/linux/page-flags.h renamed from include/linux/page-flags.h~vm-page-skipped +8 -0
diff -puN include/linux/page-flags.h~vm-page-skipped include/linux/page-flags.h
@@ -76,6 +76,8 @@
 #define PG_reclaim		18	/* To be reclaimed asap */
 #define PG_nosave_free		19	/* Free, should not be written */
 
+#define PG_usedonce		20	/* LRU page has been touched once */
+
 
 /*
  * Global page accounting.  One instance per CPU.  Only unsigned longs are
@@ -293,6 +295,12 @@ extern void __mod_page_state(unsigned of
 #define SetPageCompound(page)	set_bit(PG_compound, &(page)->flags)
 #define ClearPageCompound(page)	clear_bit(PG_compound, &(page)->flags)
 
+#define PageUsedOnce(page)	test_bit(PG_usedonce, &(page)->flags)
+#define SetPageUsedOnce(page)	set_bit(PG_usedonce, &(page)->flags)
+#define TestSetPageUsedOnce(page) test_and_set_bit(PG_usedonce, &(page)->flags)
+#define ClearPageUsedOnce(page)	clear_bit(PG_usedonce, &(page)->flags)
+#define TestClearPageUsedOnce(page) test_and_clear_bit(PG_usedonce, &(page)->flags)
+
 #ifdef CONFIG_SWAP
 #define PageSwapCache(page)	test_bit(PG_swapcache, &(page)->flags)
 #define SetPageSwapCache(page)	set_bit(PG_swapcache, &(page)->flags)

diff -puN mm/truncate.c~vm-page-skipped mm/truncate.c

mm/swap.c renamed from mm/swap.c~vm-page-skipped +2 -0
diff -puN mm/swap.c~vm-page-skipped mm/swap.c
@@ -267,6 +267,7 @@ void __pagevec_lru_add(struct pagevec *p
 		}
 		if (TestSetPageLRU(page))
 			BUG();
+		ClearPageUsedOnce(page);
 		add_page_to_inactive_list(zone, page);
 	}
 	if (zone)
@@ -296,6 +297,7 @@ void __pagevec_lru_add_active(struct pag
 			BUG();
 		if (TestSetPageActive(page))
 			BUG();
+		ClearPageUsedOnce(page);
 		add_page_to_active_list(zone, page);
 	}
 	if (zone)

diff -puN include/linux/swap.h~vm-page-skipped include/linux/swap.h

include/linux/mm_inline.h renamed from include/linux/mm_inline.h~vm-page-skipped +1 -0
diff -puN include/linux/mm_inline.h~vm-page-skipped include/linux/mm_inline.h
@@ -35,6 +35,7 @@ del_page_from_lru(struct zone *zone, str
 		ClearPageActive(page);
 		zone->nr_active--;
 	} else {
+		ClearPageUsedOnce(page);
 		zone->nr_inactive--;
 	}
 }

diff -puN mm/page_alloc.c~vm-page-skipped mm/page_alloc.c

_

#2 lore raw

Re: [RFC] how do we move the VM forward? (was Re: [RFC] cleanup of use-once)

Quoted 7 lines · Nick Piggin

I think the biggest problem with our twine and duct tape page reclaim scheme is that somehow *works* (for some value of works).

I think we branch a new tree for all interested VM developers to work on and try to get performing well. Probably try to restrict it to page reclaim and related fundamentals so it stays as small as possible and worth testing.

Sounds great. I'd be willing to maintain a quilt tree for this - in fact, I've already got a few patches ;)

Also, we should probably keep track of exactly what we're working towards. I've put my ideas on a wiki page, feel free to add yours - probably a new page for stuff that's not page replacement related ;)

http://wiki.linux-mm.org/wiki/AdvancedPageReplacement

Signature · 8 lines
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it." - Brian W. Kernighan
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#3 lore raw

Re: [RFC] how do we move the VM forward? (was Re: [RFC] cleanup of use-once)

Quoted 6 lines · Rik van Riel
Quoted 2 lines · Nick Piggin

I think the biggest problem with our twine and duct tape page reclaim scheme is that somehow *works* (for some value of works).

Quoted 9 lines
Quoted 4 lines

I think we branch a new tree for all interested VM developers to work on and try to get performing well. Probably try to restrict it to page reclaim and related fundamentals so it stays as small as possible and worth testing.

Sounds great. I'd be willing to maintain a quilt tree for this - in fact, I've already got a few patches ;)

OK I'll help maintain and review patches.

Also having a box or two for running regression and stress testing is a must. I can do a bit here, but unfortunately "kernel compiles until it hurts" is probably not the best workload to target.

In general most systems and their workloads aren't constantly swapping, so we should aim to minimise IO for normal workloads. Databases that use the pagecache (eg. postgresql) would be a good test. But again we don't want to focus on one thing.

That said, of course we don't want to hurt the "really thrashing" case - and hopefully improve it if possible.

Quoted 5 lines

Also, we should probably keep track of exactly what we're working towards. I've put my ideas on a wiki page, feel free to add yours - probably a new page for stuff that's not page replacement related ;)

I guess some of those page replacement algorithms would be really interesting to explore - and we definitely should be looking into them at some stage as part of our -vm tree.

Though my initial aims are to first simplify and rationalise and unify things where possible.

NUMA "issues" related to page reclaim are also interesting to me.

I'll try to get some time to get my patches into shape in the next week or so.

Signature · 7 lines
SUSE Labs, Novell Inc.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#4 lore raw

Re: [RFC] how do we move the VM forward? (was Re: [RFC] cleanup ofuse-once)

Quoted 6 lines · Nick Piggin

Also having a box or two for running regression and stress testing is a must. I can do a bit here, but unfortunately "kernel compiles until it hurts" is probably not the best workload to target.

Quoted 8 lines

In general most systems and their workloads aren't constantly swapping, so we should aim to minimise IO for normal workloads. Databases that use the pagecache (eg. postgresql) would be a good test. But again we don't want to focus on one thing.

That said, of course we don't want to hurt the "really thrashing" case - and hopefully improve it if possible.

may I suggest useing OpenOffice as one test, it can eat up horrendous amounts of ram in operation (I have one spreadsheet I can send you if needed that takes 45min of cpu time on a Athlon64 3200 with 1G of ram just to open, at which time it shows openoffice takeing more then 512M of ram)

David Lang

Signature · 7 lines
There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies.
 -- C.A.R. Hoare
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#5 lore raw

Re: [RFC] how do we move the VM forward? (was Re: [RFC] cleanup ofuse-once)

Quoted 7 lines · David Lang
Quoted 5 lines · Nick Piggin

Also having a box or two for running regression and stress testing is a must. I can do a bit here, but unfortunately "kernel compiles until it hurts" is probably not the best workload to target.

if there are some tests or output (kernel logs, etc) or proc info or vmstat or whatever, which doesn't take 100% cpu time, I'm able and willing to test it on different workloads (including compiling the kernel until it hurts ;)

Quoted 6 lines
Quoted 6 lines

In general most systems and their workloads aren't constantly swapping, so we should aim to minimise IO for normal workloads. Databases that use the pagecache (eg. postgresql) would be a good test. But again we don't want to focus on one thing.

Quoted 7 lines
Quoted 2 lines

That said, of course we don't want to hurt the "really thrashing" case - and hopefully improve it if possible.

may I suggest useing OpenOffice as one test, it can eat up horrendous amounts of ram in operation (I have one spreadsheet I can send you if needed that takes 45min of cpu time on a Athlon64 3200 with 1G of ram just to open, at which time it shows openoffice takeing more then 512M of ram)

cool, looks like they are taking the MS compatibility really serious nowadays ...

best,
Herbert

Quoted 12 lines

David Lang

Signature · 9 lines
There are two ways of constructing a software design. One way is to make it 
so simple that there are obviously no deficiencies. And the other way is to 
make it so complicated that there are no obvious deficiencies.
 -- C.A.R. Hoare
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#6 lore raw

Re: [RFC] how do we move the VM forward? (was Re: [RFC] cleanup ofuse-once)

Quoted 3 lines · Herbert Poetzl

cool, looks like they are taking the MS compatibility really serious nowadays ...

Um... I don't know when you last used Windows, but most Linux desktop GUI apps are way more bloated than the Windows counterparts. Take a look at some of the Gnome bounties for reducing bloat - some of them are just embarassing.

Quick demo: with a recent Gnome, open the file selector dialog, and browse to /usr/bin. The disk goes nuts for 20 seconds before the file list is even displayed. Now hit cancel and try it again. No disk activity this time, but the CPU pegs for 7-8 seconds before the files are displayed.

Now try the same on Windows. It's instantaneous.

Lee

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#7 lore raw

Re: [RFC] how do we move the VM forward? (was Re: [RFC] cleanup ofuse-once)

In reply to Herbert Poetzl
Quoted 9 lines · --On Friday, May 20, 2005 20:16:06 +0200 Herbert Poetzl <[email protected]>…
Quoted 7 lines · David Lang
Quoted 5 lines · Nick Piggin

Also having a box or two for running regression and stress testing is a must. I can do a bit here, but unfortunately "kernel compiles until it hurts" is probably not the best workload to target.

Quoted 4 lines

if there are some tests or output (kernel logs, etc) or proc info or vmstat or whatever, which doesn't take 100% cpu time, I'm able and willing to test it on different workloads (including compiling the kernel until it hurts ;)

I did take that patch and run a bunch of tests on it across a few different architectures. everything worked fine, no perf differnences either way ... but then I may not have actually put it under memory pressure, so it might not be ideal testing ;-)

M.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#8 lore raw
In reply to Rik van Riel
Quoted 12 lines · Rik van Riel

The special cases in the use-once code have annoyed me for a while, and I'd like to see if replacing them with something simpler could be worthwhile.

I haven't actually benchmarked (or even tested) this code yet, but the basic idea is that we want to ignore multiple references to the same page if they happen really close to each other, and only keep a page on the active list if it got accessed again on a time scale that matters to the pageout code. In other words, filtering out correlated references in a simpler way.

Opinions ?

[...]

mm/swap.c void fastcall activate_page(struct page · line 123

Quoted 12 lines

- * active,unreferenced -> active,referenced
*/
void fastcall mark_page_accessed(struct page *page) {

mm/swap.c +1 -5
-	if (!PageActive(page) && PageReferenced(page) && PageLRU(page)) {
-		activate_page(page);
-		ClearPageReferenced(page);
-	} else if (!PageReferenced(page)) {
+	if (!PageReferenced(page))
 		SetPageReferenced(page);
-	}
 }

So file system pages never get to the active list? Hmm... this doesn't sound right.

Quoted 4 lines

EXPORT_SYMBOL(mark_page_accessed);

mm/swap.c +0 -0
@@ -157,6 +149,7 @@ void fastcall lru_cache_add_active(struc
 	if (!pagevec_add(pvec, page))

[...]

mm/vmscan.c static int shrink_list(struct list_head · line 386

Quoted 12 lines
mm/vmscan.c +6 -2
 			goto keep_locked;
 
 		referenced = page_referenced(page, 1, sc->priority <= 0);
-		/* In active use or really unfreeable?  Activate it. */
-		if (referenced && page_mapping_inuse(page))
+
+		if (referenced) {
+			/* New page. Let's see if it'll get used again... */
+			if (TestClearPageNew(page))
+				goto keep_locked;
 			goto activate_locked;
+		}

This will screw scanning most likely: no referenced page is ever reclaimed unless lowest scanning priority is reached---this looks like sure way to oom and has capacity to increase CPU consumption significantly.

Quoted 2 lines

#ifdef CONFIG_SWAP

Nikita.

#9 lore raw
Quoted 2 lines · Nikita Danilov

So file system pages never get to the active list? Hmm... this doesn't sound right.

Yes they will, I changed vmscan.c to compensate.

Quoted 11 lines

mm/vmscan.c static int shrink_list(struct list_head · line 386

Quoted 6 lines
mm/vmscan.c +5 -0
+		if (referenced) {
+			/* New page. Let's see if it'll get used again... */
+			if (TestClearPageNew(page))
+				goto keep_locked;
 			goto activate_locked;
+		}

This will screw scanning most likely: no referenced page is ever reclaimed unless lowest scanning priority is reached---this looks like sure way to oom and has capacity to increase CPU consumption significantly.

Doubtful, the VM always manages to clear the referenced bits faster than they can be set, especially on pages that aren't even mapped!

The problem you describe should be a lot worse for mapped pages, where we already do not run into the problem, despite the VM taking no precautions.

Signature · 3 lines
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it." - Brian W. Kernighan