]> git.lizzy.rs Git - plan9front.git/commitdiff
kernel: introduce devswap #¶ to serve /dev/swap and handle swapfile encryption
authorcinap_lenrek <cinap_lenrek@felloff.net>
Sun, 29 Oct 2017 22:09:54 +0000 (23:09 +0100)
committercinap_lenrek <cinap_lenrek@felloff.net>
Sun, 29 Oct 2017 22:09:54 +0000 (23:09 +0100)
45 files changed:
lib/namespace
sys/man/3/cons
sys/man/3/swap [new file with mode: 0644]
sys/man/8/swap
sys/src/9/bcm/main.c
sys/src/9/bcm/mkfile
sys/src/9/bcm/picpuf
sys/src/9/bcm/pif
sys/src/9/boot/bootrc
sys/src/9/kw/main.c
sys/src/9/kw/mkfile
sys/src/9/kw/plug
sys/src/9/mtx/main.c
sys/src/9/mtx/mkfile
sys/src/9/mtx/mtx
sys/src/9/mtx/mtxcpu
sys/src/9/omap/beagle
sys/src/9/omap/main.c
sys/src/9/omap/mkfile
sys/src/9/pc/main.c
sys/src/9/pc/mkfile
sys/src/9/pc/pc
sys/src/9/pc64/main.c
sys/src/9/pc64/mkfile
sys/src/9/pc64/pc64
sys/src/9/port/devcons.c
sys/src/9/port/devswap.c [new file with mode: 0644]
sys/src/9/port/portfns.h
sys/src/9/port/portmkfile
sys/src/9/port/swap.c [deleted file]
sys/src/9/ppc/blast
sys/src/9/ppc/main.c
sys/src/9/ppc/mkfile
sys/src/9/sgi/indy
sys/src/9/sgi/main.c
sys/src/9/sgi/mkfile
sys/src/9/teg2/main.c
sys/src/9/teg2/mkfile
sys/src/9/teg2/ts
sys/src/9/xen/main.c
sys/src/9/xen/mkfile
sys/src/9/xen/xenpcf
sys/src/9/zynq/main.c
sys/src/9/zynq/mkfile
sys/src/9/zynq/zynq

index f98f62a2aa20026733208d706533ae8dea1b7b53..105e34be8e2b709e0579aa4aef2ace4bb2213dcb 100644 (file)
@@ -10,6 +10,7 @@ bind #p /proc
 bind -c #s /srv
 bind -q #σ /shr
 bind -a #¤ /dev
+bind -qa #¶ /dev
 
 # authentication
 mount -b /srv/factotum /mnt
index d9f75368a74f7c12cff5b2c9ac9dbdea9dd9190d..b898ebbabcbf6d0042bd0b84e9ac0603c82849c2 100644 (file)
@@ -22,7 +22,6 @@ cons \- console, clocks, process/process group ids, user, null, reboot, etc.
 .B /dev/ppid
 .B /dev/random
 .B /dev/reboot
-.B /dev/swap
 .B /dev/sysname
 .B /dev/sysstat
 .B /dev/time
@@ -240,41 +239,6 @@ Writing anything to
 .B sysstat
 resets all of the counts on all processors.
 .PP
-The
-.B swap
-device holds a text block giving memory usage statistics:
-.IP
-.EX
-\fIn\fP memory
-\fIn\fP pagesize
-\fIn\fP kernel
-\fIn\fP/\fIm\fP user
-\fIn\fP/\fIm\fP swap
-\fIa\fP/\fIn\fP/\fIm\fP kernel malloc
-\fIa\fP/\fIn\fP/\fIm\fP kernel draw
-.EE
-.PP
-These are total memory (bytes), system page size (bytes),
-kernel memory (pages), user memory (pages), swap space (pages),
-kernel malloced data (bytes), and kernel graphics data (bytes).
-The expression
-.IR n / m
-indicates
-.I n
-used out of
-.I m
-available.
-For kernel malloc and kernel draw,
-.IR a
-indicates the current allocation in bytes.
-These numbers are not blank padded.
-.PP
-To turn on swapping, write to
-.B swap
-the textual file descriptor number of a file or device on which to swap.
-See
-.IR swap (8).
-.PP
 Reads and writes to
 .IR mordor
 will inevitably cause the front to fall off.
diff --git a/sys/man/3/swap b/sys/man/3/swap
new file mode 100644 (file)
index 0000000..09ffbdb
--- /dev/null
@@ -0,0 +1,46 @@
+.TH SWAP 3
+.SH NAME
+swap \- memory usage statistics and pagefile control
+.SH SYNOPSIS
+.nf
+.B bind -a #¶ /dev
+
+.B /dev/swap
+.fi
+.SH DESCRIPTION
+The
+.B swap
+device holds a text block giving memory usage statistics:
+.IP
+.EX
+\fIn\fP memory
+\fIn\fP pagesize
+\fIn\fP kernel
+\fIn\fP/\fIm\fP user
+\fIn\fP/\fIm\fP swap
+\fIa\fP/\fIn\fP/\fIm\fP kernel malloc
+\fIa\fP/\fIn\fP/\fIm\fP kernel draw
+.EE
+.PP
+These are total memory (bytes), system page size (bytes),
+kernel memory (pages), user memory (pages), swap space (pages),
+kernel malloced data (bytes), and kernel graphics data (bytes).
+The expression
+.IR n / m
+indicates
+.I n
+used out of
+.I m
+available.
+For kernel malloc and kernel draw,
+.IR a
+indicates the current allocation in bytes.
+These numbers are not blank padded.
+.PP
+To turn on swapping, write to
+.B swap
+the textual file descriptor number of a file or device on which to swap.
+.SH SEE ALSO
+.IR swap (8).
+.SH SOURCE
+.B /sys/src/9/port/devswap.c
index aa0c811a17bec84a13c3e8b904ae3245df30f732..872d416520aa27a76ee01b90b6f7a024731647e5 100644 (file)
@@ -35,4 +35,5 @@ will lead to deadlock if the process isn't made non-swappable
 ctl-message in
 .IR proc (3)).
 .SH "SEE ALSO"
+.IR swap (3),
 .IR proc (3)
index 69fb61bb19a8213854584e341b13195eb900e603..4167f2b6fa27bb07a887103c0de362e9ef5b0b4c 100644 (file)
@@ -270,7 +270,6 @@ main(void)
        links();
        chandevreset();                 /* most devices are discovered here */
        pageinit();
-       swapinit();
        userinit();
        gpiomeminit();
        schedinit();
index 41b5438ef24e6b690f3ff2ac073921ae5847274a..e2bd4c1706124bbb52945039c84e7996443ac1dc 100644 (file)
@@ -33,7 +33,6 @@ PORT=\
        rdb.$O\
        rebootcmd.$O\
        segment.$O\
-       swap.$O\
        syscallfmt.$O\
        sysfile.$O\
        sysproc.$O\
