Re: More info: 2.1.108 page cache performance on low memory

Dr. Werner Fink
1998-07-23T19:16:10Z

On Thu, Jul 23, 1998 at 12:59:38PM +0200, Zlatko Calusic wrote:
>
> I tried the other way, to age page cache harder, and it looks like it
> works very well. Patch is simple, so simple that I can't understand
> nobody suggested (something like) it yet.
>
>
> --- filemap.c.virgin Tue Jul 21 18:41:30 1998
> +++ filemap.c Thu Jul 23 12:14:43 1998
> @@ -171,6 +171,11 @@
> touch_page(page);
> break;
> }
> + /* Age named pages aggresively, so page cache
> + * doesn't grow too fast. -zcalusic
> + */
> + age_page(page);
> + age_page(page);
> age_page(page);
> if (page->age)
> break;
>

I've something similar ... cut&paste (no tabs) ... which would only do
less graduated ageing on small systems.

-------------------------------------------------------------------------------
diff -urN linux-2.1.110/include/linux/swapctl.h linux/include/linux/swapctl.h
--- linux-2.1.110/include/linux/swapctl.h Tue Jul 21 02:32:01 1998
+++ linux/include/linux/swapctl.h Wed Jul 22 18:04:28 1998
@@ -94,12 +94,26 @@
return n;
}

+extern int pgcache_max_age;
+extern void do_pgcache_max_age(void);
+
static inline void touch_page(struct page *page)
{
- if (page->age < (MAX_PAGE_AGE - PAGE_ADVANCE))
+ int max_age = MAX_PAGE_AGE;
+
+ if (atomic_read(&page->count) == 1) {
+ static int save_max_age = 0;
+ if (save_max_age != max_age) {
+ save_max_age = max_age;
+ do_pgcache_max_age();
+ }
+ max_age = pgcache_max_age;
+ }
+
+ if (page->age < (max_age - PAGE_ADVANCE))
page->age += PAGE_ADVANCE;
else
- page->age = MAX_PAGE_AGE;
+ page->age = max_age;
}

static inline void age_page(struct page *page)
diff -urN linux-2.1.110/include/linux/swapctl.h linux/include/linux/swapctl.h
--- linux-2.1.110/include/linux/swapctl.h Tue Jul 21 02:32:01 1998
+++ linux/include/linux/swapctl.h Wed Jul 22 18:04:28 1998
@@ -94,12 +94,26 @@
return n;
}

+extern int pgcache_max_age;
+extern void do_pgcache_max_age(void);
+
static inline void touch_page(struct page *page)
{
- if (page->age < (MAX_PAGE_AGE - PAGE_ADVANCE))
+ int max_age = MAX_PAGE_AGE;
+
+ if (atomic_read(&page->count) == 1) {
+ static int save_max_age = 0;
+ if (save_max_age != max_age) {
+ save_max_age = max_age;
+ do_pgcache_max_age();
+ }
+ max_age = pgcache_max_age;
+ }
+
+ if (page->age < (max_age - PAGE_ADVANCE))
page->age += PAGE_ADVANCE;
else
- page->age = MAX_PAGE_AGE;
+ page->age = max_age;
}

static inline void age_page(struct page *page)
-------------------------------------------------------------------------------

Werner