On Tue, Nov 22, 2005 at 07:38:01PM +0200, Rafi Gordon wrote:
> Thanks! !
> 
> As I understand , a TLB flush is an expenive operation.
> 
>    Have anybody any idea if there is a TLB flush (on x86) when there is a
> context switch between two kernel threads ?

There isn't, both kernel threads are running in the same kernel
address space.

>    My guess is that there is no need for such a TLB flush (on x86) since
> the kernel thread does not need to access virtual addresses of
> the user space. (But  I am not sure about it, because a kernel thread DOES
> have access to 1GB virtual address space of the kernel ).

But that 1GB is shared across all userspace address spaces in the
system - so a tlb entry that refers to the kernel portion of the
address space is valid in all address space. Ergo - no TLB flush
required.

> (To be more precise,and If I remember well from Love's kernel book,
> the  task struct has 2 mm_struct
> members : mm and mm_acive;  and in case of kernel_thread mm is NULL
> ,but active_mm gets
> the value of previous thread , but in fact it needs ONLY the kernel
> address space part of it because anyhow a kernel thread is NOT allowed to use
> the user space address space.)
> 
> And to verify one more thing, if I may : when there is a context
> switch between 2 ***user space*** threads,is  there ALWAYS a TLB
> flush?

Not always - if they're both threads of the same process (share the
same address space) there's no need for a TLB flush when switching
between them.

Cheers,
Muli
-- 
Muli Ben-Yehuda
http://www.mulix.org | http://mulix.livejournal.com/


=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to