* active_mm and mm @ 2002-08-20 2:09 Hai Huang 2002-08-20 9:19 ` Stephen C. Tweedie 0 siblings, 1 reply; 4+ messages in thread From: Hai Huang @ 2002-08-20 2:09 UTC (permalink / raw) To: linux-mm In struct task_struct, what's the difference between active_mm and mm? I vaguely remembers it's used for reducing cache overhead during context switch, is this right or I'm totally off. Thanks - Hai -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: active_mm and mm 2002-08-20 2:09 active_mm and mm Hai Huang @ 2002-08-20 9:19 ` Stephen C. Tweedie 2002-08-20 14:55 ` Hai Huang 0 siblings, 1 reply; 4+ messages in thread From: Stephen C. Tweedie @ 2002-08-20 9:19 UTC (permalink / raw) To: Hai Huang; +Cc: linux-mm Hi, On Mon, Aug 19, 2002 at 10:09:50PM -0400, Hai Huang wrote: > In struct task_struct, what's the difference between active_mm and mm? I > vaguely remembers it's used for reducing cache overhead during context > switch, is this right Yep. Many context switches don't require us to switch to the mm of the newly running process. All processes share exactly the same kernel address space, so as long as we are only accessing kernel memory and not per-process memory, we don't need to do the mm switch. So, for operations such as waiting on an IO event, a process might get woken up, check some kernel space data structures, and go back to sleep, all in side a system call and never touching user space. It's a waste to switch to the process's mm just for that --- we'd end up throwing out the tlb cache of the old process for nothing. So, Linux has a "LAZY_TLB" mode which tasks such as the idle task (which never touch user space) all have set, and which tasks can enter if they are spinning in kernel space for a while. When we switch to a LAZY_TLB task, we don't get a new mm, so the new task's active_mm is set to whatever the old task's active_mm was. For non-LAZY_TLB running tasks, active_mm and mm should be the same. --Stephen -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: active_mm and mm 2002-08-20 9:19 ` Stephen C. Tweedie @ 2002-08-20 14:55 ` Hai Huang 2002-08-20 15:52 ` Stephen C. Tweedie 0 siblings, 1 reply; 4+ messages in thread From: Hai Huang @ 2002-08-20 14:55 UTC (permalink / raw) To: Stephen C. Tweedie; +Cc: linux-mm Ok, I see why we're differentiating between mm and active_mm, but is this actually giving us a lot of benefits considering the number of context switches that would actually take advantage of this feature is probably small (well, it depends on the workload). Also, is the tlb flush operation that expensive? - Hai > Hi, > > On Mon, Aug 19, 2002 at 10:09:50PM -0400, Hai Huang wrote: > > In struct task_struct, what's the difference between active_mm and mm? I > > vaguely remembers it's used for reducing cache overhead during context > > switch, is this right > > Yep. Many context switches don't require us to switch to the mm of > the newly running process. All processes share exactly the same > kernel address space, so as long as we are only accessing kernel > memory and not per-process memory, we don't need to do the mm switch. > > So, for operations such as waiting on an IO event, a process might get > woken up, check some kernel space data structures, and go back to > sleep, all in side a system call and never touching user space. It's > a waste to switch to the process's mm just for that --- we'd end up > throwing out the tlb cache of the old process for nothing. > > So, Linux has a "LAZY_TLB" mode which tasks such as the idle task > (which never touch user space) all have set, and which tasks can enter > if they are spinning in kernel space for a while. When we switch to a > LAZY_TLB task, we don't get a new mm, so the new task's active_mm > is set to whatever the old task's active_mm was. For non-LAZY_TLB > running tasks, active_mm and mm should be the same. > > --Stephen > -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: active_mm and mm 2002-08-20 14:55 ` Hai Huang @ 2002-08-20 15:52 ` Stephen C. Tweedie 0 siblings, 0 replies; 4+ messages in thread From: Stephen C. Tweedie @ 2002-08-20 15:52 UTC (permalink / raw) To: Hai Huang; +Cc: Stephen C. Tweedie, linux-mm Hi, On Tue, Aug 20, 2002 at 10:55:04AM -0400, Hai Huang wrote: > Ok, I see why we're differentiating between mm and active_mm, but is this > actually giving us a lot of benefits considering the number of context switches > that would actually take advantage of this feature is probably small > (well, it depends on the workload). It's actually enormous. There are a lot of kernel daemons that do background IO, for example. Those are often waking up after an IO completes, doing a tiny amount of work to submit new IO, then sleeping again. Even more significant in many workloads is the idle task. > Also, is the tlb flush operation that > expensive? Yes. Modern cpus are _way_ faster than main memory, and they rely utterly on the cache architecture to keep them busy. Doing a tlb flush forces the CPU to go back to main memory up to 2 times for every single address translation that follows until the tlb is full again. That's an enormous cost, especially on rapidly-switching workloads. --Stephen -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2002-08-20 15:52 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2002-08-20 2:09 active_mm and mm Hai Huang 2002-08-20 9:19 ` Stephen C. Tweedie 2002-08-20 14:55 ` Hai Huang 2002-08-20 15:52 ` Stephen C. Tweedie
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox