Changes in kernel/generic/src/sysinfo/stats.c [169815e:07d4271] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/sysinfo/stats.c
r169815e r07d4271 221 221 stats_task->virtmem = get_task_virtmem(task->as); 222 222 stats_task->resmem = get_task_resmem(task->as); 223 stats_task->threads = atomic_load(&task-> refcount);223 stats_task->threads = atomic_load(&task->lifecount); 224 224 task_get_accounting(task, &(stats_task->ucycles), 225 225 &(stats_task->kcycles)); … … 299 299 { 300 300 assert(interrupts_disabled()); 301 assert(irq_spinlock_locked(&thread->lock));302 301 303 302 stats_thread->thread_id = thread->tid; 304 303 stats_thread->task_id = thread->task->taskid; 305 stats_thread->state = thread->state; 306 stats_thread->priority = thread->priority; 307 stats_thread->ucycles = thread->ucycles; 308 stats_thread->kcycles = thread->kcycles; 309 310 if (thread->cpu != NULL) { 304 stats_thread->state = atomic_get_unordered(&thread->state); 305 stats_thread->priority = atomic_get_unordered(&thread->priority); 306 stats_thread->ucycles = atomic_time_read(&thread->ucycles); 307 stats_thread->kcycles = atomic_time_read(&thread->kcycles); 308 309 cpu_t *cpu = atomic_get_unordered(&thread->cpu); 310 311 if (cpu != NULL) { 311 312 stats_thread->on_cpu = true; 312 stats_thread->cpu = thread->cpu->id;313 stats_thread->cpu = cpu->id; 313 314 } else 314 315 stats_thread->on_cpu = false; … … 361 362 thread_t *thread = thread_first(); 362 363 while (thread != NULL) { 363 /* Interrupts are already disabled */364 irq_spinlock_lock(&thread->lock, false);365 366 364 /* Record the statistics and increment the index */ 367 365 produce_stats_thread(thread, &stats_threads[i]); 368 366 i++; 369 370 irq_spinlock_unlock(&thread->lock, false);371 367 372 368 thread = thread_next(thread); … … 515 511 { 516 512 /* Initially no return value */ 517 sysinfo_return_t ret; 518 ret.tag = SYSINFO_VAL_UNDEFINED; 513 sysinfo_return_t ret = { 514 .tag = SYSINFO_VAL_UNDEFINED, 515 }; 519 516 520 517 /* Parse the task ID */ … … 523 520 return ret; 524 521 525 /* Messing with task structures, avoid deadlock */526 irq_spinlock_lock(&tasks_lock, true);527 528 522 task_t *task = task_find_by_id(task_id); 529 if (task == NULL) { 530 /* No task with this ID */ 531 irq_spinlock_unlock(&tasks_lock, true); 523 if (!task) 532 524 return ret; 533 }534 525 535 526 if (dry_run) { … … 537 528 ret.data.data = NULL; 538 529 ret.data.size = sizeof(stats_task_t); 539 540 irq_spinlock_unlock(&tasks_lock, true);541 530 } else { 542 531 /* Allocate stats_task_t structure */ 543 stats_task_t *stats_task = 544 (stats_task_t *) malloc(sizeof(stats_task_t)); 545 if (stats_task == NULL) { 546 irq_spinlock_unlock(&tasks_lock, true); 547 return ret; 532 stats_task_t *stats_task = malloc(sizeof(stats_task_t)); 533 534 if (stats_task != NULL) { 535 /* Correct return value */ 536 ret.tag = SYSINFO_VAL_FUNCTION_DATA; 537 ret.data.data = stats_task; 538 ret.data.size = sizeof(stats_task_t); 539 540 irq_spinlock_lock(&task->lock, true); 541 produce_stats_task(task, stats_task); 542 irq_spinlock_unlock(&task->lock, true); 548 543 } 549 550 /* Correct return value */ 551 ret.tag = SYSINFO_VAL_FUNCTION_DATA; 552 ret.data.data = (void *) stats_task; 553 ret.data.size = sizeof(stats_task_t); 554 555 /* Hand-over-hand locking */ 556 irq_spinlock_exchange(&tasks_lock, &task->lock); 557 558 produce_stats_task(task, stats_task); 559 560 irq_spinlock_unlock(&task->lock, true); 561 } 562 544 } 545 546 task_release(task); 563 547 return ret; 564 548 } … … 624 608 ret.data.size = sizeof(stats_thread_t); 625 609 626 /*627 * Replaced hand-over-hand locking with regular nested sections628 * to avoid weak reference leak issues.629 */630 irq_spinlock_lock(&thread->lock, false);631 610 produce_stats_thread(thread, stats_thread); 632 irq_spinlock_unlock(&thread->lock, false);633 611 634 612 irq_spinlock_unlock(&threads_lock, true);
Note:
See TracChangeset
for help on using the changeset viewer.