<div dir="ltr">Hi Jeff,<div> yes, your guess is correct. The place i checked in_interrupt() was a region before which a call to spin_lock_bh() was made.</div><div>So what is the rule?</div><div>if in_interrupt() return me true then that is the region of the code which can not be context switched or if i am out of interrupt (in kernel thread) and have called spin_lock_bh(), then this macro is not reliable to safely find out if the region below this can not be context switched?</div>
<div>If that is the case, then perhaps only the "false" return of the macro in_interrupt is reliable.</div><div>thanks,</div><div>Vishwas S</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><br>
<div class="gmail_quote">On Mon, Jul 28, 2014 at 9:54 PM, Jeff Haran <span dir="ltr"><<a href="mailto:Jeff.Haran@citrix.com" target="_blank">Jeff.Haran@citrix.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><font color="#1f497d" face="Calibri"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></font></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><font face="Tahoma"><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif";font-weight:bold">From:</span></font></b><font face="Tahoma"><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">
<a href="mailto:kernelnewbies-bounces@kernelnewbies.org" target="_blank">kernelnewbies-bounces@kernelnewbies.org</a> [mailto:<a href="mailto:kernelnewbies-bounces@kernelnewbies.org" target="_blank">kernelnewbies-bounces@kernelnewbies.org</a>]
<b><span style="font-weight:bold">On Behalf Of </span></b>Vishwas Srivastava<br>
<b><span style="font-weight:bold">Sent:</span></b> Saturday, July 26, 2014 10:07 AM<br>
<b><span style="font-weight:bold">To:</span></b> <a href="mailto:kernelnewbies@kernelnewbies.org" target="_blank">kernelnewbies@kernelnewbies.org</a><br>
<b><span style="font-weight:bold">Subject:</span></b> Re: Kernelnewbies Digest, Vol 44, Issue 51<u></u><u></u></span></font></p>
</div>
</div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size:12.0pt"><u></u> <u></u></span></font></p>
<div><div><div class="h5">
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size:12.0pt">Hi All,<u></u><u></u></span></font></p>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size:12.0pt"> I have a doubt regarding the threaded interrupt handing mechanism.<u></u><u></u></span></font></p>
</div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size:12.0pt">what is the kernel context of execution while executing interrupt thread.<u></u><u></u></span></font></p>
</div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size:12.0pt">if i check for macro<u></u><u></u></span></font></p>
</div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size:12.0pt">in_irq() or in_interrupt() withing handler thread , my understanding is that they both are going to return me 0 (since we are in kernel thread),<u></u><u></u></span></font></p>
</div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size:12.0pt">as threads runs in process context.<u></u><u></u></span></font></p>
</div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size:12.0pt"><u></u> <u></u></span></font></p>
</div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size:12.0pt">Also, since they are "kernel threads", they must be schedulable enteties.<u></u><u></u></span></font></p>
</div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size:12.0pt">what conceptually deviated me from my understanding is one of the driver which had a threaded interrupt mechanism and when i checked<u></u><u></u></span></font></p>
</div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size:12.0pt"> <u></u><u></u></span></font></p>
</div>
</div></div><div><div><div class="h5">
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size:12.0pt">in_interrupt() macro, it returned me a non zero value so i am a bit confused.<u></u><u></u></span></font></p>
<p class="MsoNormal"><font color="#1f497d" face="Calibri"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></font></p>
</div></div><p class="MsoNormal"><font color="#1f497d" face="Calibri"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">By any chance had you disabled interrupts or bottom halves when you made
this call to <span>in_interrupt</span>()?<u></u><u></u></span></font></p>
<p class="MsoNormal"><font color="#1f497d" face="Calibri"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">The reason I ask is the last time I looked into this the conclusion I came
to was that <span>in_interrupt</span>() would return non-zero under a couple of different conditions; 1) the code was really executing in either a bottom half or IRQ context, or; 2) the code was executing in process context but had previously
disabled interrupts or bottom halves, e.g. a call to <span>spin_lock_bh</span>() or anything else that disables bottom halves. At the time I was trying to figure out how to tell for sure whether or not a given function was being called from
a bottom half (as opposed to executing in process context with bottom halves disabled) and from what I could see at the time, there was no way to distinguish the two conditions. Disclaimer: I’m no expert on this stuff, just reporting what I concluded at the
time from eyeballing the code. Perhaps I missed something.<span class="HOEnZb"><font color="#888888"><u></u><u></u></font></span></span></font></p><span class="HOEnZb"><font color="#888888">
<p class="MsoNormal"><font color="#1f497d" face="Calibri"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></font></p>
<p class="MsoNormal"><font color="#1f497d" face="Calibri"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Jeff Haran<u></u><u></u></span></font></p>
</font></span></div><div class="">
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size:12.0pt"><u></u> <u></u></span></font></p>
</div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size:12.0pt">thanks in advance.<u></u><u></u></span></font></p>
</div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size:12.0pt"><u></u> <u></u></span></font></p>
</div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size:12.0pt">Vishwas S<u></u><u></u></span></font></p>
</div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size:12.0pt"> <u></u><u></u></span></font></p>
</div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size:12.0pt"><u></u> <u></u></span></font></p>
</div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size:12.0pt"><u></u> <u></u></span></font></p>
</div>
<div>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size:12.0pt"><u></u> <u></u></span></font></p>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><font size="3" face="Times New Roman"><span style="font-size:12.0pt"><u></u> <u></u></span></font></p>
</div>
</div>
</div></div>
</div>
</div>
</div>
</blockquote></div><br></div>