staticvoid __sched
account_global_scheduler_latency(struct task_struct *tsk, struct latency_record *lat)
{ int firstnonnull = MAXLR; int i;
/* skip kernel threads for now */ if (!tsk->mm) return;
for (i = 0; i < MAXLR; i++) { int q, same = 1;
/* Nothing stored: */ if (!latency_record[i].backtrace[0]) { if (firstnonnull > i)
firstnonnull = i; continue;
} for (q = 0; q < LT_BACKTRACEDEPTH; q++) { unsignedlong record = lat->backtrace[q];
if (latency_record[i].backtrace[q] != record) {
same = 0; break;
}
/* 0 entry marks end of backtrace: */ if (!record) break;
} if (same) {
latency_record[i].count++;
latency_record[i].time += lat->time; if (lat->time > latency_record[i].max)
latency_record[i].max = lat->time; return;
}
}
i = firstnonnull; if (i >= MAXLR) return;
/* Allocted a new one: */
memcpy(&latency_record[i], lat, sizeof(struct latency_record));
}
/** *__account_scheduler_latency-recordanoccurredlatency *@tsk:thetaskstructofthetaskhittingthelatency *@usecs:thedurationofthelatencyinmicroseconds *@inter:1ifthesleepwasinterruptible,0ifuninterruptible * *Thisfunctionisthemainentrypointforrecordinglatencyentries *ascalledbythescheduler. * *Thisfunctionhasafewspecialcasestodealwithnormal'non-latency' *sleeps:specifically,interruptiblesleeplongerthan5msecisskipped *sincethisusuallyiscausedbywaitingforeventsviaselect()andco. * *Negativelatencies(causedbytimegoingbackwards)arealsoexplicitly *skipped.
*/ void __sched
__account_scheduler_latency(struct task_struct *tsk, int usecs, int inter)
{ unsignedlong flags; int i, q; struct latency_record lat;
/* Long interruptible waits are generally user requested... */ if (inter && usecs > 5000) return;
/* Negative sleeps are time going backwards */ /* Zero-time sleeps are non-interesting */ if (usecs <= 0) return;
for (i = 0; i < tsk->latency_record_count; i++) { struct latency_record *mylat; int same = 1;
mylat = &tsk->latency_record[i]; for (q = 0; q < LT_BACKTRACEDEPTH; q++) { unsignedlong record = lat.backtrace[q];
if (mylat->backtrace[q] != record) {
same = 0; break;
}
/* 0 entry is end of backtrace */ if (!record) break;
} if (same) {
mylat->count++;
mylat->time += lat.time; if (lat.time > mylat->max)
mylat->max = lat.time; goto out_unlock;
}
}
/* *shorttermhack;ifwe're>32westop;futurewerecycle:
*/ if (tsk->latency_record_count >= LT_SAVECOUNT) goto out_unlock;
/* Allocated a new one: */
i = tsk->latency_record_count++;
memcpy(&tsk->latency_record[i], &lat, sizeof(struct latency_record));
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.