* preempt_disable() as synchronization tool @ 2009-10-09 3:43 Daniel Rodrick 2009-10-10 2:00 ` vinit dhatrak 2009-10-12 3:05 ` Pei Lin 0 siblings, 2 replies; 6+ messages in thread From: Daniel Rodrick @ 2009-10-09 3:43 UTC (permalink / raw) To: Kernel Newbies, Linux Newbie Hi List, I have few queries related to preempt_disable() and would appreciate any answers to it. Firstly, Does preempt_disable() disable the preemption on all the processors or on just the local processor? Secondly, a preempt_disable() a suffifient synchronization technique to guard a data that is shared only among process context code on a Uni-processor? And on SMP? Lastly, is it allowable to schedule / sleep immediately after a call to preempt_disable()? Thanks & Best Regards, Dan -- To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to majordomo@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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: preempt_disable() as synchronization tool 2009-10-09 3:43 preempt_disable() as synchronization tool Daniel Rodrick @ 2009-10-10 2:00 ` vinit dhatrak 2009-10-10 4:46 ` askb ` (2 more replies) 2009-10-12 3:05 ` Pei Lin 1 sibling, 3 replies; 6+ messages in thread From: vinit dhatrak @ 2009-10-10 2:00 UTC (permalink / raw) To: Daniel Rodrick; +Cc: Kernel Newbies, Linux Newbie On Fri, Oct 9, 2009 at 9:13 AM, Daniel Rodrick <daniel.rodrick@gmail.com> wrote: > Hi List, > > I have few queries related to preempt_disable() and would appreciate > any answers to it. > > Firstly, Does preempt_disable() disable the preemption on all the > processors or on just the local processor? I guess just local processor as the preempt count is maintained in current thread_info struct. Correct me if I am wrong here. > > Secondly, a preempt_disable() a sufficient synchronization technique > to guard a data that is shared only among process context code on a > Uni-processor? And on SMP? It is sufficient only in case of uni-processor (Actually spin_lock also just disables preemption in case of uni-processor) > > Lastly, is it allowable to schedule / sleep immediately after a call > to preempt_disable()? No I guess kernel will panic with some error like , "scheduling while in Atomic Context". > > Thanks & Best Regards, > > Dan > > -- > To unsubscribe from this list: send an email with > "unsubscribe kernelnewbies" to ecartis@nl.linux.org > Please read the FAQ at http://kernelnewbies.org/FAQ > > -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@nl.linux.org Please read the FAQ at http://kernelnewbies.org/FAQ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: preempt_disable() as synchronization tool 2009-10-10 2:00 ` vinit dhatrak @ 2009-10-10 4:46 ` askb [not found] ` <1255150012.7925.6.camel@linux-k65f.site> 2009-10-10 17:41 ` Frederic Weisbecker 2 siblings, 0 replies; 6+ messages in thread From: askb @ 2009-10-10 4:46 UTC (permalink / raw) To: vinit dhatrak; +Cc: Daniel Rodrick, Kernel Newbies, Linux Newbie > > > > Lastly, is it allowable to schedule / sleep immediately after a call > > to preempt_disable()? > > No I guess kernel will panic with some error like , "scheduling while > in Atomic Context". Sorry, I somehow missed out reading this. Can you let me know why its not possible to schedule within preempt_disable() and preempt_enable()? From the code the schedule functions starts by disabling preemption? Thanks in advance. - Anil -- To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to majordomo@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 ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <1255150012.7925.6.camel@linux-k65f.site>]
* Re: preempt_disable() as synchronization tool [not found] ` <1255150012.7925.6.camel@linux-k65f.site> @ 2009-10-10 17:07 ` vinit dhatrak 0 siblings, 0 replies; 6+ messages in thread From: vinit dhatrak @ 2009-10-10 17:07 UTC (permalink / raw) To: askb; +Cc: Daniel Rodrick, Kernel Newbies, Linux Newbie On Sat, Oct 10, 2009 at 10:16 AM, askb <askb23@gmail.com> wrote: > >> > >> > Lastly, is it allowable to schedule / sleep immediately after a call >> > to preempt_disable()? >> >> No I guess kernel will panic with some error like , "scheduling while >> in Atomic Context". > > Sorry, I somehow missed out reading this. Can you let me know why its > not possible to schedule within preempt_disable() and preempt_enable()? > >From the code the schedule functions starts by disabling preemption? > Thanks in advance. - Anil > > Because, preempt_disable increments the preempt count and before scheduling the next task, schedule() function checks for the preempt count for the previous task. If its greater than 0 then it will throw an error "BUG: scheduling while atomic:" -Vinit -- To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to majordomo@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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: preempt_disable() as synchronization tool 2009-10-10 2:00 ` vinit dhatrak 2009-10-10 4:46 ` askb [not found] ` <1255150012.7925.6.camel@linux-k65f.site> @ 2009-10-10 17:41 ` Frederic Weisbecker 2 siblings, 0 replies; 6+ messages in thread From: Frederic Weisbecker @ 2009-10-10 17:41 UTC (permalink / raw) To: vinit dhatrak; +Cc: Daniel Rodrick, Kernel Newbies, Linux Newbie On Sat, Oct 10, 2009 at 07:30:08AM +0530, vinit dhatrak wrote: > On Fri, Oct 9, 2009 at 9:13 AM, Daniel Rodrick <daniel.rodrick@gmail.com> wrote: > > Hi List, > > > > I have few queries related to preempt_disable() and would appreciate > > any answers to it. > > > > Firstly, Does preempt_disable() disable the preemption on all the > > processors or on just the local processor? > > I guess just local processor as the preempt count is maintained in > current thread_info struct. Correct me if I am wrong here. Yeah, once you disable the preemption, the current task will stay on the current cpu until you reenable preemption. So no other task can be scheduled in this cpu until it's reenabled. > > > > Secondly, a preempt_disable() a sufficient synchronization technique > > to guard a data that is shared only among process context code on a > > Uni-processor? And on SMP? > > It is sufficient only in case of uni-processor (Actually spin_lock > also just disables preemption in case of uni-processor) > > > > Lastly, is it allowable to schedule / sleep immediately after a call > > to preempt_disable()? > > No I guess kernel will panic with some error like , "scheduling while > in Atomic Context". It won't panic but it won't be happy either :-) You'll get the warning message but things will continue to go ahead...badly... In most cases, disabling preemption is done when you need to manipulate per cpu data and then you don't want to be preempted in the middle and risk to be scheduled in another cpu, or let another task touch the same cpu data while you were in the middle of your work. That's why it warns when you voluntarily schedule while you have disabled preemption, because you are supposed to be manipulating per cpu data and it's dangerous. > > > > Thanks & Best Regards, > > > > Dan > > > > -- > > To unsubscribe from this list: send an email with > > "unsubscribe kernelnewbies" to ecartis@nl.linux.org > > Please read the FAQ at http://kernelnewbies.org/FAQ > > > > > > -- > To unsubscribe from this list: send an email with > "unsubscribe kernelnewbies" to ecartis@nl.linux.org > Please read the FAQ at http://kernelnewbies.org/FAQ > -- To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to majordomo@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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: preempt_disable() as synchronization tool 2009-10-09 3:43 preempt_disable() as synchronization tool Daniel Rodrick 2009-10-10 2:00 ` vinit dhatrak @ 2009-10-12 3:05 ` Pei Lin 1 sibling, 0 replies; 6+ messages in thread From: Pei Lin @ 2009-10-12 3:05 UTC (permalink / raw) To: Daniel Rodrick; +Cc: Kernel Newbies, Linux Newbie http://lxr.linux.no/#linux+v2.6.31/Documentation/preempt-locking.txt 2009/10/9 Daniel Rodrick <daniel.rodrick@gmail.com>: > Hi List, > > I have few queries related to preempt_disable() and would appreciate > any answers to it. > > Firstly, Does preempt_disable() disable the preemption on all the > processors or on just the local processor? > > Secondly, a preempt_disable() a suffifient synchronization technique > to guard a data that is shared only among process context code on a > Uni-processor? And on SMP? > > Lastly, is it allowable to schedule / sleep immediately after a call > to preempt_disable()? > > Thanks & Best Regards, > > Dan > > -- > To unsubscribe from this list: send an email with > "unsubscribe kernelnewbies" to ecartis@nl.linux.org > Please read the FAQ at http://kernelnewbies.org/FAQ > > -- Best Regards Lin -- To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to majordomo@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 ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-10-12 3:05 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-09 3:43 preempt_disable() as synchronization tool Daniel Rodrick
2009-10-10 2:00 ` vinit dhatrak
2009-10-10 4:46 ` askb
[not found] ` <1255150012.7925.6.camel@linux-k65f.site>
2009-10-10 17:07 ` vinit dhatrak
2009-10-10 17:41 ` Frederic Weisbecker
2009-10-12 3:05 ` Pei Lin
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.