Hello Luis,
if I read correctly, you are summing up the first field (or the first
and second) of vmstat output for a minute and comparing it with the
uptime load average for a minute, and the former is bigger then the
latter.
At a quick glance, the wikipedia page gives you that processes
"running or waiting" are the ones being counted. in vmstat, the man
page defines r as giving you processes waiting for run time, and b as
giving you those sleeping waiting for IO. You seem to be missing those
actually running in your count, or the man page may be inaccurate.
Of course, if processes are missing that would only *increase* your
count, and therefore increases your discrepancy.
But you are skipping over the math: while count_active_tasks is
actually counting processes in RUNNING or UNINTERRUPTIBLE as you are
trying to:
608 for_each_task(p) {
609 if ((p->state == TASK_RUNNING ||
610 (p->state & TASK_UNINTERRUPTIBLE)))
611 nr += FIXED_1;
avenrun feeds the result of that count to the exponentiating function,
and only the output of that is the load average:
633 active_tasks = count_active_tasks();
634 CALC_LOAD(avenrun[0], EXP_1, active_tasks);
So, even if your count was correct, you would still need to feed it to
CALC_LOAD to get the load average out of it you seek to match with
uptime's output.
Hope this helps.
Best -Federico
PS: Load average is always a fun subject. Besides the Wikipedia page,
there is another interesting treatment (although not necessarily fully
up
to date) on Linux Journal:
http://www.linuxjournal.com/article/9001