Changeset a2a00e8 in mainline
- Timestamp:
- 2010-03-28T23:05:18Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 07640dfd
- Parents:
- 34bba0e
- Location:
- kernel/generic
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/proc/task.h
r34bba0e ra2a00e8 123 123 /** Accumulated accounting. */ 124 124 uint64_t cycles; 125 uint64_t ucycles; 126 uint64_t kcycles; 125 127 } task_t; 126 128 … … 134 136 extern task_t *task_find_by_id(task_id_t id); 135 137 extern int task_kill(task_id_t id); 136 extern uint64_t task_get_accounting(task_t *t );138 extern uint64_t task_get_accounting(task_t *t, uint64_t *ucycles, uint64_t *kcycles); 137 139 extern void task_print_list(void); 138 140 -
kernel/generic/include/proc/thread.h
r34bba0e ra2a00e8 175 175 /** Thread accounting. */ 176 176 uint64_t cycles; 177 uint64_t ucycles; 178 uint64_t kcycles; 177 179 /** Last sampled cycle. */ 178 180 uint64_t last_cycle; … … 237 239 extern void thread_print_list(void); 238 240 extern void thread_destroy(thread_t *); 239 extern void thread_update_accounting( void);241 extern void thread_update_accounting(bool); 240 242 extern bool thread_exists(thread_t *); 241 243 -
kernel/generic/src/console/cmd.c
r34bba0e ra2a00e8 1027 1027 ipl_t ipl = interrupts_disable(); 1028 1028 spinlock_lock(&TASK->lock); 1029 uint64_t t0 = task_get_accounting(TASK); 1029 uint64_t ucycles, kcycles; 1030 uint64_t t0 = task_get_accounting(TASK, &ucycles, &kcycles); 1030 1031 spinlock_unlock(&TASK->lock); 1031 1032 interrupts_restore(ipl); … … 1038 1039 ipl = interrupts_disable(); 1039 1040 spinlock_lock(&TASK->lock); 1040 uint64_t dt = task_get_accounting(TASK ) - t0;1041 uint64_t dt = task_get_accounting(TASK, &ucycles, &kcycles) - t0; 1041 1042 spinlock_unlock(&TASK->lock); 1042 1043 interrupts_restore(ipl); … … 1080 1081 ipl_t ipl = interrupts_disable(); 1081 1082 spinlock_lock(&TASK->lock); 1082 uint64_t t0 = task_get_accounting(TASK); 1083 uint64_t ucycles, kcycles; 1084 uint64_t t0 = task_get_accounting(TASK, &ucycles, &kcycles); 1083 1085 spinlock_unlock(&TASK->lock); 1084 1086 interrupts_restore(ipl); … … 1091 1093 ipl = interrupts_disable(); 1092 1094 spinlock_lock(&TASK->lock); 1093 uint64_t dt = task_get_accounting(TASK ) - t0;1095 uint64_t dt = task_get_accounting(TASK, &ucycles, &kcycles) - t0; 1094 1096 spinlock_unlock(&TASK->lock); 1095 1097 interrupts_restore(ipl); -
kernel/generic/src/interrupt/interrupt.c
r34bba0e ra2a00e8 51 51 #include <print.h> 52 52 #include <symtab.h> 53 #include <proc/thread.h> 53 54 54 55 static struct { … … 90 91 { 91 92 ASSERT(n < IVT_ITEMS); 93 94 /* Account user cycles */ 95 if (THREAD) 96 thread_update_accounting(true); 92 97 93 98 #ifdef CONFIG_UDEBUG -
kernel/generic/src/proc/scheduler.c
r34bba0e ra2a00e8 315 315 /* Update thread accounting */ 316 316 THREAD->cycles += get_cycle() - THREAD->last_cycle; 317 THREAD->kcycles += get_cycle() - THREAD->last_cycle; 317 318 318 319 #ifndef CONFIG_FPU_LAZY -
kernel/generic/src/proc/task.c
r34bba0e ra2a00e8 185 185 ta->capabilities = 0; 186 186 ta->cycles = 0; 187 ta->ucycles = 0; 188 ta->kcycles = 0; 187 189 188 190 #ifdef CONFIG_UDEBUG … … 317 319 * 318 320 * @param t Pointer to thread. 319 * 320 * @return Number of cycles used by the task and all its threads 321 * so far. 322 */ 323 uint64_t task_get_accounting(task_t *t) 324 { 325 /* Accumulated value of task */ 321 * @param ucycles Out pointer to sum of all user cycles. 322 * @param kcycles Out pointer to sum of all kernel cycles. 323 */ 324 uint64_t task_get_accounting(task_t *t, uint64_t *ucycles, uint64_t *kcycles) 325 { 326 /* Accumulated values of task */ 326 327 uint64_t ret = t->cycles; 328 uint64_t uret = t->ucycles; 329 uint64_t kret = t->kcycles; 327 330 328 331 /* Current values of threads */ … … 336 339 if (thr == THREAD) { 337 340 /* Update accounting of current thread */ 338 thread_update_accounting( );341 thread_update_accounting(false); 339 342 } 343 uret += thr->ucycles; 344 kret += thr->kcycles; 340 345 ret += thr->cycles; 341 346 } … … 343 348 } 344 349 350 *ucycles = uret; 351 *kcycles = kret; 352 345 353 return ret; 346 354 } … … 410 418 411 419 uint64_t cycles; 412 char suffix; 413 order(task_get_accounting(t), &cycles, &suffix); 420 uint64_t ucycles; 421 uint64_t kcycles; 422 char suffix, usuffix, ksuffix; 423 cycles = task_get_accounting(t, &ucycles, &kcycles); 424 order(cycles, &cycles, &suffix); 425 order(ucycles, &ucycles, &usuffix); 426 order(kcycles, &kcycles, &ksuffix); 414 427 415 428 #ifdef __32_BITS__ 416 printf("%-6" PRIu64 " %-12s %-3" PRIu32 " %10p %10p %9" PRIu64 417 "%c %7ld %6ld", t->taskid, t->name, t->context, t, t->as, cycles, 418 suffix, atomic_get(&t->refcount), atomic_get(&t->active_calls)); 429 printf("%-6" PRIu64 " %-12s %-3" PRIu32 " %10p %10p %9" PRIu64 "%c %9" PRIu64 "%c %9" 430 PRIu64 "%c %7ld %6ld", t->taskid, t->name, t->context, t, t->as, cycles, suffix, 431 ucycles, usuffix, kcycles, ksuffix, atomic_get(&t->refcount), 432 atomic_get(&t->active_calls)); 419 433 #endif 420 434 421 435 #ifdef __64_BITS__ 422 printf("%-6" PRIu64 " %-12s %-3" PRIu32 " %18p %18p %9" PRIu64 423 "%c %7ld %6ld", t->taskid, t->name, t->context, t, t->as, cycles, 424 suffix, atomic_get(&t->refcount), atomic_get(&t->active_calls)); 436 printf("%-6" PRIu64 " %-12s %-3" PRIu32 " %18p %18p %9" PRIu64 "%c %9" PRIu64 "%c %9" 437 PRIu64 "%c %7ld %6ld", t->taskid, t->name, t->context, t, t->as, cycles, suffix, 438 ucycles, usuffix, kcycles, ksuffix, atomic_get(&t->refcount), 439 atomic_get(&t->active_calls)); 425 440 #endif 426 441 … … 445 460 446 461 #ifdef __32_BITS__ 447 printf("taskid name ctx address as 448 " cyclesthreads calls callee\n");449 printf("------ ------------ --- ---------- ---------- 450 " ---------- ------- ------ ------>\n");462 printf("taskid name ctx address as " 463 " cycles ucycles kcycles threads calls callee\n"); 464 printf("------ ------------ --- ---------- ----------" 465 " ---------- ---------- ---------- ------- ------ ------>\n"); 451 466 #endif 452 467 453 468 #ifdef __64_BITS__ 454 printf("taskid name ctx address as 455 " cyclesthreads calls callee\n");456 printf("------ ------------ --- ------------------ ------------------ 457 " ---------- ------- ------ ------>\n");469 printf("taskid name ctx address as " 470 " cycles ucycles kcycles threads calls callee\n"); 471 printf("------ ------------ --- ------------------ ------------------" 472 " ---------- ---------- ---------- ---------- ------- ------ ------>\n"); 458 473 #endif 459 474 -
kernel/generic/src/proc/thread.c
r34bba0e ra2a00e8 132 132 spinlock_lock(&THREAD->lock); 133 133 if (!THREAD->uncounted) { 134 thread_update_accounting( );134 thread_update_accounting(true); 135 135 uint64_t cycles = THREAD->cycles; 136 136 THREAD->cycles = 0; 137 uint64_t ucycles = THREAD->ucycles; 138 THREAD->ucycles = 0; 139 uint64_t kcycles = THREAD->kcycles; 140 THREAD->kcycles = 0; 141 137 142 spinlock_unlock(&THREAD->lock); 138 143 139 144 spinlock_lock(&TASK->lock); 140 145 TASK->cycles += cycles; 146 TASK->ucycles += ucycles; 147 TASK->kcycles += kcycles; 141 148 spinlock_unlock(&TASK->lock); 142 149 } else … … 324 331 t->ticks = -1; 325 332 t->cycles = 0; 333 t->ucycles = 0; 334 t->kcycles = 0; 326 335 t->uncounted = uncounted; 327 336 t->priority = -1; /* start in rq[0] */ … … 614 623 thread_t *t = avltree_get_instance(node, thread_t, threads_tree_node); 615 624 616 uint64_t cycles ;617 char suffix ;625 uint64_t cycles, ucycles, kcycles; 626 char suffix, usuffix, ksuffix; 618 627 order(t->cycles, &cycles, &suffix); 628 order(t->ucycles, &ucycles, &usuffix); 629 order(t->kcycles, &kcycles, &ksuffix); 619 630 620 631 #ifdef __32_BITS__ 621 printf("%-6" PRIu64" %-10s %10p %-8s %10p %-3" PRIu32 " %10p %10p %9" PRIu64 "%c ",632 printf("%-6" PRIu64" %-10s %10p %-8s %10p %-3" PRIu32 " %10p %10p %9" PRIu64 "%c %9" PRIu64 "%c %9" PRIu64 "%c ", 622 633 t->tid, t->name, t, thread_states[t->state], t->task, 623 t->task->context, t->thread_code, t->kstack, cycles, suffix );634 t->task->context, t->thread_code, t->kstack, cycles, suffix, ucycles, usuffix, kcycles, ksuffix); 624 635 #endif 625 636 626 637 #ifdef __64_BITS__ 627 printf("%-6" PRIu64" %-10s %18p %-8s %18p %-3" PRIu32 " %18p %18p %9" PRIu64 "%c ",638 printf("%-6" PRIu64" %-10s %18p %-8s %18p %-3" PRIu32 " %18p %18p %9" PRIu64 "%c %9" PRIu64 "%c %9" PRIu64 "%c ", 628 639 t->tid, t->name, t, thread_states[t->state], t->task, 629 t->task->context, t->thread_code, t->kstack, cycles, suffix );640 t->task->context, t->thread_code, t->kstack, cycles, suffix, ucycles, usuffix, kcycles, ksuffix); 630 641 #endif 631 642 … … 661 672 #ifdef __32_BITS__ 662 673 printf("tid name address state task " 663 "ctx code stack cycles cpu "674 "ctx code stack cycles ucycles kcycles cpu " 664 675 "waitqueue\n"); 665 676 printf("------ ---------- ---------- -------- ---------- " 666 "--- ---------- ---------- ---------- ---- "677 "--- ---------- ---------- ---------- ---------- ---------- ---- " 667 678 "----------\n"); 668 679 #endif … … 670 681 #ifdef __64_BITS__ 671 682 printf("tid name address state task " 672 "ctx code stack cycles cpu "683 "ctx code stack cycles ucycles kcycles cpu " 673 684 "waitqueue\n"); 674 685 printf("------ ---------- ------------------ -------- ------------------ " 675 "--- ------------------ ------------------ ---------- ---- "686 "--- ------------------ ------------------ ---------- ---------- ---------- ---- " 676 687 "------------------\n"); 677 688 #endif … … 706 717 * interrupts must be already disabled. 707 718 * 708 */ 709 void thread_update_accounting(void) 719 * @param user True to update user accounting, false for kernel. 720 */ 721 void thread_update_accounting(bool user) 710 722 { 711 723 uint64_t time = get_cycle(); 712 724 THREAD->cycles += time - THREAD->last_cycle; 725 if (user) { 726 THREAD->ucycles += time - THREAD->last_cycle; 727 } else { 728 THREAD->kcycles += time - THREAD->last_cycle; 729 } 713 730 THREAD->last_cycle = time; 714 731 } -
kernel/generic/src/ps/ps.c
r34bba0e ra2a00e8 132 132 copy_to_uspace(uspace_info->name, t->name, sizeof(t->name)); 133 133 134 uint64_t cycles = task_get_accounting(t); 134 uint64_t ucycles; 135 uint64_t kcycles; 136 uint64_t cycles = task_get_accounting(t, &ucycles, &kcycles); 135 137 copy_to_uspace(&uspace_info->cycles, &cycles, sizeof(cycles)); 136 138
Note:
See TracChangeset
for help on using the changeset viewer.