<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 28, 2015 at 9:56 PM, Sreejith M M <span dir="ltr">&lt;<a href="mailto:sreejith.mm@gmail.com" target="_blank">sreejith.mm@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I was trying to understand the difference in scheduling between<br>
processes and threads(belong to same process).<br>
<br>
I was thinking that, when kernel has to switch to a task which belong<br>
to the same process, it does not have to clear / replace page global<br>
directories and other memory related information.<br>
<br>
But in switch_mm function some code is put under CONFIG_SMP function.<br>
What is its signigicance? Code is<br>
below(<a href="http://lxr.free-electrons.com/source/arch/x86/include/asm/mmu_context.h#L37" target="_blank">http://lxr.free-electrons.com/source/arch/x86/include/asm/mmu_context.h#L37</a>)<br>
.<br>
What I infer is that the code is doing flush tlb, reload page table<br>
directories etc in multiprocessor mode(obviously)  but I believe this<br>
code may never be executed .<br>
<br>
Can anyone help to understand what this part of the function supposed to do?<br>
<br>
 60 #ifdef CONFIG_SMP<br>
 61           else {<br>
 62                 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);<br>
 63                 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);<br>
 64<br>
 65                 if (!cpumask_test_cpu(cpu, mm_cpumask(next))) {<br>
 66                         /*<br>
 67                          * On established mms, the mm_cpumask is<br>
only changed<br>
 68                          * from irq context, from<br>
ptep_clear_flush() while in<br>
 69                          * lazy tlb mode, and here. Irqs are blocked during<br>
 70                          * schedule, protecting us from<br>
simultaneous changes.<br>
 71                          */<br>
 72                         cpumask_set_cpu(cpu, mm_cpumask(next));<br>
 73                         /*<br>
 74                          * We were in lazy tlb mode and leave_mm disabled<br>
 75                          * tlb flush IPI delivery. We must reload CR3<br>
 76                          * to make sure to use no freed page tables.<br>
 77                          */<br>
 78                         load_cr3(next-&gt;pgd);<br>
 79                         trace_tlb_flush(TLB_FLUSH_ON_TASK_SWITCH,<br>
TLB_FLUSH_ALL);<br>
 80                         load_LDT_nolock(&amp;next-&gt;context);<br>
 81                 }<br>
 82         }<br>
 83 #endif<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
Regards,<br>
Sreejith<br>
</font></span></blockquote></div><br></div><div class="gmail_extra">Hi ,<br><br></div><div class="gmail_extra">can someone please give me any answers for this?<br clear="all"></div><div class="gmail_extra"><br>-- <br><div class="gmail_signature">Regards,<br>Sreejith</div>
</div></div>