Print this page
use NULL dump segop as a shorthand for no-op
Instead of forcing every segment driver to implement a dummy function that
does nothing, handle NULL dump segop function pointer as a no-op shorthand.
const-ify make segment ops structures
There is no reason to keep the segment ops structures writable.
use NULL setpagesize segop as a shorthand for ENOTSUP
Instead of forcing every segment driver to implement a dummp function to
return (hopefully) ENOTSUP, handle NULL setpagesize segop function pointer
as "return ENOTSUP" shorthand.
use NULL getmemid segop as a shorthand for ENODEV
Instead of forcing every segment driver to implement a dummy function to
return (hopefully) ENODEV, handle NULL getmemid segop function pointer as
"return ENODEV" shorthand.
use NULL capable segop as a shorthand for no-capabilities
Instead of forcing every segment driver to implement a dummy "return 0"
function, handle NULL capable segop function pointer as "no copabilities
supported" shorthand.
seg_inherit_notsup is redundant since segop_inherit checks for NULL properly
no need for bad-op segment op functions
The segment drivers have a number of bad-op functions that simply panic.
Keeping the function pointer NULL will accomplish the same thing in most
cases.  In other cases, keeping the function pointer NULL will result in
proper error code being returned.
use C99 initializers in segment ops structures
remove whole-process swapping
Long before Unix supported paging, it used process swapping to reclaim
memory.  The code is there and in theory it runs when we get *extremely* low
on memory.  In practice, it never runs since the definition of low-on-memory
is antiquated. (XXX: define what antiquated means)
You can check the number of swapout/swapin events with kstats:
$ kstat -p ::vm:swapin ::vm:swapout

@@ -100,43 +100,37 @@
 /*
  * Private seg op routines.
  */
 faultcode_t segkpm_fault(struct hat *hat, struct seg *seg, caddr_t addr,
                         size_t len, enum fault_type type, enum seg_rw rw);
-static void     segkpm_dump(struct seg *);
-static void     segkpm_badop(void);
-static int      segkpm_notsup(void);
-static int      segkpm_capable(struct seg *, segcapability_t);
-
-#define SEGKPM_BADOP(t) (t(*)())segkpm_badop
-#define SEGKPM_NOTSUP   (int(*)())segkpm_notsup
-
-static struct seg_ops segkpm_ops = {
-        SEGKPM_BADOP(int),      /* dup */
-        SEGKPM_BADOP(int),      /* unmap */
-        SEGKPM_BADOP(void),     /* free */
-        segkpm_fault,
-        SEGKPM_BADOP(int),      /* faulta */
-        SEGKPM_BADOP(int),      /* setprot */
-        SEGKPM_BADOP(int),      /* checkprot */
-        SEGKPM_BADOP(int),      /* kluster */
-        SEGKPM_BADOP(size_t),   /* swapout */
-        SEGKPM_BADOP(int),      /* sync */
-        SEGKPM_BADOP(size_t),   /* incore */
-        SEGKPM_BADOP(int),      /* lockop */
-        SEGKPM_BADOP(int),      /* getprot */
-        SEGKPM_BADOP(u_offset_t), /* getoffset */
-        SEGKPM_BADOP(int),      /* gettype */
-        SEGKPM_BADOP(int),      /* getvp */
-        SEGKPM_BADOP(int),      /* advise */
-        segkpm_dump,            /* dump */
-        SEGKPM_NOTSUP,          /* pagelock */
-        SEGKPM_BADOP(int),      /* setpgsz */
-        SEGKPM_BADOP(int),      /* getmemid */
-        SEGKPM_BADOP(lgrp_mem_policy_info_t *), /* getpolicy */
-        segkpm_capable,         /* capable */
-        seg_inherit_notsup      /* inherit */
+static int      segkpm_pagelock(struct seg *seg, caddr_t addr, size_t len,
+                        struct page ***page, enum lock_type type,
+                        enum seg_rw rw);
+
+static const struct seg_ops segkpm_ops = {
+        .fault          = segkpm_fault,
+        .pagelock       = segkpm_pagelock,
+//#ifndef SEGKPM_SUPPORT
+#if 0
+#error FIXME: define nop
+        .dup            = nop,
+        .unmap          = nop,
+        .free           = nop,
+        .faulta         = nop,
+        .setprot        = nop,
+        .checkprot      = nop,
+        .kluster        = nop,
+        .sync           = nop,
+        .incore         = nop,
+        .lockop         = nop,
+        .getprot        = nop,
+        .getoffset      = nop,
+        .gettype        = nop,
+        .getvp          = nop,
+        .advise         = nop,
+        .getpolicy      = nop,
+#endif
 };
 
 /*
  * kpm_pgsz and kpm_pgshft are set by platform layer.
  */

@@ -282,60 +276,43 @@
         vaddr = hat_kpm_page2va(pp, 1);
         hat_kpm_mapout(pp, kpme, vaddr);
         page_unlock(pp);
 }
 
-static void
-segkpm_badop()
-{
-        panic("segkpm_badop");
-}
-
 #else   /* SEGKPM_SUPPORT */
 
 /* segkpm stubs */
 
 /*ARGSUSED*/
-int segkpm_create(struct seg *seg, void *argsp) { return (0); }
+int segkpm_create(struct seg *seg, void *argsp)
+{
+        return (0);
+}
 
 /* ARGSUSED */
 faultcode_t
 segkpm_fault(struct hat *hat, struct seg *seg, caddr_t addr, size_t len,
         enum fault_type type, enum seg_rw rw)
 {
-        return ((faultcode_t)0);
+        return (0);
 }
 
 /* ARGSUSED */
-caddr_t segkpm_create_va(u_offset_t off) { return (NULL); }
+caddr_t segkpm_create_va(u_offset_t off)
+{
+        return (NULL);
+}
 
 /* ARGSUSED */
-void segkpm_mapout_validkpme(struct kpme *kpme) {}
-
-static void
-segkpm_badop() {}
-
-#endif  /* SEGKPM_SUPPORT */
-
-static int
-segkpm_notsup()
+void segkpm_mapout_validkpme(struct kpme *kpme)
 {
-        return (ENOTSUP);
 }
 
-/*
- * segkpm pages are not dumped, so we just return
- */
-/*ARGSUSED*/
-static void
-segkpm_dump(struct seg *seg)
-{}
+#endif  /* SEGKPM_SUPPORT */
 
-/*
- * We claim to have no special capabilities.
- */
-/*ARGSUSED*/
+/* ARGSUSED */
 static int
-segkpm_capable(struct seg *seg, segcapability_t capability)
+segkpm_pagelock(struct seg *seg, caddr_t addr, size_t len,
+        struct page ***page, enum lock_type type, enum seg_rw rw)
 {
-        return (0);
+        return (ENOTSUP);
 }