Print this page
patch as-lock-macro-simplification


1516                     p->p_task->tk_proj->kpj_id, VMUSAGE_PROJECTS, ALL_ZONES);
1517                 tmp->vme_next_calc = entities;
1518                 entities = tmp;
1519         }
1520         if (vmu_data.vmu_calc_flags & VMUSAGE_COL_RUSERS) {
1521                 tmp = vmu_find_insert_entity(vmu_data.vmu_rusers_col_hash,
1522                     crgetruid(p->p_cred), VMUSAGE_RUSERS, ALL_ZONES);
1523                 tmp->vme_next_calc = entities;
1524                 entities = tmp;
1525         }
1526         if (vmu_data.vmu_calc_flags & VMUSAGE_COL_EUSERS) {
1527                 tmp = vmu_find_insert_entity(vmu_data.vmu_eusers_col_hash,
1528                     crgetuid(p->p_cred), VMUSAGE_EUSERS, ALL_ZONES);
1529                 tmp->vme_next_calc = entities;
1530                 entities = tmp;
1531         }
1532 
1533         ASSERT(entities != NULL);
1534         /* process all segs in process's address space */
1535         as = p->p_as;
1536         AS_LOCK_ENTER(as, &as->a_lock, RW_READER);
1537         for (seg = AS_SEGFIRST(as); seg != NULL;
1538             seg = AS_SEGNEXT(as, seg)) {
1539                 vmu_calculate_seg(entities, seg);
1540         }
1541         AS_LOCK_EXIT(as, &as->a_lock);
1542 }
1543 
1544 /*
1545  * Free data created by previous call to vmu_calculate().
1546  */
1547 static void
1548 vmu_clear_calc()
1549 {
1550         if (vmu_data.vmu_system != NULL)
1551                 vmu_free_entity(vmu_data.vmu_system);
1552                 vmu_data.vmu_system = NULL;
1553         if (vmu_data.vmu_zones_hash != NULL)
1554                 i_mod_hash_clear_nosync(vmu_data.vmu_zones_hash);
1555         if (vmu_data.vmu_projects_col_hash != NULL)
1556                 i_mod_hash_clear_nosync(vmu_data.vmu_projects_col_hash);
1557         if (vmu_data.vmu_rusers_col_hash != NULL)
1558                 i_mod_hash_clear_nosync(vmu_data.vmu_rusers_col_hash);
1559         if (vmu_data.vmu_eusers_col_hash != NULL)
1560                 i_mod_hash_clear_nosync(vmu_data.vmu_eusers_col_hash);
1561 




1516                     p->p_task->tk_proj->kpj_id, VMUSAGE_PROJECTS, ALL_ZONES);
1517                 tmp->vme_next_calc = entities;
1518                 entities = tmp;
1519         }
1520         if (vmu_data.vmu_calc_flags & VMUSAGE_COL_RUSERS) {
1521                 tmp = vmu_find_insert_entity(vmu_data.vmu_rusers_col_hash,
1522                     crgetruid(p->p_cred), VMUSAGE_RUSERS, ALL_ZONES);
1523                 tmp->vme_next_calc = entities;
1524                 entities = tmp;
1525         }
1526         if (vmu_data.vmu_calc_flags & VMUSAGE_COL_EUSERS) {
1527                 tmp = vmu_find_insert_entity(vmu_data.vmu_eusers_col_hash,
1528                     crgetuid(p->p_cred), VMUSAGE_EUSERS, ALL_ZONES);
1529                 tmp->vme_next_calc = entities;
1530                 entities = tmp;
1531         }
1532 
1533         ASSERT(entities != NULL);
1534         /* process all segs in process's address space */
1535         as = p->p_as;
1536         AS_LOCK_ENTER(as, RW_READER);
1537         for (seg = AS_SEGFIRST(as); seg != NULL;
1538             seg = AS_SEGNEXT(as, seg)) {
1539                 vmu_calculate_seg(entities, seg);
1540         }
1541         AS_LOCK_EXIT(as);
1542 }
1543 
1544 /*
1545  * Free data created by previous call to vmu_calculate().
1546  */
1547 static void
1548 vmu_clear_calc()
1549 {
1550         if (vmu_data.vmu_system != NULL)
1551                 vmu_free_entity(vmu_data.vmu_system);
1552                 vmu_data.vmu_system = NULL;
1553         if (vmu_data.vmu_zones_hash != NULL)
1554                 i_mod_hash_clear_nosync(vmu_data.vmu_zones_hash);
1555         if (vmu_data.vmu_projects_col_hash != NULL)
1556                 i_mod_hash_clear_nosync(vmu_data.vmu_projects_col_hash);
1557         if (vmu_data.vmu_rusers_col_hash != NULL)
1558                 i_mod_hash_clear_nosync(vmu_data.vmu_rusers_col_hash);
1559         if (vmu_data.vmu_eusers_col_hash != NULL)
1560                 i_mod_hash_clear_nosync(vmu_data.vmu_eusers_col_hash);
1561