Commit 438b8e24 authored by Mike Rapoport's avatar Mike Rapoport Committed by Jonathan Corbet

docs/vm: active_mm.txt convert to ReST format

Just add a label for cross-referencing and indent the text to make it
``literal``
Signed-off-by: default avatarMike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
parent 86afad7d
List: linux-kernel .. _active_mm:
Subject: Re: active_mm
From: Linus Torvalds <torvalds () transmeta ! com> =========
Date: 1999-07-30 21:36:24 Active MM
=========
Cc'd to linux-kernel, because I don't write explanations all that often,
and when I do I feel better about more people reading them. ::
On Fri, 30 Jul 1999, David Mosberger wrote: List: linux-kernel
> Subject: Re: active_mm
> Is there a brief description someplace on how "mm" vs. "active_mm" in From: Linus Torvalds <torvalds () transmeta ! com>
> the task_struct are supposed to be used? (My apologies if this was Date: 1999-07-30 21:36:24
> discussed on the mailing lists---I just returned from vacation and
> wasn't able to follow linux-kernel for a while). Cc'd to linux-kernel, because I don't write explanations all that often,
and when I do I feel better about more people reading them.
Basically, the new setup is:
On Fri, 30 Jul 1999, David Mosberger wrote:
- we have "real address spaces" and "anonymous address spaces". The >
difference is that an anonymous address space doesn't care about the > Is there a brief description someplace on how "mm" vs. "active_mm" in
user-level page tables at all, so when we do a context switch into an > the task_struct are supposed to be used? (My apologies if this was
anonymous address space we just leave the previous address space > discussed on the mailing lists---I just returned from vacation and
active. > wasn't able to follow linux-kernel for a while).
The obvious use for a "anonymous address space" is any thread that Basically, the new setup is:
doesn't need any user mappings - all kernel threads basically fall into
this category, but even "real" threads can temporarily say that for - we have "real address spaces" and "anonymous address spaces". The
some amount of time they are not going to be interested in user space, difference is that an anonymous address space doesn't care about the
and that the scheduler might as well try to avoid wasting time on user-level page tables at all, so when we do a context switch into an
switching the VM state around. Currently only the old-style bdflush anonymous address space we just leave the previous address space
sync does that. active.
- "tsk->mm" points to the "real address space". For an anonymous process, The obvious use for a "anonymous address space" is any thread that
tsk->mm will be NULL, for the logical reason that an anonymous process doesn't need any user mappings - all kernel threads basically fall into
really doesn't _have_ a real address space at all. this category, but even "real" threads can temporarily say that for
some amount of time they are not going to be interested in user space,
- however, we obviously need to keep track of which address space we and that the scheduler might as well try to avoid wasting time on
"stole" for such an anonymous user. For that, we have "tsk->active_mm", switching the VM state around. Currently only the old-style bdflush
which shows what the currently active address space is. sync does that.
The rule is that for a process with a real address space (ie tsk->mm is - "tsk->mm" points to the "real address space". For an anonymous process,
non-NULL) the active_mm obviously always has to be the same as the real tsk->mm will be NULL, for the logical reason that an anonymous process
one. really doesn't _have_ a real address space at all.
For a anonymous process, tsk->mm == NULL, and tsk->active_mm is the - however, we obviously need to keep track of which address space we
"borrowed" mm while the anonymous process is running. When the "stole" for such an anonymous user. For that, we have "tsk->active_mm",
anonymous process gets scheduled away, the borrowed address space is which shows what the currently active address space is.
returned and cleared.
The rule is that for a process with a real address space (ie tsk->mm is
To support all that, the "struct mm_struct" now has two counters: a non-NULL) the active_mm obviously always has to be the same as the real
"mm_users" counter that is how many "real address space users" there are, one.
and a "mm_count" counter that is the number of "lazy" users (ie anonymous
users) plus one if there are any real users. For a anonymous process, tsk->mm == NULL, and tsk->active_mm is the
"borrowed" mm while the anonymous process is running. When the
Usually there is at least one real user, but it could be that the real anonymous process gets scheduled away, the borrowed address space is
user exited on another CPU while a lazy user was still active, so you do returned and cleared.
actually get cases where you have a address space that is _only_ used by
lazy users. That is often a short-lived state, because once that thread To support all that, the "struct mm_struct" now has two counters: a
gets scheduled away in favour of a real thread, the "zombie" mm gets "mm_users" counter that is how many "real address space users" there are,
released because "mm_users" becomes zero. and a "mm_count" counter that is the number of "lazy" users (ie anonymous
users) plus one if there are any real users.
Also, a new rule is that _nobody_ ever has "init_mm" as a real MM any
more. "init_mm" should be considered just a "lazy context when no other Usually there is at least one real user, but it could be that the real
context is available", and in fact it is mainly used just at bootup when user exited on another CPU while a lazy user was still active, so you do
no real VM has yet been created. So code that used to check actually get cases where you have a address space that is _only_ used by
lazy users. That is often a short-lived state, because once that thread
if (current->mm == &init_mm) gets scheduled away in favour of a real thread, the "zombie" mm gets
released because "mm_users" becomes zero.
should generally just do
Also, a new rule is that _nobody_ ever has "init_mm" as a real MM any
if (!current->mm) more. "init_mm" should be considered just a "lazy context when no other
context is available", and in fact it is mainly used just at bootup when
instead (which makes more sense anyway - the test is basically one of "do no real VM has yet been created. So code that used to check
we have a user context", and is generally done by the page fault handler
and things like that). if (current->mm == &init_mm)
Anyway, I put a pre-patch-2.3.13-1 on ftp.kernel.org just a moment ago, should generally just do
because it slightly changes the interfaces to accommodate the alpha (who
would have thought it, but the alpha actually ends up having one of the if (!current->mm)
ugliest context switch codes - unlike the other architectures where the MM
and register state is separate, the alpha PALcode joins the two, and you instead (which makes more sense anyway - the test is basically one of "do
need to switch both together). we have a user context", and is generally done by the page fault handler
and things like that).
(From http://marc.info/?l=linux-kernel&m=93337278602211&w=2)
Anyway, I put a pre-patch-2.3.13-1 on ftp.kernel.org just a moment ago,
because it slightly changes the interfaces to accommodate the alpha (who
would have thought it, but the alpha actually ends up having one of the
ugliest context switch codes - unlike the other architectures where the MM
and register state is separate, the alpha PALcode joins the two, and you
need to switch both together).
(From http://marc.info/?l=linux-kernel&m=93337278602211&w=2)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment