Changeset 88dea9d in mainline for kernel/generic/src/proc


Ignore:
Timestamp:
2010-04-17T16:28:49Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
30a5470
Parents:
5ba201d (diff), 95319bd (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge from measuring branch

Location:
kernel/generic/src/proc
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/proc/scheduler.c

    r5ba201d r88dea9d  
    202202                 */
    203203
     204                 spinlock_lock(&CPU->lock);
     205                 CPU->idle = true;
     206                 spinlock_unlock(&CPU->lock);
    204207                 cpu_sleep();
    205208                 goto loop;
     
    313316                spinlock_lock(&THREAD->lock);
    314317               
    315                 /* Update thread accounting */
    316                 THREAD->cycles += get_cycle() - THREAD->last_cycle;
     318                /* Update thread kernel accounting */
     319                THREAD->kcycles += get_cycle() - THREAD->last_cycle;
    317320               
    318321#ifndef CONFIG_FPU_LAZY
  • kernel/generic/src/proc/task.c

    r5ba201d r88dea9d  
    186186        ta->context = CONTEXT;
    187187        ta->capabilities = 0;
    188         ta->cycles = 0;
    189        
     188        ta->ucycles = 0;
     189        ta->kcycles = 0;
     190
     191        ta->ipc_info.call_sent = 0;
     192        ta->ipc_info.call_recieved = 0;
     193        ta->ipc_info.answer_sent = 0;
     194        ta->ipc_info.answer_recieved = 0;
     195        ta->ipc_info.irq_notif_recieved = 0;
     196        ta->ipc_info.forwarded = 0;
     197
    190198#ifdef CONFIG_UDEBUG
    191199        /* Init debugging stuff */
     
    324332 * already disabled.
    325333 *
    326  * @param t Pointer to task.
    327  *
    328  * @return Number of cycles used by the task and all its threads
    329  *         so far.
    330  *
    331  */
    332 uint64_t task_get_accounting(task_t *t)
    333 {
    334         /* Accumulated value of task */
    335         uint64_t ret = t->cycles;
     334 * @param t       Pointer to thread.
     335 * @param ucycles Out pointer to sum of all user cycles.
     336 * @param kcycles Out pointer to sum of all kernel cycles.
     337 *
     338 */
     339void task_get_accounting(task_t *t, uint64_t *ucycles, uint64_t *kcycles)
     340{
     341        /* Accumulated values of task */
     342        uint64_t uret = t->ucycles;
     343        uint64_t kret = t->kcycles;
    336344       
    337345        /* Current values of threads */
     
    345353                        if (thr == THREAD) {
    346354                                /* Update accounting of current thread */
    347                                 thread_update_accounting();
     355                                thread_update_accounting(false);
    348356                        }
    349                         ret += thr->cycles;
     357                        uret += thr->ucycles;
     358                        kret += thr->kcycles;
    350359                }
    351360                spinlock_unlock(&thr->lock);
    352361        }
    353362       
    354         return ret;
     363        *ucycles = uret;
     364        *kcycles = kret;
    355365}
    356366
     
    419429        spinlock_lock(&t->lock);
    420430       
    421         uint64_t cycles;
    422         char suffix;
    423         order(task_get_accounting(t), &cycles, &suffix);
    424        
    425 #ifdef __32_BITS__
    426         printf("%-6" PRIu64 " %-12s %-3" PRIu32 " %10p %10p %9" PRIu64
    427             "%c %7ld %6ld", t->taskid, t->name, t->context, t, t->as, cycles,
    428             suffix, atomic_get(&t->refcount), atomic_get(&t->active_calls));
     431        uint64_t ucycles;
     432        uint64_t kcycles;
     433        char usuffix, ksuffix;
     434        task_get_accounting(t, &ucycles, &kcycles);
     435        order(ucycles, &ucycles, &usuffix);
     436        order(kcycles, &kcycles, &ksuffix);
     437       
     438#ifdef __32_BITS__     
     439        printf("%-6" PRIu64 " %-12s %-3" PRIu32 " %10p %10p %9" PRIu64 "%c %9"
     440                PRIu64 "%c %7ld %6ld", t->taskid, t->name, t->context, t, t->as,
     441                ucycles, usuffix, kcycles, ksuffix, atomic_get(&t->refcount),
     442                atomic_get(&t->active_calls));
    429443#endif
    430444       
    431445#ifdef __64_BITS__
    432         printf("%-6" PRIu64 " %-12s %-3" PRIu32 " %18p %18p %9" PRIu64
    433             "%c %7ld %6ld", t->taskid, t->name, t->context, t, t->as, cycles,
    434             suffix, atomic_get(&t->refcount), atomic_get(&t->active_calls));
     446        printf("%-6" PRIu64 " %-12s %-3" PRIu32 " %18p %18p %9" PRIu64 "%c %9"
     447                PRIu64 "%c %7ld %6ld", t->taskid, t->name, t->context, t, t->as,
     448                ucycles, usuffix, kcycles, ksuffix, atomic_get(&t->refcount),
     449                atomic_get(&t->active_calls));
    435450#endif
    436451       
     
    455470       
    456471#ifdef __32_BITS__
    457         printf("taskid name         ctx address    as         "
    458             "cycles     threads calls  callee\n");
    459         printf("------ ------------ --- ---------- ---------- "
    460             "---------- ------- ------ ------>\n");
     472        printf("taskid name         ctx address    as        "
     473            " ucycles    kcycles    threads calls  callee\n");
     474        printf("------ ------------ --- ---------- ----------"
     475            " ---------- ---------- ------- ------ ------>\n");
    461476#endif
    462477       
    463478#ifdef __64_BITS__
    464         printf("taskid name         ctx address            as                 "
    465             "cycles     threads calls  callee\n");
    466         printf("------ ------------ --- ------------------ ------------------ "
    467             "---------- ------- ------ ------>\n");
     479        printf("taskid name         ctx address            as                "
     480            " ucycles    kcycles    threads calls  callee\n");
     481        printf("------ ------------ --- ------------------ ------------------"
     482            " ---------- ---------- ---------- ------- ------ ------>\n");
    468483#endif
    469484       
  • kernel/generic/src/proc/thread.c

    r5ba201d r88dea9d  
    132132        spinlock_lock(&THREAD->lock);
    133133        if (!THREAD->uncounted) {
    134                 thread_update_accounting();
    135                 uint64_t cycles = THREAD->cycles;
    136                 THREAD->cycles = 0;
     134                thread_update_accounting(true);
     135                uint64_t ucycles = THREAD->ucycles;
     136                THREAD->ucycles = 0;
     137                uint64_t kcycles = THREAD->kcycles;
     138                THREAD->kcycles = 0;
     139
    137140                spinlock_unlock(&THREAD->lock);
    138141               
    139142                spinlock_lock(&TASK->lock);
    140                 TASK->cycles += cycles;
     143                TASK->ucycles += ucycles;
     144                TASK->kcycles += kcycles;
    141145                spinlock_unlock(&TASK->lock);
    142146        } else
     
    323327        t->thread_arg = arg;
    324328        t->ticks = -1;
    325         t->cycles = 0;
     329        t->ucycles = 0;
     330        t->kcycles = 0;
    326331        t->uncounted = uncounted;
    327332        t->priority = -1;               /* start in rq[0] */
     
    614619        thread_t *t = avltree_get_instance(node, thread_t, threads_tree_node);
    615620       
    616         uint64_t cycles;
    617         char suffix;
    618         order(t->cycles, &cycles, &suffix);
     621        uint64_t ucycles, kcycles;
     622        char usuffix, ksuffix;
     623        order(t->ucycles, &ucycles, &usuffix);
     624        order(t->kcycles, &kcycles, &ksuffix);
    619625
    620626#ifdef __32_BITS__
    621         printf("%-6" PRIu64" %-10s %10p %-8s %10p %-3" PRIu32 " %10p %10p %9" PRIu64 "%c ",
    622             t->tid, t->name, t, thread_states[t->state], t->task,
    623         t->task->context, t->thread_code, t->kstack, cycles, suffix);
     627        printf("%-6" PRIu64" %-10s %10p %-8s %10p %-3" PRIu32 " %10p %10p %9"
     628                PRIu64 "%c %9" PRIu64 "%c ", t->tid, t->name, t,
     629                thread_states[t->state], t->task, t->task->context, t->thread_code,
     630                t->kstack, ucycles, usuffix, kcycles, ksuffix);
    624631#endif
    625632
    626633#ifdef __64_BITS__
    627         printf("%-6" PRIu64" %-10s %18p %-8s %18p %-3" PRIu32 " %18p %18p %9" PRIu64 "%c ",
    628             t->tid, t->name, t, thread_states[t->state], t->task,
    629         t->task->context, t->thread_code, t->kstack, cycles, suffix);
     634        printf("%-6" PRIu64" %-10s %18p %-8s %18p %-3" PRIu32 " %18p %18p %9"
     635                PRIu64 "%c %9" PRIu64 "%c ", t->tid, t->name, t,
     636                thread_states[t->state], t->task, t->task->context, t->thread_code,
     637                t->kstack, ucycles, usuffix, kcycles, ksuffix);
    630638#endif
    631639                       
     
    661669#ifdef __32_BITS__     
    662670        printf("tid    name       address    state    task       "
    663                 "ctx code       stack      cycles     cpu  "
     671                "ctx code       stack      ucycles    kcycles    cpu  "
    664672                "waitqueue\n");
    665673        printf("------ ---------- ---------- -------- ---------- "
    666                 "--- ---------- ---------- ---------- ---- "
     674                "--- ---------- ---------- ---------- ---------- ---- "
    667675                "----------\n");
    668676#endif
     
    670678#ifdef __64_BITS__
    671679        printf("tid    name       address            state    task               "
    672                 "ctx code               stack              cycles     cpu  "
     680                "ctx code               stack              ucycles    kcycles    cpu  "
    673681                "waitqueue\n");
    674682        printf("------ ---------- ------------------ -------- ------------------ "
    675                 "--- ------------------ ------------------ ---------- ---- "
     683                "--- ------------------ ------------------ ---------- ---------- ---- "
    676684                "------------------\n");
    677685#endif
     
    706714 * interrupts must be already disabled.
    707715 *
    708  */
    709 void thread_update_accounting(void)
     716 * @param user  True to update user accounting, false for kernel.
     717 */
     718void thread_update_accounting(bool user)
    710719{
    711720        uint64_t time = get_cycle();
    712         THREAD->cycles += time - THREAD->last_cycle;
     721        if (user) {
     722                THREAD->ucycles += time - THREAD->last_cycle;
     723        } else {
     724                THREAD->kcycles += time - THREAD->last_cycle;
     725        }
    713726        THREAD->last_cycle = time;
    714727}
Note: See TracChangeset for help on using the changeset viewer.