The purpose of this article is to note briefly what is really counted, not to enumerate all possibilities.
First a short note that the kernel counts threads, not processes.
With this out of the way let's take a look a relevant comment (source):
* Once every LOAD_FREQ:
*
* nr_active = 0;
* for_each_possible_cpu(cpu)
* nr_active += cpu_of(cpu)->nr_running + cpu_of(cpu)->nr_uninterruptible;
An alert reader may note that there are lies, damned lies, statistics and comments in the code. I have to agree, thus this requires validation.
A quick eye-grep reveals:
While not strictly sufficient, it's fine enough for this article.
long calc_load_fold_active(struct rq *this_rq)
{
long nr_active, delta = 0;
nr_active = this_rq->nr_running;
nr_active += (long) this_rq->nr_uninterruptible;
if (nr_active != this_rq->calc_load_active) {
delta = nr_active - this_rq->calc_load_active;
this_rq->calc_load_active = nr_active;
}
return delta;
}
So we know "threads blocked on I/O" is not the criterion here, but threads which contribute to nr_uninterruptible counter.
nr_uninterruptible represents threads in TASK_UNINTERRUPTIBLE state (which are not frozen, but what it means is beyond the scope of this article).
When can this happen?
- while waiting for event completion (also used when dealing with I/O)
- while trying to acquire a sleepable locking primitive such as a semaphore
No comments:
Post a Comment