linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Take anonymous pages off the LRU if we have no swap
@ 2007-02-21 22:12 Christoph Lameter
  2007-02-21 23:17 ` Rik van Riel
  2007-02-22 17:21 ` Paul Menage
  0 siblings, 2 replies; 10+ messages in thread
From: Christoph Lameter @ 2007-02-21 22:12 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm

If the kernel was compiled without support for swapping then we have no means
of evicting anonymous pages and they become like mlocked pages.

Do not add new anonymous pages to the LRU and if we find one on the LRU 
then take it off. This is also going to reduce the overhead of allocating 
anonymous pages since the LRU lock must no longer be taken to put pages 
onto the active list. Probably mostly of interest to embedded systems 
since normal kernels support swap.

On linux-mm we also discussed taking anonymous pages off the LRU if there 
is no swap defined or not enough swap. However, there is no easy way of 
putting the pages back to the LRU since we have no list of mlocked pages. 
We could set up such a list but then list manipulation would complicate 
the mlocked page treatment and require taking the lru lock. I'd rather 
leave the mlocked handling as simple as it is right now.

Anonymous pages will be accounted as mlocked pages.

Signed-off-by: Christoph Lameter <clameter@sgi.com>

Index: linux-2.6.20-mm2/mm/memory.c
===================================================================
--- linux-2.6.20-mm2.orig/mm/memory.c	2007-02-21 13:53:15.000000000 -0800
+++ linux-2.6.20-mm2/mm/memory.c	2007-02-21 13:53:33.000000000 -0800
@@ -907,17 +907,26 @@
 				unsigned long address)
 {
 	inc_mm_counter(vma->vm_mm, anon_rss);
-	if (vma->vm_flags & VM_LOCKED) {
-		/*
-		 * Page is new and therefore not on the LRU
-		 * so we can directly mark it as mlocked
-		 */
-		SetPageMlocked(page);
-		ClearPageActive(page);
-		inc_zone_page_state(page, NR_MLOCK);
-	} else
-		lru_cache_add_active(page);
 	page_add_new_anon_rmap(page, vma, address);
+
+#ifdef CONFIG_SWAP
+	/*
+	 * It only makes sense to put anonymous pages on the
+	 * LRU if we have a way of evicting anonymous pages.
+	 */
+	if (!(vma->vm_flags & VM_LOCKED)) {
+		lru_cache_add_active(page);
+		return;
+	}
+#endif
+
+	/*
+	 * Page is new and therefore not on the LRU
+	 * so we can directly mark it as mlocked
+	 */
+	SetPageMlocked(page);
+	ClearPageActive(page);
+	inc_zone_page_state(page, NR_MLOCK);
 }
 
 /*
Index: linux-2.6.20-mm2/mm/vmscan.c
===================================================================
--- linux-2.6.20-mm2.orig/mm/vmscan.c	2007-02-21 13:53:15.000000000 -0800
+++ linux-2.6.20-mm2/mm/vmscan.c	2007-02-21 13:53:33.000000000 -0800
@@ -495,14 +495,16 @@
 		if (referenced && page_mapping_inuse(page))
 			goto activate_locked;
 
-#ifdef CONFIG_SWAP
 		/*
 		 * Anonymous process memory has backing store?
 		 * Try to allocate it some swap space here.
 		 */
 		if (PageAnon(page) && !PageSwapCache(page))
+#ifdef CONFIG_SWAP
 			if (!add_to_swap(page, GFP_ATOMIC))
 				goto activate_locked;
