Question regarding process' final mmdrop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux