Print this page
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.


  95 static int      segspt_shmkluster(struct seg *seg, caddr_t addr, ssize_t delta);
  96 static size_t segspt_shmincore(struct seg *seg, caddr_t addr, size_t len,
  97                         register char *vec);
  98 static int segspt_shmsync(struct seg *seg, register caddr_t addr, size_t len,
  99                         int attr, uint_t flags);
 100 static int segspt_shmlockop(struct seg *seg, caddr_t addr, size_t len,
 101                         int attr, int op, ulong_t *lockmap, size_t pos);
 102 static int segspt_shmgetprot(struct seg *seg, caddr_t addr, size_t len,
 103                         uint_t *protv);
 104 static u_offset_t segspt_shmgetoffset(struct seg *seg, caddr_t addr);
 105 static int segspt_shmgettype(struct seg *seg, caddr_t addr);
 106 static int segspt_shmgetvp(struct seg *seg, caddr_t addr, struct vnode **vpp);
 107 static int segspt_shmadvise(struct seg *seg, caddr_t addr, size_t len,
 108                         uint_t behav);
 109 static void segspt_shmdump(struct seg *seg);
 110 static int segspt_shmpagelock(struct seg *, caddr_t, size_t,
 111                         struct page ***, enum lock_type, enum seg_rw);
 112 static int segspt_shmsetpgsz(struct seg *, caddr_t, size_t, uint_t);
 113 static int segspt_shmgetmemid(struct seg *, caddr_t, memid_t *);
 114 static lgrp_mem_policy_info_t *segspt_shmgetpolicy(struct seg *, caddr_t);
 115 static int segspt_shmcapable(struct seg *, segcapability_t);
 116 
 117 struct seg_ops segspt_shmops = {
 118         .dup            = segspt_shmdup,
 119         .unmap          = segspt_shmunmap,
 120         .free           = segspt_shmfree,
 121         .fault          = segspt_shmfault,
 122         .faulta         = segspt_shmfaulta,
 123         .setprot        = segspt_shmsetprot,
 124         .checkprot      = segspt_shmcheckprot,
 125         .kluster        = segspt_shmkluster,
 126         .sync           = segspt_shmsync,
 127         .incore         = segspt_shmincore,
 128         .lockop         = segspt_shmlockop,
 129         .getprot        = segspt_shmgetprot,
 130         .getoffset      = segspt_shmgetoffset,
 131         .gettype        = segspt_shmgettype,
 132         .getvp          = segspt_shmgetvp,
 133         .advise         = segspt_shmadvise,
 134         .dump           = segspt_shmdump,
 135         .pagelock       = segspt_shmpagelock,
 136         .setpagesize    = segspt_shmsetpgsz,
 137         .getmemid       = segspt_shmgetmemid,
 138         .getpolicy      = segspt_shmgetpolicy,
 139         .capable        = segspt_shmcapable,
 140 };
 141 
 142 static void segspt_purge(struct seg *seg);
 143 static int segspt_reclaim(void *, caddr_t, size_t, struct page **,
 144                 enum seg_rw, int);
 145 static int spt_anon_getpages(struct seg *seg, caddr_t addr, size_t len,
 146                 page_t **ppa);
 147 
 148 
 149 
 150 /*ARGSUSED*/
 151 int
 152 sptcreate(size_t size, struct seg **sptseg, struct anon_map *amp,
 153         uint_t prot, uint_t flags, uint_t share_szc)
 154 {
 155         int     err;
 156         struct  as      *newas;
 157         struct  segspt_crargs sptcargs;
 158 
 159 #ifdef DEBUG


3029          * Assume that no lock needs to be held on anon_map, since
3030          * it should be protected by its reference count which must be
3031          * nonzero for an existing segment
3032          * Need to grab readers lock on policy tree though
3033          */
3034         shm_data = (struct shm_data *)seg->s_data;
3035         if (shm_data == NULL)
3036                 return (NULL);
3037         amp = shm_data->shm_amp;
3038         ASSERT(amp->refcnt != 0);
3039 
3040         /*
3041          * Get policy info
3042          *
3043          * Assume starting anon index of 0
3044          */
3045         anon_index = seg_page(seg, addr);
3046         policy_info = lgrp_shm_policy_get(amp, anon_index, NULL, 0);
3047 
3048         return (policy_info);
3049 }
3050 
3051 /*ARGSUSED*/
3052 static int
3053 segspt_shmcapable(struct seg *seg, segcapability_t capability)
3054 {
3055         return (0);
3056 }


  95 static int      segspt_shmkluster(struct seg *seg, caddr_t addr, ssize_t delta);
  96 static size_t segspt_shmincore(struct seg *seg, caddr_t addr, size_t len,
  97                         register char *vec);
  98 static int segspt_shmsync(struct seg *seg, register caddr_t addr, size_t len,
  99                         int attr, uint_t flags);
 100 static int segspt_shmlockop(struct seg *seg, caddr_t addr, size_t len,
 101                         int attr, int op, ulong_t *lockmap, size_t pos);
 102 static int segspt_shmgetprot(struct seg *seg, caddr_t addr, size_t len,
 103                         uint_t *protv);
 104 static u_offset_t segspt_shmgetoffset(struct seg *seg, caddr_t addr);
 105 static int segspt_shmgettype(struct seg *seg, caddr_t addr);
 106 static int segspt_shmgetvp(struct seg *seg, caddr_t addr, struct vnode **vpp);
 107 static int segspt_shmadvise(struct seg *seg, caddr_t addr, size_t len,
 108                         uint_t behav);
 109 static void segspt_shmdump(struct seg *seg);
 110 static int segspt_shmpagelock(struct seg *, caddr_t, size_t,
 111                         struct page ***, enum lock_type, enum seg_rw);
 112 static int segspt_shmsetpgsz(struct seg *, caddr_t, size_t, uint_t);
 113 static int segspt_shmgetmemid(struct seg *, caddr_t, memid_t *);
 114 static lgrp_mem_policy_info_t *segspt_shmgetpolicy(struct seg *, caddr_t);

 115 
 116 struct seg_ops segspt_shmops = {
 117         .dup            = segspt_shmdup,
 118         .unmap          = segspt_shmunmap,
 119         .free           = segspt_shmfree,
 120         .fault          = segspt_shmfault,
 121         .faulta         = segspt_shmfaulta,
 122         .setprot        = segspt_shmsetprot,
 123         .checkprot      = segspt_shmcheckprot,
 124         .kluster        = segspt_shmkluster,
 125         .sync           = segspt_shmsync,
 126         .incore         = segspt_shmincore,
 127         .lockop         = segspt_shmlockop,
 128         .getprot        = segspt_shmgetprot,
 129         .getoffset      = segspt_shmgetoffset,
 130         .gettype        = segspt_shmgettype,
 131         .getvp          = segspt_shmgetvp,
 132         .advise         = segspt_shmadvise,
 133         .dump           = segspt_shmdump,
 134         .pagelock       = segspt_shmpagelock,
 135         .setpagesize    = segspt_shmsetpgsz,
 136         .getmemid       = segspt_shmgetmemid,
 137         .getpolicy      = segspt_shmgetpolicy,

 138 };
 139 
 140 static void segspt_purge(struct seg *seg);
 141 static int segspt_reclaim(void *, caddr_t, size_t, struct page **,
 142                 enum seg_rw, int);
 143 static int spt_anon_getpages(struct seg *seg, caddr_t addr, size_t len,
 144                 page_t **ppa);
 145 
 146 
 147 
 148 /*ARGSUSED*/
 149 int
 150 sptcreate(size_t size, struct seg **sptseg, struct anon_map *amp,
 151         uint_t prot, uint_t flags, uint_t share_szc)
 152 {
 153         int     err;
 154         struct  as      *newas;
 155         struct  segspt_crargs sptcargs;
 156 
 157 #ifdef DEBUG


3027          * Assume that no lock needs to be held on anon_map, since
3028          * it should be protected by its reference count which must be
3029          * nonzero for an existing segment
3030          * Need to grab readers lock on policy tree though
3031          */
3032         shm_data = (struct shm_data *)seg->s_data;
3033         if (shm_data == NULL)
3034                 return (NULL);
3035         amp = shm_data->shm_amp;
3036         ASSERT(amp->refcnt != 0);
3037 
3038         /*
3039          * Get policy info
3040          *
3041          * Assume starting anon index of 0
3042          */
3043         anon_index = seg_page(seg, addr);
3044         policy_info = lgrp_shm_policy_get(amp, anon_index, NULL, 0);
3045 
3046         return (policy_info);







3047 }