+#else
+			goto mlocked;
 #endif /* CONFIG_SWAP */
 
 		mapping = page_mapping(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/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Take anonymous pages off the LRU if we have no swap
  2007-02-21 22:12 [PATCH] Take anonymous pages off the LRU if we have no swap Christoph Lameter
@ 2007-02-21 23:17 ` Rik van Riel
  2007-02-22  0:06   ` Christoph Lameter
  2007-02-22 17:21 ` Paul Menage
  1 sibling, 1 reply; 10+ messages in thread
From: Rik van Riel @ 2007-02-21 23:17 UTC (permalink / raw)
  To: Christoph Lameter; +Cc: akpm, linux-mm

Christoph Lameter wrote:

> On linux-mm we also discussed taking anonymous pages off the LRU if there 
> is no swap defined or not enough swap. However, there is no easy way of 
> putting the pages back to the LRU since we have no list of mlocked pages. 

Chris,

I am working on a VM design that would take care of this issue in
a somewhat cleaner way.  I'm writing up the bits and pieces as I
find easy ways to explain them.

Want to help out with brainstorming and implementing?

http://linux-mm.org/PageReplacementDesign

-- 
Politics is the struggle between those who want to make their country
the best in the world, and those who believe it already is.  Each group
calls the other unpatriotic.

--
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>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Take anonymous pages off the LRU if we have no swap
  2007-02-21 23:17 ` Rik van Riel
@ 2007-02-22  0:06   ` Christoph Lameter
  2007-02-22  2:17     ` Rik van Riel
  0 siblings, 1 reply; 10+ messages in thread
From: Christoph Lameter @ 2007-02-22  0:06 UTC (permalink / raw)
  To: Rik van Riel; +Cc: akpm, linux-mm

On Wed, 21 Feb 2007, Rik van Riel wrote:

> I am working on a VM design that would take care of this issue in
> a somewhat cleaner way.  I'm writing up the bits and pieces as I
> find easy ways to explain them.
>
> Want to help out with brainstorming and implementing?
> 
> http://linux-mm.org/PageReplacementDesign

I do not see how this issue would be solved there. Sounds like an attempt 
to come up with requirements and some design ideas.

The patch here is just the leftover from last weeks discussion in which 
the ability to remove anonymous pages was requested. Which can be done
in the limited form presented here within the current code in mm.

--
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>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Take anonymous pages off the LRU if we have no swap
  2007-02-22  0:06   ` Christoph Lameter
@ 2007-02-22  2:17     ` Rik van Riel
  2007-02-22  3:09       ` Christoph Lameter
  0 siblings, 1 reply; 10+ messages in thread
From: Rik van Riel @ 2007-02-22  2:17 UTC (permalink / raw)
  To: Christoph Lameter; +Cc: akpm, linux-mm

Christoph Lameter wrote:
> On Wed, 21 Feb 2007, Rik van Riel wrote:
> 
>> I am working on a VM design that would take care of this issue in
>> a somewhat cleaner way.  I'm writing up the bits and pieces as I
>> find easy ways to explain them.
>>
>> Want to help out with brainstorming and implementing?
>>
>> http://linux-mm.org/PageReplacementDesign
> 
> I do not see how this issue would be solved there.

If there is no swap space, we do not bother scanning the anonymous
page pool.  When swap space becomes available, we may end up scanning
it again.

> The patch here is just the leftover from last weeks discussion in which 
> the ability to remove anonymous pages was requested. Which can be done
> in the limited form presented here within the current code in mm.

Yes, we can pile more limited fixes on top of the VM.  I suspect
that too many "limited fixes" on top of each other will just end
up introducing too many corner cases, though.

I would like to move the kernel towards something that fixes all
of the problem workloads, instead of thinking about one problem
at a time and reintroducing bugs for other workloads.

Changes still need to be introduced incrementally, of course, but
I think it would be good if we had an idea where we were headed
in the medium (or even long) term.

http://linux-mm.org/ProblemWorkloads

-- 
Politics is the struggle between those who want to make their country
the best in the world, and those who believe it already is.  Each group
calls the other unpatriotic.

--
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>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Take anonymous pages off the LRU if we have no swap
  2007-02-22  2:17     ` Rik van Riel
@ 2007-02-22  3:09       ` Christoph Lameter
  2007-02-22 12:13         ` Rik van Riel
  0 siblings, 1 reply; 10+ messages in thread
From: Christoph Lameter @ 2007-02-22  3:09 UTC (permalink / raw)
  To: Rik van Riel; +Cc: akpm, linux-mm

On Wed, 21 Feb 2007, Rik van Riel wrote:

> > > http://linux-mm.org/PageReplacementDesign
> > 
> > I do not see how this issue would be solved there.
> 
> If there is no swap space, we do not bother scanning the anonymous
> page pool.  When swap space becomes available, we may end up scanning
> it again.

Ok. This is for linux 3.0?

> I would like to move the kernel towards something that fixes all
> of the problem workloads, instead of thinking about one problem
> at a time and reintroducing bugs for other workloads.

Problem workloads appear as machines grow to handle more memory.
 
> Changes still need to be introduced incrementally, of course, but
> I think it would be good if we had an idea where we were headed
> in the medium (or even long) term.

That is difficult to foresee. I am pretty happy right now with what we 
have and it seems to be adaptable enough for different workloads. I am a 
bit concerned about the advanced page replacement algorithms since we 
toyed with them and only found advantages for specialized workloads. LRU 
is simple and easy to handle.

> http://linux-mm.org/ProblemWorkloads

Well these are not the problem workloads that we encounter. Databases seem 
to be using huge pages which are not subject to swap. The startup issue is 
not that easily handled since usually large portions of the code 
may no longer be needed. fadvise may help there.

The very large working set is likely solvable by introducing some 
notion of higher order pages. Higher order pages -> less scanning. We 
already have the issue of having to handle gazillions of page structs if 
we want to write a terabyte to disk. Higher order pages would solve the 
issues on multiple levels. The larger memory gets the more difficult it 
will be to manage the gazillions of ptes and page structs. The chunk that 
we manage needs to be changed. I do not think that the handling of the 
chunks will make much differents. Its a question of the sheer number of 
them.

--
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>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Take anonymous pages off the LRU if we have no swap
  2007-02-22  3:09       ` Christoph Lameter
@ 2007-02-22 12:13         ` Rik van Riel
  2007-02-22 15:35           ` Balbir Singh
  0 siblings, 1 reply; 10+ messages in thread
From: Rik van Riel @ 2007-02-22 12:13 UTC (permalink / raw)
  To: Christoph Lameter; +Cc: akpm, linux-mm

Christoph Lameter wrote:
> On Wed, 21 Feb 2007, Rik van Riel wrote:
> 
>>>> http://linux-mm.org/PageReplacementDesign
>>> I do not see how this issue would be solved there.
>> If there is no swap space, we do not bother scanning the anonymous
>> page pool.  When swap space becomes available, we may end up scanning
>> it again.
> 
> Ok. This is for linux 3.0?

No, I think the changes can be introduced one at a time,
after each change gets benchmarked.

>> I would like to move the kernel towards something that fixes all
>> of the problem workloads, instead of thinking about one problem
>> at a time and reintroducing bugs for other workloads.
> 
> Problem workloads appear as machines grow to handle more memory.

Absolutely.  I am convinced that the whole "swappiness" thing
of scanning past the anonymous pages in order to find the page
cache pages will fall apart on 256GB systems even with somewhat
friendly workloads.

It is already falling apart on some workloads with 32GB systems
today...

>> Changes still need to be introduced incrementally, of course, but
>> I think it would be good if we had an idea where we were headed
>> in the medium (or even long) term.
> 
> That is difficult to foresee. I am pretty happy right now with what we 
> have and it seems to be adaptable enough for different workloads. I am a 
> bit concerned about the advanced page replacement algorithms since we 
> toyed with them and only found advantages for specialized workloads. LRU 
> is simple and easy to handle.

Linux hasn't been near LRU since the 2.3 days.

-- 
Politics is the struggle between those who want to make their country
the best in the world, and those who believe it already is.  Each group
calls the other unpatriotic.

--
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>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Take anonymous pages off the LRU if we have no swap
  2007-02-22 12:13         ` Rik van Riel
@ 2007-02-22 15:35           ` Balbir Singh
  2007-02-22 17:04             ` Rik van Riel
  0 siblings, 1 reply; 10+ messages in thread
From: Balbir Singh @ 2007-02-22 15:35 UTC (permalink / raw)
  To: Rik van Riel; +Cc: Christoph Lameter, akpm, linux-mm, Vaidyanathan Srinivasan

Rik van Riel wrote:
> Christoph Lameter wrote:
>> On Wed, 21 Feb 2007, Rik van Riel wrote:
>>
> Absolutely.  I am convinced that the whole "swappiness" thing
> of scanning past the anonymous pages in order to find the page
> cache pages will fall apart on 256GB systems even with somewhat
> friendly workloads.
> 

That should probably make a good case for splitting the LRU
into unmapped and mapped page LRU's :-) I hope to get to it,
implement it and get some results.

A big global LRU is like a big piece of software that is requesting
to be broken up. Scanning through uninteresting pages (in my case
searching for pages belonging to particular container for my
memory controller) is a big overhead.


-- 
	Warm Regards,
	Balbir Singh

--
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>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Take anonymous pages off the LRU if we have no swap
  2007-02-22 15:35           ` Balbir Singh
@ 2007-02-22 17:04             ` Rik van Riel
  0 siblings, 0 replies; 10+ messages in thread
From: Rik van Riel @ 2007-02-22 17:04 UTC (permalink / raw)
  To: balbir; +Cc: Christoph Lameter, akpm, linux-mm, Vaidyanathan Srinivasan

Balbir Singh wrote:
> Rik van Riel wrote:
>> Christoph Lameter wrote:
>>> On Wed, 21 Feb 2007, Rik van Riel wrote:
>>>
>> Absolutely.  I am convinced that the whole "swappiness" thing
>> of scanning past the anonymous pages in order to find the page
>> cache pages will fall apart on 256GB systems even with somewhat
>> friendly workloads.
> 
> That should probably make a good case for splitting the LRU
> into unmapped and mapped page LRU's :-) 

Please read http://linux-mm.org/PageReplacementDesign.

There are good reasons why the split should probably be
between anonymous/swap backed and file backed pages,
not between mapped and unmapped.

> I hope to get to it, implement it and get some results.

Ditto here :)

