preempt_count variable keeps track of per CPU statistics::
static __always_inline int preempt_count(void)
{
return current_thread_info()->preempt_count;
}
Bits 0 - 7 keeps track of how many times kernel preemption is disabled.
Bits 8 - 15 if non-zero, means softirqs are disbaled that number of times.
Bits 16 - 27 specifies how many calls of irq_enter happened. It mean the number of nested interrupt handlers.
I am not able to comprehend why it is sufficient for preempt_count to be per thread. When a new process would be scheduled, off course bit 0-7 will be zero, otherwise it means preemption is disabled and switch is not allowed. But what about bits 8 - 27. Will they be 0 too? Does it mean that whenever there is a process schedule call, at that time preempt_count should be 0 and hence its value does not need to be copied across thread_info of different processes to keep the track of the status softirqs and irqs on a particular CPU?
might_sleep()). - myaut