All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nick Piggin <nickpiggin@yahoo.com.au>
To: Rik van Riel <riel@redhat.com>
Cc: Andrew Morton <akpm@osdl.org>, Paul Mackerras <paulus@samba.org>,
	brettspamacct@fastclick.com, jgarzik@pobox.com,
	linux-kernel@vger.kernel.org
Subject: Re: ~500 megs cached yet 2.6.5 goes into swap hell
Date: Fri, 30 Apr 2004 13:00:45 +1000	[thread overview]
Message-ID: <4091C15D.7040800@yahoo.com.au> (raw)
In-Reply-To: <Pine.LNX.4.44.0404291027050.9152-100000@chimarrao.boston.redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1060 bytes --]

Rik van Riel wrote:
> On Thu, 29 Apr 2004, Nick Piggin wrote:
> 
> 
>>I'm not very impressed with the pagecache use-once logic, and I
>>have a patch to remove it completely and treat non-mapped touches
>>(IMO) more sanely.
> 
> 
> The basic idea of use-once isn't bad (search for LIRS and
> ARC page replacement), however the Linux implementation
> doesn't have any of the checks and balances that the
> researched replacement algorithms have...
> 
> However, adding the checks and balancing required for LIRS,
> ARC and CAR(S) isn't easy since it requires keeping track of
> a number of recently evicted pages.  That could be quite a 
> bit of infrastructure, though it might be well worth it.
> 

No, use once logic is good in theory I think. Unfortunately
our implementation is quite fragile IMO (although it seems
to have been "good enough").

This is what I'm currently doing (on top of a couple of other
patches, but you get the idea). I should be able to transform
it into a proper use-once logic if I pick up Nikita's inactive
list second chance bit.


