diff options
author | Peter Zijlstra <peterz@infradead.org> | 2019-07-29 17:05:15 +0300 |
---|---|---|
committer | Peter Zijlstra <peterz@infradead.org> | 2019-08-08 10:09:30 +0300 |
commit | 139d025cda1da5484e7287b35c019fe1dcf9b650 (patch) | |
tree | 9cc8a5329e99b63f61711fceb0e4a53c581c2139 /kernel/sched/sched.h | |
parent | 130d9c331bc59a8733b47c58ef197a2b1fa3ed43 (diff) | |
download | linux-139d025cda1da5484e7287b35c019fe1dcf9b650.tar.xz |
sched: Clean up active_mm reference counting
The current active_mm reference counting is confusing and sub-optimal.
Rewrite the code to explicitly consider the 4 separate cases:
user -> user
When switching between two user tasks, all we need to consider
is switch_mm().
user -> kernel
When switching from a user task to a kernel task (which
doesn't have an associated mm) we retain the last mm in our
active_mm. Increment a reference count on active_mm.
kernel -> kernel
When switching between kernel threads, all we need to do is
pass along the active_mm reference.
kernel -> user
When switching between a kernel and user task, we must switch
from the last active_mm to the next mm, hoping of course that
these are the same. Decrement a reference on the active_mm.
The code keeps a different order, because as you'll note, both 'to
user' cases require switch_mm().
And where the old code would increment/decrement for the 'kernel ->
kernel' case, the new code observes this is a neutral operation and
avoids touching the reference count.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Rik van Riel <riel@surriel.com>
Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: luto@kernel.org
Diffstat (limited to 'kernel/sched/sched.h')
0 files changed, 0 insertions, 0 deletions