index 70cd23eff778b4b4f1c9539085758a5dec4c0306..b2c5ab3779d1816d77e339b1bf366018ea9ba7e7 100644 (file)
@@ -1,6 +1,7 @@
 dev
        root
        cons
+       swap
        env
        pipe
        proc
index fc9c040c5b36e91b8bbfaa5855b721c3d3d303d5..45f4c4394814f7232af40753da137d47f8ec0799 100644 (file)
@@ -1,6 +1,7 @@
 dev
        root
        cons
+       swap
        env
        pipe
        proc
index cf899fb9b7f6f7fc2c7f33cc99d46bdf70f4e814..f5f6fe5a6392fa7ab7498654ccb12f69d38d0178 100755 (executable)
@@ -10,7 +10,7 @@ unmount /root
 
 bind -q '#d' /fd
 bind -q '#p' /proc
-for(i in S f k æ t b m)
+for(i in ¶ P S f k æ t b m)
        bind -qa '#'^$i /dev
 
 # bind in an ip interface
index f2bc302dbc57833249ccef1dfe95b635246e8461..ff9a7ee34a55bd1707f89a5bc84d211f48e3a881 100644 (file)
@@ -322,7 +322,6 @@ wave(' ');
        chandevreset();                 /* most devices are discovered here */
 
        pageinit();
-       swapinit();
        userinit();
        schedinit();
        panic("schedinit returned");
index 219d06ffa6a6a560df08852884310214605c7809..8134b3bb23323808343272309313135981a5a2dd 100644 (file)
@@ -32,7 +32,6 @@ PORT=\
        qio.$O\
        qlock.$O\
        segment.$O\
-       swap.$O\
        syscallfmt.$O\
        sysfile.$O\
        sysproc.$O\
index 281d6837f07cfe0a28c1b912ee68671d10051117..1d0dc9471ca91ef2d4f50d35aa3e8b0e25bb2508 100644 (file)
@@ -3,6 +3,7 @@
 dev
        root
        cons
+       swap
        env
        pipe
        proc
index 564a197d7b4b87d44a4750cd94ca8b3bf29a7c3e..0b1f3401c7d52e9a632a5775d4da50bbbb052817 100644 (file)
@@ -35,7 +35,6 @@ main(void)
        links();
        chandevreset();
        pageinit();
-       swapinit();
        fpsave(&initfp);
        initfp.fpscr = 0;
        userinit();
index f1efadf6a1a648048d28e730c5ee043402fba3fb..daa4b3e81e1fea9ff0e01820138e4cd036dc424a 100644 (file)
@@ -30,7 +30,6 @@ PORT=\
        qlock.$O\
        rdb.$O\
        segment.$O\
-       swap.$O\
        sysfile.$O\
        sysproc.$O\
        taslock.$O\
index 01dcd101df761dfe0e8eae10909448be7d5ffa3b..5330459f5cd2c3a28d3c3e22e7364213db3e3796 100644 (file)
@@ -1,6 +1,7 @@
 dev
        root
        cons
+       swap
        arch
        pnp             pci
        env
index c95629847101b42ca122a8f0e82da3e85afb9542..3e08dd7633a545ea7fea0e544e052b2eb39f695b 100644 (file)
@@ -1,6 +1,7 @@
 dev
        root
        cons
+       swap
        arch
        pnp             pci
        env
index 5306731b0c7d369bb918e54bf8cf8043ca064b50..a292622779372c431941f7aff1b7baaa69a72cd1 100644 (file)
@@ -2,6 +2,7 @@
 dev
        root
        cons
+       swap
        env
        pipe
        proc
index 6ff256f34adcb41275924126dd64530b5422533e..598a3ac5018c206fe270110b1d62486da117fe17 100644 (file)
@@ -276,7 +276,6 @@ wave('l');
 //     i8250console();                 /* too early; see init0 */
 
        pageinit();
-       swapinit();
        userinit();
        schedinit();
 }
index 1b6fdef814bbe43eab0975efc91bc44459737bd9..c5b1f94c174efef76a20d87ca1c87aa65a4e9089 100644 (file)
@@ -33,7 +33,6 @@ PORT=\
        qio.$O\
        qlock.$O\
        segment.$O\
-       swap.$O\
        sysfile.$O\
        sysproc.$O\
        taslock.$O\
index 824259e3ae7191592c58a5e41657fa7907ed47ad..5408e69822b9582c073b6655802f916e98031b97 100644 (file)
@@ -62,7 +62,6 @@ main(void)
        chandevreset();
        netconsole();
        pageinit();
-       swapinit();
        userinit();
        schedinit();
 }
index 7aac934cccf33fb0171653dfbda791cb78ed50c1..63044be646f1912adec7341e8d6bc78e16198d91 100644 (file)
@@ -35,7 +35,6 @@ PORT=\
        rdb.$O\
        rebootcmd.$O\
        segment.$O\
-       swap.$O\
        syscallfmt.$O\
        sysfile.$O\
        sysproc.$O\
index 665b6dd816b4a63e4b5b8cadca09f1fb5b0ea79e..47e9da2c3ba008182ee961f2ed84bb3782430d1f 100644 (file)
@@ -2,6 +2,7 @@
 dev
        root
        cons
+       swap
        arch
        pnp             pci
        env
index 48e45a0d1f226be90a19b2eefca75ff01391ec9b..cc85fe76e8742ace5da4f8c168778d36e44e5aa6 100644 (file)
@@ -332,7 +332,6 @@ main()
        netconsole();
        preallocpages();
        pageinit();
-       swapinit();
        userinit();
        schedinit();
 }
index d8a436c351f4068bfd04bb905d96223a3333d33c..4d145dc2774e78a577959d04a75ae433171ebb57 100644 (file)
@@ -33,7 +33,6 @@ PORT=\
        rdb.$O\
        rebootcmd.$O\
        segment.$O\
-       swap.$O\
        syscallfmt.$O\
        sysfile.$O\
        sysproc.$O\
index 6ac8b5fab7e2b70990f619548b36a3358a471ec0..c347952dfa9505ae6863bb441d383eea957b4946 100644 (file)
@@ -2,6 +2,7 @@
 dev
        root
        cons
+       swap
        arch
        pnp             pci
        env
index 67e28a83a85ad288ab9d1bb6a05df61b60f10dfd..b6c2d87888b06c4db9da7bd19c950d6abcc7496a 100644 (file)
@@ -5,7 +5,6 @@
 #include       "fns.h"
 #include       "../port/error.h"
 
-#include       <pool.h>
 #include       <authsrv.h>
 
 void   (*consdebug)(void) = nil;
