mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Mauricio Lin" <mauriciolin@gmail.com>
To: nagar@watson.ibm.com, balbir@in.ibm.com
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
	"Nick Piggin" <nickpiggin@yahoo.com.au>
Subject: schedstats: sched_info_switch() invocation without checking (prev != next) before
Date: Fri, 28 Apr 2006 15:16:22 -0400	[thread overview]
Message-ID: <3f250c710604281216k79ebe2c8ie63fb337cec8481a@mail.gmail.com> (raw)

Hi all,

I am using the schedstats idea for tracking some schedule info and
after checking the code I have a question about sched_info_switch()
function.

According to the comments as follows:

/*
 * Called when tasks are switched involuntarily due, typically, to expiring
 * their time slice.  (This may also be called when switching to or from
 * the idle task.)  We are only called when prev != next.
 */
static inline void sched_info_switch(task_t *prev, task_t *next)
{
...
}

So after reading the comments, sched_info_switch() should be called
when the current task and next task are different (prev != next), but
this function is called in the schedule() function before checking if
the current task and next task are the same or not. See below a
snippet of schedule() code:

=========================
switch_tasks:
...
sched_info_switch(prev, next);
	if (likely(prev != next)) {
		next->timestamp = now;
		rq->nr_switches++;
		rq->curr = next;
		++*switch_count;

		prepare_task_switch(rq, next);
		prev = context_switch(rq, prev, next);
		barrier();
		/*
		 * this_rq must be evaluated again because prev may have moved
		 * CPUs since it called schedule(), thus the 'rq' on its stack
		 * frame will be invalid.
		 */
		finish_task_switch(this_rq(), prev);
	} else
		spin_unlock_irq(&rq->lock);

=========================

Look that sched_info_switch() is being invoked before verifying if the
prev and next tasks are different or not. IMHO the more logical place
to put sched_info_switch() function is inside the if (likely(prev !=
next) { } block according to the comments mentioned previously.

Any comments?

BR,

Mauricio Lin.

             reply	other threads:[~2006-04-28 19:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-28 19:16 Mauricio Lin [this message]
2006-04-28 20:41 ` Balbir Singh

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=3f250c710604281216k79ebe2c8ie63fb337cec8481a@mail.gmail.com \
    --to=mauriciolin@gmail.com \
    --cc=balbir@in.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nagar@watson.ibm.com \
    --cc=nickpiggin@yahoo.com.au \
    /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

Powered by JetHome