[-- Attachment #2: vm-dropbehind.patch --]
[-- Type: text/x-patch, Size: 3622 bytes --]


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 consistient
and all handled in mm/vmscan.c


 include/linux/buffer_head.h            |    0 
 linux-2.6-npiggin/include/linux/swap.h |    5 ++-
 linux-2.6-npiggin/mm/filemap.c         |    6 ----
 linux-2.6-npiggin/mm/swap.c            |   45 ---------------------------------
 4 files changed, 4 insertions(+), 52 deletions(-)

diff -puN mm/filemap.c~vm-dropbehind mm/filemap.c
--- linux-2.6/mm/filemap.c~vm-dropbehind	2004-04-29 17:31:38.000000000 +1000
+++ linux-2.6-npiggin/mm/filemap.c	2004-04-29 17:31:38.000000000 +1000
@@ -663,11 +663,7 @@ page_ok:
 		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);
 
 		/*
 		 * Ok, we have the page, and it's up-to-date, so
diff -puN mm/swap.c~vm-dropbehind mm/swap.c
--- linux-2.6/mm/swap.c~vm-dropbehind	2004-04-29 17:31:38.000000000 +1000
+++ linux-2.6-npiggin/mm/swap.c	2004-04-29 17:31:38.000000000 +1000
@@ -100,51 +100,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)
-		&& !PageActiveMapped(page) && !PageActiveUnmapped(page)) {
-
-		del_page_from_inactive_list(zone, page);
-
-		if (page_mapped(page)) {
-			SetPageActiveMapped(page);
-			add_page_to_active_mapped_list(zone, page);
-		} else {
-			SetPageActiveUnmapped(page);
-			add_page_to_active_unmapped_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 (!PageActiveMapped(page) && !PageActiveUnmapped(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
diff -puN include/linux/swap.h~vm-dropbehind include/linux/swap.h
--- linux-2.6/include/linux/swap.h~vm-dropbehind	2004-04-29 17:31:38.000000000 +1000
+++ linux-2.6-npiggin/include/linux/swap.h	2004-04-30 12:55:02.000000000 +1000
@@ -165,12 +165,13 @@ 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)	SetPageReferenced(page)
+
 /* 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-dropbehind include/linux/mm_inline.h
diff -puN mm/memory.c~vm-dropbehind mm/memory.c
diff -puN mm/shmem.c~vm-dropbehind mm/shmem.c
diff -puN include/linux/buffer_head.h~vm-dropbehind include/linux/buffer_head.h

_

  reply	other threads:[~2004-04-30  3:01 UTC|newest]

Thread overview: 128+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-28 21:27 ~500 megs cached yet 2.6.5 goes into swap hell Brett E.
2004-04-29  0:01 ` Andrew Morton
2004-04-29  0:10   ` Jeff Garzik
2004-04-29  0:21     ` Nick Piggin
2004-04-29  0:50       ` Wakko Warner
2004-04-29  0:53         ` Jeff Garzik
2004-04-29  0:54         ` Nick Piggin
2004-04-29  1:51           ` Tim Connors
2004-04-29 21:45         ` Denis Vlasenko
2004-04-29  0:58       ` Marc Singer
2004-04-29  3:48         ` Nick Piggin
2004-04-29  4:20           ` Marc Singer
2004-04-29  4:26             ` Nick Piggin
2004-04-29 14:49               ` Marc Singer
2004-04-30  4:08                 ` Nick Piggin
2004-04-30 22:31                   ` Marc Singer
2004-04-29  6:38             ` William Lee Irwin III
2004-04-29  7:36             ` Russell King
2004-04-29 10:44               ` Nick Piggin
2004-04-29 11:04                 ` Russell King
2004-04-29 14:52                   ` Marc Singer
2004-04-29 20:01       ` Horst von Brand
2004-04-29 20:18         ` Martin J. Bligh
2004-04-29 20:33         ` David B. Stevens
2004-04-29 22:42           ` Steve Youngs
2004-04-29 20:36         ` Paul Jackson
2004-04-29 21:19           ` Andrew Morton
2004-04-29 21:34             ` Paul Jackson
2004-04-29 21:57               ` Andrew Morton
2004-04-29 22:18                 ` Paul Jackson
2004-04-30  0:04                 ` Andy Isaacson
2004-04-30  0:32                   ` Andrew Morton
2004-04-30  0:54                     ` Paul Jackson
2004-04-30  5:38                       ` Andy Isaacson
2004-04-30  6:00                         ` Nick Piggin
2004-04-30  7:52                     ` Jeff Garzik
2004-04-30  8:02                       ` Andrew Morton
2004-04-30  8:09                         ` Jeff Garzik
2004-05-06 13:08             ` Pavel Machek
2004-05-07 15:53               ` Hugh Dickins
2004-05-07 16:57                 ` Pavel Machek
2004-05-07 17:30                   ` Timothy Miller
2004-05-07 17:43                     ` Hugh Dickins
2004-05-07 17:48                     ` Mark Frazer
2004-05-12 17:52                   ` Rob Landley
2004-05-17 20:16                     ` Hugh Dickins
2004-04-29 21:38           ` Timothy Miller
2004-04-29 21:47             ` Paul Jackson
2004-04-29 22:18               ` Timothy Miller
2004-04-29 22:46                 ` Paul Jackson
2004-04-29 23:08                   ` Timothy Miller
2004-04-30 12:31                     ` Bart Samwel
2004-04-30 15:35                       ` Clay Haapala
2004-04-30 15:44                         ` Bart Samwel
2004-04-30 22:11                       ` Paul Jackson
2004-04-30  3:37                 ` Tim Connors
2004-04-30  5:15         ` Nick Piggin
2004-04-30  6:20         ` Tim Connors
2004-04-30  6:34           ` Nick Piggin
2004-04-30  7:05             ` Tim Connors
2004-04-30  7:15               ` Nick Piggin
2004-04-30  9:18               ` Re[2]: " vda
2004-04-30  9:33                 ` Arjan van de Ven
2004-04-30 11:33                   ` Denis Vlasenko
2004-04-30 16:19                   ` Timothy Miller
2004-04-29  0:49     ` Brett E.
2004-04-29  1:00       ` Andrew Morton
2004-04-29  1:24         ` Jeff Garzik
2004-04-29  1:40           ` Andrew Morton
2004-04-29  1:47             ` Rik van Riel
2004-04-29 18:14               ` Adam Kropelin
2004-04-30  3:17                 ` Tim Connors
2004-04-29  2:19             ` Tim Connors
2004-04-29 16:24             ` Martin J. Bligh
2004-04-29 16:36               ` Chris Friesen
2004-04-29 16:56                 ` Martin J. Bligh
2004-04-29  1:30         ` Paul Mackerras
2004-04-29  1:31           ` Paul Mackerras
2004-04-29  1:53           ` Andrew Morton
2004-04-29  2:40             ` Andrew Morton
2004-04-29  2:58               ` Paul Mackerras
2004-04-29  3:09                 ` Andrew Morton
2004-04-29  3:14                 ` William Lee Irwin III
2004-04-29  6:12                 ` Benjamin Herrenschmidt
2004-04-29  6:22                   ` Andrew Morton
2004-04-29  6:25                     ` Benjamin Herrenschmidt
2004-04-29  6:31                   ` William Lee Irwin III
2004-04-29 16:50               ` Martin J. Bligh
2004-04-29  3:57             ` Nick Piggin
2004-04-29 14:29               ` Rik van Riel
2004-04-30  3:00                 ` Nick Piggin [this message]
2004-04-30 12:50                   ` Rik van Riel
2004-04-30 13:07                     ` Nick Piggin
2004-04-30 13:18                     ` Nikita Danilov
2004-04-30 13:39                       ` Nick Piggin
2004-04-29  1:46         ` Rik van Riel
2004-04-29  1:57           ` Andrew Morton
2004-04-29  2:29             ` Marc Singer
2004-04-29  2:35               ` Andrew Morton
2004-04-29  3:10                 ` Marc Singer
2004-04-29  3:19                   ` Andrew Morton
2004-04-29  4:13                     ` Marc Singer
2004-04-29  4:33                       ` Andrew Morton
2004-04-29 14:45                         ` Marc Singer
2004-04-29 16:51                     ` Andy Isaacson
2004-04-29 20:42                       ` Andrew Morton
2004-04-29 22:27                         ` Andy Isaacson
2004-04-29 23:19                           ` Andrew Morton
2004-04-30  0:14                       ` Lincoln Dale
2004-04-29  8:02                   ` Wichert Akkerman
2004-04-29 14:25                     ` Marcelo Tosatti
2004-04-29 14:27                       ` Wichert Akkerman
2004-04-29  2:41             ` Rik van Riel
2004-04-29  2:43               ` Andrew Morton
2004-04-29  1:41       ` Tim Connors
2004-04-29  9:43       ` Helge Hafting
2004-04-29 14:48         ` Marc Singer
2004-04-29  0:44   ` Brett E.
2004-04-29  1:13     ` Andrew Morton
2004-04-29  1:29       ` Brett E.
2004-04-29 18:05         ` Brett E.
2004-04-29 18:32           ` William Lee Irwin III
2004-04-29 20:47             ` Brett E.
2004-04-29  0:04 ` Brett E.
2004-04-29  0:13   ` Jeff Garzik
2004-04-29  0:43     ` Nick Piggin
2004-04-29 13:51   ` Horst von Brand
2004-04-29 18:32     ` Brett E.

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=4091C15D.7040800@yahoo.com.au \
    --to=nickpiggin@yahoo.com.au \
    --cc=akpm@osdl.org \
    --cc=brettspamacct@fastclick.com \
    --cc=jgarzik@pobox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulus@samba.org \
    --cc=riel@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.