@@ -324,7 +323,6 @@ enum{
        Qppid,
        Qrandom,
        Qreboot,
-       Qswap,
        Qsysname,
        Qsysstat,
        Qtime,
@@ -357,7 +355,6 @@ static Dirtab consdir[]={
        "ppid",         {Qppid},        NUMSIZE,        0444,
        "random",       {Qrandom},      0,              0444,
        "reboot",       {Qreboot},      0,              0664,
-       "swap",         {Qswap},        0,              0664,
        "sysname",      {Qsysname},     0,              0664,
        "sysstat",      {Qsysstat},     0,              0666,
        "time",         {Qtime},        NUMSIZE+3*VLNUMSIZE,    0664,
@@ -471,8 +468,6 @@ consread(Chan *c, void *buf, long n, vlong off)
        int i, k, id;
        vlong offset = off;
        extern char configfile[];
-       extern Image fscache;
-       extern Image swapimage;
 
        if(n <= 0)
                return n;
@@ -592,33 +587,6 @@ consread(Chan *c, void *buf, long n, vlong off)
                poperror();
                return n;
 
-       case Qswap:
-               snprint(tmp, sizeof tmp,
-                       "%llud memory\n"
-                       "%llud pagesize\n"
-                       "%lud kernel\n"
-                       "%lud/%lud user\n"
-                       "%lud/%lud swap\n"
-                       "%llud/%llud/%llud kernel malloc\n"
-                       "%llud/%llud/%llud kernel draw\n"
-                       "%llud/%llud/%llud kernel secret\n",
-                       (uvlong)conf.npage*BY2PG,
-                       (uvlong)BY2PG,
-                       conf.npage-conf.upages,
-                       palloc.user-palloc.freecount-fscache.pgref-swapimage.pgref, palloc.user,
-                       conf.nswap-swapalloc.free, conf.nswap,
-                       (uvlong)mainmem->curalloc,
-                       (uvlong)mainmem->cursize,
-                       (uvlong)mainmem->maxsize,
-                       (uvlong)imagmem->curalloc,
-                       (uvlong)imagmem->cursize,
-                       (uvlong)imagmem->maxsize,
-                       (uvlong)secrmem->curalloc,
-                       (uvlong)secrmem->cursize,
-                       (uvlong)secrmem->maxsize);
-
-               return readstr((ulong)offset, buf, n, tmp);
-
        case Qsysname:
                if(sysname == nil)
                        return 0;
@@ -669,8 +637,7 @@ conswrite(Chan *c, void *va, long n, vlong off)
        long l, bp;
        char *a;
        Mach *mp;
-       int id, fd;
-       Chan *swc;
+       int id;
        ulong offset;
        Cmdbuf *cb;
        Cmdtab *ct;
@@ -765,25 +732,6 @@ conswrite(Chan *c, void *va, long n, vlong off)
                }
                break;
 
-       case Qswap:
-               if(n >= sizeof buf)
-                       error(Egreg);
-               memmove(buf, va, n);    /* so we can NUL-terminate */
-               buf[n] = 0;
-               /* start a pager if not already started */
-               if(strncmp(buf, "start", 5) == 0){
-                       kickpager();
-                       break;
-               }
-               if(!iseve())
-                       error(Eperm);
-               if(buf[0]<'0' || '9'<buf[0])
-                       error(Ebadarg);
-               fd = strtoul(buf, 0, 0);
-               swc = fdtochan(fd, ORDWR, 1, 1);
-               setswapchan(swc);
-               break;
-
        case Qsysname:
                if(offset != 0)
                        error(Ebadarg);
diff --git a/sys/src/9/port/devswap.c b/sys/src/9/port/devswap.c
new file mode 100644 (file)
index 0000000..64c3aa6
--- /dev/null
@@ -0,0 +1,612 @@
+#include       "u.h"
+#include       "../port/lib.h"
+#include       "mem.h"
+#include       "dat.h"
+#include       "fns.h"
+#include       "../port/error.h"
+
+#include       <libsec.h>
+#include       <pool.h>
+
+static int     canflush(Proc*, Segment*);
+static void    executeio(void);
+static void    pageout(Proc*, Segment*);
+static void    pagepte(int, Page**);
+static void    pager(void*);
+
+Image  swapimage = {
+       .notext = 1,
+};
+
+static Chan    *swapchan;
+static uchar   *swapbuf;
+static AESstate *swapkey;
+
+static Page    **iolist;
+static int     ioptr;
+
+static ushort  ageclock;
+
+static void
+swapinit(void)
+{
+       swapalloc.swmap = xalloc(conf.nswap);
+       swapalloc.top = &swapalloc.swmap[conf.nswap];
+       swapalloc.alloc = swapalloc.swmap;
+       swapalloc.last = swapalloc.swmap;
+       swapalloc.free = conf.nswap;
+       swapalloc.xref = 0;
+
+       iolist = xalloc(conf.nswppo*sizeof(Page*));
+       if(swapalloc.swmap == nil || iolist == nil)
+               panic("swapinit: not enough memory");
+}
+
+static uintptr
+newswap(void)
+{
+       uchar *look;
+
+       lock(&swapalloc);
+       if(swapalloc.free == 0) {
+               unlock(&swapalloc);
+               return ~0;
+       }
+       look = memchr(swapalloc.last, 0, swapalloc.top-swapalloc.last);
+       if(look == nil)
+               look = memchr(swapalloc.swmap, 0, swapalloc.last-swapalloc.swmap);
+       *look = 2;      /* ref for pte + io transaction */
+       swapalloc.last = look;
+       swapalloc.free--;
+       unlock(&swapalloc);
+       return (look-swapalloc.swmap) * BY2PG;
+}
+
+void
+putswap(Page *p)
+{
+       uchar *idx;
+
+       lock(&swapalloc);
+       idx = &swapalloc.swmap[((uintptr)p)/BY2PG];
+       if(*idx == 0)
+               panic("putswap %#p ref == 0", p);
+
+       if(*idx == 255) {
+               if(swapalloc.xref == 0)
+                       panic("putswap %#p xref == 0", p);
+
+               if(--swapalloc.xref == 0) {
+                       for(idx = swapalloc.swmap; idx < swapalloc.top; idx++) {
+                               if(*idx == 255) {
+                                       *idx = 0;
+                                       swapalloc.free++;
+                               }
+                       }
+               }
+       } else {
+               if(--(*idx) == 0)
+                       swapalloc.free++;
+       }
+       unlock(&swapalloc);
+}
+
+void
+dupswap(Page *p)
+{
+       uchar *idx;
+
+       lock(&swapalloc);
+       idx = &swapalloc.swmap[((uintptr)p)/BY2PG];
+       if(*idx == 255)
+               swapalloc.xref++;
+       else {
+               if(++(*idx) == 255)
+                       swapalloc.xref += 255;
+       }
+       unlock(&swapalloc);
+}
+
+int
+swapcount(uintptr daddr)
+{
+       return swapalloc.swmap[daddr/BY2PG];
+}
+
+void
+kickpager(void)
+{
+       static Ref started;
+
+       if(started.ref || incref(&started) != 1)
+               wakeup(&swapalloc.r);
+       else
+               kproc("pager", pager, 0);
+}
+
+static int
+reclaim(void)
+{
+       ulong np;
+
+       for(;;){
+               if((np = pagereclaim(&fscache, 1000)) > 0) {
+                       if(0) print("reclaim: %lud fscache\n", np);
+               } else if((np = pagereclaim(&swapimage, 1000)) > 0) {
+                       if(0) print("reclaim: %lud swap\n", np);
+               } else if((np = imagereclaim(1000)) > 0) {
+                       if(0) print("reclaim: %lud image\n", np);
+               }
+               if(!needpages(nil))
+                       return 1;       /* have pages, done */
+               if(np == 0)
+                       return 0;       /* didnt reclaim, need to swap */
+               sched();
+       }
+}
+
+static void
+pager(void*)
+{
+       int i;
+       Segment *s;
+       Proc *p, *ep;
+
+       p = proctab(0);
+       ep = &p[conf.nproc];
+
+       while(waserror())
+               ;
+
+       for(;;){
+               up->psstate = "Reclaim";
+               if(reclaim()){
+                       up->psstate = "Idle";
+                       wakeup(&palloc.pwait[0]);
+                       wakeup(&palloc.pwait[1]);
+                       sleep(&swapalloc.r, needpages, nil);
+                       continue;
+               }
+
+               if(swapimage.c == nil || swapalloc.free == 0){
+               Killbig:
+                       if(!freebroken())
+                               killbig("out of memory");
+                       sched();
+                       continue;
+               }
+
+               i = ageclock;
+               do {
+                       if(++p >= ep){
+                               if(++ageclock == i)
+                                       goto Killbig;
+                               p = proctab(0);
+                       }
+               } while(p->state == Dead || p->noswap || !canqlock(&p->seglock));
+               up->psstate = "Pageout";
+               for(i = 0; i < NSEG; i++) {
+                       if((s = p->seg[i]) != nil) {
+                               switch(s->type&SG_TYPE) {
+                               default:
+                                       break;
+                               case SG_TEXT:
+                                       pageout(p, s);
+                                       break;
+                               case SG_DATA:
+                               case SG_BSS:
+                               case SG_STACK:
+                               case SG_SHARED:
+                                       pageout(p, s);
+                                       break;
+                               }
+                       }
+               }
+               qunlock(&p->seglock);
+
+               if(ioptr > 0) {
+                       up->psstate = "I/O";
+                       executeio();
+               }
+       }
+}
+
+static void
+pageout(Proc *p, Segment *s)
+{
+       int type, i, size;
+       short age;
+       Pte *l;
+       Page **pg, *entry;
+
+       if(!canqlock(s))        /* We cannot afford to wait, we will surely deadlock */
+               return;
+
+       if(!canflush(p, s)      /* Able to invalidate all tlbs with references */
+       || waserror()) {
+               qunlock(s);
+               putseg(s);
+               return;
+       }
+
+       /* Pass through the pte tables looking for memory pages to swap out */
+       type = s->type&SG_TYPE;
+       size = s->mapsize;
+       for(i = 0; i < size; i++) {
+               l = s->map[i];
+               if(l == nil)
+                       continue;
+               for(pg = l->first; pg <= l->last; pg++) {
+                       entry = *pg;
+                       if(pagedout(entry))
+                               continue;
+                       if(entry->modref & PG_REF) {
+                               entry->modref &= ~PG_REF;
+                               entry->refage = ageclock;
+                               continue;
+                       }
+                       age = (short)(ageclock - entry->refage);
+                       if(age < 16)
+                               continue;
+                       pagepte(type, pg);
+               }
+       }
+       poperror();
+       qunlock(s);
+       putseg(s);
+}
+
+static int
+canflush(Proc *p, Segment *s)
+{
+       int i;
+       Proc *ep;
+
+       if(incref(s) == 2)              /* Easy if we are the only user */
+               return canpage(p);
+
+       /* Now we must do hardwork to ensure all processes which have tlb
+        * entries for this segment will be flushed if we succeed in paging it out
+        */
+       p = proctab(0);
+       ep = &p[conf.nproc];
+       while(p < ep) {
+               if(p->state != Dead) {
+                       for(i = 0; i < NSEG; i++)
+                               if(p->seg[i] == s)
+                                       if(!canpage(p))
+                                               return 0;
+               }
+               p++;
+       }
+       return 1;
+}
+
+static void
+pagepte(int type, Page **pg)
+{
+       uintptr daddr;
+       Page *outp;
+
+       outp = *pg;
+       switch(type) {
+       case SG_TEXT:                           /* Revert to demand load */
+               putpage(outp);
+               *pg = nil;
+               break;
+
+       case SG_DATA:
+       case SG_BSS:
+       case SG_STACK:
+       case SG_SHARED:
+               if(ioptr >= conf.nswppo)
+                       break;
+
+               /*
+                *  get a new swap address with swapcount 2, one for the pte
+                *  and one extra ref for us while we write the page to disk
+                */
+               daddr = newswap();
+               if(daddr == ~0)
+                       break;
+
+               /* clear any pages referring to it from the cache */
+               cachedel(&swapimage, daddr);
+
+               /* forget anything that it used to cache */
+               uncachepage(outp);
+
+               /*
+                *  enter it into the cache so that a fault happening
+                *  during the write will grab the page from the cache
+                *  rather than one partially written to the disk
+                */
+               outp->daddr = daddr;
+               cachepage(outp, &swapimage);
+               *pg = (Page*)(daddr|PG_ONSWAP);
+
+               /* Add page to IO transaction list */
+               iolist[ioptr++] = outp;
+               break;
+       }
+}
+
+void
+pagersummary(void)
+{
+       print("%lud/%lud memory %lud/%lud swap %d iolist\n",
+               palloc.user-palloc.freecount,
+               palloc.user, conf.nswap-swapalloc.free, conf.nswap,
+               ioptr);
+}
+
+static void
+executeio(void)
+{
+       Page *outp;
+       int i, n;
+       Chan *c;
+       char *kaddr;
+       KMap *k;
+
+       c = swapimage.c;
+       for(i = 0; i < ioptr; i++) {
+               if(ioptr > conf.nswppo)
+                       panic("executeio: ioptr %d > %d", ioptr, conf.nswppo);
+               outp = iolist[i];
+
+               assert(outp->ref > 0);
+               assert(outp->image == &swapimage);
+               assert(outp->daddr != ~0);
+
+               /* only write when swap address still in use */
+               if(swapcount(outp->daddr) > 1){
+                       k = kmap(outp);
+                       kaddr = (char*)VA(k);
+
+                       if(waserror())
+                               panic("executeio: page outp I/O error");
+
+                       n = devtab[c->type]->write(c, kaddr, BY2PG, outp->daddr);
+                       if(n != BY2PG)
+                               nexterror();
+
+                       kunmap(k);
+                       poperror();
+               }
+
+               /* drop our extra swap reference */
+               putswap((Page*)outp->daddr);
+
+               /* Free up the page after I/O */
+               putpage(outp);
+       }
+       ioptr = 0;
+}
+
+int
+needpages(void*)
+{
+       return palloc.freecount < swapalloc.headroom;
+}
+
+static void
+setswapchan(Chan *c)
+{
+       uchar buf[sizeof(Dir)+100];
+       Dir d;
+       int n;
+
+       if(waserror()){
+               cclose(c);
+               nexterror();
+       }
+       if(swapimage.c != nil) {
+               if(swapalloc.free != conf.nswap)
+                       error(Einuse);
+               cclose(swapimage.c);
+               swapimage.c = nil;
+       }
+
+       /*
+        *  if this isn't a file, set the swap space
+        *  to be at most the size of the partition
+        */
+       if(devtab[c->type]->dc != L'M'){
+               n = devtab[c->type]->stat(c, buf, sizeof buf);
+               if(n <= 0 || convM2D(buf, n, &d, nil) == 0)
+                       error("stat failed in setswapchan");
+               if(d.length < conf.nswppo*BY2PG)
+                       error("swap device too small");
+               if(d.length < conf.nswap*BY2PG){
+                       conf.nswap = d.length/BY2PG;
+                       swapalloc.top = &swapalloc.swmap[conf.nswap];
+                       swapalloc.free = conf.nswap;
+               }
+       }
+       c->flag &= ~CCACHE;
+       cclunk(c);
+       poperror();
+
+       swapchan = c;
+       swapimage.c = namec("#¶/swapfile", Aopen, ORDWR, 0);
+}
+
+enum {
+       Qdir,
+       Qswap,
+       Qswapfile,
+};
+
+static Dirtab swapdir[]={
+       ".",            {Qdir, 0, QTDIR},       0,              DMDIR|0555,
+       "swap",         {Qswap},                0,              0664,
+       "swapfile",     {Qswapfile},            0,              0600,
+};
+
+static Chan*
+swapattach(char *spec)
+{
+       return devattach(L'¶', spec);
+}
+
+static Walkqid*
+swapwalk(Chan *c, Chan *nc, char **name, int nname)
+{
+       return devwalk(c, nc, name, nname, swapdir, nelem(swapdir), devgen);
+}
+
+static int
+swapstat(Chan *c, uchar *dp, int n)
+{
+       return devstat(c, dp, n, swapdir, nelem(swapdir), devgen);
+}
+
+static Chan*
+swapopen(Chan *c, int omode)
+{
+       uchar key[128/8];
+
+       switch((ulong)c->qid.path){
+       case Qswapfile:
+               if(!iseve() || omode != ORDWR)
+                       error(Eperm);
+               if(swapimage.c != nil)
+                       error(Einuse);
+               if(swapchan == nil)
+                       error(Egreg);
+
+               c->mode = openmode(omode);
+               c->flag |= COPEN;
+               c->offset = 0;
+
+               swapbuf = mallocalign(BY2PG, BY2PG, 0, 0);
+               swapkey = secalloc(sizeof(AESstate)*2);
+               if(swapbuf == nil || swapkey == nil)
+                       error(Enomem);
+
+               genrandom(key, sizeof(key));
+               setupAESstate(&swapkey[0], key, sizeof(key), nil);
+               genrandom(key, sizeof(key));
+               setupAESstate(&swapkey[1], key, sizeof(key), nil);
+               memset(key, 0, sizeof(key));
+
+               return c;
+       }
+       return devopen(c, omode, swapdir, nelem(swapdir), devgen);
+}
+
+static void
+swapclose(Chan *c)
+{
+       if((c->flag & COPEN) == 0)
+               return;
+       switch((ulong)c->qid.path){
+       case Qswapfile:
+               cclose(swapchan);
+               swapchan = nil;
+               secfree(swapkey);
+               swapkey = nil;
+               free(swapbuf);
+               swapbuf = nil;
+               break;
+       }
+}
+
+static long
+swapread(Chan *c, void *va, long n, vlong off)
+{
+       char tmp[256];          /* must be >= 18*NUMSIZE (Qswap) */
+
+       switch((ulong)c->qid.path){
+       case Qdir:
+               return devdirread(c, va, n, swapdir, nelem(swapdir), devgen);
+       case Qswap:
+               snprint(tmp, sizeof tmp,
+                       "%llud memory\n"
+                       "%llud pagesize\n"
+                       "%lud kernel\n"
+                       "%lud/%lud user\n"
+                       "%lud/%lud swap\n"
+                       "%llud/%llud/%llud kernel malloc\n"
+                       "%llud/%llud/%llud kernel draw\n"
+                       "%llud/%llud/%llud kernel secret\n",
+                       (uvlong)conf.npage*BY2PG,
+                       (uvlong)BY2PG,
+                       conf.npage-conf.upages,
+                       palloc.user-palloc.freecount-fscache.pgref-swapimage.pgref, palloc.user,
+                       conf.nswap-swapalloc.free, conf.nswap,
+                       (uvlong)mainmem->curalloc,
+                       (uvlong)mainmem->cursize,
+                       (uvlong)mainmem->maxsize,
+                       (uvlong)imagmem->curalloc,
+                       (uvlong)imagmem->cursize,
+                       (uvlong)imagmem->maxsize,
+                       (uvlong)secrmem->curalloc,
+                       (uvlong)secrmem->cursize,
+                       (uvlong)secrmem->maxsize);
+               return readstr((ulong)off, va, n, tmp);
+       case Qswapfile:
+               if(n != BY2PG)
+                       error(Ebadarg);
+               if(devtab[swapchan->type]->read(swapchan, va, n, off) != n)
+                       error(Eio);
+               aes_xts_decrypt(&swapkey[0], &swapkey[1], off, va, va, n);
+               return n;
+       }
+       error(Egreg);
+       return 0;
+}
+
+static long
+swapwrite(Chan *c, void *va, long n, vlong off)
+{
+       char buf[256];
+       
+       switch((ulong)c->qid.path){
+       case Qswap:
+               if(!iseve())
+                       error(Eperm);
+               if(n >= sizeof buf)
+                       error(Egreg);
+               memmove(buf, va, n);    /* so we can NUL-terminate */
+               buf[n] = 0;
+               /* start a pager if not already started */
+               if(strncmp(buf, "start", 5) == 0)
+                       kickpager();
+               else if(buf[0]>='0' && '9'<=buf[0])
+                       setswapchan(fdtochan(strtoul(buf, nil, 0), ORDWR, 1, 1));
+               else
+                       error(Ebadctl);
+               return n;
+       case Qswapfile:
+               if(n != BY2PG)
+                       error(Ebadarg);
+               aes_xts_encrypt(&swapkey[0], &swapkey[1], off, va, swapbuf, n);
+               if(devtab[swapchan->type]->write(swapchan, swapbuf, n, off) != n)
+                       error(Eio);
+               return n;
+       }
+       error(Egreg);
+       return 0;
+}
+
+Dev swapdevtab = {
+       L'¶',
+       "swap",
+       devreset,
+       swapinit,
+       devshutdown,
+       swapattach,
+       swapwalk,
+       swapstat,
+       swapopen,
+       devcreate,
+       swapclose,
+       swapread,
+       devbread,
+       swapwrite,
+       devbwrite,
+       devremove,
+       devwstat,
+};
index 803622fd8e21fcbb1b18abc2e00079e498a32e98..c238c818e57b9d6c7c9af6f8b1dd7b2c7ba7c318 100644 (file)
@@ -318,7 +318,6 @@ int         setlabel(Label*);
 void           setmalloctag(void*, uintptr);
 void           setrealloctag(void*, uintptr);
 void           setregisters(Ureg*, char*, char*, int);
-void           setswapchan(Chan*);
 void           setupwatchpts(Proc*, Watchpt*, int);
 char*          skipslash(char*);
 void           sleep(Rendez*, int(*)(void*), void*);
@@ -332,7 +331,6 @@ void                srvrenameuser(char*, char*);
 void           shrrenameuser(char*, char*);
 int            swapcount(uintptr);
 int            swapfull(void);
-void           swapinit(void);
 void           syscallfmt(ulong syscallno, uintptr pc, va_list list);
 void           sysretfmt(ulong syscallno, va_list list, uintptr ret, uvlong start, uvlong stop);
 void           timeradd(Timer*);
index c16cf9c9338218f4282255a6325613227233fb32..ec437d327f7cc0e0893fae3a98f866e10392e0d2 100644 (file)
@@ -62,15 +62,15 @@ errstr.h:   ../port/mkerrstr ../port/error.h
 %.db:          main.$O
        $CC -s$stem main.c | dbfmt > $stem.db
 
-alloc.$O:      /sys/include/pool.h
+alloc.$O devswap.$O:   /sys/include/pool.h
 devmnt.$O:     /sys/include/fcall.h
 proc.$O proc.acid:     errstr.h
 devroot.$O:    errstr.h
 devaudio.$O:   ../port/audioif.h
-devaoe.$O:     /$objtype/include/ureg.h
-devfs.$O:      /$objtype/include/ureg.h
-devsd.$O:      /$objtype/include/ureg.h
-sdscsi.$O:     /$objtype/include/ureg.h
+devaoe.$O:     ../port/sd.h /$objtype/include/ureg.h
+devfs.$O:      ../port/sd.h /$objtype/include/ureg.h
+devsd.$O:      ../port/sd.h /$objtype/include/ureg.h
+sdscsi.$O:     ../port/sd.h /$objtype/include/ureg.h
 trap.$O:       /$objtype/include/ureg.h
 devproc.$O:    /$objtype/include/ureg.h
 main.$O:       init.h
@@ -87,3 +87,5 @@ unthwack.$O:  ../port/thwack.h
 devsdp.$O:     ../port/thwack.h
 devproc.$O sysproc.$O: /sys/include/tos.h
 devproc.$O edf.$O proc.$O: /sys/include/trace.h
+devcons.$O:    /sys/include/authsrv.h
+devcap.$O devfs.$O devsdp.$O devssl.$O devtls.$O devswap.$O random.$O: /sys/include/libsec.h
diff --git a/sys/src/9/port/swap.c b/sys/src/9/port/swap.c
deleted file mode 100644 (file)
index 81d3bf2..0000000
+++ /dev/null
@@ -1,430 +0,0 @@
-#include       "u.h"
-#include       "../port/lib.h"
-#include       "mem.h"
-#include       "dat.h"
-#include       "fns.h"
-#include       "../port/error.h"
-
-static int     canflush(Proc*, Segment*);
-static void    executeio(void);
-static void    pageout(Proc*, Segment*);
-static void    pagepte(int, Page**);
-static void    pager(void*);
-
-Image  swapimage;
-
-static         int     swopen;
-static Page    **iolist;
-static int     ioptr;
-
-static ushort  ageclock;
-
-void
-swapinit(void)
-{
-       swapalloc.swmap = xalloc(conf.nswap);
-       swapalloc.top = &swapalloc.swmap[conf.nswap];
-       swapalloc.alloc = swapalloc.swmap;
-       swapalloc.last = swapalloc.swmap;
-       swapalloc.free = conf.nswap;
-       swapalloc.xref = 0;
-
-       iolist = xalloc(conf.nswppo*sizeof(Page*));
-       if(swapalloc.swmap == 0 || iolist == 0)
-               panic("swapinit: not enough memory");
-
-       swapimage.notext = 1;
-}
-
-static uintptr
-newswap(void)
-{
-       uchar *look;
-
-       lock(&swapalloc);
-       if(swapalloc.free == 0) {
-               unlock(&swapalloc);
-               return ~0;
-       }
-       look = memchr(swapalloc.last, 0, swapalloc.top-swapalloc.last);
-       if(look == nil)
-               look = memchr(swapalloc.swmap, 0, swapalloc.last-swapalloc.swmap);
-       *look = 2;      /* ref for pte + io transaction */
-       swapalloc.last = look;
-       swapalloc.free--;
-       unlock(&swapalloc);
-       return (look-swapalloc.swmap) * BY2PG;
-}
-
-void
-putswap(Page *p)
-{
-       uchar *idx;
-
-       lock(&swapalloc);
-       idx = &swapalloc.swmap[((uintptr)p)/BY2PG];
-       if(*idx == 0)
-               panic("putswap %#p ref == 0", p);
-
-       if(*idx == 255) {
-               if(swapalloc.xref == 0)
-                       panic("putswap %#p xref == 0", p);
-
-               if(--swapalloc.xref == 0) {
-                       for(idx = swapalloc.swmap; idx < swapalloc.top; idx++) {
-                               if(*idx == 255) {
-                                       *idx = 0;
-                                       swapalloc.free++;
-                               }
-                       }
-               }
-       } else {
-               if(--(*idx) == 0)
-                       swapalloc.free++;
-       }
-       unlock(&swapalloc);
-}
-
-void
-dupswap(Page *p)
-{
-       uchar *idx;
-
-       lock(&swapalloc);
-       idx = &swapalloc.swmap[((uintptr)p)/BY2PG];
-       if(*idx == 255)
-               swapalloc.xref++;
-       else {
-               if(++(*idx) == 255)
-                       swapalloc.xref += 255;
-       }
-       unlock(&swapalloc);
-}
-
-int
-swapcount(uintptr daddr)
-{
-       return swapalloc.swmap[daddr/BY2PG];
-}
-
-void
-kickpager(void)
-{
-       static Ref started;
-
-       if(started.ref || incref(&started) != 1)
-               wakeup(&swapalloc.r);
-       else
-               kproc("pager", pager, 0);
-}
-
-static int
-reclaim(void)
-{
-       ulong np;
-
-       for(;;){
-               if((np = pagereclaim(&fscache, 1000)) > 0) {
-                       if(0) print("reclaim: %lud fscache\n", np);
-               } else if((np = pagereclaim(&swapimage, 1000)) > 0) {
-                       if(0) print("reclaim: %lud swap\n", np);
-               } else if((np = imagereclaim(1000)) > 0) {
-                       if(0) print("reclaim: %lud image\n", np);
-               }
-               if(!needpages(nil))
-                       return 1;       /* have pages, done */
-               if(np == 0)
-                       return 0;       /* didnt reclaim, need to swap */
-               sched();
-       }
-}
-
-static void
-pager(void*)
-{
-       int i;
-       Segment *s;
-       Proc *p, *ep;
-
-       p = proctab(0);
-       ep = &p[conf.nproc];
-
-       while(waserror())
-               ;
-
-       for(;;){
-               up->psstate = "Reclaim";
-               if(reclaim()){
-                       up->psstate = "Idle";
-                       wakeup(&palloc.pwait[0]);
-                       wakeup(&palloc.pwait[1]);
-                       sleep(&swapalloc.r, needpages, nil);
-                       continue;
-               }
-
-               if(swapimage.c == nil || swapalloc.free == 0){
-               Killbig:
-                       if(!freebroken())
-                               killbig("out of memory");
-                       sched();
-                       continue;
-               }
-
-               i = ageclock;
-               do {
-                       if(++p >= ep){
-                               if(++ageclock == i)
-                                       goto Killbig;
-                               p = proctab(0);
-                       }
-               } while(p->state == Dead || p->noswap || !canqlock(&p->seglock));
-               up->psstate = "Pageout";
-               for(i = 0; i < NSEG; i++) {
-                       if((s = p->seg[i]) != nil) {
-                               switch(s->type&SG_TYPE) {
-                               default:
-                                       break;
-                               case SG_TEXT:
-                                       pageout(p, s);
-                                       break;
-                               case SG_DATA:
-                               case SG_BSS:
-                               case SG_STACK:
-                               case SG_SHARED:
-                                       pageout(p, s);
-                                       break;
-                               }
-                       }
-               }
-               qunlock(&p->seglock);
-
-               if(ioptr > 0) {
-                       up->psstate = "I/O";
-                       executeio();
-               }
-       }
-}
-
-static void
-pageout(Proc *p, Segment *s)
-{
-       int type, i, size;
-       short age;
-       Pte *l;
-       Page **pg, *entry;
-
-       if(!canqlock(s))        /* We cannot afford to wait, we will surely deadlock */
-               return;
-
-       if(!canflush(p, s)) {   /* Able to invalidate all tlbs with references */
-               qunlock(s);
-               putseg(s);
-               return;
-       }
-
-       if(waserror()) {
-               qunlock(s);
-               putseg(s);
-               return;
-       }
-
-       /* Pass through the pte tables looking for memory pages to swap out */
-       type = s->type&SG_TYPE;
-       size = s->mapsize;
-       for(i = 0; i < size; i++) {
-               l = s->map[i];
-               if(l == nil)
-                       continue;
-               for(pg = l->first; pg <= l->last; pg++) {
-                       entry = *pg;
-                       if(pagedout(entry))
-                               continue;
-                       if(entry->modref & PG_REF) {
-                               entry->modref &= ~PG_REF;
-                               entry->refage = ageclock;
-                               continue;
-                       }
-                       age = (short)(ageclock - entry->refage);
-                       if(age < 16)
-                               continue;
-                       pagepte(type, pg);
-               }
-       }
-       poperror();
-       qunlock(s);
-       putseg(s);
-}
-
-static int
-canflush(Proc *p, Segment *s)
-{
-       int i;
-       Proc *ep;
-
-       if(incref(s) == 2)              /* Easy if we are the only user */
-               return canpage(p);
-
-       /* Now we must do hardwork to ensure all processes which have tlb
-        * entries for this segment will be flushed if we succeed in paging it out
-        */
-       p = proctab(0);
-       ep = &p[conf.nproc];
-       while(p < ep) {
-               if(p->state != Dead) {
-                       for(i = 0; i < NSEG; i++)
-                               if(p->seg[i] == s)
-                                       if(!canpage(p))
-                                               return 0;
-               }
-               p++;
-       }
-       return 1;
-}
-
-static void
-pagepte(int type, Page **pg)
-{
-       uintptr daddr;
-       Page *outp;
-
-       outp = *pg;
-       switch(type) {
-       case SG_TEXT:                           /* Revert to demand load */
-               putpage(outp);
-               *pg = nil;
-               break;
-
-       case SG_DATA:
-       case SG_BSS:
-       case SG_STACK:
-       case SG_SHARED:
-               if(ioptr >= conf.nswppo)
-                       break;
-
-               /*
-                *  get a new swap address with swapcount 2, one for the pte
-                *  and one extra ref for us while we write the page to disk
-                */
-               daddr = newswap();
-               if(daddr == ~0)
-                       break;
-
-               /* clear any pages referring to it from the cache */
-               cachedel(&swapimage, daddr);
-
-               /* forget anything that it used to cache */
-               uncachepage(outp);
-
-               /*
-                *  enter it into the cache so that a fault happening
-                *  during the write will grab the page from the cache
-                *  rather than one partially written to the disk
-                */
-               outp->daddr = daddr;
-               cachepage(outp, &swapimage);
-               *pg = (Page*)(daddr|PG_ONSWAP);
-
-               /* Add page to IO transaction list */
-               iolist[ioptr++] = outp;
-               break;
-       }
-}
-
-void
-pagersummary(void)
-{
-       print("%lud/%lud memory %lud/%lud swap %d iolist\n",
-               palloc.user-palloc.freecount,
-               palloc.user, conf.nswap-swapalloc.free, conf.nswap,
-               ioptr);
-}
-
-static void
-executeio(void)
-{
-       Page *outp;
-       int i, n;
-       Chan *c;
-       char *kaddr;
-       KMap *k;
-
-       c = swapimage.c;
-       for(i = 0; i < ioptr; i++) {
-               if(ioptr > conf.nswppo)
-                       panic("executeio: ioptr %d > %d", ioptr, conf.nswppo);
-               outp = iolist[i];
-
-               assert(outp->ref > 0);
-               assert(outp->image == &swapimage);
-               assert(outp->daddr != ~0);
-
-               /* only write when swap address still in use */
-               if(swapcount(outp->daddr) > 1){
-                       k = kmap(outp);
-                       kaddr = (char*)VA(k);
-
-                       if(waserror())
-                               panic("executeio: page outp I/O error");
-
-                       n = devtab[c->type]->write(c, kaddr, BY2PG, outp->daddr);
-                       if(n != BY2PG)
-                               nexterror();
-
-                       kunmap(k);
-                       poperror();
-               }
-
-               /* drop our extra swap reference */
-               putswap((Page*)outp->daddr);
-
-               /* Free up the page after I/O */
-               putpage(outp);
-       }
-       ioptr = 0;
-}
-
-int
-needpages(void*)
-{
-       return palloc.freecount < swapalloc.headroom;
-}
-
-void
-setswapchan(Chan *c)
-{
-       uchar dirbuf[sizeof(Dir)+100];
-       Dir d;
-       int n;
-
-       if(waserror()){
-               cclose(c);
-               nexterror();
-       }
-       if(swapimage.c != nil) {
-               if(swapalloc.free != conf.nswap)
-                       error(Einuse);
-               cclose(swapimage.c);
-               swapimage.c = nil;
-       }
-
-       /*
-        *  if this isn't a file, set the swap space
-        *  to be at most the size of the partition
-        */
-       if(devtab[c->type]->dc != L'M'){
-               n = devtab[c->type]->stat(c, dirbuf, sizeof dirbuf);
-               if(n <= 0 || convM2D(dirbuf, n, &d, nil) == 0)
-                       error("stat failed in setswapchan");
-               if(d.length < conf.nswppo*BY2PG)
-                       error("swap device too small");
-               if(d.length < conf.nswap*BY2PG){
-                       conf.nswap = d.length/BY2PG;
-                       swapalloc.top = &swapalloc.swmap[conf.nswap];
-                       swapalloc.free = conf.nswap;
-               }
-       }
-       c->flag &= ~CCACHE;
-       cclunk(c);
-       swapimage.c = c;
-       poperror();
-}
index 8dd4b8028391365e1edf0cc93dd7d543cd4688d6..297a0543bfafa847fe50e3ff736be93f2523f051 100644 (file)
@@ -1,6 +1,7 @@
 dev
        root
        cons
+       swap
        env
        flash
        pipe
index 93b81fd48728c9451f66ede8f527cbe8bf895784..9beb2ed093710bf52c81341ca999a4fe7ecb602c 100644 (file)
@@ -84,7 +84,6 @@ main(void)
        links();
        chandevreset();
        pageinit();
-       swapinit();
        sharedseginit();
        fpsave(&initfp);
        initfp.fpscr = 0;
index 0ced83b9c102896a01897a885799a26decc4ab89..e18b21b54ae72e75b78f7322ec7d4358f1cc7575 100644 (file)
@@ -31,7 +31,6 @@ PORT=\
        qlock.$O\
        rdb.$O\
        segment.$O\
-       swap.$O\
        sysfile.$O\
        sysproc.$O\
        taslock.$O\
index 175e4e07c79a40288ca3add68000acfbbd9ac0d7..ec55440296eac9600567820288f630806c61aa38 100644 (file)
@@ -1,6 +1,7 @@
 dev
        root
        cons
+       swap
        uart
        mnt
        srv
index 2ed77a5b671a05d6922d417ff8732876bd78028e..f1c239e3a5b91c820596a47a77c8136562ac60d7 100644 (file)
@@ -192,8 +192,6 @@ main(void)
        initseg();
        links();
        chandevreset();
-
-       swapinit();
        userinit();
        schedinit();
        panic("schedinit returned");
index 87e5ac7b342985789fb7e5171cfb4a4ab879c456..1e39e89f843c61fd5c23887dfcf60e9bfcc83d96 100644 (file)
@@ -38,7 +38,6 @@ PORT=\
        rdb.$O\
        rebootcmd.$O\
        segment.$O\
-       swap.$O\
        syscallfmt.$O\
        sysfile.$O\
        sysproc.$O\
index 30c46647d1806a995cb3f040264467bd9d5d747b..8b1cddb9dbc8685f7a76efa44e8bb7ecfb639d74 100644 (file)
@@ -455,7 +455,6 @@ main(void)
 //     i8250console();                 /* too early; see init0 */
 
        pageinit();                     /* prints "1020M memory: ⋯ */
-       swapinit();
        userinit();
 
        /*
index 7c7eb8752330616fb1e99720603e6073323eaca8..d964d125f39462d8fd2a5d47e0cde12ded2ab60f 100644 (file)
@@ -34,7 +34,6 @@ PORT=\
        qio.$O\
        qlock.$O\
        segment.$O\
-       swap.$O\
        syscallfmt.$O\
        sysfile.$O\
        sysproc.$O\
index 236e5923e2bb1e1a9fb1711979da57322d342a00..67cd09d2df851c8d3df6c2b7fd8535853c03e0ec 100644 (file)
@@ -2,6 +2,7 @@
 dev
        root
        cons
+       swap
        env
        pipe
        proc
index f58f4628e0956f0b465cf87476dc6a20411aacdb..f5e0adf07b367af7539c79bc4ef5f286007d21ff 100644 (file)
@@ -103,8 +103,6 @@ main(void)
 //     conf.monitor = 1;
        chandevreset();
        pageinit();
-
-       swapinit();
        userinit();
        schedinit();
 }
index 5d96334393b1b50db5b619773e67f8e65afe7c5e..3d83df4fb2f9fb9bb9390dd4c177b8a7bb9e4d72 100644 (file)
@@ -32,7 +32,6 @@ PORT=\
        qlock.$O\
        rebootcmd.$O\
        segment.$O\
-       swap.$O\
        sysfile.$O\
        sysproc.$O\
        taslock.$O\
index 56cfd341f3279142892b673fdefb7cd63a25c21f..47972916305da5b366f3082bb6a958ec0fd74aa9 100644 (file)
@@ -1,6 +1,7 @@
 dev
        root            netif
        cons
+       swap
        uart
        arch
        env
index b29c288bb7e6a64547e3cd649cf6c34e3e793086..c281a5330db134433a4287e74162a4722d220b37 100644 (file)
@@ -393,7 +393,6 @@ main(void)
        archinit();
        chandevreset();
        pageinit();
-       swapinit();
        screeninit();
        userinit();
        schedinit();
index 5ba3628e971c5d02e2d088fc94dbeed697aea985..fca5f7f5c4f8d1bbc789cea59b490db85ed47f19 100644 (file)
@@ -31,7 +31,6 @@ PORT=\
        qio.$O\
        qlock.$O\
        segment.$O\
-       swap.$O\
        sysfile.$O\
        sysproc.$O\
        taslock.$O\
index 1ff7bc7888035876046e2d87dab767de7b8a260d..f627ec1b4a7c7126df1a60b2ec030816805b8131 100644 (file)
@@ -1,6 +1,7 @@
 dev
        root
        cons
+       swap
        arch
        uart
        mnt