Changes in kernel/generic/src/sysinfo/stats.c [fc47885:96b02eb9] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/sysinfo/stats.c
rfc47885 r96b02eb9 160 160 static size_t get_task_virtmem(as_t *as) 161 161 { 162 size_t result = 0; 163 162 164 /* 163 * We are holding spinlocks here and therefore are not allowed to 164 * block. Only attempt to lock the address space and address space 165 * area mutexes conditionally. If it is not possible to lock either 166 * object, return inexact statistics by skipping the respective object. 165 * We are holding some spinlocks here and therefore are not allowed to 166 * block. Only attempt to lock the address space and address space area 167 * mutexes conditionally. If it is not possible to lock either object, 168 * allow the statistics to be inexact by skipping the respective object. 169 * 170 * Note that it may be infinitely better to let the address space 171 * management code compute these statistics as it proceeds instead of 172 * having them calculated here over and over again here. 167 173 */ 168 174 169 175 if (SYNCH_FAILED(mutex_trylock(&as->lock))) 170 return 0; 171 172 size_t pages = 0; 176 return result * PAGE_SIZE; 173 177 174 178 /* Walk the B+ tree and count pages */ … … 185 189 if (SYNCH_FAILED(mutex_trylock(&area->lock))) 186 190 continue; 187 188 pages += area->pages; 191 result += area->pages; 189 192 mutex_unlock(&area->lock); 190 193 } … … 193 196 mutex_unlock(&as->lock); 194 197 195 return (pages << PAGE_WIDTH); 196 } 197 198 /** Get the resident (used) size of a virtual address space 199 * 200 * @param as Address space. 201 * 202 * @return Size of the resident (used) virtual address space (bytes). 203 * 204 */ 205 static size_t get_task_resmem(as_t *as) 206 { 207 /* 208 * We are holding spinlocks here and therefore are not allowed to 209 * block. Only attempt to lock the address space and address space 210 * area mutexes conditionally. If it is not possible to lock either 211 * object, return inexact statistics by skipping the respective object. 212 */ 213 214 if (SYNCH_FAILED(mutex_trylock(&as->lock))) 215 return 0; 216 217 size_t pages = 0; 218 219 /* Walk the B+ tree and count pages */ 220 link_t *cur; 221 for (cur = as->as_area_btree.leaf_head.next; 222 cur != &as->as_area_btree.leaf_head; cur = cur->next) { 223 btree_node_t *node = 224 list_get_instance(cur, btree_node_t, leaf_link); 225 226 unsigned int i; 227 for (i = 0; i < node->keys; i++) { 228 as_area_t *area = node->value[i]; 229 230 if (SYNCH_FAILED(mutex_trylock(&area->lock))) 231 continue; 232 233 pages += area->resident; 234 mutex_unlock(&area->lock); 235 } 236 } 237 238 mutex_unlock(&as->lock); 239 240 return (pages << PAGE_WIDTH); 198 return result * PAGE_SIZE; 241 199 } 242 200 … … 257 215 str_cpy(stats_task->name, TASK_NAME_BUFLEN, task->name); 258 216 stats_task->virtmem = get_task_virtmem(task->as); 259 stats_task->resmem = get_task_resmem(task->as);260 217 stats_task->threads = atomic_get(&task->refcount); 261 218 task_get_accounting(task, &(stats_task->ucycles),
Note:
See TracChangeset
for help on using the changeset viewer.