-- 
All Rights Reversed

--
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>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Take anonymous pages off the LRU if we have no swap
  2007-02-21 22:12 [PATCH] Take anonymous pages off the LRU if we have no swap Christoph Lameter
  2007-02-21 23:17 ` Rik van Riel
@ 2007-02-22 17:21 ` Paul Menage
  2007-02-22 18:45   ` Christoph Lameter
  1 sibling, 1 reply; 10+ messages in thread
From: Paul Menage @ 2007-02-22 17:21 UTC (permalink / raw)
  To: Christoph Lameter; +Cc: akpm, linux-mm

On 2/21/07, Christoph Lameter <clameter@sgi.com> wrote:
> If the kernel was compiled without support for swapping then we have no means
> of evicting anonymous pages and they become like mlocked pages.

How will this interact with page migration?

In order to start migrating a page, the migration paths call
isolate_lru_page(), which returns -EBUSY if the page isn't on an LRU.

At a minimum, CONFIG_MIGRATION should either select or depend on CONFIG_SWAP.

Paul

--
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>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Take anonymous pages off the LRU if we have no swap
  2007-02-22 17:21 ` Paul Menage
@ 2007-02-22 18:45   ` Christoph Lameter
  0 siblings, 0 replies; 10+ messages in thread
From: Christoph Lameter @ 2007-02-22 18:45 UTC (permalink / raw)
  To: Paul Menage; +Cc: akpm, linux-mm

On Thu, 22 Feb 2007, Paul Menage wrote:

> On 2/21/07, Christoph Lameter <clameter@sgi.com> wrote:
> > If the kernel was compiled without support for swapping then we have no
> > means
> > of evicting anonymous pages and they become like mlocked pages.
> 
> How will this interact with page migration?

The same way as mlocked pages are handled.

> In order to start migrating a page, the migration paths call
> isolate_lru_page(), which returns -EBUSY if the page isn't on an LRU.

Not anymore. Check Andrew's tree.

--
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>

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2007-02-22 18:45 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-21 22:12 [PATCH] Take anonymous pages off the LRU if we have no swap Christoph Lameter
2007-02-21 23:17 ` Rik van Riel
2007-02-22  0:06   ` Christoph Lameter
2007-02-22  2:17     ` Rik van Riel
2007-02-22  3:09       ` Christoph Lameter
2007-02-22 12:13         ` Rik van Riel
2007-02-22 15:35           ` Balbir Singh
2007-02-22 17:04             ` Rik van Riel
2007-02-22 17:21 ` Paul Menage
2007-02-22 18:45   ` Christoph Lameter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox