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.
segspt_ops can be static
There is nothing that needs access to this structure outside of the spt
segment driver itself.
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 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
remove xhat
The xhat infrastructure was added to support hardware such as the zulu
graphics card - hardware which had on-board MMUs.  The VM used the xhat code
to keep the CPU's and Zulu's page tables in-sync.  Since the only xhat user
was zulu (which is gone), we can safely remove it simplifying the whole VM
subsystem.
Assorted notes:
- AS_BUSY flag was used solely by xhat

@@ -74,44 +74,14 @@
 static int segspt_unmap(struct seg *seg, caddr_t raddr, size_t ssize);
 static void segspt_free(struct seg *seg);
 static void segspt_free_pages(struct seg *seg, caddr_t addr, size_t len);
 static lgrp_mem_policy_info_t *segspt_getpolicy(struct seg *seg, caddr_t addr);
 
-static void
-segspt_badop()
-{
-        panic("segspt_badop called");
-        /*NOTREACHED*/
-}
-
-#define SEGSPT_BADOP(t) (t(*)())segspt_badop
-
-struct seg_ops segspt_ops = {
-        SEGSPT_BADOP(int),              /* dup */
-        segspt_unmap,
-        segspt_free,
-        SEGSPT_BADOP(int),              /* fault */
-        SEGSPT_BADOP(faultcode_t),      /* faulta */
-        SEGSPT_BADOP(int),              /* setprot */
-        SEGSPT_BADOP(int),              /* checkprot */
-        SEGSPT_BADOP(int),              /* kluster */
-        SEGSPT_BADOP(size_t),           /* swapout */
-        SEGSPT_BADOP(int),              /* sync */
-        SEGSPT_BADOP(size_t),           /* incore */
-        SEGSPT_BADOP(int),              /* lockop */
-        SEGSPT_BADOP(int),              /* getprot */
-        SEGSPT_BADOP(u_offset_t),       /* getoffset */
-        SEGSPT_BADOP(int),              /* gettype */
-        SEGSPT_BADOP(int),              /* getvp */
-        SEGSPT_BADOP(int),              /* advise */
-        SEGSPT_BADOP(void),             /* dump */
-        SEGSPT_BADOP(int),              /* pagelock */
-        SEGSPT_BADOP(int),              /* setpgsz */
-        SEGSPT_BADOP(int),              /* getmemid */
-        segspt_getpolicy,               /* getpolicy */
-        SEGSPT_BADOP(int),              /* capable */
-        seg_inherit_notsup              /* inherit */
+static const struct seg_ops segspt_ops = {
+        .unmap          = segspt_unmap,
+        .free           = segspt_free,
+        .getpolicy      = segspt_getpolicy,
 };
 
 static int segspt_shmdup(struct seg *seg, struct seg *newseg);
 static int segspt_shmunmap(struct seg *seg, caddr_t raddr, size_t ssize);
 static void segspt_shmfree(struct seg *seg);

@@ -121,11 +91,10 @@
 static int segspt_shmsetprot(register struct seg *seg, register caddr_t addr,
                         register size_t len, register uint_t prot);
 static int segspt_shmcheckprot(struct seg *seg, caddr_t addr, size_t size,
                         uint_t prot);
 static int      segspt_shmkluster(struct seg *seg, caddr_t addr, ssize_t delta);
-static size_t   segspt_shmswapout(struct seg *seg);
 static size_t segspt_shmincore(struct seg *seg, caddr_t addr, size_t len,
                         register char *vec);
 static int segspt_shmsync(struct seg *seg, register caddr_t addr, size_t len,
                         int attr, uint_t flags);
 static int segspt_shmlockop(struct seg *seg, caddr_t addr, size_t len,

@@ -135,43 +104,35 @@
 static u_offset_t segspt_shmgetoffset(struct seg *seg, caddr_t addr);
 static int segspt_shmgettype(struct seg *seg, caddr_t addr);
 static int segspt_shmgetvp(struct seg *seg, caddr_t addr, struct vnode **vpp);
 static int segspt_shmadvise(struct seg *seg, caddr_t addr, size_t len,
                         uint_t behav);
-static void segspt_shmdump(struct seg *seg);
 static int segspt_shmpagelock(struct seg *, caddr_t, size_t,
                         struct page ***, enum lock_type, enum seg_rw);
-static int segspt_shmsetpgsz(struct seg *, caddr_t, size_t, uint_t);
 static int segspt_shmgetmemid(struct seg *, caddr_t, memid_t *);
 static lgrp_mem_policy_info_t *segspt_shmgetpolicy(struct seg *, caddr_t);
-static int segspt_shmcapable(struct seg *, segcapability_t);
 
-struct seg_ops segspt_shmops = {
-        segspt_shmdup,
-        segspt_shmunmap,
-        segspt_shmfree,
-        segspt_shmfault,
-        segspt_shmfaulta,
-        segspt_shmsetprot,
-        segspt_shmcheckprot,
-        segspt_shmkluster,
-        segspt_shmswapout,
-        segspt_shmsync,
-        segspt_shmincore,
-        segspt_shmlockop,
-        segspt_shmgetprot,
-        segspt_shmgetoffset,
-        segspt_shmgettype,
-        segspt_shmgetvp,
-        segspt_shmadvise,       /* advise */
-        segspt_shmdump,
-        segspt_shmpagelock,
-        segspt_shmsetpgsz,
-        segspt_shmgetmemid,
-        segspt_shmgetpolicy,
-        segspt_shmcapable,
-        seg_inherit_notsup
+const struct seg_ops segspt_shmops = {
+        .dup            = segspt_shmdup,
+        .unmap          = segspt_shmunmap,
+        .free           = segspt_shmfree,
+        .fault          = segspt_shmfault,
+        .faulta         = segspt_shmfaulta,
+        .setprot        = segspt_shmsetprot,
+        .checkprot      = segspt_shmcheckprot,
+        .kluster        = segspt_shmkluster,
+        .sync           = segspt_shmsync,
+        .incore         = segspt_shmincore,
+        .lockop         = segspt_shmlockop,
+        .getprot        = segspt_shmgetprot,
+        .getoffset      = segspt_shmgetoffset,
+        .gettype        = segspt_shmgettype,
+        .getvp          = segspt_shmgetvp,
+        .advise         = segspt_shmadvise,
+        .pagelock       = segspt_shmpagelock,
+        .getmemid       = segspt_shmgetmemid,
+        .getpolicy      = segspt_shmgetpolicy,
 };
 
 static void segspt_purge(struct seg *seg);
 static int segspt_reclaim(void *, caddr_t, size_t, struct page **,
                 enum seg_rw, int);

@@ -1922,32 +1883,22 @@
                                 hat_memload_array(sptseg->s_as->a_hat,
                                     a, pgsz, &ppa[pidx], sptd->spt_prot,
                                     HAT_LOAD_LOCK | HAT_LOAD_SHARE);
                         }
                 } else {
-                        if (hat == seg->s_as->a_hat) {
-
                                 /*
                                  * Migrate pages marked for migration
                                  */
                                 if (lgrp_optimizations())
-                                        page_migrate(seg, shm_addr, ppa,
-                                            npages);
+                                page_migrate(seg, shm_addr, ppa, npages);
 
-                                /* CPU HAT */
-                                for (; pidx < npages;
-                                    a += pgsz, pidx += pgcnt) {
+                        for (; pidx < npages; a += pgsz, pidx += pgcnt) {
                                         hat_memload_array(sptseg->s_as->a_hat,
                                             a, pgsz, &ppa[pidx],
                                             sptd->spt_prot,
                                             HAT_LOAD_SHARE);
                                 }
-                        } else {
-                                /* XHAT. Pass real address */
-                                hat_memload_array(hat, shm_addr,
-                                    size, ppa, sptd->spt_prot, HAT_LOAD_SHARE);
-                        }
 
                         /*
                          * And now drop the SE_SHARED lock(s).
                          */
                         if (dyn_ism_unmap) {

@@ -2182,33 +2133,22 @@
                                 hat_memload_array(sptseg->s_as->a_hat, a,
                                     sz, &ppa[pidx], sptd->spt_prot,
                                     HAT_LOAD_LOCK | HAT_LOAD_SHARE);
                         }
                 } else {
-                        if (hat == seg->s_as->a_hat) {
-
                                 /*
                                  * Migrate pages marked for migration.
                                  */
                                 if (lgrp_optimizations())
-                                        page_migrate(seg, shm_addr, ppa,
-                                            npages);
+                                page_migrate(seg, shm_addr, ppa, npages);
 
-                                /* CPU HAT */
-                                for (; pidx < npages;
-                                    a += pgsz, pidx += pgcnt) {
+                        for (; pidx < npages; a += pgsz, pidx += pgcnt) {
                                         sz = MIN(pgsz, ptob(npages - pidx));
                                         hat_memload_array(sptseg->s_as->a_hat,
                                             a, sz, &ppa[pidx],
                                             sptd->spt_prot, HAT_LOAD_SHARE);
                                 }
-                        } else {
-                                /* XHAT. Pass real address */
-                                hat_memload_array(hat, shm_addr,
-                                    ptob(npages), ppa, sptd->spt_prot,
-                                    HAT_LOAD_SHARE);
-                        }
 
                         /*
                          * And now drop the SE_SHARED lock(s).
                          */
                         for (i = 0; i < npages; i++)

@@ -2262,17 +2202,10 @@
 segspt_shmkluster(struct seg *seg, caddr_t addr, ssize_t delta)
 {
         return (0);
 }
 
-/*ARGSUSED*/
-static size_t
-segspt_shmswapout(struct seg *seg)
-{
-        return (0);
-}
-
 /*
  * duplicate the shared page tables
  */
 int
 segspt_shmdup(struct seg *seg, struct seg *newseg)

@@ -3012,24 +2945,10 @@
         }
 
         return (0);
 }
 
-/*ARGSUSED*/
-void
-segspt_shmdump(struct seg *seg)
-{
-        /* no-op for ISM segment */
-}
-
-/*ARGSUSED*/
-static faultcode_t
-segspt_shmsetpgsz(struct seg *seg, caddr_t addr, size_t len, uint_t szc)
-{
-        return (ENOTSUP);
-}
-
 /*
  * get a memory ID for an addr in a given segment
  */
 static int
 segspt_shmgetmemid(struct seg *seg, caddr_t addr, memid_t *memidp)

@@ -3106,12 +3025,5 @@
         anon_index = seg_page(seg, addr);
         policy_info = lgrp_shm_policy_get(amp, anon_index, NULL, 0);
 
         return (policy_info);
 }
-
-/*ARGSUSED*/
-static int
-segspt_shmcapable(struct seg *seg, segcapability_t capability)
-{
-        return (0);
-}