Print this page
lgrp: getpolicy seg op has been around long enough
This special casing has been around for more than 10 years.  It's time for
it to go.  (There are no third party segment drivers anyway.)
segop_getpolicy already checks for a NULL op
patch lower-case-segops


3484                         policy = LGRP_MEM_POLICY_RANDOM_PSET;
3485                 else
3486                         policy = LGRP_MEM_POLICY_RANDOM;
3487         } else
3488                 /*
3489                  * Apply default policy for private memory and
3490                  * shared memory under the respective random
3491                  * threshold.
3492                  */
3493                 policy = lgrp_mem_default_policy;
3494 
3495         return (policy);
3496 }
3497 
3498 /*
3499  * Get memory allocation policy for this segment
3500  */
3501 lgrp_mem_policy_info_t *
3502 lgrp_mem_policy_get(struct seg *seg, caddr_t vaddr)
3503 {
3504         lgrp_mem_policy_info_t  *policy_info;
3505         extern struct seg_ops   segspt_ops;
3506         extern struct seg_ops   segspt_shmops;
3507 
3508         /*
3509          * This is for binary compatibility to protect against third party
3510          * segment drivers which haven't recompiled to allow for
3511          * SEGOP_GETPOLICY()
3512          */
3513         if (seg->s_ops != &segvn_ops && seg->s_ops != &segspt_ops &&
3514             seg->s_ops != &segspt_shmops)
3515                 return (NULL);
3516 
3517         policy_info = NULL;
3518         if (seg->s_ops->getpolicy != NULL)
3519                 policy_info = SEGOP_GETPOLICY(seg, vaddr);
3520 
3521         return (policy_info);
3522 }
3523 
3524 /*
3525  * Set policy for allocating private memory given desired policy, policy info,
3526  * size in bytes of memory that policy is being applied.
3527  * Return 0 if policy wasn't set already and 1 if policy was set already
3528  */
3529 int
3530 lgrp_privm_policy_set(lgrp_mem_policy_t policy,
3531     lgrp_mem_policy_info_t *policy_info, size_t size)
3532 {
3533 
3534         ASSERT(policy_info != NULL);
3535 
3536         if (policy == LGRP_MEM_POLICY_DEFAULT)
3537                 policy = lgrp_mem_policy_default(size, MAP_PRIVATE);
3538 
3539         /*
3540          * Policy set already?
3541          */




3484                         policy = LGRP_MEM_POLICY_RANDOM_PSET;
3485                 else
3486                         policy = LGRP_MEM_POLICY_RANDOM;
3487         } else
3488                 /*
3489                  * Apply default policy for private memory and
3490                  * shared memory under the respective random
3491                  * threshold.
3492                  */
3493                 policy = lgrp_mem_default_policy;
3494 
3495         return (policy);
3496 }
3497 
3498 /*
3499  * Get memory allocation policy for this segment
3500  */
3501 lgrp_mem_policy_info_t *
3502 lgrp_mem_policy_get(struct seg *seg, caddr_t vaddr)
3503 {
3504         return (segop_getpolicy(seg, vaddr));

















3505 }
3506 
3507 /*
3508  * Set policy for allocating private memory given desired policy, policy info,
3509  * size in bytes of memory that policy is being applied.
3510  * Return 0 if policy wasn't set already and 1 if policy was set already
3511  */
3512 int
3513 lgrp_privm_policy_set(lgrp_mem_policy_t policy,
3514     lgrp_mem_policy_info_t *policy_info, size_t size)
3515 {
3516 
3517         ASSERT(policy_info != NULL);
3518 
3519         if (policy == LGRP_MEM_POLICY_DEFAULT)
3520                 policy = lgrp_mem_policy_default(size, MAP_PRIVATE);
3521 
3522         /*
3523          * Policy set already?
3524          */