lkml.org 
[lkml]   [2007]   [Jul]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectQuestion regarding process' final mmdrop
Hello,
I've been reading through the kernel source code trying to figure
out when the final mmdrop() after a exit_mm() is called on a task that
is having its virtual address deleted. I have discovered one instance
in finish_task_switch(), the local variable mm is set (for a single
access) to the last user task's active mm_struct, which is then
mmdrop()'d if found not to be NULL. This implies that the user task
that runs before a kernel thread has its mm_struct mmdrop()'d after
said kernel thread is switched out because the kernel thread leeched
off of its mm_struct. When kernel threads leeches off a user task's
active_mm, it's logical for the kernel to increase the reference value
to avoid race conditions, however, exit_mm() increases the mm_struct's
count value in order to deffer the final mmdrop() to
finish_task_switch() (according to the UTLK, end of chapter 9.5). I
assume the final mmdrop() is deferred solely to have a valid pgd left
in %cr3 after mmput() calls mmdrop().
This one pair of switching to a kernel thread then mmdrop()ing its
active_mm once it's switched out makes sense to me. But what I don't
understand is, how the kernel calls mmdrop() after exit_mm().
To clarify, the kernel executes the following code at
finish_task_switch() (kernel/sched.c):
struct mm_struct *mm = rq->prev_mm;
...
if (mm)
mmdrop(mm);
I don't see how the kernel is supposed to execute mmdrop() on a
exit_mm()'s behalf when exit_mm() does not set nor even touch
rq->prev_mm.
Thank you, Robert G.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-07-30 13:57    [from the cache]
©2003-2011 Jasper Spaans