public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Robert Love <rml@tech9.net>
To: William Lee Irwin III <wli@holomorphy.com>
Cc: linux-kernel@vger.kernel.org, mingo@elte.hu, torvalds@transmeta.com
Subject: Re: O(1) count_active_tasks()
Date: 26 May 2002 15:17:52 -0700	[thread overview]
Message-ID: <1022451477.20316.24.camel@sinai> (raw)
In-Reply-To: <20020526035115.GM14918@holomorphy.com>

On Sat, 2002-05-25 at 20:51, William Lee Irwin III wrote:
> rml, I heard you're interested in this, but regardless, here it is.
> AFAICT it computes a faithful load average. Against latest 2.5.18 bk.
> rml, don't worry about stomping on this if you need the counters
> ticking for something else and you can do the same thing(s).

I like.  Very clean.

One question...

>  	rq = task_rq_lock(p, &flags);
> +	if (p->state == TASK_UNINTERRUPTIBLE)
> +		uninterruptible = 1;
>  	p->state = TASK_RUNNING;
>  	if (!p->array) {
> +		if (uninterruptible)
> +			rq->nr_uninterruptible--;
>  		activate_task(p, rq);
>  		if (p->prio < rq->curr->prio)
>  			resched_task(rq->curr);

Why only decrement nr_uninterruptible if it is not already on a
runqueue?  I suspect because then you assume it is a spurious wakeup and
did not have a corresponding deactivate_task?  Same reason we increment
nr_running in activate_task and not here, I suspect... makes sense.

One thought on a quick way to test if the new method is returning
accurate results would be to leave the current count_active_task code
and then add:

	if (nr != (nr_running() + nr_uninterruptible()))
		printk("Danger Will Robinson!\n");

but you probably already did something similar.

	Robert Love


  reply	other threads:[~2002-05-26 22:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-26  3:51 O(1) count_active_tasks() William Lee Irwin III
2002-05-26 22:17 ` Robert Love [this message]
2002-05-26 23:03   ` William Lee Irwin III
2002-05-28 15:33     ` Robert Love
2002-05-28 18:08       ` Robert Love
2002-05-28 18:56         ` William Lee Irwin III

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1022451477.20316.24.camel@sinai \
    --to=rml@tech9.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=torvalds@transmeta.com \
    --cc=wli@holomorphy.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox