Discussion:
preempt_disable() - disables preemption on all processors?
Rajat Jain
2007-09-28 10:53:04 UTC
Permalink
Hi list,

Does the preempt_disable() disable preemption on all the processors or just the current processor?

Thanks,

Rajat

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Mulyadi Santosa
2007-09-28 17:21:30 UTC
Permalink
HI...
Post by Rajat Jain
Does the preempt_disable() disable preemption on all the processors or just the current processor?
Fast check on schedule() code makes me believe it just disables the
preemption on current processor which call preempt_disable().

regards,

Mulyadi
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Ricardo Maraschini
2007-09-28 17:42:05 UTC
Permalink
And the get_cpu() ? Its not supposed to disable preemption in all cpus?
from include/linux/smp.h:

#define get_cpu() ({ preempt_disable(); smp_processor_id(); })

rjm;
Post by Rajat Jain
HI...
Post by Rajat Jain
Does the preempt_disable() disable preemption on all the processors or
just the current processor?
Fast check on schedule() code makes me believe it just disables the
preemption on current processor which call preempt_disable().
regards,
Mulyadi
--
To unsubscribe from this list: send an email with
Please read the FAQ at http://kernelnewbies.org/FAQ
Mulyadi Santosa
2007-09-29 15:43:27 UTC
Permalink
Hi...
Post by Ricardo Maraschini
And the get_cpu() ? Its not supposed to disable preemption in all cpus?
#define get_cpu() ({ preempt_disable(); smp_processor_id(); })
Same thing, only for current CPU with executes the code path that calls
preempt_enable/disable(). You can check the definition of
preempt_count() in {kerneldir}/include/linux/smp.h:

#define preempt_count() (current_thread_info()->preempt_count)


There, you'll see that the preemption flag is actually tied to current
task_struct's stack. Since a task run on a processor at a time, I follow
the same logic that preemption is also enabled/disabled for current
processor only.

regards,

Mulyadi.


--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ***@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ

Loading...