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.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]