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.
segop_getpolicy already checks for a NULL op
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

*** 29,40 **** /* * Portions of this source code were derived from Berkeley 4.3 BSD * under license from the Regents of the University of California. */ - #pragma ident "%Z%%M% %I% %E% SMI" - /* * VM - segment for non-faulting loads. */ #include <sys/types.h> --- 29,38 ----
*** 66,122 **** static faultcode_t segnf_nomap(void); static int segnf_setprot(struct seg *seg, caddr_t addr, size_t len, uint_t prot); static int segnf_checkprot(struct seg *seg, caddr_t addr, size_t len, uint_t prot); - static void segnf_badop(void); static int segnf_nop(void); static int segnf_getprot(struct seg *seg, caddr_t addr, size_t len, uint_t *protv); static u_offset_t segnf_getoffset(struct seg *seg, caddr_t addr); static int segnf_gettype(struct seg *seg, caddr_t addr); static int segnf_getvp(struct seg *seg, caddr_t addr, struct vnode **vpp); - static void segnf_dump(struct seg *seg); static int segnf_pagelock(struct seg *seg, caddr_t addr, size_t len, struct page ***ppp, enum lock_type type, enum seg_rw rw); ! static int segnf_setpagesize(struct seg *seg, caddr_t addr, size_t len, ! uint_t szc); ! static int segnf_getmemid(struct seg *seg, caddr_t addr, memid_t *memidp); ! static lgrp_mem_policy_info_t *segnf_getpolicy(struct seg *seg, ! caddr_t addr); ! ! ! struct seg_ops segnf_ops = { ! segnf_dup, ! segnf_unmap, ! segnf_free, ! (faultcode_t (*)(struct hat *, struct seg *, caddr_t, size_t, ! enum fault_type, enum seg_rw)) ! segnf_nomap, /* fault */ ! (faultcode_t (*)(struct seg *, caddr_t)) ! segnf_nomap, /* faulta */ ! segnf_setprot, ! segnf_checkprot, ! (int (*)())segnf_badop, /* kluster */ ! (size_t (*)(struct seg *))NULL, /* swapout */ ! (int (*)(struct seg *, caddr_t, size_t, int, uint_t)) ! segnf_nop, /* sync */ ! (size_t (*)(struct seg *, caddr_t, size_t, char *)) ! segnf_nop, /* incore */ ! (int (*)(struct seg *, caddr_t, size_t, int, int, ulong_t *, size_t)) ! segnf_nop, /* lockop */ ! segnf_getprot, ! segnf_getoffset, ! segnf_gettype, ! segnf_getvp, ! (int (*)(struct seg *, caddr_t, size_t, uint_t)) ! segnf_nop, /* advise */ ! segnf_dump, ! segnf_pagelock, ! segnf_setpagesize, ! segnf_getmemid, ! segnf_getpolicy, }; /* * vnode and page for the page of zeros we use for the nf mappings. */ --- 64,105 ---- static faultcode_t segnf_nomap(void); static int segnf_setprot(struct seg *seg, caddr_t addr, size_t len, uint_t prot); static int segnf_checkprot(struct seg *seg, caddr_t addr, size_t len, uint_t prot); static int segnf_nop(void); static int segnf_getprot(struct seg *seg, caddr_t addr, size_t len, uint_t *protv); static u_offset_t segnf_getoffset(struct seg *seg, caddr_t addr); static int segnf_gettype(struct seg *seg, caddr_t addr); static int segnf_getvp(struct seg *seg, caddr_t addr, struct vnode **vpp); static int segnf_pagelock(struct seg *seg, caddr_t addr, size_t len, struct page ***ppp, enum lock_type type, enum seg_rw rw); ! ! ! const struct seg_ops segnf_ops = { ! .dup = segnf_dup, ! .unmap = segnf_unmap, ! .free = segnf_free, ! .fault = (faultcode_t (*)(struct hat *, struct seg *, caddr_t, ! size_t, enum fault_type, enum seg_rw))segnf_nomap, ! .faulta = (faultcode_t (*)(struct seg *, caddr_t)) segnf_nomap, ! .setprot = segnf_setprot, ! .checkprot = segnf_checkprot, ! .sync = (int (*)(struct seg *, caddr_t, size_t, int, uint_t)) ! segnf_nop, ! .incore = (size_t (*)(struct seg *, caddr_t, size_t, char *)) ! segnf_nop, ! .lockop = (int (*)(struct seg *, caddr_t, size_t, int, int, ! ulong_t *, size_t))segnf_nop, ! .getprot = segnf_getprot, ! .getoffset = segnf_getoffset, ! .gettype = segnf_gettype, ! .getvp = segnf_getvp, ! .advise = (int (*)(struct seg *, caddr_t, size_t, uint_t)) ! segnf_nop, ! .pagelock = segnf_pagelock, }; /* * vnode and page for the page of zeros we use for the nf mappings. */
*** 404,420 **** sprot = seg->s_as == &kas ? PROT_READ : PROT_READ|PROT_USER; return ((prot & sprot) == prot ? 0 : EACCES); } - static void - segnf_badop(void) - { - panic("segnf_badop"); - /*NOTREACHED*/ - } - static int segnf_nop(void) { return (0); } --- 387,396 ----
*** 457,498 **** *vpp = &nfvp; return (0); } - /* - * segnf pages are not dumped, so we just return - */ - /* ARGSUSED */ - static void - segnf_dump(struct seg *seg) - {} - /*ARGSUSED*/ static int segnf_pagelock(struct seg *seg, caddr_t addr, size_t len, struct page ***ppp, enum lock_type type, enum seg_rw rw) { return (ENOTSUP); } - - /*ARGSUSED*/ - static int - segnf_setpagesize(struct seg *seg, caddr_t addr, size_t len, - uint_t szc) - { - return (ENOTSUP); - } - - /*ARGSUSED*/ - static int - segnf_getmemid(struct seg *seg, caddr_t addr, memid_t *memidp) - { - return (ENODEV); - } - - /*ARGSUSED*/ - static lgrp_mem_policy_info_t * - segnf_getpolicy(struct seg *seg, caddr_t addr) - { - return (NULL); - } --- 433,444 ----