Subject: Re: My latest page scanner patch
To: None <thorpej@zembu.com>
From: Lars Heidieker <paradoxix@heidieker.de>
List: tech-kern
Date: 01/27/2001 01:44:33
Jason R Thorpe wrote:

> Folks..
>
> Here is my latest page scanner patch.  Note that I'm still debating
> whether or not to clear_reference or actually deactivate the pages
> in the aobj/map "clean" path, tho I'm leaning towards deactivate (they
> go on the end of the list, so other references won't be penalized unless
> there's a free page shortage).
>
> I would really appreciate it if people would "cvs update" their
> sys/uvm directory and try this patch, and report to me any change
> in behavior (positive or negative) on their systems.
>
> --
>         -- Jason R. Thorpe <thorpej@zembu.com>
>

I started thinking again about my changes to the scanner and advanced the changes
(should avoid the mp-issue) and if you think about a big number of pages an the
active queue:

1->2->3->4->5->6->7->8->9->10->11->12->13->14
                 |                           |
  this one is referenced     reaching inactive target

then the queue will look like this on the next invocation

9->10->11->12->13->14->4

and this time 4 is far further away from the "start of scanning" then with the old
algorithm where it has been left uin front of the 9
and I add the case that vnode pages are deactivated no matter if they where
referenced.
This way "normal" pages get an advantage over vnode cache pages by "getting a
second round on the active queue"

lars

the patch on top of Jason R. Thorpes one:

--- uvm_pdaemon.c.old   Sat Jan 27 01:06:26 2001
+++ uvm_pdaemon.c       Sat Jan 27 01:19:13 2001
@@ -963,7 +963,7 @@
 void
 uvmpd_scan()
 {
-       int s, free, inactive_shortage, swap_shortage, pages_freed;
+       int s, free, inactive_shortage, swap_shortage, pages_freed, active_count;
        struct vm_page *p, *nextpg;
        struct uvm_object *uobj;
        boolean_t got_it;
@@ -1041,8 +1041,11 @@

        UVMHIST_LOG(pdhist, "  loop 2: inactive_shortage=%d swap_shortage=%d",
                    inactive_shortage, swap_shortage,0,0);
+
+        active_count = uvmexp.active;
        for (p = TAILQ_FIRST(&uvm.page_active);
-            p != NULL && (inactive_shortage > 0 || swap_shortage > 0);
+            p != NULL && (inactive_shortage > 0 || swap_shortage > 0) &&
+             --active_count > 0;
             p = nextpg) {
                nextpg = TAILQ_NEXT(p, pageq);
                if (p->flags & PG_BUSY)
@@ -1109,12 +1112,18 @@
                 * shortage of inactive pages.
                 */

-               if (inactive_shortage > 0 &&
-                   pmap_clear_reference(p) == FALSE) {
-                       /* no need to check wire_count as pg is "active" */
-                       uvm_pagedeactivate(p);
-                       uvmexp.pddeact++;
-                       inactive_shortage--;
+               if (inactive_shortage > 0 ) {
+                        if((pmap_clear_reference(p) == FALSE) ||
+                           (p->uobject != NULL &&
+                           p->uobject->pgops == &uvm_vnodeops)) {
+                            /* no need to check wire_count as pg is "active"
*/+                            uvm_pagedeactivate(p);
+                            uvmexp.pddeact++;
+                            inactive_shortage--;
+                        } else {
+                            TAILQ_REMOVE(&uvm.page_active, p, pageq);
+                            TAILQ_INSERT_TAIL(&uvm.page_active, p, pageq);
+                        }
                }
                if (p->pqflags & PQ_ANON)
                        simple_unlock(&p->uanon->an_lock);