From: RG <cryptococa@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: Question regarding process' final mmdrop
Date: Mon, 30 Jul 2007 07:54:58 -0400 [thread overview]
Message-ID: <6a1c323c0707300454yaf6eebfye9c5aaa3d4fe3723@mail.gmail.com> (raw)
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.
reply other threads:[~2007-07-30 11:55 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6a1c323c0707300454yaf6eebfye9c5aaa3d4fe3723@mail.gmail.com \
--to=cryptococa@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®