A question from a beginner: why not record TIF_NEED_RESCHED flag foreach CPU rather than for each thread?

From: Yongle Zhang
Date: Sat Apr 21 2012 - 02:52:14 EST


Hi everyone~,

I'm a student, and a beginner learning linux. And when I'm reading the
kernel source code I got a question.
I discussed it with some friends and posed it on the internet, but
didn't get a clear answer. And they recommended me to ask for help
directly from the developers~
Wish this won't bother you!

The question is as below:

In linux kernel 2.6.11, the TIF_NEED_RESCHED flag is recorded in
thread_info struct for each task.

I searched the kernel and found that, it can only be set by the
current thread on the CPU for itself. So why not put the
TIF_NEED_RESCHED in some per CPU structure instead of in each
thread_info?

If this flag is only used to show that current thread on this cpu
needs schedule(), then I think perhaps it is OK to record it for each
CPU rather than for each thread?

If both of the methods are logically OK, then why is the flag recorded
in thread_info? Is it because of some performance issue, or some
historical reason?

Thanks for your attention and time~!
Best regards,

Kevin Zhang
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/