Subject: kern/17334: UBC swapout fix
To: None <gnats-bugs@gnats.netbsd.org>
From: None <wojtek@3miasto.net>
List: netbsd-bugs
Date: 06/20/2002 03:42:32
>Number:         17334
>Category:       kern
>Synopsis:       UBC swapout fix
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jun 20 03:43:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Wojciech Puchar
>Release:        1.6BETA2
>Organization:
TENSOR ap
>Environment:
NetBSD chylonia.3miasto.net 1.6_BETA2 NetBSD 1.6_BETA2 (local) #3: Thu Jun 20 12:32:27 CEST 2002     wojtek@chylonia.3miasto.net:/home/wojtek/kernel/local i386

>Description:
UBC tends to massively swapout everything on high I/O load


>How-To-Repeat:
copy large files and try to work same time.

UBC is broken be design IMHO. following patch is only partial fix of 
generally bad algorithm.


>Fix:
Index: uvm/uvm_object.h
===================================================================
RCS file: /cvsroot/syssrc/sys/uvm/uvm_object.h,v
retrieving revision 1.14
diff -u -r1.14 uvm_object.h
--- uvm/uvm_object.h    2001/10/30 15:32:05     1.14
+++ uvm/uvm_object.h    2002/03/22 05:21:26
@@ -73,6 +73,7 @@
 #ifdef _KERNEL
 
 extern struct uvm_pagerops uvm_vnodeops;
+extern struct uvm_pagerops aobj_pager;
 
 #define        UVM_OBJ_IS_VNODE(uobj)                                          \
        ((uobj)->pgops == &uvm_vnodeops)
@@ -81,6 +82,8 @@
        ((uobj)->pgops == &uvm_vnodeops &&                              \
         ((struct vnode *)uobj)->v_flag & VEXECMAP)
 
+#define        UVM_OBJ_IS_AOBJ(uobj)                                           \
+       ((uobj)->pgops == &aobj_pager)
 
 #endif /* _KERNEL */
 
Index: uvm/uvm_page.c
===================================================================
RCS file: /cvsroot/syssrc/sys/uvm/uvm_page.c,v
retrieving revision 1.74
diff -u -r1.74 uvm_page.c
--- uvm/uvm_page.c      2002/02/20 07:06:56     1.74
+++ uvm/uvm_page.c      2002/03/22 05:21:34
@@ -172,6 +172,10 @@
        TAILQ_INSERT_TAIL(buck, pg, hashq);
        simple_unlock(&uvm.hashlock);
 
+       if (UVM_OBJ_IS_AOBJ(uobj)) {
+               uvmexp.anonpages++;
+       }
+
        TAILQ_INSERT_TAIL(&uobj->memq, pg, listq);
        pg->flags |= PG_TABLED;
        uobj->uo_npages++;
@@ -201,6 +205,8 @@
                uvmexp.execpages--;
        } else if (UVM_OBJ_IS_VNODE(uobj)) {
                uvmexp.filepages--;
+       } else if (UVM_OBJ_IS_AOBJ(uobj)) {
+               uvmexp.anonpages--;
        }
 
        /* object should be locked */
Index: uvm/uvm_pdaemon.c
===================================================================
RCS file: /cvsroot/syssrc/sys/uvm/uvm_pdaemon.c,v
retrieving revision 1.45
diff -u -r1.45 uvm_pdaemon.c
--- uvm/uvm_pdaemon.c   2002/01/21 14:42:27     1.45
+++ uvm/uvm_pdaemon.c   2002/03/22 05:21:35
@@ -463,7 +463,7 @@
                                uvmexp.pdrefile++;
                                continue;
                        }
-                       if (anon && anonreact) {
+                       if ((anon || UVM_OBJ_IS_AOBJ(uobj)) && anonreact) {
                                uvm_pageactivate(p);
                                uvmexp.pdreanon++;
                                continue;


>Release-Note:
>Audit-Trail:
>Unformatted: