Print this page
const-ify make segment ops structures
There is no reason to keep the segment ops structures writable.
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.
segop_getpolicy already checks for a NULL op
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

@@ -85,48 +85,30 @@
 static int      segmap_getvp(struct seg *seg, caddr_t addr, struct vnode **vpp);
 static void     segmap_dump(struct seg *seg);
 static int      segmap_pagelock(struct seg *seg, caddr_t addr, size_t len,
                         struct page ***ppp, enum lock_type type,
                         enum seg_rw rw);
-static void     segmap_badop(void);
 static int      segmap_getmemid(struct seg *seg, caddr_t addr, memid_t *memidp);
-static lgrp_mem_policy_info_t   *segmap_getpolicy(struct seg *seg,
-    caddr_t addr);
-static int      segmap_capable(struct seg *seg, segcapability_t capability);
 
 /* segkpm support */
 static caddr_t  segmap_pagecreate_kpm(struct seg *, vnode_t *, u_offset_t,
                         struct smap *, enum seg_rw);
 struct smap     *get_smap_kpm(caddr_t, page_t **);
 
-#define SEGMAP_BADOP(t) (t(*)())segmap_badop
-
-static struct seg_ops segmap_ops = {
-        SEGMAP_BADOP(int),      /* dup */
-        SEGMAP_BADOP(int),      /* unmap */
-        segmap_free,
-        segmap_fault,
-        segmap_faulta,
-        SEGMAP_BADOP(int),      /* setprot */
-        segmap_checkprot,
-        segmap_kluster,
-        SEGMAP_BADOP(size_t),   /* swapout */
-        SEGMAP_BADOP(int),      /* sync */
-        SEGMAP_BADOP(size_t),   /* incore */
-        SEGMAP_BADOP(int),      /* lockop */
-        segmap_getprot,
-        segmap_getoffset,
-        segmap_gettype,
-        segmap_getvp,
-        SEGMAP_BADOP(int),      /* advise */
-        segmap_dump,
-        segmap_pagelock,        /* pagelock */
-        SEGMAP_BADOP(int),      /* setpgsz */
-        segmap_getmemid,        /* getmemid */
-        segmap_getpolicy,       /* getpolicy */
-        segmap_capable,         /* capable */
-        seg_inherit_notsup      /* inherit */
+static const struct seg_ops segmap_ops = {
+        .free           = segmap_free,
+        .fault          = segmap_fault,
+        .faulta         = segmap_faulta,
+        .checkprot      = segmap_checkprot,
+        .kluster        = segmap_kluster,
+        .getprot        = segmap_getprot,
+        .getoffset      = segmap_getoffset,
+        .gettype        = segmap_gettype,
+        .getvp          = segmap_getvp,
+        .dump           = segmap_dump,
+        .pagelock       = segmap_pagelock,
+        .getmemid       = segmap_getmemid,
 };
 
 /*
  * Private segmap routines.
  */

@@ -907,17 +889,10 @@
 segmap_kluster(struct seg *seg, caddr_t addr, ssize_t delta)
 {
         return (0);
 }
 
-static void
-segmap_badop()
-{
-        panic("segmap_badop");
-        /*NOTREACHED*/
-}
-
 /*
  * Special private segmap operations
  */
 
 /*

@@ -2189,24 +2164,10 @@
         memidp->val[0] = (uintptr_t)smd->smd_sm->sm_vp;
         memidp->val[1] = smd->smd_sm->sm_off + (uintptr_t)(addr - seg->s_base);
         return (0);
 }
 
-/*ARGSUSED*/
-static lgrp_mem_policy_info_t *
-segmap_getpolicy(struct seg *seg, caddr_t addr)
-{
-        return (NULL);
-}
-
-/*ARGSUSED*/
-static int
-segmap_capable(struct seg *seg, segcapability_t capability)
-{
-        return (0);
-}
-
 
 #ifdef  SEGKPM_SUPPORT
 
 /*
  * segkpm support routines